@wordpress/editor 14.43.0 → 14.43.1-next.v.202604091042.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 (103) hide show
  1. package/README.md +8 -0
  2. package/build/components/autocompleters/index.cjs +3 -0
  3. package/build/components/autocompleters/index.cjs.map +2 -2
  4. package/build/components/autocompleters/link.cjs +71 -0
  5. package/build/components/autocompleters/link.cjs.map +7 -0
  6. package/build/components/collaborators-overlay/cursor-dom-utils.cjs +1 -1
  7. package/build/components/collaborators-overlay/cursor-dom-utils.cjs.map +2 -2
  8. package/build/components/collaborators-overlay/timing-utils.cjs +1 -1
  9. package/build/components/collaborators-overlay/timing-utils.cjs.map +2 -2
  10. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +2 -2
  11. package/build/components/error-boundary/index.cjs +1 -1
  12. package/build/components/error-boundary/index.cjs.map +2 -2
  13. package/build/components/post-revisions-preview/revisions-slider.cjs +9 -17
  14. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  15. package/build/components/post-title/index.cjs +2 -2
  16. package/build/components/post-title/index.cjs.map +2 -2
  17. package/build/components/styles-canvas/revisions.cjs +2 -2
  18. package/build/components/styles-canvas/revisions.cjs.map +1 -1
  19. package/build/components/sync-connection-error-modal/index.cjs +57 -74
  20. package/build/components/sync-connection-error-modal/index.cjs.map +3 -3
  21. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs +32 -9
  22. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs.map +2 -2
  23. package/build/hooks/default-autocompleters.cjs +1 -1
  24. package/build/hooks/default-autocompleters.cjs.map +2 -2
  25. package/build/store/private-actions.cjs +1 -6
  26. package/build/store/private-actions.cjs.map +2 -2
  27. package/build/store/private-selectors.cjs +4 -6
  28. package/build/store/private-selectors.cjs.map +2 -2
  29. package/build/store/reducer.cjs +1 -1
  30. package/build/store/reducer.cjs.map +2 -2
  31. package/build-module/components/autocompleters/index.mjs +4 -2
  32. package/build-module/components/autocompleters/index.mjs.map +2 -2
  33. package/build-module/components/autocompleters/link.mjs +40 -0
  34. package/build-module/components/autocompleters/link.mjs.map +7 -0
  35. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs +1 -1
  36. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs.map +2 -2
  37. package/build-module/components/collaborators-overlay/timing-utils.mjs +1 -1
  38. package/build-module/components/collaborators-overlay/timing-utils.mjs.map +2 -2
  39. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  40. package/build-module/components/error-boundary/index.mjs +1 -1
  41. package/build-module/components/error-boundary/index.mjs.map +2 -2
  42. package/build-module/components/post-revisions-preview/revisions-slider.mjs +9 -17
  43. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  44. package/build-module/components/post-title/index.mjs +2 -2
  45. package/build-module/components/post-title/index.mjs.map +2 -2
  46. package/build-module/components/styles-canvas/revisions.mjs +2 -2
  47. package/build-module/components/styles-canvas/revisions.mjs.map +1 -1
  48. package/build-module/components/sync-connection-error-modal/index.mjs +57 -75
  49. package/build-module/components/sync-connection-error-modal/index.mjs.map +2 -2
  50. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +33 -10
  51. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +2 -2
  52. package/build-module/hooks/default-autocompleters.mjs +2 -2
  53. package/build-module/hooks/default-autocompleters.mjs.map +2 -2
  54. package/build-module/store/private-actions.mjs +1 -6
  55. package/build-module/store/private-actions.mjs.map +2 -2
  56. package/build-module/store/private-selectors.mjs +4 -6
  57. package/build-module/store/private-selectors.mjs.map +2 -2
  58. package/build-module/store/reducer.mjs +1 -1
  59. package/build-module/store/reducer.mjs.map +2 -2
  60. package/build-style/style-rtl.css +13 -2
  61. package/build-style/style.css +13 -2
  62. package/build-types/bindings/post-data.d.ts +3 -3
  63. package/build-types/bindings/term-data.d.ts +14 -14
  64. package/build-types/components/autocompleters/index.d.ts +1 -0
  65. package/build-types/components/autocompleters/link.d.ts +12 -0
  66. package/build-types/components/autocompleters/link.d.ts.map +1 -0
  67. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  68. package/build-types/components/keyboard-shortcut-help-modal/config.d.ts +11 -11
  69. package/build-types/components/post-actions/set-as-homepage.d.ts +1 -1
  70. package/build-types/components/post-actions/set-as-posts-page.d.ts +1 -1
  71. package/build-types/components/post-format/index.d.ts +10 -10
  72. package/build-types/components/post-locked-modal/index.d.ts +2 -2
  73. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  74. package/build-types/components/post-status/index.d.ts +10 -10
  75. package/build-types/components/post-visibility/utils.d.ts +6 -6
  76. package/build-types/components/sync-connection-error-modal/index.d.ts +0 -14
  77. package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -1
  78. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -1
  79. package/build-types/store/private-actions.d.ts.map +1 -1
  80. package/build-types/store/private-selectors.d.ts.map +1 -1
  81. package/build-types/store/reducer.d.ts +10 -10
  82. package/build-types/store/reducer.d.ts.map +1 -1
  83. package/build-types/utils/pageTypeBadge.d.ts +1 -1
  84. package/build-types/utils/pageTypeBadge.d.ts.map +1 -1
  85. package/package.json +45 -45
  86. package/src/components/autocompleters/index.js +1 -0
  87. package/src/components/autocompleters/link.js +47 -0
  88. package/src/components/autocompleters/style.scss +6 -0
  89. package/src/components/collaborators-overlay/cursor-dom-utils.ts +1 -1
  90. package/src/components/collaborators-overlay/timing-utils.ts +1 -1
  91. package/src/components/collaborators-overlay/use-render-cursors.ts +4 -2
  92. package/src/components/error-boundary/index.js +1 -1
  93. package/src/components/error-boundary/index.native.js +1 -1
  94. package/src/components/post-revisions-preview/revisions-slider.js +9 -27
  95. package/src/components/post-title/index.js +3 -3
  96. package/src/components/styles-canvas/revisions.js +2 -2
  97. package/src/components/sync-connection-error-modal/index.tsx +127 -154
  98. package/src/components/sync-connection-error-modal/use-retry-countdown.ts +46 -10
  99. package/src/hooks/default-autocompleters.js +2 -2
  100. package/src/hooks/test/default-autocompleters.js +2 -2
  101. package/src/store/private-actions.js +1 -6
  102. package/src/store/private-selectors.js +4 -13
  103. package/src/store/reducer.js +9 -8
@@ -29,6 +29,7 @@ var import_blocks = require("@wordpress/blocks");
29
29
  var import_core_data = require("@wordpress/core-data");
30
30
  var import_block_editor = require("@wordpress/block-editor");
31
31
  var import_components = require("@wordpress/components");
32
+ var import_hooks = require("@wordpress/hooks");
32
33
  var import_element = require("@wordpress/element");
33
34
  var import_i18n = require("@wordpress/i18n");
34
35
  var import_sync_error_messages = require("../../utils/sync-error-messages.cjs");
@@ -39,32 +40,72 @@ var import_jsx_runtime = require("react/jsx-runtime");
39
40
  var { BlockCanvasCover } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
40
41
  var { retrySyncConnection } = (0, import_lock_unlock.unlock)(import_core_data.privateApis);
41
42
  var INITIAL_DISCONNECTED_DEBOUNCE_MS = 2e4;
