@wordpress/editor 14.48.2-next.v.202606191442.0 → 14.49.1
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 +2 -0
- package/README.md +5 -13
- package/build/components/autosave-monitor/index.cjs +40 -83
- package/build/components/autosave-monitor/index.cjs.map +3 -3
- package/build/components/post-publish-panel/postpublish.cjs +0 -1
- package/build/components/post-publish-panel/postpublish.cjs.map +2 -2
- package/build/components/post-status/index.cjs +0 -1
- package/build/components/post-status/index.cjs.map +2 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.cjs +0 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.cjs.map +2 -2
- package/build/components/post-template/create-new-template-modal.cjs +0 -1
- package/build/components/post-template/create-new-template-modal.cjs.map +2 -2
- package/build/components/post-text-editor/utils.cjs +2 -2
- package/build/components/post-text-editor/utils.cjs.map +1 -1
- package/build/components/post-visibility/index.cjs +0 -1
- package/build/components/post-visibility/index.cjs.map +2 -2
- package/build/components/provider/disable-non-page-content-blocks.cjs +23 -3
- package/build/components/provider/disable-non-page-content-blocks.cjs.map +2 -2
- package/build/components/provider/navigation-block-editing-mode.cjs +9 -2
- package/build/components/provider/navigation-block-editing-mode.cjs.map +2 -2
- package/build/components/provider/use-block-editor-settings.cjs +2 -1
- package/build/components/provider/use-block-editor-settings.cjs.map +2 -2
- package/build/components/sidebar/dataform-post-summary.cjs +87 -32
- package/build/components/sidebar/dataform-post-summary.cjs.map +3 -3
- package/build/components/sidebar/post-summary.cjs +8 -6
- package/build/components/sidebar/post-summary.cjs.map +3 -3
- package/build/dataviews/store/private-actions.cjs +3 -1
- package/build/dataviews/store/private-actions.cjs.map +2 -2
- package/build/store/private-actions.cjs +2 -2
- package/build/store/private-actions.cjs.map +2 -2
- package/build-module/components/autosave-monitor/index.mjs +42 -81
- package/build-module/components/autosave-monitor/index.mjs.map +2 -2
- package/build-module/components/post-publish-panel/postpublish.mjs +0 -1
- package/build-module/components/post-publish-panel/postpublish.mjs.map +2 -2
- package/build-module/components/post-status/index.mjs +0 -1
- package/build-module/components/post-status/index.mjs.map +2 -2
- package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs +0 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs.map +2 -2
- package/build-module/components/post-template/create-new-template-modal.mjs +0 -1
- package/build-module/components/post-template/create-new-template-modal.mjs.map +2 -2
- package/build-module/components/post-text-editor/utils.mjs +2 -2
- package/build-module/components/post-text-editor/utils.mjs.map +1 -1
- package/build-module/components/post-visibility/index.mjs +0 -1
- package/build-module/components/post-visibility/index.mjs.map +2 -2
- package/build-module/components/provider/disable-non-page-content-blocks.mjs +23 -3
- package/build-module/components/provider/disable-non-page-content-blocks.mjs.map +2 -2
- package/build-module/components/provider/navigation-block-editing-mode.mjs +10 -3
- package/build-module/components/provider/navigation-block-editing-mode.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +2 -1
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/sidebar/dataform-post-summary.mjs +88 -33
- package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
- package/build-module/components/sidebar/post-summary.mjs +8 -6
- package/build-module/components/sidebar/post-summary.mjs.map +2 -2
- package/build-module/dataviews/store/private-actions.mjs +5 -1
- package/build-module/dataviews/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +2 -2
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-style/style-rtl.css +29 -33
- package/build-style/style.css +29 -33
- package/build-types/components/autosave-monitor/index.d.ts +11 -29
- package/build-types/components/autosave-monitor/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/postpublish.d.ts.map +1 -1
- package/build-types/components/post-status/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
- package/build-types/components/post-visibility/index.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/navigation-block-editing-mode.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
- package/package.json +46 -46
- package/src/components/autosave-monitor/index.js +69 -104
- package/src/components/autosave-monitor/test/index.js +137 -122
- package/src/components/plugin-post-publish-panel/test/__snapshots__/index.js.snap +1 -0
- package/src/components/post-publish-panel/postpublish.js +0 -1
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +7 -2
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +1 -0
- package/src/components/post-status/index.js +0 -1
- package/src/components/post-taxonomies/hierarchical-term-selector.js +0 -1
- package/src/components/post-template/create-new-template-modal.js +0 -1
- package/src/components/post-text-editor/utils.js +2 -2
- package/src/components/post-visibility/index.js +0 -1
- package/src/components/provider/disable-non-page-content-blocks.js +23 -6
- package/src/components/provider/navigation-block-editing-mode.js +10 -4
- package/src/components/provider/use-block-editor-settings.js +3 -1
- package/src/components/sidebar/dataform-post-summary.js +133 -49
- package/src/components/sidebar/post-summary.js +12 -10
- package/src/dataviews/store/private-actions.ts +8 -1
- package/src/store/private-actions.js +2 -2
- package/src/store/test/actions.js +2 -2
package/build-style/style.css
CHANGED
|
@@ -1400,7 +1400,7 @@ button.font-library__upload-area {
|
|
|
1400
1400
|
flex-grow: 1;
|
|
1401
1401
|
min-height: 0;
|
|
1402
1402
|
box-sizing: border-box;
|
|
1403
|
-
scroll-padding-bottom:
|
|
1403
|
+
scroll-padding-bottom: 64px;
|
|
1404
1404
|
/* stylelint-disable-next-line property-no-unknown -- '@container' not globally permitted */
|
|
1405
1405
|
container: dataviews-wrapper/inline-size;
|
|
1406
1406
|
display: flex;
|
|
@@ -1718,7 +1718,7 @@ button.font-library__upload-area {
|
|
|
1718
1718
|
}
|
|
1719
1719
|
|
|
1720
1720
|
.dataviews-filters__search-widget-filter-combobox-list {
|
|
1721
|
-
max-height:
|
|
1721
|
+
max-height: 184px;
|
|
1722
1722
|
padding: var(--wpds-dimension-padding-xs, 4px);
|
|
1723
1723
|
overflow: auto;
|
|
1724
1724
|
border-top: 1px solid var(--wpds-color-stroke-surface-neutral, #dbdbdb);
|
|
@@ -2492,7 +2492,7 @@ button.font-library__upload-area {
|
|
|
2492
2492
|
.dataviews-view-grid-infinite-scroll .dataviews-view-grid__fields .dataviews-view-grid__field-value:not(:empty) {
|
|
2493
2493
|
min-height: var(--wpds-dimension-size-sm, 24px);
|
|
2494
2494
|
line-height: var(--wpds-typography-line-height-sm, 20px);
|
|
2495
|
-
padding-top: calc(var(--wpds-dimension-
|
|
2495
|
+
padding-top: calc((var(--wpds-dimension-size-sm, 24px) - var(--wpds-typography-line-height-sm, 20px)) / 2);
|
|
2496
2496
|
}
|
|
2497
2497
|
|
|
2498
2498
|
.dataviews-view-grid .dataviews-view-grid__fields .dataviews-view-grid__field,
|
|
@@ -2768,8 +2768,8 @@ div.dataviews-view-list {
|
|
|
2768
2768
|
}
|
|
2769
2769
|
|
|
2770
2770
|
.dataviews-view-list .dataviews-view-list__media-wrapper {
|
|
2771
|
-
width:
|
|
2772
|
-
height:
|
|
2771
|
+
width: 48px;
|
|
2772
|
+
height: 48px;
|
|
2773
2773
|
overflow: hidden;
|
|
2774
2774
|
position: relative;
|
|
2775
2775
|
flex-shrink: 0;
|
|
@@ -2796,7 +2796,7 @@ div.dataviews-view-list {
|
|
|
2796
2796
|
}
|
|
2797
2797
|
|
|
2798
2798
|
.dataviews-view-list .dataviews-view-list__field-wrapper {
|
|
2799
|
-
min-height:
|
|
2799
|
+
min-height: 48px;
|
|
2800
2800
|
flex-grow: 1;
|
|
2801
2801
|
min-width: 0;
|
|
2802
2802
|
}
|
|
@@ -2870,12 +2870,12 @@ div.dataviews-view-list {
|
|
|
2870
2870
|
}
|
|
2871
2871
|
|
|
2872
2872
|
.dataviews-view-list.has-comfortable-density div[role=row] .dataviews-view-list__media-wrapper {
|
|
2873
|
-
width:
|
|
2874
|
-
height:
|
|
2873
|
+
width: 64px;
|
|
2874
|
+
height: 64px;
|
|
2875
2875
|
}
|
|
2876
2876
|
|
|
2877
2877
|
.dataviews-view-list.has-comfortable-density div[role=row] .dataviews-view-list__field-wrapper {
|
|
2878
|
-
min-height:
|
|
2878
|
+
min-height: 64px;
|
|
2879
2879
|
}
|
|
2880
2880
|
|
|
2881
2881
|
.dataviews-view-list.has-comfortable-density div[role=row] .dataviews-view-list__fields {
|
|
@@ -3308,7 +3308,7 @@ div.dataviews-view-list {
|
|
|
3308
3308
|
.dataviews-view-picker-grid .dataviews-view-picker-grid__fields .dataviews-view-picker-grid__field-value:not(:empty) {
|
|
3309
3309
|
min-height: var(--wpds-dimension-size-sm, 24px);
|
|
3310
3310
|
line-height: var(--wpds-typography-line-height-sm, 20px);
|
|
3311
|
-
padding-top: calc(var(--wpds-dimension-
|
|
3311
|
+
padding-top: calc((var(--wpds-dimension-size-sm, 24px) - var(--wpds-typography-line-height-sm, 20px)) / 2);
|
|
3312
3312
|
}
|
|
3313
3313
|
|
|
3314
3314
|
.dataviews-view-picker-grid .dataviews-view-picker-grid__fields .dataviews-view-picker-grid__field {
|
|
@@ -3371,7 +3371,7 @@ div.dataviews-view-list {
|
|
|
3371
3371
|
font-weight: var(--wpds-typography-font-weight-medium, 499);
|
|
3372
3372
|
color: var(--wpds-color-foreground-content-neutral, #1e1e1e);
|
|
3373
3373
|
margin: 0 0 var(--wpds-dimension-gap-sm, 8px) 0;
|
|
3374
|
-
padding: 0
|
|
3374
|
+
padding: 0 48px;
|
|
3375
3375
|
}
|
|
3376
3376
|
|
|
3377
3377
|
.dataviews-view-picker-table {
|
|
@@ -3379,7 +3379,7 @@ div.dataviews-view-list {
|
|
|
3379
3379
|
}
|
|
3380
3380
|
|
|
3381
3381
|
.dataviews-view-picker-table .dataviews-view-table__checkbox-column {
|
|
3382
|
-
width:
|
|
3382
|
+
width: 48px;
|
|
3383
3383
|
}
|
|
3384
3384
|
|
|
3385
3385
|
.dataviews-view-picker-table tbody:focus-visible[aria-activedescendant] {
|
|
@@ -3519,8 +3519,8 @@ div.dataviews-view-list {
|
|
|
3519
3519
|
}
|
|
3520
3520
|
|
|
3521
3521
|
.dataviews-view-activity .dataviews-view-activity__item.is-compact .dataviews-view-activity__item-type-icon {
|
|
3522
|
-
width: calc(var(--wpds-dimension-
|
|
3523
|
-
height: calc(var(--wpds-dimension-
|
|
3522
|
+
width: calc(var(--wpds-dimension-size-3xs, 12px) - 1px);
|
|
3523
|
+
height: calc(var(--wpds-dimension-size-3xs, 12px) - 1px);
|
|
3524
3524
|
}
|
|
3525
3525
|
|
|
3526
3526
|
.dataviews-view-activity .dataviews-view-activity__item.is-compact .dataviews-view-activity__item-content {
|
|
@@ -3536,8 +3536,8 @@ div.dataviews-view-list {
|
|
|
3536
3536
|
}
|
|
3537
3537
|
|
|
3538
3538
|
.dataviews-view-activity .dataviews-view-activity__item.is-balanced .dataviews-view-activity__item-type-icon {
|
|
3539
|
-
width: calc(var(--wpds-dimension-
|
|
3540
|
-
height: calc(var(--wpds-dimension-
|
|
3539
|
+
width: calc(var(--wpds-dimension-size-sm, 24px) + 1px);
|
|
3540
|
+
height: calc(var(--wpds-dimension-size-sm, 24px) + 1px);
|
|
3541
3541
|
}
|
|
3542
3542
|
|
|
3543
3543
|
.dataviews-view-activity .dataviews-view-activity__item.is-balanced .dataviews-view-activity__item-content {
|
|
@@ -3554,8 +3554,8 @@ div.dataviews-view-list {
|
|
|
3554
3554
|
}
|
|
3555
3555
|
|
|
3556
3556
|
.dataviews-view-activity .dataviews-view-activity__item.is-comfortable .dataviews-view-activity__item-type-icon {
|
|
3557
|
-
width: calc(var(--wpds-dimension-
|
|
3558
|
-
height: calc(var(--wpds-dimension-
|
|
3557
|
+
width: calc(var(--wpds-dimension-size-md, 32px) + 1px);
|
|
3558
|
+
height: calc(var(--wpds-dimension-size-md, 32px) + 1px);
|
|
3559
3559
|
}
|
|
3560
3560
|
|
|
3561
3561
|
.dataviews-view-activity .dataviews-view-activity__item.is-comfortable .dataviews-view-activity__item-content {
|
|
@@ -3564,8 +3564,8 @@ div.dataviews-view-list {
|
|
|
3564
3564
|
}
|
|
3565
3565
|
|
|
3566
3566
|
.dataviews-view-activity .dataviews-view-activity__item.is-comfortable .dataviews-view-activity__item-bullet, .dataviews-view-activity .dataviews-view-activity__item.is-balanced .dataviews-view-activity__item-bullet {
|
|
3567
|
-
width: calc(var(--wpds-dimension-
|
|
3568
|
-
height: calc(var(--wpds-dimension-
|
|
3567
|
+
width: calc(var(--wpds-dimension-size-4xs, 8px) + 1px);
|
|
3568
|
+
height: calc(var(--wpds-dimension-size-4xs, 8px) + 1px);
|
|
3569
3569
|
position: relative;
|
|
3570
3570
|
top: 50%;
|
|
3571
3571
|
transform: translateY(-50%);
|
|
@@ -3663,8 +3663,8 @@ div.dataviews-view-list {
|
|
|
3663
3663
|
}
|
|
3664
3664
|
|
|
3665
3665
|
.dataviews-view-picker-activity .dataviews-view-picker-activity__item.is-compact .dataviews-view-picker-activity__item-type-icon {
|
|
3666
|
-
width: calc(var(--wpds-dimension-
|
|
3667
|
-
height: calc(var(--wpds-dimension-
|
|
3666
|
+
width: calc(var(--wpds-dimension-size-3xs, 12px) - 1px);
|
|
3667
|
+
height: calc(var(--wpds-dimension-size-3xs, 12px) - 1px);
|
|
3668
3668
|
}
|
|
3669
3669
|
|
|
3670
3670
|
.dataviews-view-picker-activity .dataviews-view-picker-activity__item.is-compact .dataviews-view-picker-activity__item-content {
|
|
@@ -3680,8 +3680,8 @@ div.dataviews-view-list {
|
|
|
3680
3680
|
}
|
|
3681
3681
|
|
|
3682
3682
|
.dataviews-view-picker-activity .dataviews-view-picker-activity__item.is-balanced .dataviews-view-picker-activity__item-type-icon {
|
|
3683
|
-
width: calc(var(--wpds-dimension-
|
|
3684
|
-
height: calc(var(--wpds-dimension-
|
|
3683
|
+
width: calc(var(--wpds-dimension-size-sm, 24px) + 1px);
|
|
3684
|
+
height: calc(var(--wpds-dimension-size-sm, 24px) + 1px);
|
|
3685
3685
|
}
|
|
3686
3686
|
|
|
3687
3687
|
.dataviews-view-picker-activity .dataviews-view-picker-activity__item.is-balanced .dataviews-view-picker-activity__item-content {
|
|
@@ -3698,8 +3698,8 @@ div.dataviews-view-list {
|
|
|
3698
3698
|
}
|
|
3699
3699
|
|
|
3700
3700
|
.dataviews-view-picker-activity .dataviews-view-picker-activity__item.is-comfortable .dataviews-view-picker-activity__item-type-icon {
|
|
3701
|
-
width: calc(var(--wpds-dimension-
|
|
3702
|
-
height: calc(var(--wpds-dimension-
|
|
3701
|
+
width: calc(var(--wpds-dimension-size-md, 32px) + 1px);
|
|
3702
|
+
height: calc(var(--wpds-dimension-size-md, 32px) + 1px);
|
|
3703
3703
|
}
|
|
3704
3704
|
|
|
3705
3705
|
.dataviews-view-picker-activity .dataviews-view-picker-activity__item.is-comfortable .dataviews-view-picker-activity__item-content {
|
|
@@ -3708,8 +3708,8 @@ div.dataviews-view-list {
|
|
|
3708
3708
|
}
|
|
3709
3709
|
|
|
3710
3710
|
.dataviews-view-picker-activity .dataviews-view-picker-activity__item.is-comfortable .dataviews-view-picker-activity__item-bullet, .dataviews-view-picker-activity .dataviews-view-picker-activity__item.is-balanced .dataviews-view-picker-activity__item-bullet {
|
|
3711
|
-
width: calc(var(--wpds-dimension-
|
|
3712
|
-
height: calc(var(--wpds-dimension-
|
|
3711
|
+
width: calc(var(--wpds-dimension-size-4xs, 8px) + 1px);
|
|
3712
|
+
height: calc(var(--wpds-dimension-size-4xs, 8px) + 1px);
|
|
3713
3713
|
position: relative;
|
|
3714
3714
|
top: 50%;
|
|
3715
3715
|
transform: translateY(-50%);
|
|
@@ -3967,17 +3967,13 @@ div.dataviews-view-list {
|
|
|
3967
3967
|
position: relative;
|
|
3968
3968
|
z-index: 1;
|
|
3969
3969
|
cursor: help;
|
|
3970
|
-
|
|
3970
|
+
color: var(--wpds-color-foreground-content-error-weak, #cc1818);
|
|
3971
3971
|
display: inline-flex;
|
|
3972
3972
|
flex-direction: row;
|
|
3973
3973
|
align-items: center;
|
|
3974
3974
|
gap: var(--wpds-dimension-gap-xs, 4px);
|
|
3975
3975
|
}
|
|
3976
3976
|
|
|
3977
|
-
.dataforms-layouts-panel__field-label-error-content svg {
|
|
3978
|
-
fill: currentColor;
|
|
3979
|
-
}
|
|
3980
|
-
|
|
3981
3977
|
.dataforms-layouts-panel__field-control {
|
|
3982
3978
|
flex-grow: 1;
|
|
3983
3979
|
min-width: 0;
|
|
@@ -1,39 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Component } from '@wordpress/element';
|
|
5
|
-
export declare class AutosaveMonitor extends Component {
|
|
6
|
-
constructor(props: any);
|
|
7
|
-
componentDidMount(): void;
|
|
8
|
-
componentDidUpdate(prevProps: any): void;
|
|
9
|
-
componentWillUnmount(): void;
|
|
10
|
-
setAutosaveTimer(timeout?: number): void;
|
|
11
|
-
autosaveTimerHandler(): void;
|
|
12
|
-
render(): null;
|
|
13
|
-
}
|
|
14
1
|
/**
|
|
15
2
|
* Monitors the changes made to the edited post and triggers autosave if necessary.
|
|
16
3
|
*
|
|
17
|
-
* The
|
|
18
|
-
* The time between the change and the autosave varies but is no larger than `props.interval` seconds. Refer to the code below for more details, such as
|
|
19
|
-
* the specific way of detecting changes.
|
|
20
|
-
*
|
|
21
|
-
* There are two caveats:
|
|
22
|
-
* * If `props.isAutosaveable` happens to be false at a time of checking for changes, the check is retried every second.
|
|
23
|
-
* * The timer may be disabled by setting `props.disableIntervalChecks` to `true`. In that mode, any change will immediately trigger `props.autosave()`.
|
|
4
|
+
* The post is checked every `interval` seconds and autosaved when there is something new to save.
|
|
24
5
|
*
|
|
25
|
-
* @param {Object} props
|
|
26
|
-
* @param {
|
|
27
|
-
*
|
|
28
|
-
* @param {
|
|
29
|
-
*
|
|
30
|
-
* @param {boolean} props.isDirty - Indicates if there are unsaved changes.
|
|
6
|
+
* @param {Object} props The component props.
|
|
7
|
+
* @param {number} [props.interval] Time in seconds between checks. Defaults to the editor's
|
|
8
|
+
* `autosaveInterval` setting.
|
|
9
|
+
* @param {Function} [props.autosave] Function to call when changes need to be saved. Defaults to the
|
|
10
|
+
* editor store's `autosave` action.
|
|
31
11
|
*
|
|
32
12
|
* @example
|
|
33
13
|
* ```jsx
|
|
34
|
-
* <AutosaveMonitor interval={
|
|
14
|
+
* <AutosaveMonitor interval={ 30 } />
|
|
35
15
|
* ```
|
|
36
16
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
export default function AutosaveMonitor({ interval, autosave }: {
|
|
18
|
+
interval?: number;
|
|
19
|
+
autosave?: Function;
|
|
20
|
+
}): null;
|
|
39
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/autosave-monitor/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/autosave-monitor/index.js"],"names":[],"mappings":"AAwCA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAV5D;IAAyB,QAAQ,AAAjC,CAEA,EAFQ,MAAM,CAEd;IAAyB,QAAQ,AAAjC,CAGA,WAAA;CAK4D,QAyC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postpublish.d.ts","sourceRoot":"","sources":["../../../src/components/post-publish-panel/postpublish.js"],"names":[],"mappings":"AA8EA,MAAM,CAAC,OAAO,UAAU,2BAA2B,CAAE,EACpD,YAAY,EACZ,QAAQ,EACR;;;CAAA,+
|
|
1
|
+
{"version":3,"file":"postpublish.d.ts","sourceRoot":"","sources":["../../../src/components/post-publish-panel/postpublish.js"],"names":[],"mappings":"AA8EA,MAAM,CAAC,OAAO,UAAU,2BAA2B,CAAE,EACpD,YAAY,EACZ,QAAQ,EACR;;;CAAA,+BAwGA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/post-status/index.js"],"names":[],"mappings":"AA2CA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;IA0B1B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/post-status/index.js"],"names":[],"mappings":"AA2CA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;IA0B1B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,UAAU,uCAoMjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hierarchical-term-selector.d.ts","sourceRoot":"","sources":["../../../src/components/post-taxonomies/hierarchical-term-selector.js"],"names":[],"mappings":"AAmDA;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAE,SAAS,EAL9B,QAK8B,EAAE,KAAK,EAJrC,MAAM,EAI+B,GAFpC,QAAQ,CAqCnB;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAE,KAAK,EALpB,QAKoB,EAAE,MAAM,EAJ5B,MAAM,GAAC,MAIqB,EAAE,IAAI,EAHlC,MAGkC,UAQ5C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAE,WAAW,EAHlC,MAGkC,GAFjC,UAAS,CAqCpB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAE,EAAE,IAAI,EAAE,EAH/C;IAAsB,IAAI,EAAlB,MAAM,CACd;CAE+C,
|
|
1
|
+
{"version":3,"file":"hierarchical-term-selector.d.ts","sourceRoot":"","sources":["../../../src/components/post-taxonomies/hierarchical-term-selector.js"],"names":[],"mappings":"AAmDA;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAE,SAAS,EAL9B,QAK8B,EAAE,KAAK,EAJrC,MAAM,EAI+B,GAFpC,QAAQ,CAqCnB;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAE,KAAK,EALpB,QAKoB,EAAE,MAAM,EAJ5B,MAAM,GAAC,MAIqB,EAAE,IAAI,EAHlC,MAGkC,UAQ5C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAE,WAAW,EAHlC,MAGkC,GAFjC,UAAS,CAqCpB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAE,EAAE,IAAI,EAAE,EAH/C;IAAsB,IAAI,EAAlB,MAAM,CACd;CAE+C,WA2UjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-new-template-modal.d.ts","sourceRoot":"","sources":["../../../src/components/post-template/create-new-template-modal.js"],"names":[],"mappings":"AA4BA,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAE,EAAE,OAAO,EAAE;;CAAA,+
|
|
1
|
+
{"version":3,"file":"create-new-template-modal.d.ts","sourceRoot":"","sources":["../../../src/components/post-template/create-new-template-modal.js"],"names":[],"mappings":"AA4BA,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAE,EAAE,OAAO,EAAE;;CAAA,+BAgI1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/post-visibility/index.js"],"names":[],"mappings":"AAoBA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAE,EAAE,OAAO,EAAE,EAHhD;IAAwB,OAAO,WAC/B;CAEgD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/post-visibility/index.js"],"names":[],"mappings":"AAoBA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAE,EAAE,OAAO,EAAE,EAHhD;IAAwB,OAAO,WAC/B;CAEgD,6BA+DlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disable-non-page-content-blocks.d.ts","sourceRoot":"","sources":["../../../src/components/provider/disable-non-page-content-blocks.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,2BAA2B,
|
|
1
|
+
{"version":3,"file":"disable-non-page-content-blocks.d.ts","sourceRoot":"","sources":["../../../src/components/provider/disable-non-page-content-blocks.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,2BAA2B,SAkHlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation-block-editing-mode.d.ts","sourceRoot":"","sources":["../../../src/components/provider/navigation-block-editing-mode.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,UAAU,0BAA0B,
|
|
1
|
+
{"version":3,"file":"navigation-block-editing-mode.d.ts","sourceRoot":"","sources":["../../../src/components/provider/navigation-block-editing-mode.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,UAAU,0BAA0B,SA2BjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-block-editor-settings.d.ts","sourceRoot":"","sources":["../../../src/components/provider/use-block-editor-settings.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-block-editor-settings.d.ts","sourceRoot":"","sources":["../../../src/components/provider/use-block-editor-settings.js"],"names":[],"mappings":"AA2HA;;;;;;;;;GASG;AACH,iBAAS,sBAAsB,CAAE,QAAQ,QAAA,EAAE,QAAQ,EANxC,MAMwC,EAAE,MAAM,EALhD,MAKgD,EAAE,aAAa,EAJ/D,MAI+D,UAyUzE;eAEc,sBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataform-post-summary.d.ts","sourceRoot":"","sources":["../../../src/components/sidebar/dataform-post-summary.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dataform-post-summary.d.ts","sourceRoot":"","sources":["../../../src/components/sidebar/dataform-post-summary.js"],"names":[],"mappings":"AA+KA,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,EAAE,iBAAiB,EAAE;;CAAA,+BAkOjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-summary.d.ts","sourceRoot":"","sources":["../../../src/components/sidebar/post-summary.js"],"names":[],"mappings":"AAsCA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,EAAE,iBAAiB,EAAE;;CAAA,+
|
|
1
|
+
{"version":3,"file":"post-summary.d.ts","sourceRoot":"","sources":["../../../src/components/sidebar/post-summary.js"],"names":[],"mappings":"AAsCA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,EAAE,iBAAiB,EAAE;;CAAA,+BAczD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-actions.d.ts","sourceRoot":"","sources":["../../../src/dataviews/store/private-actions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"private-actions.d.ts","sourceRoot":"","sources":["../../../src/dataviews/store/private-actions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAoE1D,OAAO,CAAC,MAAM,CAAC,CAAC;IACf,UAAU,MAAM;QACf,8BAA8B,CAAC,EAAE,OAAO,CAAC;KACzC;CACD;AAgBD,wBAAgB,oBAAoB,CAAE,IAAI,EACzC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAE,IAAI,CAAE;UAGf,wBAAwB;;;;EAK/B;AAED,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM;UAGT,0BAA0B;;;;EAKjC;AAED,wBAAgB,mBAAmB,CAAE,IAAI,EACxC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,KAAK,CAAE,IAAI,CAAE;UAGd,uBAAuB;;;;EAK9B;AAED,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM;UAGR,yBAAyB;;;;EAKhC;AAED,wBAAgB,UAAU,CAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;UAE9C,cAAc;;;EAIrB;AA2BD,eAAO,MAAM,sBAAsB,aACtB,MAAM,oBACI;IAAE,QAAQ,EAAE,GAAG,CAAA;CAAE,kBA+KtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-template-part-icon.d.ts","sourceRoot":"","sources":["../../src/utils/get-template-part-icon.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAE,cAAc,EAJxC,MAIwC,
|
|
1
|
+
{"version":3,"file":"get-template-part-icon.d.ts","sourceRoot":"","sources":["../../src/utils/get-template-part-icon.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAE,cAAc,EAJxC,MAIwC,UAWlD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.49.1",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -59,50 +59,50 @@
|
|
|
59
59
|
"build-module/bindings/**"
|
|
60
60
|
],
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@wordpress/a11y": "^4.
|
|
63
|
-
"@wordpress/api-fetch": "^7.
|
|
64
|
-
"@wordpress/base-styles": "^10.
|
|
65
|
-
"@wordpress/blob": "^4.
|
|
66
|
-
"@wordpress/block-editor": "^15.22.1
|
|
67
|
-
"@wordpress/block-serialization-default-parser": "^5.
|
|
68
|
-
"@wordpress/blocks": "^15.
|
|
69
|
-
"@wordpress/commands": "^1.
|
|
70
|
-
"@wordpress/components": "^
|
|
71
|
-
"@wordpress/compose": "^8.
|
|
72
|
-
"@wordpress/core-data": "^7.
|
|
73
|
-
"@wordpress/data": "^10.
|
|
74
|
-
"@wordpress/dataviews": "^17.0.1
|
|
75
|
-
"@wordpress/date": "^5.
|
|
76
|
-
"@wordpress/deprecated": "^4.
|
|
77
|
-
"@wordpress/dom": "^4.
|
|
78
|
-
"@wordpress/element": "^8.
|
|
79
|
-
"@wordpress/fields": "^0.
|
|
80
|
-
"@wordpress/global-styles-engine": "^1.
|
|
81
|
-
"@wordpress/global-styles-ui": "^1.
|
|
82
|
-
"@wordpress/hooks": "^4.
|
|
83
|
-
"@wordpress/html-entities": "^4.
|
|
84
|
-
"@wordpress/i18n": "^6.
|
|
85
|
-
"@wordpress/icons": "^
|
|
86
|
-
"@wordpress/interface": "^9.
|
|
87
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
88
|
-
"@wordpress/keycodes": "^4.
|
|
89
|
-
"@wordpress/media-editor": "^0.
|
|
90
|
-
"@wordpress/media-fields": "^0.
|
|
91
|
-
"@wordpress/media-utils": "^5.
|
|
92
|
-
"@wordpress/notices": "^5.
|
|
93
|
-
"@wordpress/patterns": "^2.
|
|
94
|
-
"@wordpress/plugins": "^7.
|
|
95
|
-
"@wordpress/preferences": "^4.
|
|
96
|
-
"@wordpress/private-apis": "^1.
|
|
97
|
-
"@wordpress/reusable-blocks": "^5.
|
|
98
|
-
"@wordpress/rich-text": "^7.
|
|
99
|
-
"@wordpress/server-side-render": "^6.
|
|
100
|
-
"@wordpress/ui": "^0.16.1
|
|
101
|
-
"@wordpress/upload-media": "^0.34.1
|
|
102
|
-
"@wordpress/url": "^4.
|
|
103
|
-
"@wordpress/views": "^1.
|
|
104
|
-
"@wordpress/warning": "^3.
|
|
105
|
-
"@wordpress/wordcount": "^4.
|
|
62
|
+
"@wordpress/a11y": "^4.49.0",
|
|
63
|
+
"@wordpress/api-fetch": "^7.49.0",
|
|
64
|
+
"@wordpress/base-styles": "^10.1.0",
|
|
65
|
+
"@wordpress/blob": "^4.49.0",
|
|
66
|
+
"@wordpress/block-editor": "^15.22.1",
|
|
67
|
+
"@wordpress/block-serialization-default-parser": "^5.49.0",
|
|
68
|
+
"@wordpress/blocks": "^15.22.0",
|
|
69
|
+
"@wordpress/commands": "^1.49.1",
|
|
70
|
+
"@wordpress/components": "^36.0.1",
|
|
71
|
+
"@wordpress/compose": "^8.2.0",
|
|
72
|
+
"@wordpress/core-data": "^7.49.1",
|
|
73
|
+
"@wordpress/data": "^10.49.0",
|
|
74
|
+
"@wordpress/dataviews": "^17.0.1",
|
|
75
|
+
"@wordpress/date": "^5.49.0",
|
|
76
|
+
"@wordpress/deprecated": "^4.49.0",
|
|
77
|
+
"@wordpress/dom": "^4.49.0",
|
|
78
|
+
"@wordpress/element": "^8.1.0",
|
|
79
|
+
"@wordpress/fields": "^0.41.1",
|
|
80
|
+
"@wordpress/global-styles-engine": "^1.16.0",
|
|
81
|
+
"@wordpress/global-styles-ui": "^1.16.1",
|
|
82
|
+
"@wordpress/hooks": "^4.49.0",
|
|
83
|
+
"@wordpress/html-entities": "^4.49.0",
|
|
84
|
+
"@wordpress/i18n": "^6.22.0",
|
|
85
|
+
"@wordpress/icons": "^15.0.0",
|
|
86
|
+
"@wordpress/interface": "^9.34.1",
|
|
87
|
+
"@wordpress/keyboard-shortcuts": "^5.49.0",
|
|
88
|
+
"@wordpress/keycodes": "^4.49.0",
|
|
89
|
+
"@wordpress/media-editor": "^0.12.1",
|
|
90
|
+
"@wordpress/media-fields": "^0.14.1",
|
|
91
|
+
"@wordpress/media-utils": "^5.49.1",
|
|
92
|
+
"@wordpress/notices": "^5.49.1",
|
|
93
|
+
"@wordpress/patterns": "^2.49.1",
|
|
94
|
+
"@wordpress/plugins": "^7.49.1",
|
|
95
|
+
"@wordpress/preferences": "^4.49.1",
|
|
96
|
+
"@wordpress/private-apis": "^1.49.0",
|
|
97
|
+
"@wordpress/reusable-blocks": "^5.49.1",
|
|
98
|
+
"@wordpress/rich-text": "^7.49.0",
|
|
99
|
+
"@wordpress/server-side-render": "^6.25.1",
|
|
100
|
+
"@wordpress/ui": "^0.16.1",
|
|
101
|
+
"@wordpress/upload-media": "^0.34.1",
|
|
102
|
+
"@wordpress/url": "^4.49.0",
|
|
103
|
+
"@wordpress/views": "^1.16.1",
|
|
104
|
+
"@wordpress/warning": "^3.49.0",
|
|
105
|
+
"@wordpress/wordcount": "^4.49.0",
|
|
106
106
|
"change-case": "^4.1.2",
|
|
107
107
|
"client-zip": "^2.4.5",
|
|
108
108
|
"clsx": "^2.1.1",
|
|
@@ -135,5 +135,5 @@
|
|
|
135
135
|
"publishConfig": {
|
|
136
136
|
"access": "public"
|
|
137
137
|
},
|
|
138
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "9a75283890dda96ae1d37197b5070fae8c9cf66f"
|
|
139
139
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { withSelect, withDispatch } from '@wordpress/data';
|
|
4
|
+
import { useEffect, useRef } from '@wordpress/element';
|
|
5
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -11,123 +10,89 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
11
10
|
*/
|
|
12
11
|
import { store as editorStore } from '../../store';
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
componentDidUpdate( prevProps ) {
|
|
27
|
-
if ( this.props.disableIntervalChecks ) {
|
|
28
|
-
if ( this.props.editsReference !== prevProps.editsReference ) {
|
|
29
|
-
this.props.autosave();
|
|
30
|
-
}
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if ( this.props.interval !== prevProps.interval ) {
|
|
35
|
-
clearTimeout( this.timerId );
|
|
36
|
-
this.setAutosaveTimer();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if ( ! this.props.isDirty ) {
|
|
40
|
-
this.needsAutosave = false;
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if ( this.props.isAutosaving && ! prevProps.isAutosaving ) {
|
|
45
|
-
this.needsAutosave = false;
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if ( this.props.editsReference !== prevProps.editsReference ) {
|
|
50
|
-
this.needsAutosave = true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
componentWillUnmount() {
|
|
55
|
-
clearTimeout( this.timerId );
|
|
56
|
-
}
|
|
13
|
+
/**
|
|
14
|
+
* Calls `callback` every `intervalInSeconds`. The latest `callback` is always
|
|
15
|
+
* invoked without resetting the timer.
|
|
16
|
+
*
|
|
17
|
+
* @param {Function} callback Function to call on each tick.
|
|
18
|
+
* @param {number} intervalInSeconds Seconds between ticks.
|
|
19
|
+
*/
|
|
20
|
+
function useInterval( callback, intervalInSeconds ) {
|
|
21
|
+
const callbackRef = useRef( callback );
|
|
57
22
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}, timeout );
|
|
62
|
-
}
|
|
23
|
+
useEffect( () => {
|
|
24
|
+
callbackRef.current = callback;
|
|
25
|
+
}, [ callback ] );
|
|
63
26
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
27
|
+
useEffect( () => {
|
|
28
|
+
// Interval can be undefined before editor settings are populated.
|
|
29
|
+
if ( ! intervalInSeconds ) {
|
|
67
30
|
return;
|
|
68
31
|
}
|
|
69
32
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
render() {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
33
|
+
const id = setInterval(
|
|
34
|
+
() => callbackRef.current(),
|
|
35
|
+
intervalInSeconds * 1000
|
|
36
|
+
);
|
|
37
|
+
return () => clearInterval( id );
|
|
38
|
+
}, [ intervalInSeconds ] );
|
|
81
39
|
}
|
|
82
40
|
|
|
83
41
|
/**
|
|
84
42
|
* Monitors the changes made to the edited post and triggers autosave if necessary.
|
|
85
43
|
*
|
|
86
|
-
* The
|
|
87
|
-
* The time between the change and the autosave varies but is no larger than `props.interval` seconds. Refer to the code below for more details, such as
|
|
88
|
-
* the specific way of detecting changes.
|
|
44
|
+
* The post is checked every `interval` seconds and autosaved when there is something new to save.
|
|
89
45
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* @param {Function} props.autosave - The function to call when changes need to be saved.
|
|
96
|
-
* @param {number} props.interval - The maximum time in seconds between an unsaved change and an autosave.
|
|
97
|
-
* @param {boolean} props.isAutosaveable - If false, the check for changes is retried every second.
|
|
98
|
-
* @param {boolean} props.disableIntervalChecks - If true, disables the timer and any change will immediately trigger `props.autosave()`.
|
|
99
|
-
* @param {boolean} props.isDirty - Indicates if there are unsaved changes.
|
|
46
|
+
* @param {Object} props The component props.
|
|
47
|
+
* @param {number} [props.interval] Time in seconds between checks. Defaults to the editor's
|
|
48
|
+
* `autosaveInterval` setting.
|
|
49
|
+
* @param {Function} [props.autosave] Function to call when changes need to be saved. Defaults to the
|
|
50
|
+
* editor store's `autosave` action.
|
|
100
51
|
*
|
|
101
52
|
* @example
|
|
102
53
|
* ```jsx
|
|
103
|
-
* <AutosaveMonitor interval={
|
|
54
|
+
* <AutosaveMonitor interval={ 30 } />
|
|
104
55
|
* ```
|
|
105
56
|
*/
|
|
106
|
-
export default
|
|
107
|
-
|
|
108
|
-
|
|
57
|
+
export default function AutosaveMonitor( { interval, autosave } ) {
|
|
58
|
+
const { autosave: autosaveAction } = useDispatch( editorStore );
|
|
59
|
+
const triggerAutosave = autosave ?? autosaveAction;
|
|
60
|
+
|
|
61
|
+
const { getReferenceByDistinctEdits } = useSelect( coreStore );
|
|
62
|
+
const { isEditedPostDirty, isEditedPostAutosaveable, isAutosavingPost } =
|
|
63
|
+
useSelect( editorStore );
|
|
64
|
+
|
|
65
|
+
const autosaveInterval = useSelect(
|
|
66
|
+
( select ) => {
|
|
67
|
+
if ( interval !== undefined ) {
|
|
68
|
+
return interval;
|
|
69
|
+
}
|
|
109
70
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
getEditorSettings,
|
|
115
|
-
} = select( editorStore );
|
|
71
|
+
return select( editorStore ).getEditorSettings().autosaveInterval;
|
|
72
|
+
},
|
|
73
|
+
[ interval ]
|
|
74
|
+
);
|
|
116
75
|
|
|
117
|
-
|
|
76
|
+
// Reference of the edits last considered for autosaving. Mutable state that
|
|
77
|
+
// must not trigger a re-render, hence a ref.
|
|
78
|
+
const lastEditsReferenceRef = useRef();
|
|
118
79
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
autosave
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
80
|
+
useInterval( () => {
|
|
81
|
+
// The post can't be autosaved yet (e.g. its existing autosave is still
|
|
82
|
+
// loading). Keep any pending edits and try again on the next tick.
|
|
83
|
+
if ( ! isEditedPostAutosaveable() ) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const editsReference = getReferenceByDistinctEdits();
|
|
88
|
+
const hasNewEdits = editsReference !== lastEditsReferenceRef.current;
|
|
89
|
+
if ( hasNewEdits && isEditedPostDirty() && ! isAutosavingPost() ) {
|
|
90
|
+
// Only consume the edits reference when we autosave,
|
|
91
|
+
// so edits made during an in-flight autosave aren't skipped.
|
|
92
|
+
lastEditsReferenceRef.current = editsReference;
|
|
93
|
+
triggerAutosave();
|
|
94
|
+
}
|
|
95
|
+
}, autosaveInterval );
|
|
96
|
+
|
|
97
|
+
return null;
|
|
98
|
+
}
|