@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,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, select } from '@wordpress/data';
|
|
5
|
+
import { useCopyToClipboard } from '@wordpress/compose';
|
|
6
|
+
// @ts-ignore No exported types.
|
|
7
|
+
import { serialize } from '@wordpress/blocks';
|
|
8
|
+
import {
|
|
9
|
+
store as coreDataStore,
|
|
10
|
+
privateApis as coreDataPrivateApis,
|
|
11
|
+
type ConnectionError,
|
|
12
|
+
} from '@wordpress/core-data';
|
|
13
|
+
// @ts-expect-error - No type declarations available for @wordpress/block-editor
|
|
14
|
+
// prettier-ignore
|
|
15
|
+
import { privateApis, store as blockEditorStore } from '@wordpress/block-editor';
|
|
16
|
+
import {
|
|
17
|
+
Button,
|
|
18
|
+
Modal,
|
|
19
|
+
withFilters,
|
|
20
|
+
__experimentalHStack as HStack,
|
|
21
|
+
__experimentalVStack as VStack,
|
|
22
|
+
} from '@wordpress/components';
|
|
23
|
+
import { useState, useEffect } from '@wordpress/element';
|
|
24
|
+
import { __, sprintf, _n } from '@wordpress/i18n';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Internal dependencies
|
|
28
|
+
*/
|
|
29
|
+
import { getSyncErrorMessages } from '../../utils/sync-error-messages';
|
|
30
|
+
import { store as editorStore } from '../../store';
|
|
31
|
+
import { unlock } from '../../lock-unlock';
|
|
32
|
+
import { useRetryCountdown } from './use-retry-countdown';
|
|
33
|
+
|
|
34
|
+
const { BlockCanvasCover } = unlock( privateApis );
|
|
35
|
+
const { retrySyncConnection } = unlock( coreDataPrivateApis );
|
|
36
|
+
|
|
37
|
+
// Debounce time for initial disconnected status to allow connection to establish.
|
|
38
|
+
const INITIAL_DISCONNECTED_DEBOUNCE_MS = 5000;
|
|
39
|
+
|
|
40
|
+
// Debounce time for showing the disconnect dialog after the intial connection,
|
|
41
|
+
// allowing brief network interruptions to resolve.
|
|
42
|
+
const DISCONNECTED_DEBOUNCE_MS = 2000;
|
|
43
|
+
|
|
44
|
+
export interface SyncConnectionErrorModalProps {
|
|
45
|
+
description: string; // Modal description.
|
|
46
|
+
error?: ConnectionError; // Error object with a `code` property.
|
|
47
|
+
manualRetry?: () => void; // Callback for when the retry button is clicked.
|
|
48
|
+
postType?: { slug?: string; labels?: { name?: string } } | null; // Current post type object.
|
|
49
|
+
secondsRemainingUntilAutoRetry?: number; // Seconds remaining until the next automatic retry attempt, if applicable.
|
|
50
|
+
title: string; // Modal title.
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Default sync connection modal component.
|
|
55
|
+
*
|
|
56
|
+
* Can be replaced or wrapped via the `editor.SyncConnectionErrorModal` filter.
|
|
57
|
+
*
|
|
58
|
+
* @param props - SyncConnectionErrorModalProps.
|
|
59
|
+
*/
|
|
60
|
+
function DefaultSyncConnectionErrorModal(
|
|
61
|
+
props: SyncConnectionErrorModalProps
|
|
62
|
+
) {
|
|
63
|
+
const {
|
|
64
|
+
description,
|
|
65
|
+
manualRetry,
|
|
66
|
+
postType,
|
|
67
|
+
secondsRemainingUntilAutoRetry,
|
|
68
|
+
title,
|
|
69
|
+
} = props;
|
|
70
|
+
const copyButtonRef = useCopyToClipboard( () => {
|
|
71
|
+
const blocks = select( blockEditorStore ).getBlocks();
|
|
72
|
+
return serialize( blocks );
|
|
73
|
+
} );
|
|
74
|
+
|
|
75
|
+
let retryCountdownText: string = '';
|
|
76
|
+
let isRetrying = false;
|
|
77
|
+
if (
|
|
78
|
+
secondsRemainingUntilAutoRetry &&
|
|
79
|
+
secondsRemainingUntilAutoRetry > 0
|
|
80
|
+
) {
|
|
81
|
+
retryCountdownText = sprintf(
|
|
82
|
+
/* translators: %d: number of seconds until retry */
|
|
83
|
+
_n(
|
|
84
|
+
'Retrying connection in %d second\u2026',
|
|
85
|
+
'Retrying connection in %d seconds\u2026',
|
|
86
|
+
secondsRemainingUntilAutoRetry
|
|
87
|
+
),
|
|
88
|
+
secondsRemainingUntilAutoRetry
|
|
89
|
+
);
|
|
90
|
+
} else if ( 0 === secondsRemainingUntilAutoRetry ) {
|
|
91
|
+
isRetrying = true;
|
|
92
|
+
retryCountdownText = __( 'Retrying\u2026' );
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let editPostHref = 'edit.php';
|
|
96
|
+
if ( postType?.slug ) {
|
|
97
|
+
editPostHref = `edit.php?post_type=${ postType.slug }`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<Modal
|
|
102
|
+
overlayClassName="editor-sync-connection-error-modal"
|
|
103
|
+
isDismissible={ false }
|
|
104
|
+
onRequestClose={ () => {} }
|
|
105
|
+
shouldCloseOnClickOutside={ false }
|
|
106
|
+
shouldCloseOnEsc={ false }
|
|
107
|
+
size="medium"
|
|
108
|
+
title={ title }
|
|
109
|
+
>
|
|
110
|
+
<VStack spacing={ 6 }>
|
|
111
|
+
<p>{ description }</p>
|
|
112
|
+
{ retryCountdownText && (
|
|
113
|
+
<p className="editor-sync-connection-error-modal__retry-countdown">
|
|
114
|
+
{ retryCountdownText }
|
|
115
|
+
</p>
|
|
116
|
+
) }
|
|
117
|
+
<HStack justify="right">
|
|
118
|
+
<Button
|
|
119
|
+
__next40pxDefaultSize
|
|
120
|
+
href={ editPostHref }
|
|
121
|
+
isDestructive
|
|
122
|
+
variant="tertiary"
|
|
123
|
+
>
|
|
124
|
+
{ sprintf(
|
|
125
|
+
/* translators: %s: Post type name (e.g., "Posts", "Pages"). */
|
|
126
|
+
__( 'Back to %s' ),
|
|
127
|
+
postType?.labels?.name ?? __( 'Posts' )
|
|
128
|
+
) }
|
|
129
|
+
</Button>
|
|
130
|
+
<Button
|
|
131
|
+
__next40pxDefaultSize
|
|
132
|
+
ref={ copyButtonRef }
|
|
133
|
+
variant={ manualRetry ? 'secondary' : 'primary' }
|
|
134
|
+
>
|
|
135
|
+
{ __( 'Copy Post Content' ) }
|
|
136
|
+
</Button>
|
|
137
|
+
{ manualRetry && (
|
|
138
|
+
<Button
|
|
139
|
+
__next40pxDefaultSize
|
|
140
|
+
accessibleWhenDisabled
|
|
141
|
+
aria-disabled={ isRetrying }
|
|
142
|
+
disabled={ isRetrying }
|
|
143
|
+
isBusy={ isRetrying }
|
|
144
|
+
variant="primary"
|
|
145
|
+
onClick={ manualRetry }
|
|
146
|
+
>
|
|
147
|
+
{ __( 'Retry' ) }
|
|
148
|
+
</Button>
|
|
149
|
+
) }
|
|
150
|
+
</HStack>
|
|
151
|
+
</VStack>
|
|
152
|
+
</Modal>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Filtered version of the sync connection modal, allowing third-party
|
|
158
|
+
* plugins to replace the default modal via:
|
|
159
|
+
*
|
|
160
|
+
* ```js
|
|
161
|
+
* wp.hooks.addFilter(
|
|
162
|
+
* 'editor.SyncConnectionErrorModal',
|
|
163
|
+
* 'my-plugin/custom-sync-connection-error-modal',
|
|
164
|
+
* ( OriginalComponent ) => ( props ) => {
|
|
165
|
+
* // Return a custom component or wrap the original.
|
|
166
|
+
* return <OriginalComponent { ...props } />;
|
|
167
|
+
* }
|
|
168
|
+
* );
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
// @ts-ignore
|
|
172
|
+
const FilteredSyncConnectionErrorModal = globalThis.IS_GUTENBERG_PLUGIN
|
|
173
|
+
? withFilters( 'editor.SyncConnectionErrorModal' )(
|
|
174
|
+
DefaultSyncConnectionErrorModal
|
|
175
|
+
)
|
|
176
|
+
: DefaultSyncConnectionErrorModal;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Sync connection modal that displays when any entity reports a disconnection.
|
|
180
|
+
* Uses BlockCanvasCover.Fill to render in the block canvas.
|
|
181
|
+
*
|
|
182
|
+
* @return The modal component or null if not disconnected.
|
|
183
|
+
*/
|
|
184
|
+
export function SyncConnectionErrorModal() {
|
|
185
|
+
const [ hasInitialized, setHasInitialized ] = useState( false );
|
|
186
|
+
const [ showModal, setShowModal ] = useState( false );
|
|
187
|
+
|
|
188
|
+
const { connectionStatus, isCollaborationEnabled, postType } = useSelect(
|
|
189
|
+
( selectFn ) => {
|
|
190
|
+
const currentPostType =
|
|
191
|
+
selectFn( editorStore ).getCurrentPostType();
|
|
192
|
+
return {
|
|
193
|
+
connectionStatus:
|
|
194
|
+
selectFn( coreDataStore ).getSyncConnectionStatus() || null,
|
|
195
|
+
isCollaborationEnabled:
|
|
196
|
+
selectFn(
|
|
197
|
+
editorStore
|
|
198
|
+
).isCollaborationEnabledForCurrentPost(),
|
|
199
|
+
postType: currentPostType
|
|
200
|
+
? selectFn( coreDataStore ).getPostType( currentPostType )
|
|
201
|
+
: null,
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
[]
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
const { onManualRetry, secondsRemaining } =
|
|
208
|
+
useRetryCountdown( connectionStatus );
|
|
209
|
+
|
|
210
|
+
const isConnected = 'connected' === connectionStatus?.status;
|
|
211
|
+
|
|
212
|
+
// Set hasInitialized after a debounce to give extra time on initial load.
|
|
213
|
+
useEffect( () => {
|
|
214
|
+
const timeout = setTimeout( () => {
|
|
215
|
+
setHasInitialized( true );
|
|
216
|
+
}, INITIAL_DISCONNECTED_DEBOUNCE_MS );
|
|
217
|
+
|
|
218
|
+
return () => clearTimeout( timeout );
|
|
219
|
+
}, [] );
|
|
220
|
+
|
|
221
|
+
useEffect( () => {
|
|
222
|
+
if ( isConnected ) {
|
|
223
|
+
setShowModal( false );
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const timeout = setTimeout( () => {
|
|
228
|
+
setShowModal( true );
|
|
229
|
+
}, DISCONNECTED_DEBOUNCE_MS );
|
|
230
|
+
|
|
231
|
+
return () => clearTimeout( timeout );
|
|
232
|
+
}, [ isConnected ] );
|
|
233
|
+
|
|
234
|
+
if ( ! isCollaborationEnabled || ! hasInitialized || ! showModal ) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const error =
|
|
239
|
+
connectionStatus && 'error' in connectionStatus
|
|
240
|
+
? connectionStatus?.error
|
|
241
|
+
: undefined;
|
|
242
|
+
const manualRetry =
|
|
243
|
+
connectionStatus &&
|
|
244
|
+
'canManuallyRetry' in connectionStatus &&
|
|
245
|
+
connectionStatus.canManuallyRetry
|
|
246
|
+
? () => {
|
|
247
|
+
onManualRetry();
|
|
248
|
+
retrySyncConnection();
|
|
249
|
+
}
|
|
250
|
+
: undefined;
|
|
251
|
+
const messages = getSyncErrorMessages( error );
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<BlockCanvasCover.Fill>
|
|
255
|
+
<FilteredSyncConnectionErrorModal
|
|
256
|
+
description={ messages.description }
|
|
257
|
+
error={ error }
|
|
258
|
+
manualRetry={ manualRetry }
|
|
259
|
+
postType={ postType }
|
|
260
|
+
secondsRemainingUntilAutoRetry={ secondsRemaining }
|
|
261
|
+
title={ messages.title }
|
|
262
|
+
/>
|
|
263
|
+
</BlockCanvasCover.Fill>
|
|
264
|
+
);
|
|
265
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
@use "@wordpress/base-styles/colors" as *;
|
|
2
|
+
@use "@wordpress/base-styles/z-index" as *;
|
|
3
|
+
|
|
4
|
+
.editor-sync-connection-error-modal {
|
|
5
|
+
z-index: z-index(".editor-sync-connection-error-modal");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.editor-sync-connection-error-modal p {
|
|
9
|
+
margin: 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.editor-sync-connection-error-modal__retry-countdown {
|
|
13
|
+
color: $gray-700;
|
|
14
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ConnectionStatus } from '@wordpress/core-data';
|
|
5
|
+
import { useState, useEffect } from '@wordpress/element';
|
|
6
|
+
|
|
7
|
+
interface UseRetryCountdownResult {
|
|
8
|
+
onManualRetry: () => void;
|
|
9
|
+
secondsRemaining?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useRetryCountdown(
|
|
13
|
+
connectionStatus?: ConnectionStatus | null
|
|
14
|
+
): UseRetryCountdownResult {
|
|
15
|
+
const [ secondsRemaining, setSecondsRemaining ] = useState< number >();
|
|
16
|
+
|
|
17
|
+
useEffect( () => {
|
|
18
|
+
if ( ! connectionStatus ) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Only clear countdown when explicitly connected.
|
|
23
|
+
if ( 'connected' === connectionStatus.status ) {
|
|
24
|
+
setSecondsRemaining( undefined );
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// For transient states (e.g. 'connecting' during a retry attempt)
|
|
29
|
+
// or when retryInMs is not yet available, keep the previous
|
|
30
|
+
// countdown value to avoid a brief flash.
|
|
31
|
+
if (
|
|
32
|
+
'disconnected' !== connectionStatus.status ||
|
|
33
|
+
! connectionStatus.willAutoRetryInMs
|
|
34
|
+
) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { willAutoRetryInMs: retryInMs } = connectionStatus;
|
|
39
|
+
const retryAt = Date.now() + retryInMs;
|
|
40
|
+
setSecondsRemaining( Math.ceil( retryInMs / 1000 ) );
|
|
41
|
+
|
|
42
|
+
const intervalId = setInterval( () => {
|
|
43
|
+
const remaining = Math.ceil( ( retryAt - Date.now() ) / 1000 );
|
|
44
|
+
setSecondsRemaining( Math.max( 0, remaining ) );
|
|
45
|
+
if ( remaining <= 0 ) {
|
|
46
|
+
clearInterval( intervalId );
|
|
47
|
+
}
|
|
48
|
+
}, 1000 );
|
|
49
|
+
|
|
50
|
+
return () => clearInterval( intervalId );
|
|
51
|
+
}, [ connectionStatus ] );
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
onManualRetry: () => setSecondsRemaining( 0 ),
|
|
55
|
+
secondsRemaining,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -6,8 +6,6 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
|
6
6
|
import { PanelBody } from '@wordpress/components';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
9
|
-
import { applyFilters } from '@wordpress/hooks';
|
|
10
|
-
import { useMemo } from '@wordpress/element';
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* Internal dependencies
|
|
@@ -15,54 +13,30 @@ import { useMemo } from '@wordpress/element';
|
|
|
15
13
|
import { unlock } from '../../lock-unlock';
|
|
16
14
|
import { TEMPLATE_POST_TYPE } from '../../store/constants';
|
|
17
15
|
import { store as editorStore } from '../../store';
|
|
16
|
+
import usePostContentBlockTypes from '../provider/use-post-content-block-types';
|
|
18
17
|
|
|
19
18
|
const { BlockQuickNavigation } = unlock( blockEditorPrivateApis );
|
|
20
19
|
|
|
21
|
-
const POST_CONTENT_BLOCK_TYPES = [
|
|
22
|
-
'core/post-title',
|
|
23
|
-
'core/post-featured-image',
|
|
24
|
-
'core/post-content',
|
|
25
|
-
];
|
|
26
|
-
|
|
27
20
|
const TEMPLATE_PART_BLOCK = 'core/template-part';
|
|
28
21
|
|
|
29
|
-
|
|
30
|
-
const postContentBlockTypes =
|
|
31
|
-
() =>
|
|
32
|
-
applyFilters(
|
|
33
|
-
'editor.postContentBlockTypes',
|
|
34
|
-
POST_CONTENT_BLOCK_TYPES
|
|
35
|
-
),
|
|
36
|
-
[]
|
|
37
|
-
);
|
|
22
|
+
function TemplateContentPanelInner( { postType } ) {
|
|
23
|
+
const postContentBlockTypes = usePostContentBlockTypes();
|
|
38
24
|
|
|
39
|
-
const
|
|
25
|
+
const clientIds = useSelect(
|
|
40
26
|
( select ) => {
|
|
41
|
-
const {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
postType: _postType,
|
|
49
|
-
clientIds: getPostBlocksByName(
|
|
50
|
-
TEMPLATE_POST_TYPE === _postType
|
|
51
|
-
? TEMPLATE_PART_BLOCK
|
|
52
|
-
: postContentBlockTypes
|
|
53
|
-
),
|
|
54
|
-
renderingMode: getRenderingMode(),
|
|
55
|
-
};
|
|
27
|
+
const { getPostBlocksByName } = unlock( select( editorStore ) );
|
|
28
|
+
return getPostBlocksByName(
|
|
29
|
+
TEMPLATE_POST_TYPE === postType
|
|
30
|
+
? TEMPLATE_PART_BLOCK
|
|
31
|
+
: postContentBlockTypes
|
|
32
|
+
);
|
|
56
33
|
},
|
|
57
|
-
[ postContentBlockTypes ]
|
|
34
|
+
[ postType, postContentBlockTypes ]
|
|
58
35
|
);
|
|
59
36
|
|
|
60
37
|
const { enableComplementaryArea } = useDispatch( interfaceStore );
|
|
61
38
|
|
|
62
|
-
if (
|
|
63
|
-
( renderingMode === 'post-only' && postType !== TEMPLATE_POST_TYPE ) ||
|
|
64
|
-
clientIds.length === 0
|
|
65
|
-
) {
|
|
39
|
+
if ( clientIds.length === 0 ) {
|
|
66
40
|
return null;
|
|
67
41
|
}
|
|
68
42
|
|
|
@@ -77,3 +51,21 @@ export default function TemplateContentPanel() {
|
|
|
77
51
|
</PanelBody>
|
|
78
52
|
);
|
|
79
53
|
}
|
|
54
|
+
|
|
55
|
+
export default function TemplateContentPanel() {
|
|
56
|
+
const { postType, renderingMode } = useSelect( ( select ) => {
|
|
57
|
+
const { getCurrentPostType, getRenderingMode } = unlock(
|
|
58
|
+
select( editorStore )
|
|
59
|
+
);
|
|
60
|
+
return {
|
|
61
|
+
postType: getCurrentPostType(),
|
|
62
|
+
renderingMode: getRenderingMode(),
|
|
63
|
+
};
|
|
64
|
+
}, [] );
|
|
65
|
+
|
|
66
|
+
if ( renderingMode === 'post-only' && postType !== TEMPLATE_POST_TYPE ) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return <TemplateContentPanelInner postType={ postType } />;
|
|
71
|
+
}
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
import { useZoomOutModeExit } from './use-zoom-out-mode-exit';
|
|
42
42
|
import { usePaddingAppender } from './use-padding-appender';
|
|
43
43
|
import { useEditContentOnlySectionExit } from './use-edit-content-only-section-exit';
|
|
44
|
-
import {
|
|
44
|
+
import { SyncConnectionErrorModal } from '../sync-connection-error-modal';
|
|
45
45
|
|
|
46
46
|
const {
|
|
47
47
|
LayoutStyle,
|
|
@@ -427,7 +427,7 @@ function VisualEditor( {
|
|
|
427
427
|
}
|
|
428
428
|
) }
|
|
429
429
|
>
|
|
430
|
-
<
|
|
430
|
+
<SyncConnectionErrorModal />
|
|
431
431
|
<ResizableEditor enableResizing={ enableResizing } height="100%">
|
|
432
432
|
<BlockCanvas
|
|
433
433
|
shouldIframe={ ! disableIframe }
|
package/src/store/actions.js
CHANGED
|
@@ -189,10 +189,7 @@ export const savePost =
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
const content = select.getEditedPostContent();
|
|
192
|
-
|
|
193
|
-
if ( ! options.isAutosave ) {
|
|
194
|
-
dispatch.editPost( { content }, { undoIgnore: true } );
|
|
195
|
-
}
|
|
192
|
+
dispatch.editPost( { content }, { undoIgnore: true } );
|
|
196
193
|
|
|
197
194
|
const previousRecord = select.getCurrentPost();
|
|
198
195
|
let edits = {
|
|
@@ -602,6 +602,19 @@ export function setCurrentRevisionId( revisionId ) {
|
|
|
602
602
|
};
|
|
603
603
|
}
|
|
604
604
|
|
|
605
|
+
/**
|
|
606
|
+
* Set whether the revision diff highlighting is shown.
|
|
607
|
+
*
|
|
608
|
+
* @param {boolean} showDiff Whether to show diff highlighting.
|
|
609
|
+
* @return {Object} Action object.
|
|
610
|
+
*/
|
|
611
|
+
export function setShowRevisionDiff( showDiff ) {
|
|
612
|
+
return {
|
|
613
|
+
type: 'SET_SHOW_REVISION_DIFF',
|
|
614
|
+
showDiff,
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
|
|
605
618
|
/**
|
|
606
619
|
* Restore a revision by replacing the current content with the revision's content
|
|
607
620
|
* and auto-saving.
|
|
@@ -614,10 +627,16 @@ export const restoreRevision =
|
|
|
614
627
|
const postType = select.getCurrentPostType();
|
|
615
628
|
const postId = select.getCurrentPostId();
|
|
616
629
|
|
|
617
|
-
|
|
618
|
-
|
|
630
|
+
// Use resolveSelect to ensure the revision is fetched if not yet
|
|
631
|
+
// in the store. The _fields parameter matches the query used by
|
|
632
|
+
// getRevisions so the result is served from cache without an
|
|
633
|
+
// extra API call.
|
|
634
|
+
const revision = await registry
|
|
635
|
+
.resolveSelect( coreStore )
|
|
619
636
|
.getRevision( 'postType', postType, postId, revisionId, {
|
|
620
637
|
context: 'edit',
|
|
638
|
+
_fields:
|
|
639
|
+
'id,date,author,meta,title.raw,excerpt.raw,content.raw',
|
|
621
640
|
} );
|
|
622
641
|
|
|
623
642
|
if ( ! revision ) {
|
|
@@ -55,14 +55,36 @@ export const getInserter = createRegistrySelector( ( select ) =>
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
if ( getRenderingMode( state ) === 'template-locked' ) {
|
|
58
|
+
const {
|
|
59
|
+
getBlocksByName,
|
|
60
|
+
getSelectedBlockClientId,
|
|
61
|
+
getBlockParents,
|
|
62
|
+
getBlockOrder,
|
|
63
|
+
} = select( blockEditorStore );
|
|
58
64
|
const [ postContentClientId ] =
|
|
59
|
-
|
|
60
|
-
'core/post-content'
|
|
61
|
-
);
|
|
65
|
+
getBlocksByName( 'core/post-content' );
|
|
62
66
|
if ( postContentClientId ) {
|
|
67
|
+
const selectedBlockClientId = getSelectedBlockClientId();
|
|
68
|
+
|
|
69
|
+
// If a block inside Post Content is selected,
|
|
70
|
+
// let the inserter use its default logic for determining the
|
|
71
|
+
// insertion position by returning an empty insertion point.
|
|
72
|
+
if (
|
|
73
|
+
selectedBlockClientId &&
|
|
74
|
+
selectedBlockClientId !== postContentClientId &&
|
|
75
|
+
getBlockParents( selectedBlockClientId ).includes(
|
|
76
|
+
postContentClientId
|
|
77
|
+
)
|
|
78
|
+
) {
|
|
79
|
+
return EMPTY_INSERTION_POINT;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Otherwise (no selection, or Post Content itself
|
|
83
|
+
// is selected), insert at the end of Post Content.
|
|
63
84
|
return {
|
|
64
85
|
rootClientId: postContentClientId,
|
|
65
|
-
insertionIndex:
|
|
86
|
+
insertionIndex:
|
|
87
|
+
getBlockOrder( postContentClientId ).length,
|
|
66
88
|
filterValue: undefined,
|
|
67
89
|
};
|
|
68
90
|
}
|
|
@@ -71,14 +93,26 @@ export const getInserter = createRegistrySelector( ( select ) =>
|
|
|
71
93
|
return EMPTY_INSERTION_POINT;
|
|
72
94
|
},
|
|
73
95
|
( state ) => {
|
|
96
|
+
const {
|
|
97
|
+
getBlocksByName,
|
|
98
|
+
getSelectedBlockClientId,
|
|
99
|
+
getBlockParents,
|
|
100
|
+
getBlockOrder,
|
|
101
|
+
} = select( blockEditorStore );
|
|
74
102
|
const [ postContentClientId ] =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
);
|
|
103
|
+
getBlocksByName( 'core/post-content' );
|
|
104
|
+
const selectedBlockClientId = getSelectedBlockClientId();
|
|
78
105
|
return [
|
|
79
106
|
state.blockInserterPanel,
|
|
80
107
|
getRenderingMode( state ),
|
|
81
108
|
postContentClientId,
|
|
109
|
+
selectedBlockClientId,
|
|
110
|
+
selectedBlockClientId
|
|
111
|
+
? getBlockParents( selectedBlockClientId )
|
|
112
|
+
: undefined,
|
|
113
|
+
postContentClientId
|
|
114
|
+
? getBlockOrder( postContentClientId ).length
|
|
115
|
+
: undefined,
|
|
82
116
|
];
|
|
83
117
|
}
|
|
84
118
|
)
|
|
@@ -216,7 +250,18 @@ export const getPostBlocksByName = createRegistrySelector( ( select ) =>
|
|
|
216
250
|
} )
|
|
217
251
|
);
|
|
218
252
|
},
|
|
219
|
-
(
|
|
253
|
+
( state, blockNames ) => {
|
|
254
|
+
blockNames = Array.isArray( blockNames )
|
|
255
|
+
? blockNames
|
|
256
|
+
: [ blockNames ];
|
|
257
|
+
const { getBlocksByName, getBlockParents } =
|
|
258
|
+
select( blockEditorStore );
|
|
259
|
+
const clientIds = getBlocksByName( blockNames );
|
|
260
|
+
const parentsOfClientIds = clientIds.map( ( id ) =>
|
|
261
|
+
getBlockParents( id )
|
|
262
|
+
);
|
|
263
|
+
return [ clientIds, ...parentsOfClientIds ];
|
|
264
|
+
}
|
|
220
265
|
)
|
|
221
266
|
);
|
|
222
267
|
|
|
@@ -311,6 +356,16 @@ export function isRevisionsMode( state ) {
|
|
|
311
356
|
return state.revisionId !== null;
|
|
312
357
|
}
|
|
313
358
|
|
|
359
|
+
/**
|
|
360
|
+
* Returns whether the revision diff highlighting is shown.
|
|
361
|
+
*
|
|
362
|
+
* @param {Object} state Global application state.
|
|
363
|
+
* @return {boolean} Whether revision diff is being shown.
|
|
364
|
+
*/
|
|
365
|
+
export function isShowingRevisionDiff( state ) {
|
|
366
|
+
return state.showRevisionDiff;
|
|
367
|
+
}
|
|
368
|
+
|
|
314
369
|
/**
|
|
315
370
|
* Returns the current revision ID in revisions mode.
|
|
316
371
|
*
|
|
@@ -346,7 +401,12 @@ export const getCurrentRevision = createRegistrySelector(
|
|
|
346
401
|
'postType',
|
|
347
402
|
postType,
|
|
348
403
|
postId,
|
|
349
|
-
{
|
|
404
|
+
{
|
|
405
|
+
per_page: -1,
|
|
406
|
+
context: 'edit',
|
|
407
|
+
_fields:
|
|
408
|
+
'id,date,author,meta,title.raw,excerpt.raw,content.raw',
|
|
409
|
+
}
|
|
350
410
|
);
|
|
351
411
|
if ( ! revisions ) {
|
|
352
412
|
return null;
|
|
@@ -401,7 +461,12 @@ export const getPreviousRevision = createRegistrySelector(
|
|
|
401
461
|
'postType',
|
|
402
462
|
postType,
|
|
403
463
|
postId,
|
|
404
|
-
{
|
|
464
|
+
{
|
|
465
|
+
per_page: -1,
|
|
466
|
+
context: 'edit',
|
|
467
|
+
_fields:
|
|
468
|
+
'id,date,author,meta,title.raw,excerpt.raw,content.raw',
|
|
469
|
+
}
|
|
405
470
|
);
|
|
406
471
|
if ( ! revisions ) {
|
|
407
472
|
return null;
|
package/src/store/reducer.js
CHANGED
|
@@ -456,6 +456,24 @@ export function revisionId( state = null, action ) {
|
|
|
456
456
|
* @param {Object} action Dispatched action.
|
|
457
457
|
* @return {Object} Updated state.
|
|
458
458
|
*/
|
|
459
|
+
/**
|
|
460
|
+
* Reducer for whether the revision diff is shown.
|
|
461
|
+
* Resets to true when entering/exiting revisions mode.
|
|
462
|
+
*
|
|
463
|
+
* @param {boolean} state Current state.
|
|
464
|
+
* @param {Object} action Dispatched action.
|
|
465
|
+
* @return {boolean} Updated state.
|
|
466
|
+
*/
|
|
467
|
+
export function showRevisionDiff( state = true, action ) {
|
|
468
|
+
switch ( action.type ) {
|
|
469
|
+
case 'SET_SHOW_REVISION_DIFF':
|
|
470
|
+
return action.showDiff;
|
|
471
|
+
case 'SET_CURRENT_REVISION_ID':
|
|
472
|
+
return true; // reset on enter/exit revisions
|
|
473
|
+
}
|
|
474
|
+
return state;
|
|
475
|
+
}
|
|
476
|
+
|
|
459
477
|
export function selectedNote( state = {}, action ) {
|
|
460
478
|
switch ( action.type ) {
|
|
461
479
|
case 'SELECT_NOTE':
|
|
@@ -487,6 +505,7 @@ export default combineReducers( {
|
|
|
487
505
|
showStylebook,
|
|
488
506
|
canvasMinHeight,
|
|
489
507
|
revisionId,
|
|
508
|
+
showRevisionDiff,
|
|
490
509
|
selectedNote,
|
|
491
510
|
dataviews: dataviewsReducer,
|
|
492
511
|
} );
|
package/src/style.scss
CHANGED
|
@@ -39,13 +39,14 @@
|
|
|
39
39
|
@use "./components/post-panel-section/style.scss" as *;
|
|
40
40
|
@use "./components/post-publish-panel/style.scss" as *;
|
|
41
41
|
@use "./components/post-revisions-preview/style.scss" as *;
|
|
42
|
+
@use "./components/revision-block-diff/style.scss" as *;
|
|
42
43
|
@use "./components/post-saved-state/style.scss" as *;
|
|
43
44
|
@use "./components/post-schedule/style.scss" as *;
|
|
44
45
|
@use "./components/post-status/style.scss" as *;
|
|
45
46
|
@use "./components/post-sticky/style.scss" as *;
|
|
46
47
|
@use "./components/post-sync-status/style.scss" as *;
|
|
47
48
|
@use "./components/post-taxonomies/style.scss" as *;
|
|
48
|
-
@use "./components/sync-connection-modal/style.scss" as *;
|
|
49
|
+
@use "./components/sync-connection-error-modal/style.scss" as *;
|
|
49
50
|
@use "./components/post-template/style.scss" as *;
|
|
50
51
|
@use "./components/post-text-editor/style.scss" as *;
|
|
51
52
|
@use "./components/post-title/style.scss" as *;
|