42
- var DISCONNECTED_DEBOUNCE_MS = 8e3;
43
- function DefaultSyncConnectionErrorModal(props) {
44
- const {
45
- description,
46
- manualRetry,
47
- postType,
48
- secondsRemainingUntilAutoRetry,
49
- title
50
- } = props;
43
+ function SyncConnectionErrorModal() {
44
+ const [hasInitialized, setHasInitialized] = (0, import_element.useState)(false);
45
+ const [showModal, setShowModal] = (0, import_element.useState)(false);
46
+ const { connectionStatus, isCollaborationEnabled, postType } = (0, import_data.useSelect)(
47
+ (selectFn) => {
48
+ const currentPostType = selectFn(import_store.store).getCurrentPostType();
49
+ return {
50
+ connectionStatus: selectFn(import_core_data.store).getSyncConnectionStatus() || null,
51
+ isCollaborationEnabled: selectFn(
52
+ import_store.store
53
+ ).isCollaborationEnabledForCurrentPost(),
54
+ postType: currentPostType ? selectFn(import_core_data.store).getPostType(currentPostType) : null
55
+ };
56
+ },
57
+ []
58
+ );
59
+ const { onManualRetry, secondsRemaining } = (0, import_use_retry_countdown.useRetryCountdown)(connectionStatus);
51
60
  const copyButtonRef = (0, import_compose.useCopyToClipboard)(() => {
52
61
  const blocks = (0, import_data.select)(import_block_editor.store).getBlocks();
53
62
  return (0, import_blocks.serialize)(blocks);
54
63
  });
64
+ (0, import_element.useEffect)(() => {
65
+ const timeout = setTimeout(() => {
66
+ setHasInitialized(true);
67
+ }, INITIAL_DISCONNECTED_DEBOUNCE_MS);
68
+ return () => clearTimeout(timeout);
69
+ }, []);
70
+ const canRetry = connectionStatus && "disconnected" === connectionStatus.status && (connectionStatus.canManuallyRetry || connectionStatus.willAutoRetryInMs);
71
+ (0, import_element.useEffect)(() => {
72
+ if ("connected" === connectionStatus?.status) {
73
+ setShowModal(false);
74
+ return;
75
+ }
76
+ if (connectionStatus?.status && "connecting" !== connectionStatus.status && (!canRetry || connectionStatus.backgroundRetriesFailed)) {
77
+ setShowModal(true);
78
+ }
79
+ }, [connectionStatus, canRetry]);
80
+ if (!isCollaborationEnabled || !hasInitialized || !showModal) {
81
+ return null;
82
+ }
83
+ const error = connectionStatus && "error" in connectionStatus ? connectionStatus?.error : void 0;
84
+ if (!canRetry && (0, import_hooks.applyFilters)(
85
+ "editor.isSyncConnectionErrorHandled",
86
+ false,
87
+ error?.code
88
+ ) !== false) {
89
+ return null;
90
+ }
91
+ const manualRetry = connectionStatus && "canManuallyRetry" in connectionStatus && connectionStatus.canManuallyRetry ? () => {
92
+ onManualRetry();
93
+ retrySyncConnection();
94
+ } : void 0;
95
+ const messages = (0, import_sync_error_messages.getSyncErrorMessages)(error);
55
96
  let retryCountdownText = "";
56
97
  let isRetrying = false;
57
- if (secondsRemainingUntilAutoRetry && secondsRemainingUntilAutoRetry > 0) {
98
+ if (secondsRemaining && secondsRemaining > 0) {
58
99
  retryCountdownText = (0, import_i18n.sprintf)(
59
100
  /* translators: %d: number of seconds until retry */
60
101
  (0, import_i18n._n)(
61
102
  "Retrying connection in %d second\u2026",
62
103
  "Retrying connection in %d seconds\u2026",
63
- secondsRemainingUntilAutoRetry
104
+ secondsRemaining
64
105
  ),
65
- secondsRemainingUntilAutoRetry
106
+ secondsRemaining
66
107
  );
67
- } else if (0 === secondsRemainingUntilAutoRetry) {
108
+ } else if (0 === secondsRemaining) {
68
109
  isRetrying = true;
69
110
  retryCountdownText = (0, import_i18n.__)("Retrying\u2026");
70
111
  }
@@ -72,7 +113,7 @@ function DefaultSyncConnectionErrorModal(props) {
72
113
  if (postType?.slug) {
73
114
  editPostHref = `edit.php?post_type=${postType.slug}`;
74
115
  }
75
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
116
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BlockCanvasCover.Fill, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
76
117
  import_components.Modal,
77
118
  {
78
119
  overlayClassName: "editor-sync-connection-error-modal",
@@ -82,9 +123,9 @@ function DefaultSyncConnectionErrorModal(props) {
82
123
  shouldCloseOnClickOutside: false,
83
124
  shouldCloseOnEsc: false,
84
125
  size: "medium",
85
- title,
126
+ title: messages.title,
86
127
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: 6, children: [
87
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: description }),
128
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: messages.description }),
88
129
  retryCountdownText && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "editor-sync-connection-error-modal__retry-countdown", children: retryCountdownText }),
89
130
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { justify: "right", children: [
90
131
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -126,64 +167,6 @@ function DefaultSyncConnectionErrorModal(props) {
126
167
  ] })
127
168
  ] })
128
169
  }
129
- );
130
- }
131
- var FilteredSyncConnectionErrorModal = globalThis.IS_GUTENBERG_PLUGIN ? (0, import_components.withFilters)("editor.SyncConnectionErrorModal")(
132
- DefaultSyncConnectionErrorModal
133
- ) : DefaultSyncConnectionErrorModal;
134
- function SyncConnectionErrorModal() {
135
- const [hasInitialized, setHasInitialized] = (0, import_element.useState)(false);
136
- const [showModal, setShowModal] = (0, import_element.useState)(false);
137
- const { connectionStatus, isCollaborationEnabled, postType } = (0, import_data.useSelect)(
138
- (selectFn) => {
139
- const currentPostType = selectFn(import_store.store).getCurrentPostType();
140
- return {
141
- connectionStatus: selectFn(import_core_data.store).getSyncConnectionStatus() || null,
142
- isCollaborationEnabled: selectFn(
143
- import_store.store
144
- ).isCollaborationEnabledForCurrentPost(),
145
- postType: currentPostType ? selectFn(import_core_data.store).getPostType(currentPostType) : null
146
- };
147
- },
148
- []
149
- );
150
- const { onManualRetry, secondsRemaining } = (0, import_use_retry_countdown.useRetryCountdown)(connectionStatus);
151
- const isConnected = "connected" === connectionStatus?.status;
152
- (0, import_element.useEffect)(() => {
153
- const timeout = setTimeout(() => {
154
- setHasInitialized(true);
155
- }, INITIAL_DISCONNECTED_DEBOUNCE_MS);
156
- return () => clearTimeout(timeout);
157
- }, []);
158
- (0, import_element.useEffect)(() => {
159
- if (isConnected) {
160
- setShowModal(false);
161
- return;
162
- }
163
- const timeout = setTimeout(() => {
164
- setShowModal(true);
165
- }, DISCONNECTED_DEBOUNCE_MS);
166
- return () => clearTimeout(timeout);
167
- }, [isConnected]);
168
- if (!isCollaborationEnabled || !hasInitialized || !showModal) {
169
- return null;
170
- }
171
- const error = connectionStatus && "error" in connectionStatus ? connectionStatus?.error : void 0;
172
- const manualRetry = connectionStatus && "canManuallyRetry" in connectionStatus && connectionStatus.canManuallyRetry ? () => {
173
- onManualRetry();
174
- retrySyncConnection();
175
- } : void 0;
176
- const messages = (0, import_sync_error_messages.getSyncErrorMessages)(error);
177
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BlockCanvasCover.Fill, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
178
- FilteredSyncConnectionErrorModal,
179
- {
180
- description: messages.description,
181
- error,
182
- manualRetry,
183
- postType,
184
- secondsRemainingUntilAutoRetry: secondsRemaining,
185
- title: messages.title
186
- }
187
170
  ) });
188
171
  }
