@wordpress/editor 14.41.1-next.v.202603102151.0 → 14.42.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.
- package/CHANGELOG.md +6 -0
- package/build/components/collaborators-overlay/avatar-iframe-styles.cjs +12 -4
- package/build/components/collaborators-overlay/avatar-iframe-styles.cjs.map +2 -2
- package/build/components/collaborators-overlay/compute-selection.cjs +181 -0
- package/build/components/collaborators-overlay/compute-selection.cjs.map +7 -0
- package/build/components/collaborators-overlay/cursor-dom-utils.cjs +243 -0
- package/build/components/collaborators-overlay/cursor-dom-utils.cjs.map +7 -0
- package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +6 -0
- package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +2 -2
- package/build/components/collaborators-overlay/overlay.cjs +61 -37
- package/build/components/collaborators-overlay/overlay.cjs.map +2 -2
- package/build/components/collaborators-overlay/timing-utils.cjs +46 -0
- package/build/components/collaborators-overlay/timing-utils.cjs.map +7 -0
- package/build/components/collaborators-overlay/use-block-highlighting.cjs +5 -6
- package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +2 -2
- package/build/components/collaborators-overlay/use-render-cursors.cjs +50 -140
- package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
- package/build/components/collaborators-presence/index.cjs +38 -12
- package/build/components/collaborators-presence/index.cjs.map +2 -2
- package/build/components/collaborators-presence/list.cjs +27 -24
- package/build/components/collaborators-presence/list.cjs.map +2 -2
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs +79 -107
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +3 -3
- package/build/components/editor-interface/index.cjs +9 -6
- package/build/components/editor-interface/index.cjs.map +2 -2
- package/build/components/inserter-sidebar/index.cjs +2 -1
- package/build/components/inserter-sidebar/index.cjs.map +2 -2
- package/build/components/page-attributes/parent.cjs +1 -1
- package/build/components/page-attributes/parent.cjs.map +2 -2
- package/build/components/post-locked-modal/index.cjs +16 -3
- package/build/components/post-locked-modal/index.cjs.map +2 -2
- package/build/components/post-revisions-preview/block-diff.cjs +39 -11
- package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
- package/build/components/post-revisions-preview/diff-markers.cjs +2 -2
- package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
- package/build/components/post-revisions-preview/revisions-canvas.cjs +12 -75
- package/build/components/post-revisions-preview/revisions-canvas.cjs.map +3 -3
- package/build/components/post-revisions-preview/revisions-slider.cjs +5 -1
- package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
- package/build/components/post-template/block-theme.cjs +7 -4
- package/build/components/post-template/block-theme.cjs.map +2 -2
- package/build/components/post-template/hooks.cjs +39 -2
- package/build/components/post-template/hooks.cjs.map +2 -2
- package/build/components/post-template/panel.cjs +5 -42
- package/build/components/post-template/panel.cjs.map +3 -3
- package/build/components/preferences-modal/index.cjs +24 -0
- package/build/components/preferences-modal/index.cjs.map +2 -2
- package/build/components/provider/disable-non-page-content-blocks.cjs +31 -28
- package/build/components/provider/disable-non-page-content-blocks.cjs.map +3 -3
- package/build/components/provider/index.cjs +17 -5
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/use-block-editor-settings.cjs +19 -5
- package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
- package/build/components/provider/{use-post-content-blocks.cjs → use-post-content-block-types.cjs} +8 -19
- package/build/components/provider/use-post-content-block-types.cjs.map +7 -0
- package/build/components/provider/use-revision-blocks.cjs +106 -0
- package/build/components/provider/use-revision-blocks.cjs.map +7 -0
- package/build/components/revision-block-diff/index.cjs +84 -0
- package/build/components/revision-block-diff/index.cjs.map +7 -0
- package/build/components/sidebar/dataform-post-summary.cjs +36 -6
- package/build/components/sidebar/dataform-post-summary.cjs.map +2 -2
- package/build/components/sidebar/header.cjs +1 -1
- package/build/components/sidebar/header.cjs.map +2 -2
- package/build/components/sidebar/index.cjs +5 -1
- package/build/components/sidebar/index.cjs.map +3 -3
- package/build/components/{sync-connection-modal → sync-connection-error-modal}/index.cjs +90 -78
- package/build/components/sync-connection-error-modal/index.cjs.map +7 -0
- package/build/components/{sync-connection-modal → sync-connection-error-modal}/use-retry-countdown.cjs +14 -27
- package/build/components/sync-connection-error-modal/use-retry-countdown.cjs.map +7 -0
- package/build/components/template-content-panel/index.cjs +35 -31
- package/build/components/template-content-panel/index.cjs.map +3 -3
- package/build/components/visual-editor/index.cjs +2 -2
- package/build/components/visual-editor/index.cjs.map +2 -2
- package/build/store/actions.cjs +1 -3
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-actions.cjs +11 -2
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +52 -13
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +12 -0
- package/build/store/reducer.cjs.map +2 -2
- package/build/utils/media-finalize/index.cjs +43 -0
- package/build/utils/media-finalize/index.cjs.map +7 -0
- package/build/utils/sync-error-messages.cjs +29 -16
- package/build/utils/sync-error-messages.cjs.map +3 -3
- package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs +12 -4
- package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/compute-selection.mjs +162 -0
- package/build-module/components/collaborators-overlay/compute-selection.mjs.map +7 -0
- package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs +213 -0
- package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs.map +7 -0
- package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +6 -0
- package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/overlay.mjs +61 -37
- package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/timing-utils.mjs +21 -0
- package/build-module/components/collaborators-overlay/timing-utils.mjs.map +7 -0
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +5 -6
- package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs +50 -140
- package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
- package/build-module/components/collaborators-presence/index.mjs +39 -13
- package/build-module/components/collaborators-presence/index.mjs.map +2 -2
- package/build-module/components/collaborators-presence/list.mjs +27 -24
- package/build-module/components/collaborators-presence/list.mjs.map +2 -2
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +80 -108
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
- package/build-module/components/editor-interface/index.mjs +10 -7
- package/build-module/components/editor-interface/index.mjs.map +2 -2
- package/build-module/components/inserter-sidebar/index.mjs +2 -1
- package/build-module/components/inserter-sidebar/index.mjs.map +2 -2
- package/build-module/components/page-attributes/parent.mjs +1 -1
- package/build-module/components/page-attributes/parent.mjs.map +2 -2
- package/build-module/components/post-locked-modal/index.mjs +16 -3
- package/build-module/components/post-locked-modal/index.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/block-diff.mjs +39 -11
- package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/diff-markers.mjs +2 -2
- package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs +14 -80
- package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +5 -1
- package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
- package/build-module/components/post-template/block-theme.mjs +7 -4
- package/build-module/components/post-template/block-theme.mjs.map +2 -2
- package/build-module/components/post-template/hooks.mjs +37 -1
- package/build-module/components/post-template/hooks.mjs.map +2 -2
- package/build-module/components/post-template/panel.mjs +5 -42
- package/build-module/components/post-template/panel.mjs.map +2 -2
- package/build-module/components/preferences-modal/index.mjs +24 -0
- package/build-module/components/preferences-modal/index.mjs.map +2 -2
- package/build-module/components/provider/disable-non-page-content-blocks.mjs +31 -28
- package/build-module/components/provider/disable-non-page-content-blocks.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +17 -5
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +19 -5
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/provider/use-post-content-block-types.mjs +23 -0
- package/build-module/components/provider/use-post-content-block-types.mjs.map +7 -0
- package/build-module/components/provider/use-revision-blocks.mjs +81 -0
- package/build-module/components/provider/use-revision-blocks.mjs.map +7 -0
- package/build-module/components/revision-block-diff/index.mjs +53 -0
- package/build-module/components/revision-block-diff/index.mjs.map +7 -0
- package/build-module/components/sidebar/dataform-post-summary.mjs +36 -6
- package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
- package/build-module/components/sidebar/header.mjs +1 -1
- package/build-module/components/sidebar/header.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +5 -1
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/sync-connection-error-modal/index.mjs +177 -0
- package/build-module/components/sync-connection-error-modal/index.mjs.map +7 -0
- package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +36 -0
- package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +7 -0
- package/build-module/components/template-content-panel/index.mjs +25 -31
- package/build-module/components/template-content-panel/index.mjs.map +2 -2
- package/build-module/components/visual-editor/index.mjs +2 -2
- package/build-module/components/visual-editor/index.mjs.map +2 -2
- package/build-module/store/actions.mjs +1 -3
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +10 -2
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +50 -12
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +11 -0
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/utils/media-finalize/index.mjs +12 -0
- package/build-module/utils/media-finalize/index.mjs.map +7 -0
- package/build-module/utils/sync-error-messages.mjs +24 -16
- package/build-module/utils/sync-error-messages.mjs.map +3 -3
- package/build-style/style-rtl.css +95 -16
- package/build-style/style.css +95 -16
- package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts +1 -1
- package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/compute-selection.d.ts +24 -0
- package/build-types/components/collaborators-overlay/compute-selection.d.ts.map +1 -0
- package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts +72 -0
- package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts.map +1 -0
- package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +1 -1
- package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/timing-utils.d.ts +11 -0
- package/build-types/components/collaborators-overlay/timing-utils.d.ts.map +1 -0
- package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
- package/build-types/components/collaborators-overlay/use-render-cursors.d.ts +4 -0
- package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/list.d.ts +2 -1
- package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts +2 -2
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/revisions-canvas.d.ts +2 -5
- package/build-types/components/post-revisions-preview/revisions-canvas.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
- package/build-types/components/post-template/block-theme.d.ts +1 -3
- package/build-types/components/post-template/block-theme.d.ts.map +1 -1
- package/build-types/components/post-template/hooks.d.ts +1 -0
- package/build-types/components/post-template/hooks.d.ts.map +1 -1
- package/build-types/components/post-template/panel.d.ts.map +1 -1
- package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/provider/use-post-content-block-types.d.ts +9 -0
- package/build-types/components/provider/use-post-content-block-types.d.ts.map +1 -0
- package/build-types/components/provider/use-revision-blocks.d.ts +10 -0
- package/build-types/components/provider/use-revision-blocks.d.ts.map +1 -0
- package/build-types/components/revision-block-diff/index.d.ts +6 -0
- package/build-types/components/revision-block-diff/index.d.ts.map +1 -0
- package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/sync-connection-error-modal/index.d.ts +22 -0
- package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -0
- package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts +11 -0
- package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -0
- package/build-types/components/template-content-panel/index.d.ts.map +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +7 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +7 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +14 -3
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/utils/media-finalize/index.d.ts +2 -0
- package/build-types/utils/media-finalize/index.d.ts.map +1 -0
- package/build-types/utils/sync-error-messages.d.ts +17 -3
- package/build-types/utils/sync-error-messages.d.ts.map +1 -1
- package/package.json +44 -44
- package/src/components/collaborators-overlay/avatar-iframe-styles.ts +12 -4
- package/src/components/collaborators-overlay/compute-selection.ts +307 -0
- package/src/components/collaborators-overlay/cursor-dom-utils.ts +382 -0
- package/src/components/collaborators-overlay/overlay-iframe-styles.ts +6 -0
- package/src/components/collaborators-overlay/overlay.tsx +59 -27
- package/src/components/collaborators-overlay/timing-utils.ts +30 -0
- package/src/components/collaborators-overlay/use-block-highlighting.ts +11 -10
- package/src/components/collaborators-overlay/use-render-cursors.ts +70 -242
- package/src/components/collaborators-presence/avatar/styles.scss +20 -4
- package/src/components/collaborators-presence/index.tsx +30 -5
- package/src/components/collaborators-presence/list.tsx +38 -24
- package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +188 -246
- package/src/components/collaborators-presence/use-collaborator-notifications.ts +109 -166
- package/src/components/document-bar/style.scss +1 -1
- package/src/components/editor-interface/index.js +8 -6
- package/src/components/inserter-sidebar/index.js +4 -1
- package/src/components/page-attributes/parent.js +1 -1
- package/src/components/post-locked-modal/index.js +21 -3
- package/src/components/post-revisions-preview/block-diff.js +59 -20
- package/src/components/post-revisions-preview/diff-markers.js +2 -2
- package/src/components/post-revisions-preview/revisions-canvas.js +20 -98
- package/src/components/post-revisions-preview/revisions-slider.js +6 -1
- package/src/components/post-revisions-preview/test/block-diff.js +69 -31
- package/src/components/post-template/block-theme.js +4 -1
- package/src/components/post-template/hooks.js +42 -0
- package/src/components/post-template/panel.js +5 -59
- package/src/components/preferences-modal/index.js +18 -0
- package/src/components/provider/disable-non-page-content-blocks.js +42 -40
- package/src/components/provider/index.js +20 -2
- package/src/components/provider/use-block-editor-settings.js +21 -8
- package/src/components/provider/use-post-content-block-types.js +30 -0
- package/src/components/provider/use-revision-blocks.js +105 -0
- package/src/components/revision-block-diff/index.js +74 -0
- package/src/components/revision-block-diff/style.scss +13 -0
- package/src/components/sidebar/dataform-post-summary.js +61 -16
- package/src/components/sidebar/header.js +1 -1
- package/src/components/sidebar/index.js +2 -0
- package/src/components/sync-connection-error-modal/index.tsx +265 -0
- package/src/components/sync-connection-error-modal/style.scss +14 -0
- package/src/components/sync-connection-error-modal/use-retry-countdown.ts +57 -0
- package/src/components/template-content-panel/index.js +30 -38
- package/src/components/visual-editor/index.js +2 -2
- package/src/store/actions.js +1 -4
- package/src/store/private-actions.js +21 -2
- package/src/store/private-selectors.js +75 -10
- package/src/store/reducer.js +19 -0
- package/src/style.scss +2 -1
- package/src/utils/media-finalize/index.js +11 -0
- package/src/utils/media-finalize/test/index.js +34 -0
- package/src/utils/sync-error-messages.ts +72 -0
- package/src/utils/test/sync-error-messages.js +9 -32
- package/build/components/provider/use-post-content-blocks.cjs.map +0 -7
- package/build/components/sync-connection-modal/index.cjs.map +0 -7
- package/build/components/sync-connection-modal/use-retry-countdown.cjs.map +0 -7
- package/build-module/components/provider/use-post-content-blocks.mjs +0 -34
- package/build-module/components/provider/use-post-content-blocks.mjs.map +0 -7
- package/build-module/components/sync-connection-modal/index.mjs +0 -167
- package/build-module/components/sync-connection-modal/index.mjs.map +0 -7
- package/build-module/components/sync-connection-modal/use-retry-countdown.mjs +0 -49
- package/build-module/components/sync-connection-modal/use-retry-countdown.mjs.map +0 -7
- package/build-types/components/provider/use-post-content-blocks.d.ts +0 -2
- package/build-types/components/provider/use-post-content-blocks.d.ts.map +0 -1
- package/build-types/components/sync-connection-modal/index.d.ts +0 -8
- package/build-types/components/sync-connection-modal/index.d.ts.map +0 -1
- package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts +0 -9
- package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts.map +0 -1
- package/src/components/provider/use-post-content-blocks.js +0 -42
- package/src/components/sync-connection-modal/index.js +0 -200
- package/src/components/sync-connection-modal/style.scss +0 -9
- package/src/components/sync-connection-modal/use-retry-countdown.js +0 -70
- package/src/utils/sync-error-messages.js +0 -58
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect, select } from '@wordpress/data';
|
|
5
|
-
import { useCopyToClipboard } from '@wordpress/compose';
|
|
6
|
-
import { serialize } from '@wordpress/blocks';
|
|
7
|
-
import {
|
|
8
|
-
store as coreDataStore,
|
|
9
|
-
privateApis as coreDataPrivateApis,
|
|
10
|
-
} from '@wordpress/core-data';
|
|
11
|
-
import {
|
|
12
|
-
privateApis,
|
|
13
|
-
store as blockEditorStore,
|
|
14
|
-
} from '@wordpress/block-editor';
|
|
15
|
-
import {
|
|
16
|
-
Button,
|
|
17
|
-
Modal,
|
|
18
|
-
__experimentalHStack as HStack,
|
|
19
|
-
__experimentalVStack as VStack,
|
|
20
|
-
} from '@wordpress/components';
|
|
21
|
-
import { useState, useEffect, useRef } from '@wordpress/element';
|
|
22
|
-
import { __, sprintf, _n } from '@wordpress/i18n';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Internal dependencies
|
|
26
|
-
*/
|
|
27
|
-
import { getSyncErrorMessages } from '../../utils/sync-error-messages';
|
|
28
|
-
import { store as editorStore } from '../../store';
|
|
29
|
-
import { unlock } from '../../lock-unlock';
|
|
30
|
-
import { useRetryCountdown } from './use-retry-countdown';
|
|
31
|
-
|
|
32
|
-
const { BlockCanvasCover } = unlock( privateApis );
|
|
33
|
-
const { retrySyncConnection } = unlock( coreDataPrivateApis );
|
|
34
|
-
|
|
35
|
-
// Debounce time for initial disconnected status to allow connection to establish.
|
|
36
|
-
const INITIAL_DISCONNECTED_DEBOUNCE_MS = 5000;
|
|
37
|
-
const noop = () => {};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Sync connection modal that displays when any entity reports a disconnection.
|
|
41
|
-
* Uses BlockCanvasCover.Fill to render in the block canvas.
|
|
42
|
-
*
|
|
43
|
-
* @return {Element|null} The modal component or null if not disconnected.
|
|
44
|
-
*/
|
|
45
|
-
export function SyncConnectionModal() {
|
|
46
|
-
const { connectionState, postType } = useSelect( ( selectFn ) => {
|
|
47
|
-
const currentPostType = selectFn( editorStore ).getCurrentPostType();
|
|
48
|
-
return {
|
|
49
|
-
connectionState:
|
|
50
|
-
selectFn( coreDataStore ).getSyncConnectionStatus() || null,
|
|
51
|
-
postType: currentPostType
|
|
52
|
-
? selectFn( coreDataStore ).getPostType( currentPostType )
|
|
53
|
-
: null,
|
|
54
|
-
};
|
|
55
|
-
}, [] );
|
|
56
|
-
|
|
57
|
-
const { secondsRemaining, markRetrying } = useRetryCountdown(
|
|
58
|
-
connectionState?.retryInMs,
|
|
59
|
-
connectionState?.status
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
const copyButtonRef = useCopyToClipboard( () => {
|
|
63
|
-
const blocks = select( blockEditorStore ).getBlocks();
|
|
64
|
-
return serialize( blocks );
|
|
65
|
-
} );
|
|
66
|
-
const [ syncConnectionMessage, setSyncConnectionMessage ] =
|
|
67
|
-
useState( null );
|
|
68
|
-
const debounceTimerRef = useRef( null );
|
|
69
|
-
// Track whether we've passed the initial load phase.
|
|
70
|
-
// Once true, disconnected status will show immediately without debounce.
|
|
71
|
-
const hasInitializedRef = useRef( false );
|
|
72
|
-
|
|
73
|
-
const connectionStatus = connectionState?.status;
|
|
74
|
-
const connectionErrorCode = connectionState?.error?.code;
|
|
75
|
-
|
|
76
|
-
useEffect( () => {
|
|
77
|
-
// Clear any pending debounce timer when status changes.
|
|
78
|
-
if ( debounceTimerRef.current ) {
|
|
79
|
-
clearTimeout( debounceTimerRef.current );
|
|
80
|
-
debounceTimerRef.current = null;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if ( connectionStatus === 'connected' ) {
|
|
84
|
-
hasInitializedRef.current = true;
|
|
85
|
-
setSyncConnectionMessage( null );
|
|
86
|
-
} else if ( connectionStatus === 'disconnected' ) {
|
|
87
|
-
const showModal = () => {
|
|
88
|
-
hasInitializedRef.current = true;
|
|
89
|
-
setSyncConnectionMessage(
|
|
90
|
-
getSyncErrorMessages( { code: connectionErrorCode } )
|
|
91
|
-
);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// Debounce only on first load to allow connection to establish.
|
|
95
|
-
if ( hasInitializedRef.current ) {
|
|
96
|
-
showModal();
|
|
97
|
-
} else {
|
|
98
|
-
debounceTimerRef.current = setTimeout(
|
|
99
|
-
showModal,
|
|
100
|
-
INITIAL_DISCONNECTED_DEBOUNCE_MS
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return () => {
|
|
106
|
-
if ( debounceTimerRef.current ) {
|
|
107
|
-
clearTimeout( debounceTimerRef.current );
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}, [ connectionStatus, connectionErrorCode ] );
|
|
111
|
-
|
|
112
|
-
if ( ! syncConnectionMessage ) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const { title, description, canRetry } = syncConnectionMessage;
|
|
117
|
-
|
|
118
|
-
let retryCountdownText;
|
|
119
|
-
if ( secondsRemaining > 0 ) {
|
|
120
|
-
retryCountdownText = sprintf(
|
|
121
|
-
/* translators: %d: number of seconds until retry */
|
|
122
|
-
_n(
|
|
123
|
-
'Retrying connection in %d second\u2026',
|
|
124
|
-
'Retrying connection in %d seconds\u2026',
|
|
125
|
-
secondsRemaining
|
|
126
|
-
),
|
|
127
|
-
secondsRemaining
|
|
128
|
-
);
|
|
129
|
-
} else if ( secondsRemaining === 0 ) {
|
|
130
|
-
retryCountdownText = __( 'Retrying\u2026' );
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
let editPostHref = 'edit.php';
|
|
134
|
-
if ( postType?.slug ) {
|
|
135
|
-
editPostHref = `edit.php?post_type=${ postType.slug }`;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const isRetrying = secondsRemaining === 0;
|
|
139
|
-
|
|
140
|
-
return (
|
|
141
|
-
<BlockCanvasCover.Fill>
|
|
142
|
-
<Modal
|
|
143
|
-
className="editor-sync-connection-modal"
|
|
144
|
-
isDismissible={ false }
|
|
145
|
-
onRequestClose={ noop }
|
|
146
|
-
shouldCloseOnClickOutside={ false }
|
|
147
|
-
shouldCloseOnEsc={ false }
|
|
148
|
-
size="medium"
|
|
149
|
-
title={ title }
|
|
150
|
-
>
|
|
151
|
-
<VStack spacing={ 6 }>
|
|
152
|
-
<p>{ description }</p>
|
|
153
|
-
{ retryCountdownText && (
|
|
154
|
-
<p className="editor-sync-connection-modal__retry-countdown">
|
|
155
|
-
{ retryCountdownText }
|
|
156
|
-
</p>
|
|
157
|
-
) }
|
|
158
|
-
<HStack justify="right">
|
|
159
|
-
<Button
|
|
160
|
-
__next40pxDefaultSize
|
|
161
|
-
href={ editPostHref }
|
|
162
|
-
isDestructive
|
|
163
|
-
variant="tertiary"
|
|
164
|
-
>
|
|
165
|
-
{ sprintf(
|
|
166
|
-
/* translators: %s: Post type name (e.g., "Posts", "Pages"). */
|
|
167
|
-
__( 'Back to %s' ),
|
|
168
|
-
postType?.labels?.name ?? __( 'Posts' )
|
|
169
|
-
) }
|
|
170
|
-
</Button>
|
|
171
|
-
<Button
|
|
172
|
-
__next40pxDefaultSize
|
|
173
|
-
ref={ copyButtonRef }
|
|
174
|
-
variant={ canRetry ? 'secondary' : 'primary' }
|
|
175
|
-
>
|
|
176
|
-
{ __( 'Copy Post Content' ) }
|
|
177
|
-
</Button>
|
|
178
|
-
{ canRetry && (
|
|
179
|
-
<Button
|
|
180
|
-
__next40pxDefaultSize
|
|
181
|
-
aria-disabled={ isRetrying }
|
|
182
|
-
isBusy={ isRetrying }
|
|
183
|
-
variant="primary"
|
|
184
|
-
onClick={ () => {
|
|
185
|
-
if ( isRetrying ) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
markRetrying();
|
|
189
|
-
retrySyncConnection();
|
|
190
|
-
} }
|
|
191
|
-
>
|
|
192
|
-
{ __( 'Retry' ) }
|
|
193
|
-
</Button>
|
|
194
|
-
) }
|
|
195
|
-
</HStack>
|
|
196
|
-
</VStack>
|
|
197
|
-
</Modal>
|
|
198
|
-
</BlockCanvasCover.Fill>
|
|
199
|
-
);
|
|
200
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useState, useEffect, useRef } from '@wordpress/element';
|
|
5
|
-
|
|
6
|
-
const MIN_RETRYING_DISPLAY_MS = 600;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook that computes a countdown in seconds from a retryInMs value.
|
|
10
|
-
*
|
|
11
|
-
* @param {number|undefined} retryInMs Milliseconds until next retry.
|
|
12
|
-
* @param {string|undefined} status Current connection status.
|
|
13
|
-
* @return {Object} Object with `secondsRemaining` (number|null) and `markRetrying` callback.
|
|
14
|
-
*/
|
|
15
|
-
export function useRetryCountdown( retryInMs, status ) {
|
|
16
|
-
const [ secondsRemaining, setSecondsRemaining ] = useState( null );
|
|
17
|
-
const [ isRetrying, setIsRetrying ] = useState( false );
|
|
18
|
-
const retryAtRef = useRef( null );
|
|
19
|
-
|
|
20
|
-
// Show "Retrying…" for a minimum duration when manually triggered.
|
|
21
|
-
const markRetrying = () => setIsRetrying( true );
|
|
22
|
-
|
|
23
|
-
useEffect( () => {
|
|
24
|
-
if ( ! isRetrying ) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const id = setTimeout(
|
|
28
|
-
() => setIsRetrying( false ),
|
|
29
|
-
MIN_RETRYING_DISPLAY_MS
|
|
30
|
-
);
|
|
31
|
-
return () => clearTimeout( id );
|
|
32
|
-
}, [ isRetrying ] );
|
|
33
|
-
|
|
34
|
-
useEffect( () => {
|
|
35
|
-
// Only clear countdown when explicitly connected.
|
|
36
|
-
if ( status === 'connected' ) {
|
|
37
|
-
setSecondsRemaining( null );
|
|
38
|
-
retryAtRef.current = null;
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// For transient states (e.g. 'connecting' during a retry attempt)
|
|
43
|
-
// or when retryInMs is not yet available, keep the previous
|
|
44
|
-
// countdown value to avoid a brief flash.
|
|
45
|
-
if ( status !== 'disconnected' || ! retryInMs ) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const retryAt = Date.now() + retryInMs;
|
|
50
|
-
retryAtRef.current = retryAt;
|
|
51
|
-
setSecondsRemaining( Math.ceil( retryInMs / 1000 ) );
|
|
52
|
-
|
|
53
|
-
const intervalId = setInterval( () => {
|
|
54
|
-
const remaining = Math.ceil(
|
|
55
|
-
( retryAtRef.current - Date.now() ) / 1000
|
|
56
|
-
);
|
|
57
|
-
setSecondsRemaining( Math.max( 0, remaining ) );
|
|
58
|
-
if ( remaining <= 0 ) {
|
|
59
|
-
clearInterval( intervalId );
|
|
60
|
-
setIsRetrying( true );
|
|
61
|
-
}
|
|
62
|
-
}, 1000 );
|
|
63
|
-
|
|
64
|
-
return () => clearInterval( intervalId );
|
|
65
|
-
}, [ retryInMs, status ] );
|
|
66
|
-
|
|
67
|
-
const displaySeconds = isRetrying ? 0 : secondsRemaining;
|
|
68
|
-
|
|
69
|
-
return { secondsRemaining: displaySeconds, markRetrying };
|
|
70
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Default error messages for known error codes.
|
|
8
|
-
*/
|
|
9
|
-
const ERROR_MESSAGES = {
|
|
10
|
-
'authentication-failed': {
|
|
11
|
-
title: __( 'Unable to connect' ),
|
|
12
|
-
description: __(
|
|
13
|
-
"Real-time collaboration couldn't verify your permissions. " +
|
|
14
|
-
'Check that you have access to edit this post, or contact your site administrator.'
|
|
15
|
-
),
|
|
16
|
-
canRetry: false,
|
|
17
|
-
},
|
|
18
|
-
'connection-expired': {
|
|
19
|
-
title: __( 'Connection expired' ),
|
|
20
|
-
description: __(
|
|
21
|
-
'Your connection to real-time collaboration has timed out. ' +
|
|
22
|
-
'Editing is paused to prevent conflicts with other editors.'
|
|
23
|
-
),
|
|
24
|
-
canRetry: true,
|
|
25
|
-
},
|
|
26
|
-
'connection-limit-exceeded': {
|
|
27
|
-
title: __( 'Too many editors connected' ),
|
|
28
|
-
description: __(
|
|
29
|
-
'Real-time collaboration has reached its connection limit. ' +
|
|
30
|
-
'Try again later or contact your site administrator.'
|
|
31
|
-
),
|
|
32
|
-
canRetry: true,
|
|
33
|
-
},
|
|
34
|
-
'unknown-error': {
|
|
35
|
-
title: __( 'Connection lost' ),
|
|
36
|
-
description: __(
|
|
37
|
-
'The connection to real-time collaboration was interrupted. ' +
|
|
38
|
-
'Editing is paused to prevent conflicts with other editors.'
|
|
39
|
-
),
|
|
40
|
-
canRetry: true,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Get user-facing title and description from a sync connection error.
|
|
46
|
-
*
|
|
47
|
-
* Provides default messages based on error.code.
|
|
48
|
-
*
|
|
49
|
-
* @param {Object} error - Connection error object.
|
|
50
|
-
* @return {Object} Object with title, description, and canRetry flag.
|
|
51
|
-
*/
|
|
52
|
-
export function getSyncErrorMessages( error ) {
|
|
53
|
-
if ( ERROR_MESSAGES[ error?.code ] ) {
|
|
54
|
-
return ERROR_MESSAGES[ error.code ];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return ERROR_MESSAGES[ 'unknown-error' ];
|
|
58
|
-
}
|