@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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import mediaFinalize from '..';
|
|
10
|
+
|
|
11
|
+
jest.mock( '@wordpress/api-fetch', () => jest.fn() );
|
|
12
|
+
|
|
13
|
+
describe( 'mediaFinalize', () => {
|
|
14
|
+
beforeEach( () => {
|
|
15
|
+
jest.clearAllMocks();
|
|
16
|
+
} );
|
|
17
|
+
|
|
18
|
+
it( 'should call the finalize endpoint with the correct path and method', async () => {
|
|
19
|
+
apiFetch.mockResolvedValue( {} );
|
|
20
|
+
|
|
21
|
+
await mediaFinalize( 123 );
|
|
22
|
+
|
|
23
|
+
expect( apiFetch ).toHaveBeenCalledWith( {
|
|
24
|
+
path: '/wp/v2/media/123/finalize',
|
|
25
|
+
method: 'POST',
|
|
26
|
+
} );
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
it( 'should propagate errors from apiFetch', async () => {
|
|
30
|
+
apiFetch.mockRejectedValue( new Error( 'Network error' ) );
|
|
31
|
+
|
|
32
|
+
await expect( mediaFinalize( 456 ) ).rejects.toThrow( 'Network error' );
|
|
33
|
+
} );
|
|
34
|
+
} );
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { type ConnectionError } from '@wordpress/core-data';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
// These error codes are defined in the sync package:
|
|
8
|
+
// packages/sync/src/errors.ts
|
|
9
|
+
export const AUTHENTICATION_FAILED = 'authentication-failed';
|
|
10
|
+
export const CONNECTION_EXPIRED = 'connection-expired';
|
|
11
|
+
export const CONNECTION_LIMIT_EXCEEDED = 'connection-limit-exceeded';
|
|
12
|
+
export const DOCUMENT_SIZE_LIMIT_EXCEEDED = 'document-size-limit-exceeded';
|
|
13
|
+
export const UNKNOWN_ERROR = 'unknown-error';
|
|
14
|
+
|
|
15
|
+
interface ConnectionErrorMessages {
|
|
16
|
+
description: string;
|
|
17
|
+
title: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Default error messages for known error codes.
|
|
22
|
+
*/
|
|
23
|
+
const ERROR_MESSAGES: Record< string, ConnectionErrorMessages > = {
|
|
24
|
+
[ AUTHENTICATION_FAILED ]: {
|
|
25
|
+
title: __( 'Unable to connect' ),
|
|
26
|
+
description: __(
|
|
27
|
+
"Real-time collaboration couldn't verify your permissions. " +
|
|
28
|
+
'Check that you have access to edit this post or contact your site administrator.'
|
|
29
|
+
),
|
|
30
|
+
},
|
|
31
|
+
[ CONNECTION_EXPIRED ]: {
|
|
32
|
+
title: __( 'Connection expired' ),
|
|
33
|
+
description: __(
|
|
34
|
+
'Your connection to real-time collaboration has timed out. ' +
|
|
35
|
+
'Editing is paused to prevent conflicts with other editors.'
|
|
36
|
+
),
|
|
37
|
+
},
|
|
38
|
+
[ CONNECTION_LIMIT_EXCEEDED ]: {
|
|
39
|
+
title: __( 'Too many editors connected' ),
|
|
40
|
+
description: __(
|
|
41
|
+
'Real-time collaboration has reached its connection limit. ' +
|
|
42
|
+
'Try again later or contact your site administrator.'
|
|
43
|
+
),
|
|
44
|
+
},
|
|
45
|
+
// DOCUMENT_SIZE_LIMIT_EXCEEDED is not included here because it results in
|
|
46
|
+
// collaboration being disabled entirely.
|
|
47
|
+
[ UNKNOWN_ERROR ]: {
|
|
48
|
+
title: __( 'Connection lost' ),
|
|
49
|
+
description: __(
|
|
50
|
+
'The connection to real-time collaboration was interrupted. ' +
|
|
51
|
+
'Editing is paused to prevent conflicts with other editors.'
|
|
52
|
+
),
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get user-facing title and description from a sync connection error.
|
|
58
|
+
*
|
|
59
|
+
* Provides default messages based on error.code.
|
|
60
|
+
*
|
|
61
|
+
* @param error - Connection error.
|
|
62
|
+
* @return Object with title, description, and canRetry flag.
|
|
63
|
+
*/
|
|
64
|
+
export function getSyncErrorMessages(
|
|
65
|
+
error?: ConnectionError
|
|
66
|
+
): ConnectionErrorMessages {
|
|
67
|
+
if ( error?.code && ERROR_MESSAGES[ error?.code ] ) {
|
|
68
|
+
return ERROR_MESSAGES[ error.code ];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return ERROR_MESSAGES[ UNKNOWN_ERROR ];
|
|
72
|
+
}
|
|
@@ -8,39 +8,16 @@ describe( 'getSyncErrorMessages', () => {
|
|
|
8
8
|
'authentication-failed',
|
|
9
9
|
'connection-expired',
|
|
10
10
|
'connection-limit-exceeded',
|
|
11
|
+
'document-size-limit-exceeded',
|
|
11
12
|
'unknown-error',
|
|
12
|
-
] )(
|
|
13
|
-
|
|
14
|
-
(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
expect.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
canRetry: expect.any( Boolean ),
|
|
21
|
-
} )
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
it( 'should set canRetry to false for authentication-failed', () => {
|
|
27
|
-
const result = getSyncErrorMessages( {
|
|
28
|
-
code: 'authentication-failed',
|
|
29
|
-
} );
|
|
30
|
-
expect( result.canRetry ).toBe( false );
|
|
31
|
-
} );
|
|
32
|
-
|
|
33
|
-
it( 'should set canRetry to true for retryable errors', () => {
|
|
34
|
-
expect(
|
|
35
|
-
getSyncErrorMessages( { code: 'connection-expired' } ).canRetry
|
|
36
|
-
).toBe( true );
|
|
37
|
-
expect(
|
|
38
|
-
getSyncErrorMessages( { code: 'connection-limit-exceeded' } )
|
|
39
|
-
.canRetry
|
|
40
|
-
).toBe( true );
|
|
41
|
-
expect(
|
|
42
|
-
getSyncErrorMessages( { code: 'unknown-error' } ).canRetry
|
|
43
|
-
).toBe( true );
|
|
13
|
+
] )( 'should return title and description for "%s"', ( code ) => {
|
|
14
|
+
const result = getSyncErrorMessages( { code } );
|
|
15
|
+
expect( result ).toEqual(
|
|
16
|
+
expect.objectContaining( {
|
|
17
|
+
title: expect.any( String ),
|
|
18
|
+
description: expect.any( String ),
|
|
19
|
+
} )
|
|
20
|
+
);
|
|
44
21
|
} );
|
|
45
22
|
|
|
46
23
|
it( 'should fall back to unknown-error for unrecognized codes', () => {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/provider/use-post-content-blocks.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst POST_CONTENT_BLOCK_TYPES = [\n\t'core/post-title',\n\t'core/post-featured-image',\n\t'core/post-content',\n];\n\nexport default function usePostContentBlocks() {\n\tconst contentOnlyBlockTypes = useMemo(\n\t\t() => [\n\t\t\t...applyFilters(\n\t\t\t\t'editor.postContentBlockTypes',\n\t\t\t\tPOST_CONTENT_BLOCK_TYPES\n\t\t\t),\n\t\t],\n\t\t[]\n\t);\n\n\t// Note that there are two separate subscriptions because the result for each\n\t// returns a new array.\n\tconst contentOnlyIds = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostBlocksByName } = unlock( select( editorStore ) );\n\t\t\treturn getPostBlocksByName( contentOnlyBlockTypes );\n\t\t},\n\t\t[ contentOnlyBlockTypes ]\n\t);\n\n\treturn contentOnlyIds;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,qBAAwB;AACxB,mBAA6B;AAK7B,mBAAqC;AACrC,yBAAuB;AAEvB,IAAM,2BAA2B;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACD;AAEe,SAAR,uBAAwC;AAC9C,QAAM,4BAAwB;AAAA,IAC7B,MAAM;AAAA,MACL,OAAG;AAAA,QACF;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AAIA,QAAM,qBAAiB;AAAA,IACtB,CAAE,WAAY;AACb,YAAM,EAAE,oBAAoB,QAAI,2BAAQ,OAAQ,aAAAA,KAAY,CAAE;AAC9D,aAAO,oBAAqB,qBAAsB;AAAA,IACnD;AAAA,IACA,CAAE,qBAAsB;AAAA,EACzB;AAEA,SAAO;AACR;",
|
|
6
|
-
"names": ["editorStore"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/sync-connection-modal/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, select } from '@wordpress/data';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { serialize } from '@wordpress/blocks';\nimport {\n\tstore as coreDataStore,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport {\n\tprivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState, useEffect, useRef } 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 = 5000;\nconst noop = () => {};\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 {Element|null} The modal component or null if not disconnected.\n */\nexport function SyncConnectionModal() {\n\tconst { connectionState, postType } = useSelect( ( selectFn ) => {\n\t\tconst currentPostType = selectFn( editorStore ).getCurrentPostType();\n\t\treturn {\n\t\t\tconnectionState:\n\t\t\t\tselectFn( coreDataStore ).getSyncConnectionStatus() || null,\n\t\t\tpostType: currentPostType\n\t\t\t\t? selectFn( coreDataStore ).getPostType( currentPostType )\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst { secondsRemaining, markRetrying } = useRetryCountdown(\n\t\tconnectionState?.retryInMs,\n\t\tconnectionState?.status\n\t);\n\n\tconst copyButtonRef = useCopyToClipboard( () => {\n\t\tconst blocks = select( blockEditorStore ).getBlocks();\n\t\treturn serialize( blocks );\n\t} );\n\tconst [ syncConnectionMessage, setSyncConnectionMessage ] =\n\t\tuseState( null );\n\tconst debounceTimerRef = useRef( null );\n\t// Track whether we've passed the initial load phase.\n\t// Once true, disconnected status will show immediately without debounce.\n\tconst hasInitializedRef = useRef( false );\n\n\tconst connectionStatus = connectionState?.status;\n\tconst connectionErrorCode = connectionState?.error?.code;\n\n\tuseEffect( () => {\n\t\t// Clear any pending debounce timer when status changes.\n\t\tif ( debounceTimerRef.current ) {\n\t\t\tclearTimeout( debounceTimerRef.current );\n\t\t\tdebounceTimerRef.current = null;\n\t\t}\n\n\t\tif ( connectionStatus === 'connected' ) {\n\t\t\thasInitializedRef.current = true;\n\t\t\tsetSyncConnectionMessage( null );\n\t\t} else if ( connectionStatus === 'disconnected' ) {\n\t\t\tconst showModal = () => {\n\t\t\t\thasInitializedRef.current = true;\n\t\t\t\tsetSyncConnectionMessage(\n\t\t\t\t\tgetSyncErrorMessages( { code: connectionErrorCode } )\n\t\t\t\t);\n\t\t\t};\n\n\t\t\t// Debounce only on first load to allow connection to establish.\n\t\t\tif ( hasInitializedRef.current ) {\n\t\t\t\tshowModal();\n\t\t\t} else {\n\t\t\t\tdebounceTimerRef.current = setTimeout(\n\t\t\t\t\tshowModal,\n\t\t\t\t\tINITIAL_DISCONNECTED_DEBOUNCE_MS\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( debounceTimerRef.current ) {\n\t\t\t\tclearTimeout( debounceTimerRef.current );\n\t\t\t}\n\t\t};\n\t}, [ connectionStatus, connectionErrorCode ] );\n\n\tif ( ! syncConnectionMessage ) {\n\t\treturn null;\n\t}\n\n\tconst { title, description, canRetry } = syncConnectionMessage;\n\n\tlet retryCountdownText;\n\tif ( 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 ( secondsRemaining === 0 ) {\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\tconst isRetrying = secondsRemaining === 0;\n\n\treturn (\n\t\t<BlockCanvasCover.Fill>\n\t\t\t<Modal\n\t\t\t\tclassName=\"editor-sync-connection-modal\"\n\t\t\t\tisDismissible={ false }\n\t\t\t\tonRequestClose={ noop }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t\tshouldCloseOnEsc={ false }\n\t\t\t\tsize=\"medium\"\n\t\t\t\ttitle={ title }\n\t\t\t>\n\t\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t\t<p>{ description }</p>\n\t\t\t\t\t{ retryCountdownText && (\n\t\t\t\t\t\t<p className=\"editor-sync-connection-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={ canRetry ? '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{ canRetry && (\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\taria-disabled={ 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={ () => {\n\t\t\t\t\t\t\t\t\tif ( isRetrying ) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmarkRetrying();\n\t\t\t\t\t\t\t\t\tretrySyncConnection();\n\t\t\t\t\t\t\t\t} }\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;AACnC,oBAA0B;AAC1B,uBAGO;AACP,0BAGO;AACP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a;AAAA,cACb,SAAQ;AAAA,cAEN;AAAA;AAAA,oBAED,gBAAI,YAAa;AAAA,gBACjB,UAAU,QAAQ,YAAQ,gBAAI,OAAQ;AAAA,cACvC;AAAA;AAAA,UACD;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,KAAM;AAAA,cACN,SAAU,WAAW,cAAc;AAAA,cAEjC,8BAAI,mBAAoB;AAAA;AAAA,UAC3B;AAAA,UACE,YACD;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,iBAAgB;AAAA,cAChB,QAAS;AAAA,cACT,SAAQ;AAAA,cACR,SAAU,MAAM;AACf,oBAAK,YAAa;AACjB;AAAA,gBACD;AACA,6BAAa;AACb,oCAAoB;AAAA,cACrB;AAAA,cAEE,8BAAI,OAAQ;AAAA;AAAA,UACf;AAAA,WAEF;AAAA,SACD;AAAA;AAAA,EACD,GACD;AAEF;",
|
|
6
|
-
"names": ["coreDataPrivateApis", "editorStore", "coreDataStore", "blockEditorStore", "VStack", "HStack"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/sync-connection-modal/use-retry-countdown.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useRef } from '@wordpress/element';\n\nconst MIN_RETRYING_DISPLAY_MS = 600;\n\n/**\n * Hook that computes a countdown in seconds from a retryInMs value.\n *\n * @param {number|undefined} retryInMs Milliseconds until next retry.\n * @param {string|undefined} status Current connection status.\n * @return {Object} Object with `secondsRemaining` (number|null) and `markRetrying` callback.\n */\nexport function useRetryCountdown( retryInMs, status ) {\n\tconst [ secondsRemaining, setSecondsRemaining ] = useState( null );\n\tconst [ isRetrying, setIsRetrying ] = useState( false );\n\tconst retryAtRef = useRef( null );\n\n\t// Show \"Retrying\u2026\" for a minimum duration when manually triggered.\n\tconst markRetrying = () => setIsRetrying( true );\n\n\tuseEffect( () => {\n\t\tif ( ! isRetrying ) {\n\t\t\treturn;\n\t\t}\n\t\tconst id = setTimeout(\n\t\t\t() => setIsRetrying( false ),\n\t\t\tMIN_RETRYING_DISPLAY_MS\n\t\t);\n\t\treturn () => clearTimeout( id );\n\t}, [ isRetrying ] );\n\n\tuseEffect( () => {\n\t\t// Only clear countdown when explicitly connected.\n\t\tif ( status === 'connected' ) {\n\t\t\tsetSecondsRemaining( null );\n\t\t\tretryAtRef.current = null;\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 ( status !== 'disconnected' || ! retryInMs ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst retryAt = Date.now() + retryInMs;\n\t\tretryAtRef.current = retryAt;\n\t\tsetSecondsRemaining( Math.ceil( retryInMs / 1000 ) );\n\n\t\tconst intervalId = setInterval( () => {\n\t\t\tconst remaining = Math.ceil(\n\t\t\t\t( retryAtRef.current - Date.now() ) / 1000\n\t\t\t);\n\t\t\tsetSecondsRemaining( Math.max( 0, remaining ) );\n\t\t\tif ( remaining <= 0 ) {\n\t\t\t\tclearInterval( intervalId );\n\t\t\t\tsetIsRetrying( true );\n\t\t\t}\n\t\t}, 1000 );\n\n\t\treturn () => clearInterval( intervalId );\n\t}, [ retryInMs, status ] );\n\n\tconst displaySeconds = isRetrying ? 0 : secondsRemaining;\n\n\treturn { secondsRemaining: displaySeconds, markRetrying };\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4C;AAE5C,IAAM,0BAA0B;AASzB,SAAS,kBAAmB,WAAW,QAAS;AACtD,QAAM,CAAE,kBAAkB,mBAAoB,QAAI,yBAAU,IAAK;AACjE,QAAM,CAAE,YAAY,aAAc,QAAI,yBAAU,KAAM;AACtD,QAAM,iBAAa,uBAAQ,IAAK;AAGhC,QAAM,eAAe,MAAM,cAAe,IAAK;AAE/C,gCAAW,MAAM;AAChB,QAAK,CAAE,YAAa;AACnB;AAAA,IACD;AACA,UAAM,KAAK;AAAA,MACV,MAAM,cAAe,KAAM;AAAA,MAC3B;AAAA,IACD;AACA,WAAO,MAAM,aAAc,EAAG;AAAA,EAC/B,GAAG,CAAE,UAAW,CAAE;AAElB,gCAAW,MAAM;AAEhB,QAAK,WAAW,aAAc;AAC7B,0BAAqB,IAAK;AAC1B,iBAAW,UAAU;AACrB;AAAA,IACD;AAKA,QAAK,WAAW,kBAAkB,CAAE,WAAY;AAC/C;AAAA,IACD;AAEA,UAAM,UAAU,KAAK,IAAI,IAAI;AAC7B,eAAW,UAAU;AACrB,wBAAqB,KAAK,KAAM,YAAY,GAAK,CAAE;AAEnD,UAAM,aAAa,YAAa,MAAM;AACrC,YAAM,YAAY,KAAK;AAAA,SACpB,WAAW,UAAU,KAAK,IAAI,KAAM;AAAA,MACvC;AACA,0BAAqB,KAAK,IAAK,GAAG,SAAU,CAAE;AAC9C,UAAK,aAAa,GAAI;AACrB,sBAAe,UAAW;AAC1B,sBAAe,IAAK;AAAA,MACrB;AAAA,IACD,GAAG,GAAK;AAER,WAAO,MAAM,cAAe,UAAW;AAAA,EACxC,GAAG,CAAE,WAAW,MAAO,CAAE;AAEzB,QAAM,iBAAiB,aAAa,IAAI;AAExC,SAAO,EAAE,kBAAkB,gBAAgB,aAAa;AACzD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// packages/editor/src/components/provider/use-post-content-blocks.js
|
|
2
|
-
import { useSelect } from "@wordpress/data";
|
|
3
|
-
import { useMemo } from "@wordpress/element";
|
|
4
|
-
import { applyFilters } from "@wordpress/hooks";
|
|
5
|
-
import { store as editorStore } from "../../store/index.mjs";
|
|
6
|
-
import { unlock } from "../../lock-unlock.mjs";
|
|
7
|
-
var POST_CONTENT_BLOCK_TYPES = [
|
|
8
|
-
"core/post-title",
|
|
9
|
-
"core/post-featured-image",
|
|
10
|
-
"core/post-content"
|
|
11
|
-
];
|
|
12
|
-
function usePostContentBlocks() {
|
|
13
|
-
const contentOnlyBlockTypes = useMemo(
|
|
14
|
-
() => [
|
|
15
|
-
...applyFilters(
|
|
16
|
-
"editor.postContentBlockTypes",
|
|
17
|
-
POST_CONTENT_BLOCK_TYPES
|
|
18
|
-
)
|
|
19
|
-
],
|
|
20
|
-
[]
|
|
21
|
-
);
|
|
22
|
-
const contentOnlyIds = useSelect(
|
|
23
|
-
(select) => {
|
|
24
|
-
const { getPostBlocksByName } = unlock(select(editorStore));
|
|
25
|
-
return getPostBlocksByName(contentOnlyBlockTypes);
|
|
26
|
-
},
|
|
27
|
-
[contentOnlyBlockTypes]
|
|
28
|
-
);
|
|
29
|
-
return contentOnlyIds;
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
usePostContentBlocks as default
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=use-post-content-blocks.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/provider/use-post-content-blocks.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst POST_CONTENT_BLOCK_TYPES = [\n\t'core/post-title',\n\t'core/post-featured-image',\n\t'core/post-content',\n];\n\nexport default function usePostContentBlocks() {\n\tconst contentOnlyBlockTypes = useMemo(\n\t\t() => [\n\t\t\t...applyFilters(\n\t\t\t\t'editor.postContentBlockTypes',\n\t\t\t\tPOST_CONTENT_BLOCK_TYPES\n\t\t\t),\n\t\t],\n\t\t[]\n\t);\n\n\t// Note that there are two separate subscriptions because the result for each\n\t// returns a new array.\n\tconst contentOnlyIds = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostBlocksByName } = unlock( select( editorStore ) );\n\t\t\treturn getPostBlocksByName( contentOnlyBlockTypes );\n\t\t},\n\t\t[ contentOnlyBlockTypes ]\n\t);\n\n\treturn contentOnlyIds;\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAK7B,SAAS,SAAS,mBAAmB;AACrC,SAAS,cAAc;AAEvB,IAAM,2BAA2B;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACD;AAEe,SAAR,uBAAwC;AAC9C,QAAM,wBAAwB;AAAA,IAC7B,MAAM;AAAA,MACL,GAAG;AAAA,QACF;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AAIA,QAAM,iBAAiB;AAAA,IACtB,CAAE,WAAY;AACb,YAAM,EAAE,oBAAoB,IAAI,OAAQ,OAAQ,WAAY,CAAE;AAC9D,aAAO,oBAAqB,qBAAsB;AAAA,IACnD;AAAA,IACA,CAAE,qBAAsB;AAAA,EACzB;AAEA,SAAO;AACR;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
// packages/editor/src/components/sync-connection-modal/index.js
|
|
2
|
-
import { useSelect, select } from "@wordpress/data";
|
|
3
|
-
import { useCopyToClipboard } from "@wordpress/compose";
|
|
4
|
-
import { serialize } from "@wordpress/blocks";
|
|
5
|
-
import {
|
|
6
|
-
store as coreDataStore,
|
|
7
|
-
privateApis as coreDataPrivateApis
|
|
8
|
-
} from "@wordpress/core-data";
|
|
9
|
-
import {
|
|
10
|
-
privateApis,
|
|
11
|
-
store as blockEditorStore
|
|
12
|
-
} from "@wordpress/block-editor";
|
|
13
|
-
import {
|
|
14
|
-
Button,
|
|
15
|
-
Modal,
|
|
16
|
-
__experimentalHStack as HStack,
|
|
17
|
-
__experimentalVStack as VStack
|
|
18
|
-
} from "@wordpress/components";
|
|
19
|
-
import { useState, useEffect, useRef } from "@wordpress/element";
|
|
20
|
-
import { __, sprintf, _n } from "@wordpress/i18n";
|
|
21
|
-
import { getSyncErrorMessages } from "../../utils/sync-error-messages.mjs";
|
|
22
|
-
import { store as editorStore } from "../../store/index.mjs";
|
|
23
|
-
import { unlock } from "../../lock-unlock.mjs";
|
|
24
|
-
import { useRetryCountdown } from "./use-retry-countdown.mjs";
|
|
25
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
-
var { BlockCanvasCover } = unlock(privateApis);
|
|
27
|
-
var { retrySyncConnection } = unlock(coreDataPrivateApis);
|
|
28
|
-
var INITIAL_DISCONNECTED_DEBOUNCE_MS = 5e3;
|
|
29
|
-
var noop = () => {
|
|
30
|
-
};
|
|
31
|
-
function SyncConnectionModal() {
|
|
32
|
-
const { connectionState, postType } = useSelect((selectFn) => {
|
|
33
|
-
const currentPostType = selectFn(editorStore).getCurrentPostType();
|
|
34
|
-
return {
|
|
35
|
-
connectionState: selectFn(coreDataStore).getSyncConnectionStatus() || null,
|
|
36
|
-
postType: currentPostType ? selectFn(coreDataStore).getPostType(currentPostType) : null
|
|
37
|
-
};
|
|
38
|
-
}, []);
|
|
39
|
-
const { secondsRemaining, markRetrying } = useRetryCountdown(
|
|
40
|
-
connectionState?.retryInMs,
|
|
41
|
-
connectionState?.status
|
|
42
|
-
);
|
|
43
|
-
const copyButtonRef = useCopyToClipboard(() => {
|
|
44
|
-
const blocks = select(blockEditorStore).getBlocks();
|
|
45
|
-
return serialize(blocks);
|
|
46
|
-
});
|
|
47
|
-
const [syncConnectionMessage, setSyncConnectionMessage] = useState(null);
|
|
48
|
-
const debounceTimerRef = useRef(null);
|
|
49
|
-
const hasInitializedRef = useRef(false);
|
|
50
|
-
const connectionStatus = connectionState?.status;
|
|
51
|
-
const connectionErrorCode = connectionState?.error?.code;
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (debounceTimerRef.current) {
|
|
54
|
-
clearTimeout(debounceTimerRef.current);
|
|
55
|
-
debounceTimerRef.current = null;
|
|
56
|
-
}
|
|
57
|
-
if (connectionStatus === "connected") {
|
|
58
|
-
hasInitializedRef.current = true;
|
|
59
|
-
setSyncConnectionMessage(null);
|
|
60
|
-
} else if (connectionStatus === "disconnected") {
|
|
61
|
-
const showModal = () => {
|
|
62
|
-
hasInitializedRef.current = true;
|
|
63
|
-
setSyncConnectionMessage(
|
|
64
|
-
getSyncErrorMessages({ code: connectionErrorCode })
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
if (hasInitializedRef.current) {
|
|
68
|
-
showModal();
|
|
69
|
-
} else {
|
|
70
|
-
debounceTimerRef.current = setTimeout(
|
|
71
|
-
showModal,
|
|
72
|
-
INITIAL_DISCONNECTED_DEBOUNCE_MS
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return () => {
|
|
77
|
-
if (debounceTimerRef.current) {
|
|
78
|
-
clearTimeout(debounceTimerRef.current);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}, [connectionStatus, connectionErrorCode]);
|
|
82
|
-
if (!syncConnectionMessage) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
const { title, description, canRetry } = syncConnectionMessage;
|
|
86
|
-
let retryCountdownText;
|
|
87
|
-
if (secondsRemaining > 0) {
|
|
88
|
-
retryCountdownText = sprintf(
|
|
89
|
-
/* translators: %d: number of seconds until retry */
|
|
90
|
-
_n(
|
|
91
|
-
"Retrying connection in %d second\u2026",
|
|
92
|
-
"Retrying connection in %d seconds\u2026",
|
|
93
|
-
secondsRemaining
|
|
94
|
-
),
|
|
95
|
-
secondsRemaining
|
|
96
|
-
);
|
|
97
|
-
} else if (secondsRemaining === 0) {
|
|
98
|
-
retryCountdownText = __("Retrying\u2026");
|
|
99
|
-
}
|
|
100
|
-
let editPostHref = "edit.php";
|
|
101
|
-
if (postType?.slug) {
|
|
102
|
-
editPostHref = `edit.php?post_type=${postType.slug}`;
|
|
103
|
-
}
|
|
104
|
-
const isRetrying = secondsRemaining === 0;
|
|
105
|
-
return /* @__PURE__ */ jsx(BlockCanvasCover.Fill, { children: /* @__PURE__ */ jsx(
|
|
106
|
-
Modal,
|
|
107
|
-
{
|
|
108
|
-
className: "editor-sync-connection-modal",
|
|
109
|
-
isDismissible: false,
|
|
110
|
-
onRequestClose: noop,
|
|
111
|
-
shouldCloseOnClickOutside: false,
|
|
112
|
-
shouldCloseOnEsc: false,
|
|
113
|
-
size: "medium",
|
|
114
|
-
title,
|
|
115
|
-
children: /* @__PURE__ */ jsxs(VStack, { spacing: 6, children: [
|
|
116
|
-
/* @__PURE__ */ jsx("p", { children: description }),
|
|
117
|
-
retryCountdownText && /* @__PURE__ */ jsx("p", { className: "editor-sync-connection-modal__retry-countdown", children: retryCountdownText }),
|
|
118
|
-
/* @__PURE__ */ jsxs(HStack, { justify: "right", children: [
|
|
119
|
-
/* @__PURE__ */ jsx(
|
|
120
|
-
Button,
|
|
121
|
-
{
|
|
122
|
-
__next40pxDefaultSize: true,
|
|
123
|
-
href: editPostHref,
|
|
124
|
-
isDestructive: true,
|
|
125
|
-
variant: "tertiary",
|
|
126
|
-
children: sprintf(
|
|
127
|
-
/* translators: %s: Post type name (e.g., "Posts", "Pages"). */
|
|
128
|
-
__("Back to %s"),
|
|
129
|
-
postType?.labels?.name ?? __("Posts")
|
|
130
|
-
)
|
|
131
|
-
}
|
|
132
|
-
),
|
|
133
|
-
/* @__PURE__ */ jsx(
|
|
134
|
-
Button,
|
|
135
|
-
{
|
|
136
|
-
__next40pxDefaultSize: true,
|
|
137
|
-
ref: copyButtonRef,
|
|
138
|
-
variant: canRetry ? "secondary" : "primary",
|
|
139
|
-
children: __("Copy Post Content")
|
|
140
|
-
}
|
|
141
|
-
),
|
|
142
|
-
canRetry && /* @__PURE__ */ jsx(
|
|
143
|
-
Button,
|
|
144
|
-
{
|
|
145
|
-
__next40pxDefaultSize: true,
|
|
146
|
-
"aria-disabled": isRetrying,
|
|
147
|
-
isBusy: isRetrying,
|
|
148
|
-
variant: "primary",
|
|
149
|
-
onClick: () => {
|
|
150
|
-
if (isRetrying) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
markRetrying();
|
|
154
|
-
retrySyncConnection();
|
|
155
|
-
},
|
|
156
|
-
children: __("Retry")
|
|
157
|
-
}
|
|
158
|
-
)
|
|
159
|
-
] })
|
|
160
|
-
] })
|
|
161
|
-
}
|
|
162
|
-
) });
|
|
163
|
-
}
|
|
164
|
-
export {
|
|
165
|
-
SyncConnectionModal
|
|
166
|
-
};
|
|
167
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/sync-connection-modal/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, select } from '@wordpress/data';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { serialize } from '@wordpress/blocks';\nimport {\n\tstore as coreDataStore,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport {\n\tprivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState, useEffect, useRef } 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 = 5000;\nconst noop = () => {};\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 {Element|null} The modal component or null if not disconnected.\n */\nexport function SyncConnectionModal() {\n\tconst { connectionState, postType } = useSelect( ( selectFn ) => {\n\t\tconst currentPostType = selectFn( editorStore ).getCurrentPostType();\n\t\treturn {\n\t\t\tconnectionState:\n\t\t\t\tselectFn( coreDataStore ).getSyncConnectionStatus() || null,\n\t\t\tpostType: currentPostType\n\t\t\t\t? selectFn( coreDataStore ).getPostType( currentPostType )\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst { secondsRemaining, markRetrying } = useRetryCountdown(\n\t\tconnectionState?.retryInMs,\n\t\tconnectionState?.status\n\t);\n\n\tconst copyButtonRef = useCopyToClipboard( () => {\n\t\tconst blocks = select( blockEditorStore ).getBlocks();\n\t\treturn serialize( blocks );\n\t} );\n\tconst [ syncConnectionMessage, setSyncConnectionMessage ] =\n\t\tuseState( null );\n\tconst debounceTimerRef = useRef( null );\n\t// Track whether we've passed the initial load phase.\n\t// Once true, disconnected status will show immediately without debounce.\n\tconst hasInitializedRef = useRef( false );\n\n\tconst connectionStatus = connectionState?.status;\n\tconst connectionErrorCode = connectionState?.error?.code;\n\n\tuseEffect( () => {\n\t\t// Clear any pending debounce timer when status changes.\n\t\tif ( debounceTimerRef.current ) {\n\t\t\tclearTimeout( debounceTimerRef.current );\n\t\t\tdebounceTimerRef.current = null;\n\t\t}\n\n\t\tif ( connectionStatus === 'connected' ) {\n\t\t\thasInitializedRef.current = true;\n\t\t\tsetSyncConnectionMessage( null );\n\t\t} else if ( connectionStatus === 'disconnected' ) {\n\t\t\tconst showModal = () => {\n\t\t\t\thasInitializedRef.current = true;\n\t\t\t\tsetSyncConnectionMessage(\n\t\t\t\t\tgetSyncErrorMessages( { code: connectionErrorCode } )\n\t\t\t\t);\n\t\t\t};\n\n\t\t\t// Debounce only on first load to allow connection to establish.\n\t\t\tif ( hasInitializedRef.current ) {\n\t\t\t\tshowModal();\n\t\t\t} else {\n\t\t\t\tdebounceTimerRef.current = setTimeout(\n\t\t\t\t\tshowModal,\n\t\t\t\t\tINITIAL_DISCONNECTED_DEBOUNCE_MS\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( debounceTimerRef.current ) {\n\t\t\t\tclearTimeout( debounceTimerRef.current );\n\t\t\t}\n\t\t};\n\t}, [ connectionStatus, connectionErrorCode ] );\n\n\tif ( ! syncConnectionMessage ) {\n\t\treturn null;\n\t}\n\n\tconst { title, description, canRetry } = syncConnectionMessage;\n\n\tlet retryCountdownText;\n\tif ( 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 ( secondsRemaining === 0 ) {\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\tconst isRetrying = secondsRemaining === 0;\n\n\treturn (\n\t\t<BlockCanvasCover.Fill>\n\t\t\t<Modal\n\t\t\t\tclassName=\"editor-sync-connection-modal\"\n\t\t\t\tisDismissible={ false }\n\t\t\t\tonRequestClose={ noop }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t\tshouldCloseOnEsc={ false }\n\t\t\t\tsize=\"medium\"\n\t\t\t\ttitle={ title }\n\t\t\t>\n\t\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t\t<p>{ description }</p>\n\t\t\t\t\t{ retryCountdownText && (\n\t\t\t\t\t\t<p className=\"editor-sync-connection-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={ canRetry ? '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{ canRetry && (\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\taria-disabled={ 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={ () => {\n\t\t\t\t\t\t\t\t\tif ( isRetrying ) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmarkRetrying();\n\t\t\t\t\t\t\t\t\tretrySyncConnection();\n\t\t\t\t\t\t\t\t} }\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</BlockCanv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kBAAmB;AAAA,MACnB,MAAK;AAAA,MACL;AAAA,MAEA,+BAAC,UAAO,SAAU,GACjB;AAAA,4BAAC,OAAI,uBAAa;AAAA,QAChB,sBACD,oBAAC,OAAE,WAAU,iDACV,8BACH;AAAA,QAED,qBAAC,UAAO,SAAQ,SACf;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,MAAO;AAAA,cACP,eAAa;AAAA,cACb,SAAQ;AAAA,cAEN;AAAA;AAAA,gBAED,GAAI,YAAa;AAAA,gBACjB,UAAU,QAAQ,QAAQ,GAAI,OAAQ;AAAA,cACvC;AAAA;AAAA,UACD;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,KAAM;AAAA,cACN,SAAU,WAAW,cAAc;AAAA,cAEjC,aAAI,mBAAoB;AAAA;AAAA,UAC3B;AAAA,UACE,YACD;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,iBAAgB;AAAA,cAChB,QAAS;AAAA,cACT,SAAQ;AAAA,cACR,SAAU,MAAM;AACf,oBAAK,YAAa;AACjB;AAAA,gBACD;AACA,6BAAa;AACb,oCAAoB;AAAA,cACrB;AAAA,cAEE,aAAI,OAAQ;AAAA;AAAA,UACf;AAAA,WAEF;AAAA,SACD;AAAA;AAAA,EACD,GACD;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// packages/editor/src/components/sync-connection-modal/use-retry-countdown.js
|
|
2
|
-
import { useState, useEffect, useRef } from "@wordpress/element";
|
|
3
|
-
var MIN_RETRYING_DISPLAY_MS = 600;
|
|
4
|
-
function useRetryCountdown(retryInMs, status) {
|
|
5
|
-
const [secondsRemaining, setSecondsRemaining] = useState(null);
|
|
6
|
-
const [isRetrying, setIsRetrying] = useState(false);
|
|
7
|
-
const retryAtRef = useRef(null);
|
|
8
|
-
const markRetrying = () => setIsRetrying(true);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
if (!isRetrying) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const id = setTimeout(
|
|
14
|
-
() => setIsRetrying(false),
|
|
15
|
-
MIN_RETRYING_DISPLAY_MS
|
|
16
|
-
);
|
|
17
|
-
return () => clearTimeout(id);
|
|
18
|
-
}, [isRetrying]);
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
if (status === "connected") {
|
|
21
|
-
setSecondsRemaining(null);
|
|
22
|
-
retryAtRef.current = null;
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (status !== "disconnected" || !retryInMs) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const retryAt = Date.now() + retryInMs;
|
|
29
|
-
retryAtRef.current = retryAt;
|
|
30
|
-
setSecondsRemaining(Math.ceil(retryInMs / 1e3));
|
|
31
|
-
const intervalId = setInterval(() => {
|
|
32
|
-
const remaining = Math.ceil(
|
|
33
|
-
(retryAtRef.current - Date.now()) / 1e3
|
|
34
|
-
);
|
|
35
|
-
setSecondsRemaining(Math.max(0, remaining));
|
|
36
|
-
if (remaining <= 0) {
|
|
37
|
-
clearInterval(intervalId);
|
|
38
|
-
setIsRetrying(true);
|
|
39
|
-
}
|
|
40
|
-
}, 1e3);
|
|
41
|
-
return () => clearInterval(intervalId);
|
|
42
|
-
}, [retryInMs, status]);
|
|
43
|
-
const displaySeconds = isRetrying ? 0 : secondsRemaining;
|
|
44
|
-
return { secondsRemaining: displaySeconds, markRetrying };
|
|
45
|
-
}
|
|
46
|
-
export {
|
|
47
|
-
useRetryCountdown
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=use-retry-countdown.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/sync-connection-modal/use-retry-countdown.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useRef } from '@wordpress/element';\n\nconst MIN_RETRYING_DISPLAY_MS = 600;\n\n/**\n * Hook that computes a countdown in seconds from a retryInMs value.\n *\n * @param {number|undefined} retryInMs Milliseconds until next retry.\n * @param {string|undefined} status Current connection status.\n * @return {Object} Object with `secondsRemaining` (number|null) and `markRetrying` callback.\n */\nexport function useRetryCountdown( retryInMs, status ) {\n\tconst [ secondsRemaining, setSecondsRemaining ] = useState( null );\n\tconst [ isRetrying, setIsRetrying ] = useState( false );\n\tconst retryAtRef = useRef( null );\n\n\t// Show \"Retrying\u2026\" for a minimum duration when manually triggered.\n\tconst markRetrying = () => setIsRetrying( true );\n\n\tuseEffect( () => {\n\t\tif ( ! isRetrying ) {\n\t\t\treturn;\n\t\t}\n\t\tconst id = setTimeout(\n\t\t\t() => setIsRetrying( false ),\n\t\t\tMIN_RETRYING_DISPLAY_MS\n\t\t);\n\t\treturn () => clearTimeout( id );\n\t}, [ isRetrying ] );\n\n\tuseEffect( () => {\n\t\t// Only clear countdown when explicitly connected.\n\t\tif ( status === 'connected' ) {\n\t\t\tsetSecondsRemaining( null );\n\t\t\tretryAtRef.current = null;\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 ( status !== 'disconnected' || ! retryInMs ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst retryAt = Date.now() + retryInMs;\n\t\tretryAtRef.current = retryAt;\n\t\tsetSecondsRemaining( Math.ceil( retryInMs / 1000 ) );\n\n\t\tconst intervalId = setInterval( () => {\n\t\t\tconst remaining = Math.ceil(\n\t\t\t\t( retryAtRef.current - Date.now() ) / 1000\n\t\t\t);\n\t\t\tsetSecondsRemaining( Math.max( 0, remaining ) );\n\t\t\tif ( remaining <= 0 ) {\n\t\t\t\tclearInterval( intervalId );\n\t\t\t\tsetIsRetrying( true );\n\t\t\t}\n\t\t}, 1000 );\n\n\t\treturn () => clearInterval( intervalId );\n\t}, [ retryInMs, status ] );\n\n\tconst displaySeconds = isRetrying ? 0 : secondsRemaining;\n\n\treturn { secondsRemaining: displaySeconds, markRetrying };\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU,WAAW,cAAc;AAE5C,IAAM,0BAA0B;AASzB,SAAS,kBAAmB,WAAW,QAAS;AACtD,QAAM,CAAE,kBAAkB,mBAAoB,IAAI,SAAU,IAAK;AACjE,QAAM,CAAE,YAAY,aAAc,IAAI,SAAU,KAAM;AACtD,QAAM,aAAa,OAAQ,IAAK;AAGhC,QAAM,eAAe,MAAM,cAAe,IAAK;AAE/C,YAAW,MAAM;AAChB,QAAK,CAAE,YAAa;AACnB;AAAA,IACD;AACA,UAAM,KAAK;AAAA,MACV,MAAM,cAAe,KAAM;AAAA,MAC3B;AAAA,IACD;AACA,WAAO,MAAM,aAAc,EAAG;AAAA,EAC/B,GAAG,CAAE,UAAW,CAAE;AAElB,YAAW,MAAM;AAEhB,QAAK,WAAW,aAAc;AAC7B,0BAAqB,IAAK;AAC1B,iBAAW,UAAU;AACrB;AAAA,IACD;AAKA,QAAK,WAAW,kBAAkB,CAAE,WAAY;AAC/C;AAAA,IACD;AAEA,UAAM,UAAU,KAAK,IAAI,IAAI;AAC7B,eAAW,UAAU;AACrB,wBAAqB,KAAK,KAAM,YAAY,GAAK,CAAE;AAEnD,UAAM,aAAa,YAAa,MAAM;AACrC,YAAM,YAAY,KAAK;AAAA,SACpB,WAAW,UAAU,KAAK,IAAI,KAAM;AAAA,MACvC;AACA,0BAAqB,KAAK,IAAK,GAAG,SAAU,CAAE;AAC9C,UAAK,aAAa,GAAI;AACrB,sBAAe,UAAW;AAC1B,sBAAe,IAAK;AAAA,MACrB;AAAA,IACD,GAAG,GAAK;AAER,WAAO,MAAM,cAAe,UAAW;AAAA,EACxC,GAAG,CAAE,WAAW,MAAO,CAAE;AAEzB,QAAM,iBAAiB,aAAa,IAAI;AAExC,SAAO,EAAE,kBAAkB,gBAAgB,aAAa;AACzD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-post-content-blocks.d.ts","sourceRoot":"","sources":["../../../src/components/provider/use-post-content-blocks.js"],"names":[],"mappings":"AAmBA,oDAsBC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sync connection modal that displays when any entity reports a disconnection.
|
|
3
|
-
* Uses BlockCanvasCover.Fill to render in the block canvas.
|
|
4
|
-
*
|
|
5
|
-
* @return {Element|null} The modal component or null if not disconnected.
|
|
6
|
-
*/
|
|
7
|
-
export function SyncConnectionModal(): Element | null;
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/sync-connection-modal/index.js"],"names":[],"mappings":"AAsCA;;;;;GAKG;AACH,uCAFY,OAAO,GAAC,IAAI,CA6JvB"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook that computes a countdown in seconds from a retryInMs value.
|
|
3
|
-
*
|
|
4
|
-
* @param {number|undefined} retryInMs Milliseconds until next retry.
|
|
5
|
-
* @param {string|undefined} status Current connection status.
|
|
6
|
-
* @return {Object} Object with `secondsRemaining` (number|null) and `markRetrying` callback.
|
|
7
|
-
*/
|
|
8
|
-
export function useRetryCountdown(retryInMs: number | undefined, status: string | undefined): Object;
|
|
9
|
-
//# sourceMappingURL=use-retry-countdown.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-retry-countdown.d.ts","sourceRoot":"","sources":["../../../src/components/sync-connection-modal/use-retry-countdown.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,6CAJW,MAAM,GAAC,SAAS,UAChB,MAAM,GAAC,SAAS,GACf,MAAM,CAyDjB"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { useMemo } from '@wordpress/element';
|
|
6
|
-
import { applyFilters } from '@wordpress/hooks';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import { store as editorStore } from '../../store';
|
|
12
|
-
import { unlock } from '../../lock-unlock';
|
|
13
|
-
|
|
14
|
-
const POST_CONTENT_BLOCK_TYPES = [
|
|
15
|
-
'core/post-title',
|
|
16
|
-
'core/post-featured-image',
|
|
17
|
-
'core/post-content',
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
export default function usePostContentBlocks() {
|
|
21
|
-
const contentOnlyBlockTypes = useMemo(
|
|
22
|
-
() => [
|
|
23
|
-
...applyFilters(
|
|
24
|
-
'editor.postContentBlockTypes',
|
|
25
|
-
POST_CONTENT_BLOCK_TYPES
|
|
26
|
-
),
|
|
27
|
-
],
|
|
28
|
-
[]
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
// Note that there are two separate subscriptions because the result for each
|
|
32
|
-
// returns a new array.
|
|
33
|
-
const contentOnlyIds = useSelect(
|
|
34
|
-
( select ) => {
|
|
35
|
-
const { getPostBlocksByName } = unlock( select( editorStore ) );
|
|
36
|
-
return getPostBlocksByName( contentOnlyBlockTypes );
|
|
37
|
-
},
|
|
38
|
-
[ contentOnlyBlockTypes ]
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
return contentOnlyIds;
|
|
42
|
-
}
|