189
172
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/sync-connection-error-modal/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, select } from '@wordpress/data';\nimport { useCopyToClipboard } from '@wordpress/compose';\n// @ts-ignore No exported types.\nimport { serialize } from '@wordpress/blocks';\nimport {\n\tstore as coreDataStore,\n\tprivateApis as coreDataPrivateApis,\n\ttype ConnectionError,\n} from '@wordpress/core-data';\n// @ts-expect-error - No type declarations available for @wordpress/block-editor\n// prettier-ignore\nimport { privateApis, store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tModal,\n\twithFilters,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getSyncErrorMessages } from '../../utils/sync-error-messages';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useRetryCountdown } from './use-retry-countdown';\n\nconst { BlockCanvasCover } = unlock( privateApis );\nconst { retrySyncConnection } = unlock( coreDataPrivateApis );\n\n// Debounce time for initial disconnected status to allow connection to establish.\nconst INITIAL_DISCONNECTED_DEBOUNCE_MS = 20000;\n\n// Debounce time for showing the disconnect dialog after the intial connection,\n// allowing brief network interruptions to resolve.\nconst DISCONNECTED_DEBOUNCE_MS = 8000;\n\nexport interface SyncConnectionErrorModalProps {\n\tdescription: string; // Modal description.\n\terror?: ConnectionError; // Error object with a `code` property.\n\tmanualRetry?: () => void; // Callback for when the retry button is clicked.\n\tpostType?: { slug?: string; labels?: { name?: string } } | null; // Current post type object.\n\tsecondsRemainingUntilAutoRetry?: number; // Seconds remaining until the next automatic retry attempt, if applicable.\n\ttitle: string; // Modal title.\n}\n\n/**\n * Default sync connection modal component.\n *\n * Can be replaced or wrapped via the `editor.SyncConnectionErrorModal` filter.\n *\n * @param props - SyncConnectionErrorModalProps.\n */\nfunction DefaultSyncConnectionErrorModal(\n\tprops: SyncConnectionErrorModalProps\n) {\n\tconst {\n\t\tdescription,\n\t\tmanualRetry,\n\t\tpostType,\n\t\tsecondsRemainingUntilAutoRetry,\n\t\ttitle,\n\t} = props;\n\tconst copyButtonRef = useCopyToClipboard( () => {\n\t\tconst blocks = select( blockEditorStore ).getBlocks();\n\t\treturn serialize( blocks );\n\t} );\n\n\tlet retryCountdownText: string = '';\n\tlet isRetrying = false;\n\tif (\n\t\tsecondsRemainingUntilAutoRetry &&\n\t\tsecondsRemainingUntilAutoRetry > 0\n\t) {\n\t\tretryCountdownText = sprintf(\n\t\t\t/* translators: %d: number of seconds until retry */\n\t\t\t_n(\n\t\t\t\t'Retrying connection in %d second\\u2026',\n\t\t\t\t'Retrying connection in %d seconds\\u2026',\n\t\t\t\tsecondsRemainingUntilAutoRetry\n\t\t\t),\n\t\t\tsecondsRemainingUntilAutoRetry\n\t\t);\n\t} else if ( 0 === secondsRemainingUntilAutoRetry ) {\n\t\tisRetrying = true;\n\t\tretryCountdownText = __( 'Retrying\\u2026' );\n\t}\n\n\tlet editPostHref = 'edit.php';\n\tif ( postType?.slug ) {\n\t\teditPostHref = `edit.php?post_type=${ postType.slug }`;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\toverlayClassName=\"editor-sync-connection-error-modal\"\n\t\t\tisDismissible={ false }\n\t\t\tonRequestClose={ () => {} }\n\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\tshouldCloseOnEsc={ false }\n\t\t\tsize=\"medium\"\n\t\t\ttitle={ title }\n\t\t>\n\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t<p>{ description }</p>\n\t\t\t\t{ retryCountdownText && (\n\t\t\t\t\t<p className=\"editor-sync-connection-error-modal__retry-countdown\">\n\t\t\t\t\t\t{ retryCountdownText }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\thref={ editPostHref }\n\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Post type name (e.g., \"Posts\", \"Pages\"). */\n\t\t\t\t\t\t\t__( 'Back to %s' ),\n\t\t\t\t\t\t\tpostType?.labels?.name ?? __( 'Posts' )\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tref={ copyButtonRef }\n\t\t\t\t\t\tvariant={ manualRetry ? 'secondary' : 'primary' }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Copy Post Content' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t{ manualRetry && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\taria-disabled={ isRetrying }\n\t\t\t\t\t\t\tdisabled={ isRetrying }\n\t\t\t\t\t\t\tisBusy={ isRetrying }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tonClick={ manualRetry }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Retry' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</Modal>\n\t);\n}\n\n/**\n * Filtered version of the sync connection modal, allowing third-party\n * plugins to replace the default modal via:\n *\n * ```js\n * wp.hooks.addFilter(\n * 'editor.SyncConnectionErrorModal',\n * 'my-plugin/custom-sync-connection-error-modal',\n * ( OriginalComponent ) => ( props ) => {\n * // Return a custom component or wrap the original.\n * return <OriginalComponent { ...props } />;\n * }\n * );\n * ```\n */\n// @ts-ignore\nconst FilteredSyncConnectionErrorModal = globalThis.IS_GUTENBERG_PLUGIN\n\t? withFilters( 'editor.SyncConnectionErrorModal' )(\n\t\t\tDefaultSyncConnectionErrorModal\n\t )\n\t: DefaultSyncConnectionErrorModal;\n\n/**\n * Sync connection modal that displays when any entity reports a disconnection.\n * Uses BlockCanvasCover.Fill to render in the block canvas.\n *\n * @return The modal component or null if not disconnected.\n */\nexport function SyncConnectionErrorModal() {\n\tconst [ hasInitialized, setHasInitialized ] = useState( false );\n\tconst [ showModal, setShowModal ] = useState( false );\n\n\tconst { connectionStatus, isCollaborationEnabled, postType } = useSelect(\n\t\t( selectFn ) => {\n\t\t\tconst currentPostType =\n\t\t\t\tselectFn( editorStore ).getCurrentPostType();\n\t\t\treturn {\n\t\t\t\tconnectionStatus:\n\t\t\t\t\tselectFn( coreDataStore ).getSyncConnectionStatus() || null,\n\t\t\t\tisCollaborationEnabled:\n\t\t\t\t\tselectFn(\n\t\t\t\t\t\teditorStore\n\t\t\t\t\t).isCollaborationEnabledForCurrentPost(),\n\t\t\t\tpostType: currentPostType\n\t\t\t\t\t? selectFn( coreDataStore ).getPostType( currentPostType )\n\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { onManualRetry, secondsRemaining } =\n\t\tuseRetryCountdown( connectionStatus );\n\n\tconst isConnected = 'connected' === connectionStatus?.status;\n\n\t// Set hasInitialized after a debounce to give extra time on initial load.\n\tuseEffect( () => {\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetHasInitialized( true );\n\t\t}, INITIAL_DISCONNECTED_DEBOUNCE_MS );\n\n\t\treturn () => clearTimeout( timeout );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( isConnected ) {\n\t\t\tsetShowModal( false );\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetShowModal( true );\n\t\t}, DISCONNECTED_DEBOUNCE_MS );\n\n\t\treturn () => clearTimeout( timeout );\n\t}, [ isConnected ] );\n\n\tif ( ! isCollaborationEnabled || ! hasInitialized || ! showModal ) {\n\t\treturn null;\n\t}\n\n\tconst error =\n\t\tconnectionStatus && 'error' in connectionStatus\n\t\t\t? connectionStatus?.error\n\t\t\t: undefined;\n\tconst manualRetry =\n\t\tconnectionStatus &&\n\t\t'canManuallyRetry' in connectionStatus &&\n\t\tconnectionStatus.canManuallyRetry\n\t\t\t? () => {\n\t\t\t\t\tonManualRetry();\n\t\t\t\t\tretrySyncConnection();\n\t\t\t }\n\t\t\t: undefined;\n\tconst messages = getSyncErrorMessages( error );\n\n\treturn (\n\t\t<BlockCanvasCover.Fill>\n\t\t\t<FilteredSyncConnectionErrorModal\n\t\t\t\tdescription={ messages.description }\n\t\t\t\terror={ error }\n\t\t\t\tmanualRetry={ manualRetry }\n\t\t\t\tpostType={ postType }\n\t\t\t\tsecondsRemainingUntilAutoRetry={ secondsRemaining }\n\t\t\t\ttitle={ messages.title }\n\t\t\t/>\n\t\t</BlockCanvasCover.Fill>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAkC;AAClC,qBAAmC;AAEnC,oBAA0B;AAC1B,uBAIO;AAGP,0BAAuD;AACvD,wBAMO;AACP,qBAAoC;AACpC,kBAAgC;AAKhC,iCAAqC;AACrC,mBAAqC;AACrC,yBAAuB;AACvB,iCAAkC;AA+E9B;AA7EJ,IAAM,EAAE,iBAAiB,QAAI,2BAAQ,+BAAY;AACjD,IAAM,EAAE,oBAAoB,QAAI,2BAAQ,iBAAAA,WAAoB;AAG5D,IAAM,mCAAmC;AAIzC,IAAM,2BAA2B;AAkBjC,SAAS,gCACR,OACC;AACD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AACJ,QAAM,oBAAgB,mC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E;AAEnB,MAAK,CAAE,0BAA0B,CAAE,kBAAkB,CAAE,WAAY;AAClE,WAAO;AAAA,EACR;AAEA,QAAM,QACL,oBAAoB,WAAW,mBAC5B,kBAAkB,QAClB;AACJ,QAAM,cACL,oBACA,sBAAsB,oBACtB,iBAAiB,mBACd,MAAM;AACN,kBAAc;AACd,wBAAoB;AAAA,EACpB,IACA;AACJ,QAAM,eAAW,iDAAsB,KAAM;AAE7C,SACC,4CAAC,iBAAiB,MAAjB,EACA;AAAA,IAAC;AAAA;AAAA,MACA,aAAc,SAAS;AAAA,MACvB;AAAA,MACA;AAAA,MACA;AAAA,MACA,gCAAiC;AAAA,MACjC,OAAQ,SAAS;AAAA;AAAA,EAClB,GACD;AAEF;",
6
- "names": ["coreDataPrivateApis", "blockEditorStore", "VStack", "HStack", "editorStore", "coreDataStore"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, select } from '@wordpress/data';\nimport { useCopyToClipboard } from '@wordpress/compose';\n// @ts-ignore No exported types.\nimport { serialize } from '@wordpress/blocks';\nimport {\n\tstore as coreDataStore,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\n// @ts-expect-error - No type declarations available for @wordpress/block-editor\n// prettier-ignore\nimport { privateApis, store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { applyFilters } from '@wordpress/hooks';\nimport { useState, useEffect } from '@wordpress/element';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getSyncErrorMessages } from '../../utils/sync-error-messages';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useRetryCountdown } from './use-retry-countdown';\n\nconst { BlockCanvasCover } = unlock( privateApis );\nconst { retrySyncConnection } = unlock( coreDataPrivateApis );\n\n// Debounce time for initial disconnected status to allow connection to establish.\nconst INITIAL_DISCONNECTED_DEBOUNCE_MS = 20000;\n\n/**\n * Sync connection modal that displays when any entity reports a disconnection.\n * Uses BlockCanvasCover.Fill to render in the block canvas.\n *\n * @return The modal component or null if not disconnected.\n */\nexport function SyncConnectionErrorModal() {\n\tconst [ hasInitialized, setHasInitialized ] = useState( false );\n\tconst [ showModal, setShowModal ] = useState( false );\n\n\tconst { connectionStatus, isCollaborationEnabled, postType } = useSelect(\n\t\t( selectFn ) => {\n\t\t\tconst currentPostType =\n\t\t\t\tselectFn( editorStore ).getCurrentPostType();\n\t\t\treturn {\n\t\t\t\tconnectionStatus:\n\t\t\t\t\tselectFn( coreDataStore ).getSyncConnectionStatus() || null,\n\t\t\t\tisCollaborationEnabled:\n\t\t\t\t\tselectFn(\n\t\t\t\t\t\teditorStore\n\t\t\t\t\t).isCollaborationEnabledForCurrentPost(),\n\t\t\t\tpostType: currentPostType\n\t\t\t\t\t? selectFn( coreDataStore ).getPostType( currentPostType )\n\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { onManualRetry, secondsRemaining } =\n\t\tuseRetryCountdown( connectionStatus );\n\n\tconst copyButtonRef = useCopyToClipboard( () => {\n\t\tconst blocks = select( blockEditorStore ).getBlocks();\n\t\treturn serialize( blocks );\n\t} );\n\n\t// Set hasInitialized after a debounce to give extra time on initial load.\n\tuseEffect( () => {\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetHasInitialized( true );\n\t\t}, INITIAL_DISCONNECTED_DEBOUNCE_MS );\n\n\t\treturn () => clearTimeout( timeout );\n\t}, [] );\n\n\t// Show the modal when disconnected and either retries are exhausted or\n\t// no retry is available (unrecoverable error). Hide on reconnect.\n\t// The 'connecting' state is ignored so the modal preserves its current\n\t// visibility during active retry attempts.\n\tconst canRetry =\n\t\tconnectionStatus &&\n\t\t'disconnected' === connectionStatus.status &&\n\t\t( connectionStatus.canManuallyRetry ||\n\t\t\tconnectionStatus.willAutoRetryInMs );\n\n\tuseEffect( () => {\n\t\tif ( 'connected' === connectionStatus?.status ) {\n\t\t\tsetShowModal( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tconnectionStatus?.status &&\n\t\t\t'connecting' !== connectionStatus.status &&\n\t\t\t( ! canRetry || connectionStatus.backgroundRetriesFailed )\n\t\t) {\n\t\t\tsetShowModal( true );\n\t\t}\n\t}, [ connectionStatus, canRetry ] );\n\n\tif ( ! isCollaborationEnabled || ! hasInitialized || ! showModal ) {\n\t\treturn null;\n\t}\n\n\tconst error =\n\t\tconnectionStatus && 'error' in connectionStatus\n\t\t\t? connectionStatus?.error\n\t\t\t: undefined;\n\n\t// For unrecoverable errors (no retry available), allow plugins to handle\n\t// the error themselves. If a plugin returns a value other than false, it\n\t// signals that it has taken over error display and the default modal is\n\t// suppressed.\n\t//\n\t// @example\n\t// ```js\n\t// wp.hooks.addFilter(\n\t// 'editor.isSyncConnectionErrorHandled',\n\t// 'my-plugin/handle-sync-error',\n\t// ( isHandled, errorCode ) => {\n\t// if ( errorCode === 'connection-limit-exceeded' ) {\n\t// return true; // Plugin handles this error via its own UI.\n\t// }\n\t// return isHandled;\n\t// }\n\t// );\n\t// ```\n\tif (\n\t\t! canRetry &&\n\t\tapplyFilters(\n\t\t\t'editor.isSyncConnectionErrorHandled',\n\t\t\tfalse,\n\t\t\terror?.code\n\t\t) !== false\n\t) {\n\t\treturn null;\n\t}\n\n\tconst manualRetry =\n\t\tconnectionStatus &&\n\t\t'canManuallyRetry' in connectionStatus &&\n\t\tconnectionStatus.canManuallyRetry\n\t\t\t? () => {\n\t\t\t\t\tonManualRetry();\n\t\t\t\t\tretrySyncConnection();\n\t\t\t }\n\t\t\t: undefined;\n\n\tconst messages = getSyncErrorMessages( error );\n\n\tlet retryCountdownText: string = '';\n\tlet isRetrying = false;\n\tif ( secondsRemaining && secondsRemaining > 0 ) {\n\t\tretryCountdownText = sprintf(\n\t\t\t/* translators: %d: number of seconds until retry */\n\t\t\t_n(\n\t\t\t\t'Retrying connection in %d second\\u2026',\n\t\t\t\t'Retrying connection in %d seconds\\u2026',\n\t\t\t\tsecondsRemaining\n\t\t\t),\n\t\t\tsecondsRemaining\n\t\t);\n\t} else if ( 0 === secondsRemaining ) {\n\t\tisRetrying = true;\n\t\tretryCountdownText = __( 'Retrying\\u2026' );\n\t}\n\n\tlet editPostHref = 'edit.php';\n\tif ( postType?.slug ) {\n\t\teditPostHref = `edit.php?post_type=${ postType.slug }`;\n\t}\n\n\treturn (\n\t\t<BlockCanvasCover.Fill>\n\t\t\t<Modal\n\t\t\t\toverlayClassName=\"editor-sync-connection-error-modal\"\n\t\t\t\tisDismissible={ false }\n\t\t\t\tonRequestClose={ () => {} }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t\tshouldCloseOnEsc={ false }\n\t\t\t\tsize=\"medium\"\n\t\t\t\ttitle={ messages.title }\n\t\t\t>\n\t\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t\t<p>{ messages.description }</p>\n\t\t\t\t\t{ retryCountdownText && (\n\t\t\t\t\t\t<p className=\"editor-sync-connection-error-modal__retry-countdown\">\n\t\t\t\t\t\t\t{ retryCountdownText }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\thref={ editPostHref }\n\t\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Post type name (e.g., \"Posts\", \"Pages\"). */\n\t\t\t\t\t\t\t\t__( 'Back to %s' ),\n\t\t\t\t\t\t\t\tpostType?.labels?.name ?? __( 'Posts' )\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tref={ copyButtonRef }\n\t\t\t\t\t\t\tvariant={ manualRetry ? 'secondary' : 'primary' }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Copy Post Content' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t{ manualRetry && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\taria-disabled={ isRetrying }\n\t\t\t\t\t\t\t\tdisabled={ isRetrying }\n\t\t\t\t\t\t\t\tisBusy={ isRetrying }\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ manualRetry }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Retry' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</Modal>\n\t\t</BlockCanvasCover.Fill>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAkC;AAClC,qBAAmC;AAEnC,oBAA0B;AAC1B,uBAGO;AAGP,0BAAuD;AACvD,wBAKO;AACP,mBAA6B;AAC7B,qBAAoC;AACpC,kBAAgC;AAKhC,iCAAqC;AACrC,mBAAqC;AACrC,yBAAuB;AACvB,iCAAkC;AAmK7B;AAjKL,IAAM,EAAE,iBAAiB,QAAI,2BAAQ,+BAAY;AACjD,IAAM,EAAE,oBAAoB,QAAI,2BAAQ,iBAAAA,WAAoB;AAG5D,IAAM,mCAAmC;AAQlC,SAAS,2BAA2B;AAC1C,QAAM,CAAE,gBAAgB,iBAAkB,QAAI,yBAAU,KAAM;AAC9D,QAAM,CAAE,WAAW,YAAa,QAAI,yBAAU,KAAM;AAEpD,QAAM,EAAE,kBAAkB,wBAAwB,SAAS,QAAI;AAAA,IAC9D,CAAE,aAAc;AACf,YA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YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,wBAAsB;AAAA,cACtB,iBAAgB;AAAA,cAChB,UAAW;AAAA,cACX,QAAS;AAAA,cACT,SAAQ;AAAA,cACR,SAAU;AAAA,cAER,8BAAI,OAAQ;AAAA;AAAA,UACf;AAAA,WAEF;AAAA,SACD;AAAA;AAAA,EACD,GACD;AAEF;",
6
+ "names": ["coreDataPrivateApis", "editorStore", "coreDataStore", "blockEditorStore", "VStack", "HStack"]
7
7
  }
@@ -26,12 +26,14 @@ module.exports = __toCommonJS(use_retry_countdown_exports);
26
26
  var import_element = require("@wordpress/element");
27
27
  function useRetryCountdown(connectionStatus) {
28
28
  const [secondsRemaining, setSecondsRemaining] = (0, import_element.useState)();
29
+ const hasRetriedRef = (0, import_element.useRef)(false);
29
30
  (0, import_element.useEffect)(() => {
30
31
  if (!connectionStatus) {
31
32
  return;
32
33
  }
33
34
  if ("connected" === connectionStatus.status) {
34
35
  setSecondsRemaining(void 0);
36
+ hasRetriedRef.current = false;
35
37
  return;
36
38
  }
37
39
  if ("disconnected" !== connectionStatus.status || !connectionStatus.willAutoRetryInMs) {
@@ -39,18 +41,39 @@ function useRetryCountdown(connectionStatus) {
39
41
  }
40
42
  const { willAutoRetryInMs: retryInMs } = connectionStatus;
41
43
  const retryAt = Date.now() + retryInMs;
42
- setSecondsRemaining(Math.ceil(retryInMs / 1e3));
43
- const intervalId = setInterval(() => {
44
- const remaining = Math.ceil((retryAt - Date.now()) / 1e3);
45
- setSecondsRemaining(Math.max(0, remaining));
46
- if (remaining <= 0) {
47
- clearInterval(intervalId);
44
+ const hasRetried = hasRetriedRef.current;
45
+ hasRetriedRef.current = true;
46
+ if (hasRetried) {
47
+ setSecondsRemaining(0);
48
+ }
49
+ let countdownIntervalId = null;
50
+ const startCountdown = () => {
51
+ setSecondsRemaining(Math.ceil((retryAt - Date.now()) / 1e3));
52
+ countdownIntervalId = setInterval(() => {
53
+ const remaining = Math.ceil((retryAt - Date.now()) / 1e3);
54
+ setSecondsRemaining(Math.max(0, remaining));
55
+ if (remaining <= 0 && countdownIntervalId) {
56
+ clearInterval(countdownIntervalId);
57
+ }
58
+ }, 1e3);
59
+ };
60
+ const retryingDelayId = hasRetried ? setTimeout(startCountdown, 500) : null;
61
+ if (!retryingDelayId) {
62
+ startCountdown();
63
+ }
64
+ return () => {
65
+ if (retryingDelayId) {
66
+ clearTimeout(retryingDelayId);
67
+ }
68
+ if (countdownIntervalId) {
69
+ clearInterval(countdownIntervalId);
48
70
  }
49
- }, 1e3);
50
- return () => clearInterval(intervalId);
71
+ };
51
72
  }, [connectionStatus]);
52
73
  return {
53
- onManualRetry: () => setSecondsRemaining(0),
74
+ onManualRetry: () => {
75
+ setSecondsRemaining(0);
76
+ },
54
77
  secondsRemaining
55
78
  };
56
79
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/sync-connection-error-modal/use-retry-countdown.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { ConnectionStatus } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\n\ninterface UseRetryCountdownResult {\n\tonManualRetry: () => void;\n\tsecondsRemaining?: number;\n}\n\nexport function useRetryCountdown(\n\tconnectionStatus?: ConnectionStatus | null\n): UseRetryCountdownResult {\n\tconst [ secondsRemaining, setSecondsRemaining ] = useState< number >();\n\n\tuseEffect( () => {\n\t\tif ( ! connectionStatus ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Only clear countdown when explicitly connected.\n\t\tif ( 'connected' === connectionStatus.status ) {\n\t\t\tsetSecondsRemaining( undefined );\n\t\t\treturn;\n\t\t}\n\n\t\t// For transient states (e.g. 'connecting' during a retry attempt)\n\t\t// or when retryInMs is not yet available, keep the previous\n\t\t// countdown value to avoid a brief flash.\n\t\tif (\n\t\t\t'disconnected' !== connectionStatus.status ||\n\t\t\t! connectionStatus.willAutoRetryInMs\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { willAutoRetryInMs: retryInMs } = connectionStatus;\n\t\tconst retryAt = Date.now() + retryInMs;\n\t\tsetSecondsRemaining( Math.ceil( retryInMs / 1000 ) );\n\n\t\tconst intervalId = setInterval( () => {\n\t\t\tconst remaining = Math.ceil( ( retryAt - Date.now() ) / 1000 );\n\t\t\tsetSecondsRemaining( Math.max( 0, remaining ) );\n\t\t\tif ( remaining <= 0 ) {\n\t\t\t\tclearInterval( intervalId );\n\t\t\t}\n\t\t}, 1000 );\n\n\t\treturn () => clearInterval( intervalId );\n\t}, [ connectionStatus ] );\n\n\treturn {\n\t\tonManualRetry: () => setSecondsRemaining( 0 ),\n\t\tsecondsRemaining,\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,qBAAoC;AAO7B,SAAS,kBACf,kBAC0B;AAC1B,QAAM,CAAE,kBAAkB,mBAAoB,QAAI,yBAAmB;AAErE,gCAAW,MAAM;AAChB,QAAK,CAAE,kBAAmB;AACzB;AAAA,IACD;AAGA,QAAK,gBAAgB,iBAAiB,QAAS;AAC9C,0BAAqB,MAAU;AAC/B;AAAA,IACD;AAKA,QACC,mBAAmB,iBAAiB,UACpC,CAAE,iBAAiB,mBAClB;AACD;AAAA,IACD;AAEA,UAAM,EAAE,mBAAmB,UAAU,IAAI;AACzC,UAAM,UAAU,KAAK,IAAI,IAAI;AAC7B,wBAAqB,KAAK,KAAM,YAAY,GAAK,CAAE;AAEnD,UAAM,aAAa,YAAa,MAAM;AACrC,YAAM,YAAY,KAAK,MAAQ,UAAU,KAAK,IAAI,KAAM,GAAK;AAC7D,0BAAqB,KAAK,IAAK,GAAG,SAAU,CAAE;AAC9C,UAAK,aAAa,GAAI;AACrB,sBAAe,UAAW;AAAA,MAC3B;AAAA,IACD,GAAG,GAAK;AAER,WAAO,MAAM,cAAe,UAAW;AAAA,EACxC,GAAG,CAAE,gBAAiB,CAAE;AAExB,SAAO;AAAA,IACN,eAAe,MAAM,oBAAqB,CAAE;AAAA,IAC5C;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { ConnectionStatus } from '@wordpress/core-data';\nimport { useState, useEffect, useRef } from '@wordpress/element';\n\ninterface UseRetryCountdownResult {\n\tonManualRetry: () => void;\n\tsecondsRemaining?: number;\n}\n\nexport function useRetryCountdown(\n\tconnectionStatus?: ConnectionStatus | null\n): UseRetryCountdownResult {\n\tconst [ secondsRemaining, setSecondsRemaining ] = useState< number >();\n\tconst hasRetriedRef = useRef( false );\n\n\tuseEffect( () => {\n\t\tif ( ! connectionStatus ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Only clear countdown when explicitly connected.\n\t\tif ( 'connected' === connectionStatus.status ) {\n\t\t\tsetSecondsRemaining( undefined );\n\t\t\thasRetriedRef.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\t// For transient states (e.g. 'connecting' during a retry attempt)\n\t\t// or when retryInMs is not yet available, keep the previous\n\t\t// countdown value to avoid a brief flash.\n\t\tif (\n\t\t\t'disconnected' !== connectionStatus.status ||\n\t\t\t! connectionStatus.willAutoRetryInMs\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { willAutoRetryInMs: retryInMs } = connectionStatus;\n\t\tconst retryAt = Date.now() + retryInMs;\n\n\t\t// After a retry attempt (manual or automatic), show \"Retrying...\"\n\t\t// for 500ms before starting the next countdown. Skip the delay on\n\t\t// the very first disconnect so the countdown starts immediately.\n\t\tconst hasRetried = hasRetriedRef.current;\n\t\thasRetriedRef.current = true;\n\n\t\tif ( hasRetried ) {\n\t\t\tsetSecondsRemaining( 0 );\n\t\t}\n\n\t\tlet countdownIntervalId: ReturnType< typeof setInterval > | null = null;\n\n\t\tconst startCountdown = () => {\n\t\t\tsetSecondsRemaining( Math.ceil( ( retryAt - Date.now() ) / 1000 ) );\n\n\t\t\tcountdownIntervalId = setInterval( () => {\n\t\t\t\tconst remaining = Math.ceil( ( retryAt - Date.now() ) / 1000 );\n\t\t\t\tsetSecondsRemaining( Math.max( 0, remaining ) );\n\n\t\t\t\tif ( remaining <= 0 && countdownIntervalId ) {\n\t\t\t\t\tclearInterval( countdownIntervalId );\n\t\t\t\t}\n\t\t\t}, 1000 );\n\t\t};\n\n\t\tconst retryingDelayId = hasRetried\n\t\t\t? setTimeout( startCountdown, 500 )\n\t\t\t: null;\n\n\t\tif ( ! retryingDelayId ) {\n\t\t\tstartCountdown();\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( retryingDelayId ) {\n\t\t\t\tclearTimeout( retryingDelayId );\n\t\t\t}\n\n\t\t\tif ( countdownIntervalId ) {\n\t\t\t\tclearInterval( countdownIntervalId );\n\t\t\t}\n\t\t};\n\t}, [ connectionStatus ] );\n\n\treturn {\n\t\tonManualRetry: () => {\n\t\t\tsetSecondsRemaining( 0 );\n\t\t},\n\t\tsecondsRemaining,\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,qBAA4C;AAOrC,SAAS,kBACf,kBAC0B;AAC1B,QAAM,CAAE,kBAAkB,mBAAoB,QAAI,yBAAmB;AACrE,QAAM,oBAAgB,uBAAQ,KAAM;AAEpC,gCAAW,MAAM;AAChB,QAAK,CAAE,kBAAmB;AACzB;AAAA,IACD;AAGA,QAAK,gBAAgB,iBAAiB,QAAS;AAC9C,0BAAqB,MAAU;AAC/B,oBAAc,UAAU;AACxB;AAAA,IACD;AAKA,QACC,mBAAmB,iBAAiB,UACpC,CAAE,iBAAiB,mBAClB;AACD;AAAA,IACD;AAEA,UAAM,EAAE,mBAAmB,UAAU,IAAI;AACzC,UAAM,UAAU,KAAK,IAAI,IAAI;AAK7B,UAAM,aAAa,cAAc;AACjC,kBAAc,UAAU;AAExB,QAAK,YAAa;AACjB,0BAAqB,CAAE;AAAA,IACxB;AAEA,QAAI,sBAA+D;AAEnE,UAAM,iBAAiB,MAAM;AAC5B,0BAAqB,KAAK,MAAQ,UAAU,KAAK,IAAI,KAAM,GAAK,CAAE;AAElE,4BAAsB,YAAa,MAAM;AACxC,cAAM,YAAY,KAAK,MAAQ,UAAU,KAAK,IAAI,KAAM,GAAK;AAC7D,4BAAqB,KAAK,IAAK,GAAG,SAAU,CAAE;AAE9C,YAAK,aAAa,KAAK,qBAAsB;AAC5C,wBAAe,mBAAoB;AAAA,QACpC;AAAA,MACD,GAAG,GAAK;AAAA,IACT;AAEA,UAAM,kBAAkB,aACrB,WAAY,gBAAgB,GAAI,IAChC;AAEH,QAAK,CAAE,iBAAkB;AACxB,qBAAe;AAAA,IAChB;AAEA,WAAO,MAAM;AACZ,UAAK,iBAAkB;AACtB,qBAAc,eAAgB;AAAA,MAC/B;AAEA,UAAK,qBAAsB;AAC1B,sBAAe,mBAAoB;AAAA,MACpC;AAAA,IACD;AAAA,EACD,GAAG,CAAE,gBAAiB,CAAE;AAExB,SAAO;AAAA,IACN,eAAe,MAAM;AACpB,0BAAqB,CAAE;AAAA,IACxB;AAAA,IACA;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -4,7 +4,7 @@
4
4
  var import_hooks = require("@wordpress/hooks");
5
5
  var import_components = require("../components/index.cjs");
6
6
  function setDefaultCompleters(completers = []) {
7
- completers.push({ ...import_components.userAutocompleter });
7
+ completers.push({ ...import_components.linkAutocompleter }, { ...import_components.userAutocompleter });
8
8
  return completers;
9
9
  }
10
10
  (0, import_hooks.addFilter)(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/default-autocompleters.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { userAutocompleter } from '../components';\n\nfunction setDefaultCompleters( completers = [] ) {\n\t// Provide copies so filters may directly modify them.\n\tcompleters.push( { ...userAutocompleter } );\n\n\treturn completers;\n}\n\naddFilter(\n\t'editor.Autocomplete.completers',\n\t'editor/autocompleters/set-default-completers',\n\tsetDefaultCompleters\n);\n"],
5
- "mappings": ";;;AAGA,mBAA0B;AAK1B,wBAAkC;AAElC,SAAS,qBAAsB,aAAa,CAAC,GAAI;AAEhD,aAAW,KAAM,EAAE,GAAG,oCAAkB,CAAE;AAE1C,SAAO;AACR;AAAA,IAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { linkAutocompleter, userAutocompleter } from '../components';\n\nfunction setDefaultCompleters( completers = [] ) {\n\t// Provide copies so filters may directly modify them.\n\tcompleters.push( { ...linkAutocompleter }, { ...userAutocompleter } );\n\n\treturn completers;\n}\n\naddFilter(\n\t'editor.Autocomplete.completers',\n\t'editor/autocompleters/set-default-completers',\n\tsetDefaultCompleters\n);\n"],
5
+ "mappings": ";;;AAGA,mBAA0B;AAK1B,wBAAqD;AAErD,SAAS,qBAAsB,aAAa,CAAC,GAAI;AAEhD,aAAW,KAAM,EAAE,GAAG,oCAAkB,GAAG,EAAE,GAAG,oCAAkB,CAAE;AAEpE,SAAO;AACR;AAAA,IAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
6
6
  "names": []
7
7
  }
@@ -468,12 +468,7 @@ var restoreRevision = (revisionId) => async ({ select, dispatch, registry }) =>
468
468
  (0, import_i18n.sprintf)(
469
469
  /* translators: %s: Date and time of the revision. */
470
470
  (0, import_i18n.__)("Restored to revision from %s."),
471
- (0, import_date.dateI18n)(
472
- (0, import_date.getSettings)().formats.datetime,
473
- // Template revisions use the template REST API format, which
474
- // exposes 'modified' instead of 'date'.
475
- revisionKey === "wp_id" ? revision.modified : revision.date
476
- )
471
+ (0, import_date.dateI18n)((0, import_date.getSettings)().formats.datetime, revision.date)
477
472
  ),
478
473
  {
479
474
  type: "snackbar",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/private-actions.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { dateI18n, getSettings as getDateSettings } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from './utils/is-template-revertable';\nexport * from '../dataviews/store/private-actions';\n\n/**\n * Returns an action object used to set which template is currently being used/edited.\n *\n * @param {string} id Template Id.\n *\n * @return {Object} Action object.\n */\nexport function setCurrentTemplateId( id ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_TEMPLATE_ID',\n\t\tid,\n\t};\n}\n\n/**\n * Create a block based template.\n *\n * @param {?Object} template Template to create and assign.\n */\nexport const createTemplate =\n\t( template ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst savedTemplate = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tselect.getCurrentPostType(),\n\t\t\t\tselect.getCurrentPostId(),\n\t\t\t\t{\n\t\t\t\t\ttemplate: savedTemplate.slug,\n\t\t\t\t}\n\t\t\t);\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createSuccessNotice(\n\t\t\t\t__( \"Custom template created. You're in template mode now.\" ),\n\t\t\t\t{\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: __( 'Go back' ),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tdispatch.setRenderingMode(\n\t\t\t\t\t\t\t\t\tselect.getEditorSettings()\n\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\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\treturn savedTemplate;\n\t};\n\n/**\n * Update the provided block types to be visible.\n *\n * @param {string[]} blockNames Names of block types to show.\n */\nexport const showBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst newBlockNames = existingBlockNames.filter(\n\t\t\t( type ) =>\n\t\t\t\t! (\n\t\t\t\t\tArray.isArray( blockNames ) ? blockNames : [ blockNames ]\n\t\t\t\t).includes( type )\n\t\t);\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', newBlockNames );\n\t};\n\n/**\n * Update the provided block types to be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n */\nexport const hideBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst mergedBlockNames = new Set( [\n\t\t\t...existingBlockNames,\n\t\t\t...( Array.isArray( blockNames ) ? blockNames : [ blockNames ] ),\n\t\t] );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n\t};\n\n/**\n * Save entity records marked as dirty.\n *\n * @param {Object} options Options for the action.\n * @param {Function} [options.onSave] Callback when saving happens.\n * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.\n * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.\n * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.\n * @param {string} [options.successNoticeContent] Optional custom success notice content. Defaults to 'Site updated.'.\n */\nexport const saveDirtyEntities =\n\t( {\n\t\tonSave,\n\t\tdirtyEntityRecords = [],\n\t\tentitiesToSkip = [],\n\t\tclose,\n\t\tsuccessNoticeContent,\n\t} = {} ) =>\n\t( { registry } ) => {\n\t\tconst PUBLISH_ON_SAVE_ENTITIES = [\n\t\t\t{ kind: 'postType', name: 'wp_navigation' },\n\t\t];\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tconst homeUrl = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEntityRecord( 'root', '__unstableBase' )?.home;\n\t\tregistry.dispatch( noticesStore ).removeNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! entitiesToSkip.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\tclose?.( entitiesToSave );\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord( kind, name, key, {\n\t\t\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.saveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.__experimentalSaveSpecifiedEntityEdits(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'site',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tsiteItemsToSave\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave ? onSave( values ) : values;\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createSuccessNotice(\n\t\t\t\t\t\t\tsuccessNoticeContent || __( 'Site updated.' ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t\t\t\topenInNewTab: true,\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}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t`${ __( 'Saving failed.' ) } ${ error }`\n\t\t\t\t\t)\n\t\t\t);\n\t};\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate =\n\t( template, { allowUndo = true } = {} ) =>\n\tasync ( { registry } ) => {\n\t\tconst noticeId = 'edit-site-template-reverted';\n\t\tregistry.dispatch( noticesStore ).removeNotice( noticeId );\n\t\tif ( ! isTemplateRevertable( template ) ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templateEntityConfig = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityConfig( 'postType', template.type );\n\n\t\t\tif ( ! templateEntityConfig ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t\t{ context: 'edit', source: template.origin }\n\t\t\t);\n\n\t\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\t\tif ( ! fileTemplate ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst serializeBlocks = ( {\n\t\t\t\tblocks: blocksForSerialization = [],\n\t\t\t} ) => __unstableSerializeAndClean( blocksForSerialization );\n\n\t\t\tconst edited = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t\t// the revert in the header toolbar correctly.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks,\n\t\t\t\t\tsource: 'theme',\n\t\t\t\t} );\n\n\t\t\tif ( allowUndo ) {\n\t\t\t\tconst undoRevert = () => {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\tedited.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reset.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: noticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: undoRevert,\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}\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Action that removes an array of templates, template parts or patterns.\n *\n * @param {Array} items An array of template,template part or pattern objects to remove.\n */\nexport const removeTemplates =\n\t( items ) =>\n\tasync ( { registry } ) => {\n\t\tconst isResetting = items.every( ( item ) => item?.has_theme_file );\n\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\titems.map( ( item ) => {\n\t\t\t\treturn registry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\titem.type,\n\t\t\t\t\t\titem.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t} )\n\t\t);\n\n\t\t// If all the promises were fulfilled with success.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\n\t\t\tif ( items.length === 1 ) {\n\t\t\t\t// Depending on how the entity was retrieved its title might be\n\t\t\t\t// an object or simple string.\n\t\t\t\tlet title;\n\t\t\t\tif ( typeof items[ 0 ].title === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title;\n\t\t\t\t} else if ( typeof items[ 0 ].title?.rendered === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title?.rendered;\n\t\t\t\t} else if ( typeof items[ 0 ].title?.raw === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title?.raw;\n\t\t\t\t}\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: The template/part's name. */\n\t\t\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: The template/part's name. */\n\t\t\t\t\t\t\t_x( '\"%s\" deleted.', 'template part' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t );\n\t\t\t} else {\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? __( 'Items reset.' )\n\t\t\t\t\t: __( 'Items deleted.' );\n\t\t\t}\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( successMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'editor-template-deleted-success',\n\t\t\t\t} );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to delete a single template.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\terrorMessage = promiseResult[ 0 ].reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? __( 'An error occurred while reverting the item.' )\n\t\t\t\t\t\t: __( 'An error occurred while deleting the item.' );\n\t\t\t\t}\n\t\t\t\t// If we were trying to delete a multiple templates\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( failedPromise.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t );\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t );\n\t\t\t\t}\n\t\t\t}\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Set the default rendering mode preference for the current post type.\n *\n * @param {string} mode The rendering mode to set as default.\n */\nexport const setDefaultRenderingMode =\n\t( mode ) =>\n\t( { select, registry } ) => {\n\t\tconst postType = select.getCurrentPostType();\n\t\tconst theme = registry\n\t\t\t.select( coreStore )\n\t\t\t.getCurrentTheme()?.stylesheet;\n\t\tconst renderingModes =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'renderingModes' )?.[ theme ] ?? {};\n\n\t\tif ( renderingModes[ postType ] === mode ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newModes = {\n\t\t\t[ theme ]: {\n\t\t\t\t...renderingModes,\n\t\t\t\t[ postType ]: mode,\n\t\t\t},\n\t\t};\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'renderingModes', newModes );\n\t};\n\n/**\n * Set the current global styles navigation path.\n *\n * @param {string} path The navigation path.\n * @return {Object} Action object.\n */\nexport function setStylesPath( path ) {\n\treturn {\n\t\ttype: 'SET_STYLES_PATH',\n\t\tpath,\n\t};\n}\n\n/**\n * Set whether the stylebook is visible.\n *\n * @param {boolean} show Whether to show the stylebook.\n * @return {Object} Action object.\n */\nexport function setShowStylebook( show ) {\n\treturn {\n\t\ttype: 'SET_SHOW_STYLEBOOK',\n\t\tshow,\n\t};\n}\n\n/**\n * Reset the global styles navigation to initial state.\n *\n * @return {Object} Action object.\n */\nexport function resetStylesNavigation() {\n\treturn {\n\t\ttype: 'RESET_STYLES_NAVIGATION',\n\t};\n}\n\n/**\n * Set the minimum height of the canvas.\n *\n * @param {number} minHeight\n * @return {Object} Action object.\n */\nexport function setCanvasMinHeight( minHeight ) {\n\treturn {\n\t\ttype: 'SET_CANVAS_MIN_HEIGHT',\n\t\tminHeight,\n\t};\n}\n\n/**\n * Set the current revision ID for revisions preview mode.\n * Pass a revision ID to enter revisions mode, or null to exit.\n *\n * @param {number|null} revisionId The revision ID, or null to exit revisions mode.\n * @return {Object} Action object.\n */\nexport function setCurrentRevisionId( revisionId ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_REVISION_ID',\n\t\trevisionId,\n\t};\n}\n\n/**\n * Set whether the revision diff highlighting is shown.\n *\n * @param {boolean} showDiff Whether to show diff highlighting.\n * @return {Object} Action object.\n */\nexport function setShowRevisionDiff( showDiff ) {\n\treturn {\n\t\ttype: 'SET_SHOW_REVISION_DIFF',\n\t\tshowDiff,\n\t};\n}\n\n/**\n * Restore a revision by replacing the current content with the revision's content\n * and auto-saving.\n *\n * @param {number} revisionId The revision ID to restore.\n */\nexport const restoreRevision =\n\t( revisionId ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst postType = select.getCurrentPostType();\n\t\tconst postId = select.getCurrentPostId();\n\n\t\tconst entityConfig = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEntityConfig( 'postType', postType );\n\t\tconst revisionKey = entityConfig?.revisionKey || 'id';\n\n\t\t// Use resolveSelect to ensure the revision is fetched if not yet\n\t\t// in the store. The _fields parameter matches the query used by\n\t\t// getRevisions so the result is served from cache without an\n\t\t// extra API call.\n\t\tconst revision = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getRevision( 'postType', postType, postId, revisionId, {\n\t\t\t\tcontext: 'edit',\n\t\t\t\t_fields: [\n\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t'id',\n\t\t\t\t\t\t'date',\n\t\t\t\t\t\t'modified',\n\t\t\t\t\t\t'author',\n\t\t\t\t\t\t'meta',\n\t\t\t\t\t\t'title.raw',\n\t\t\t\t\t\t'excerpt.raw',\n\t\t\t\t\t\t'content.raw',\n\t\t\t\t\t\trevisionKey,\n\t\t\t\t\t] ),\n\t\t\t\t].join(),\n\t\t\t} );\n\n\t\tif ( ! revision ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Build the edits object with all restorable fields from the revision.\n\t\tconst edits = {\n\t\t\tblocks: undefined,\n\t\t\tcontent: revision.content.raw,\n\t\t};\n\t\tif ( revision.title?.raw !== undefined ) {\n\t\t\tedits.title = revision.title.raw;\n\t\t}\n\t\tif ( revision.excerpt?.raw !== undefined ) {\n\t\t\tedits.excerpt = revision.excerpt.raw;\n\t\t}\n\t\tif ( revision.meta !== undefined ) {\n\t\t\tedits.meta = revision.meta;\n\t\t}\n\n\t\t// Apply edits and save.\n\t\tdispatch.editPost( edits );\n\n\t\t// Exit revisions mode.\n\t\tdispatch.setCurrentRevisionId( null );\n\n\t\t// Save the post to persist the restored revision.\n\t\tawait dispatch.savePost();\n\n\t\t// Show success notice.\n\t\tregistry.dispatch( noticesStore ).createSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: Date and time of the revision. */\n\t\t\t\t__( 'Restored to revision from %s.' ),\n\t\t\t\tdateI18n(\n\t\t\t\t\tgetDateSettings().formats.datetime,\n\t\t\t\t\t// Template revisions use the template REST API format, which\n\t\t\t\t\t// exposes 'modified' instead of 'date'.\n\t\t\t\t\trevisionKey === 'wp_id' ? revision.modified : revision.date\n\t\t\t\t)\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'editor-revision-restored',\n\t\t\t}\n\t\t);\n\t};\n\n/**\n * Select a note by its ID, or clear the selection.\n *\n * @param {undefined|number|'new'} noteId The note ID to select, 'new' to open the new note form, or undefined to clear.\n * @param {Object} [options] Optional options for the selection.\n * @param {boolean} [options.focus] Whether to focus the selected note. Default false.\n * @return {Object} Action object.\n */\nexport function selectNote( noteId, options = { focus: false } ) {\n\treturn {\n\t\ttype: 'SELECT_NOTE',\n\t\tnoteId,\n\t\toptions,\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAmC;AACnC,kBAAgC;AAChC,qBAAsC;AACtC,0BAA0C;AAC1C,yBAA0C;AAC1C,iBAA6B;AAC7B,uBAAqB;AACrB,oBAAmD;AACnD,2BAA+B;AAC/B,kBAAyD;AAKzD,oCAAiC;AACjC,oCAAc,mDAlBd;AA2BO,SAAS,qBAAsB,IAAK;AAC1C,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;AAOO,IAAM,iBACZ,CAAE,aACF,OAAQ,EAAE,QAAQ,UAAU,SAAS,MAAO;AAC3C,QAAM,gBAAgB,MAAM,SAC1B,SAAU,iBAAAA,KAAU,EACpB,iBAAkB,YAAY,eAAe,QAAS;AACxD,WACE,SAAU,iBAAAA,KAAU,EACpB;AAAA,IACA;AAAA,IACA,OAAO,mBAAmB;AAAA,IAC1B,OAAO,iBAAiB;AAAA,IACxB;AAAA,MACC,UAAU,cAAc;AAAA,IACzB;AAAA,EACD;AACD,WACE,SAAU,eAAAC,KAAa,EACvB;AAAA,QACA,gBAAI,uDAAwD;AAAA,IAC5D;AAAA,MACC,MAAM;AAAA,MACN,SAAS;AAAA,QACR;AAAA,UACC,WAAO,gBAAI,SAAU;AAAA,UACrB,SAAS,MACR,SAAS;AAAA,YACR,OAAO,kBAAkB,EACvB;AAAA,UACH;AAAA,QACF;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD,SAAO;AACR;AAOM,IAAM,iBACZ,CAAE,eACF,CAAE,EAAE,SAAS,MAAO;AACnB,QAAM,qBACL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ACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,CAAE;AAAA,IACH,EAAE,KAAK;AAAA,EACR,CAAE;AAEH,MAAK,CAAE,UAAW;AACjB;AAAA,EACD;AAGA,QAAM,QAAQ;AAAA,IACb,QAAQ;AAAA,IACR,SAAS,SAAS,QAAQ;AAAA,EAC3B;AACA,MAAK,SAAS,OAAO,QAAQ,QAAY;AACxC,UAAM,QAAQ,SAAS,MAAM;AAAA,EAC9B;AACA,MAAK,SAAS,SAAS,QAAQ,QAAY;AAC1C,UAAM,UAAU,SAAS,QAAQ;AAAA,EAClC;AACA,MAAK,SAAS,SAAS,QAAY;AAClC,UAAM,OAAO,SAAS;AAAA,EACvB;AAGA,WAAS,SAAU,KAAM;AAGzB,WAAS,qBAAsB,IAAK;AAGpC,QAAM,SAAS,SAAS;AAGxB,WAAS,SAAU,eAAAC,KAAa,EAAE;AAAA,QACjC;AAAA;AAAA,UAEC,gBAAI,+BAAgC;AAAA,UACpC;AAAA,YACC,YAAAK,aAAgB,EAAE,QAAQ;AAAA;AAAA;AAAA,QAG1B,gBAAgB,UAAU,SAAS,WAAW,SAAS;AAAA,MACxD;AAAA,IACD;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,IAAI;AAAA,IACL;AAAA,EACD;AACD;AAUM,SAAS,WAAY,QAAQ,UAAU,EAAE,OAAO,MAAM,GAAI;AAChE,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { dateI18n, getSettings as getDateSettings } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from './utils/is-template-revertable';\nexport * from '../dataviews/store/private-actions';\n\n/**\n * Returns an action object used to set which template is currently being used/edited.\n *\n * @param {string} id Template Id.\n *\n * @return {Object} Action object.\n */\nexport function setCurrentTemplateId( id ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_TEMPLATE_ID',\n\t\tid,\n\t};\n}\n\n/**\n * Create a block based template.\n *\n * @param {?Object} template Template to create and assign.\n */\nexport const createTemplate =\n\t( template ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst savedTemplate = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tselect.getCurrentPostType(),\n\t\t\t\tselect.getCurrentPostId(),\n\t\t\t\t{\n\t\t\t\t\ttemplate: savedTemplate.slug,\n\t\t\t\t}\n\t\t\t);\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createSuccessNotice(\n\t\t\t\t__( \"Custom template created. You're in template mode now.\" ),\n\t\t\t\t{\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: __( 'Go back' ),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tdispatch.setRenderingMode(\n\t\t\t\t\t\t\t\t\tselect.getEditorSettings()\n\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\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\treturn savedTemplate;\n\t};\n\n/**\n * Update the provided block types to be visible.\n *\n * @param {string[]} blockNames Names of block types to show.\n */\nexport const showBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst newBlockNames = existingBlockNames.filter(\n\t\t\t( type ) =>\n\t\t\t\t! (\n\t\t\t\t\tArray.isArray( blockNames ) ? blockNames : [ blockNames ]\n\t\t\t\t).includes( type )\n\t\t);\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', newBlockNames );\n\t};\n\n/**\n * Update the provided block types to be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n */\nexport const hideBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst mergedBlockNames = new Set( [\n\t\t\t...existingBlockNames,\n\t\t\t...( Array.isArray( blockNames ) ? blockNames : [ blockNames ] ),\n\t\t] );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n\t};\n\n/**\n * Save entity records marked as dirty.\n *\n * @param {Object} options Options for the action.\n * @param {Function} [options.onSave] Callback when saving happens.\n * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.\n * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.\n * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.\n * @param {string} [options.successNoticeContent] Optional custom success notice content. Defaults to 'Site updated.'.\n */\nexport const saveDirtyEntities =\n\t( {\n\t\tonSave,\n\t\tdirtyEntityRecords = [],\n\t\tentitiesToSkip = [],\n\t\tclose,\n\t\tsuccessNoticeContent,\n\t} = {} ) =>\n\t( { registry } ) => {\n\t\tconst PUBLISH_ON_SAVE_ENTITIES = [\n\t\t\t{ kind: 'postType', name: 'wp_navigation' },\n\t\t];\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tconst homeUrl = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEntityRecord( 'root', '__unstableBase' )?.home;\n\t\tregistry.dispatch( noticesStore ).removeNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! entitiesToSkip.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\tclose?.( entitiesToSave );\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord( kind, name, key, {\n\t\t\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.saveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.__experimentalSaveSpecifiedEntityEdits(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'site',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tsiteItemsToSave\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave ? onSave( values ) : values;\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createSuccessNotice(\n\t\t\t\t\t\t\tsuccessNoticeContent || __( 'Site updated.' ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t\t\t\topenInNewTab: true,\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}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t`${ __( 'Saving failed.' ) } ${ error }`\n\t\t\t\t\t)\n\t\t\t);\n\t};\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate =\n\t( template, { allowUndo = true } = {} ) =>\n\tasync ( { registry } ) => {\n\t\tconst noticeId = 'edit-site-template-reverted';\n\t\tregistry.dispatch( noticesStore ).removeNotice( noticeId );\n\t\tif ( ! isTemplateRevertable( template ) ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templateEntityConfig = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityConfig( 'postType', template.type );\n\n\t\t\tif ( ! templateEntityConfig ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t\t{ context: 'edit', source: template.origin }\n\t\t\t);\n\n\t\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\t\tif ( ! fileTemplate ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst serializeBlocks = ( {\n\t\t\t\tblocks: blocksForSerialization = [],\n\t\t\t} ) => __unstableSerializeAndClean( blocksForSerialization );\n\n\t\t\tconst edited = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t\t// the revert in the header toolbar correctly.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks,\n\t\t\t\t\tsource: 'theme',\n\t\t\t\t} );\n\n\t\t\tif ( allowUndo ) {\n\t\t\t\tconst undoRevert = () => {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\tedited.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reset.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: noticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: undoRevert,\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}\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Action that removes an array of templates, template parts or patterns.\n *\n * @param {Array} items An array of template,template part or pattern objects to remove.\n */\nexport const removeTemplates =\n\t( items ) =>\n\tasync ( { registry } ) => {\n\t\tconst isResetting = items.every( ( item ) => item?.has_theme_file );\n\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\titems.map( ( item ) => {\n\t\t\t\treturn registry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\titem.type,\n\t\t\t\t\t\titem.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t} )\n\t\t);\n\n\t\t// If all the promises were fulfilled with success.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\n\t\t\tif ( items.length === 1 ) {\n\t\t\t\t// Depending on how the entity was retrieved its title might be\n\t\t\t\t// an object or simple string.\n\t\t\t\tlet title;\n\t\t\t\tif ( typeof items[ 0 ].title === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title;\n\t\t\t\t} else if ( typeof items[ 0 ].title?.rendered === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title?.rendered;\n\t\t\t\t} else if ( typeof items[ 0 ].title?.raw === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title?.raw;\n\t\t\t\t}\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: The template/part's name. */\n\t\t\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: The template/part's name. */\n\t\t\t\t\t\t\t_x( '\"%s\" deleted.', 'template part' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t );\n\t\t\t} else {\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? __( 'Items reset.' )\n\t\t\t\t\t: __( 'Items deleted.' );\n\t\t\t}\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( successMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'editor-template-deleted-success',\n\t\t\t\t} );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to delete a single template.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\terrorMessage = promiseResult[ 0 ].reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? __( 'An error occurred while reverting the item.' )\n\t\t\t\t\t\t: __( 'An error occurred while deleting the item.' );\n\t\t\t\t}\n\t\t\t\t// If we were trying to delete a multiple templates\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( failedPromise.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t );\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t );\n\t\t\t\t}\n\t\t\t}\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Set the default rendering mode preference for the current post type.\n *\n * @param {string} mode The rendering mode to set as default.\n */\nexport const setDefaultRenderingMode =\n\t( mode ) =>\n\t( { select, registry } ) => {\n\t\tconst postType = select.getCurrentPostType();\n\t\tconst theme = registry\n\t\t\t.select( coreStore )\n\t\t\t.getCurrentTheme()?.stylesheet;\n\t\tconst renderingModes =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'renderingModes' )?.[ theme ] ?? {};\n\n\t\tif ( renderingModes[ postType ] === mode ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newModes = {\n\t\t\t[ theme ]: {\n\t\t\t\t...renderingModes,\n\t\t\t\t[ postType ]: mode,\n\t\t\t},\n\t\t};\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'renderingModes', newModes );\n\t};\n\n/**\n * Set the current global styles navigation path.\n *\n * @param {string} path The navigation path.\n * @return {Object} Action object.\n */\nexport function setStylesPath( path ) {\n\treturn {\n\t\ttype: 'SET_STYLES_PATH',\n\t\tpath,\n\t};\n}\n\n/**\n * Set whether the stylebook is visible.\n *\n * @param {boolean} show Whether to show the stylebook.\n * @return {Object} Action object.\n */\nexport function setShowStylebook( show ) {\n\treturn {\n\t\ttype: 'SET_SHOW_STYLEBOOK',\n\t\tshow,\n\t};\n}\n\n/**\n * Reset the global styles navigation to initial state.\n *\n * @return {Object} Action object.\n */\nexport function resetStylesNavigation() {\n\treturn {\n\t\ttype: 'RESET_STYLES_NAVIGATION',\n\t};\n}\n\n/**\n * Set the minimum height of the canvas.\n *\n * @param {number} minHeight\n * @return {Object} Action object.\n */\nexport function setCanvasMinHeight( minHeight ) {\n\treturn {\n\t\ttype: 'SET_CANVAS_MIN_HEIGHT',\n\t\tminHeight,\n\t};\n}\n\n/**\n * Set the current revision ID for revisions preview mode.\n * Pass a revision ID to enter revisions mode, or null to exit.\n *\n * @param {number|null} revisionId The revision ID, or null to exit revisions mode.\n * @return {Object} Action object.\n */\nexport function setCurrentRevisionId( revisionId ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_REVISION_ID',\n\t\trevisionId,\n\t};\n}\n\n/**\n * Set whether the revision diff highlighting is shown.\n *\n * @param {boolean} showDiff Whether to show diff highlighting.\n * @return {Object} Action object.\n */\nexport function setShowRevisionDiff( showDiff ) {\n\treturn {\n\t\ttype: 'SET_SHOW_REVISION_DIFF',\n\t\tshowDiff,\n\t};\n}\n\n/**\n * Restore a revision by replacing the current content with the revision's content\n * and auto-saving.\n *\n * @param {number} revisionId The revision ID to restore.\n */\nexport const restoreRevision =\n\t( revisionId ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst postType = select.getCurrentPostType();\n\t\tconst postId = select.getCurrentPostId();\n\n\t\tconst entityConfig = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEntityConfig( 'postType', postType );\n\t\tconst revisionKey = entityConfig?.revisionKey || 'id';\n\n\t\t// Use resolveSelect to ensure the revision is fetched if not yet\n\t\t// in the store. The _fields parameter matches the query used by\n\t\t// getRevisions so the result is served from cache without an\n\t\t// extra API call.\n\t\tconst revision = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getRevision( 'postType', postType, postId, revisionId, {\n\t\t\t\tcontext: 'edit',\n\t\t\t\t_fields: [\n\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t'id',\n\t\t\t\t\t\t'date',\n\t\t\t\t\t\t'modified',\n\t\t\t\t\t\t'author',\n\t\t\t\t\t\t'meta',\n\t\t\t\t\t\t'title.raw',\n\t\t\t\t\t\t'excerpt.raw',\n\t\t\t\t\t\t'content.raw',\n\t\t\t\t\t\trevisionKey,\n\t\t\t\t\t] ),\n\t\t\t\t].join(),\n\t\t\t} );\n\n\t\tif ( ! revision ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Build the edits object with all restorable fields from the revision.\n\t\tconst edits = {\n\t\t\tblocks: undefined,\n\t\t\tcontent: revision.content.raw,\n\t\t};\n\t\tif ( revision.title?.raw !== undefined ) {\n\t\t\tedits.title = revision.title.raw;\n\t\t}\n\t\tif ( revision.excerpt?.raw !== undefined ) {\n\t\t\tedits.excerpt = revision.excerpt.raw;\n\t\t}\n\t\tif ( revision.meta !== undefined ) {\n\t\t\tedits.meta = revision.meta;\n\t\t}\n\n\t\t// Apply edits and save.\n\t\tdispatch.editPost( edits );\n\n\t\t// Exit revisions mode.\n\t\tdispatch.setCurrentRevisionId( null );\n\n\t\t// Save the post to persist the restored revision.\n\t\tawait dispatch.savePost();\n\n\t\t// Show success notice.\n\t\tregistry.dispatch( noticesStore ).createSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: Date and time of the revision. */\n\t\t\t\t__( 'Restored to revision from %s.' ),\n\t\t\t\tdateI18n( getDateSettings().formats.datetime, revision.date )\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'editor-revision-restored',\n\t\t\t}\n\t\t);\n\t};\n\n/**\n * Select a note by its ID, or clear the selection.\n *\n * @param {undefined|number|'new'} noteId The note ID to select, 'new' to open the new note form, or undefined to clear.\n * @param {Object} [options] Optional options for the selection.\n * @param {boolean} [options.focus] Whether to focus the selected note. Default false.\n * @return {Object} Action object.\n */\nexport function selectNote( noteId, options = { focus: false } ) {\n\treturn {\n\t\ttype: 'SELECT_NOTE',\n\t\tnoteId,\n\t\toptions,\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAmC;AACnC,kBAAgC;AAChC,qBAAsC;AACtC,0BAA0C;AAC1C,yBAA0C;AAC1C,iBAA6B;AAC7B,uBAAqB;AACrB,oBAAmD;AACnD,2BAA+B;AAC/B,kBAAyD;AAKzD,oCAAiC;AACjC,oCAAc,mDAlB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;AAGpC,QAAM,SAAS,SAAS;AAGxB,WAAS,SAAU,eAAAC,KAAa,EAAE;AAAA,QACjC;AAAA;AAAA,UAEC,gBAAI,+BAAgC;AAAA,UACpC,0BAAU,YAAAK,aAAgB,EAAE,QAAQ,UAAU,SAAS,IAAK;AAAA,IAC7D;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,IAAI;AAAA,IACL;AAAA,EACD;AACD;AAUM,SAAS,WAAY,QAAQ,UAAU,EAAE,OAAO,MAAM,GAAI;AAChE,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
6
6
  "names": ["coreStore", "noticesStore", "preferencesStore", "blockEditorStore", "isTemplateRevertable", "apiFetch", "getDateSettings"]
7
7
  }
@@ -319,6 +319,8 @@ var getPreviousRevision = (0, import_data.createRegistrySelector)(
319
319
  {
320
320
  per_page: -1,
321
321
  context: "edit",
322
+ orderby: "date",
323
+ order: "asc",
322
324
  _fields: [
323
325
  .../* @__PURE__ */ new Set([
324
326
  "id",
@@ -337,15 +339,11 @@ var getPreviousRevision = (0, import_data.createRegistrySelector)(
337
339
  if (!revisions) {
338
340
  return null;
339
341
  }
340
- const revisionDateField = revisionKey === "wp_id" ? "modified" : "date";
341
- const sortedRevisions = [...revisions].sort(
342
- (a, b) => new Date(a[revisionDateField]) - new Date(b[revisionDateField])
343
- );
344
- const currentIndex = sortedRevisions.findIndex(
342
+ const currentIndex = revisions.findIndex(
345
343
  (r) => r[revisionKey] === currentRevisionId
346
344
  );
347
345
  if (currentIndex > 0) {
348
- return sortedRevisions[currentIndex - 1];
346
+ return revisions[currentIndex - 1];
349
347
  }
350
348
  return null;
351
349
  }