@wordpress/editor 12.19.0 → 12.21.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 +4 -0
- package/build/components/entities-saved-states/entity-record-item.js +1 -0
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js +1 -7
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/index.js +1 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/index.js +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/post-comments/index.js +1 -0
- package/build/components/post-comments/index.js.map +1 -1
- package/build/components/post-format/index.js +1 -1
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-pending-status/index.js +1 -0
- package/build/components/post-pending-status/index.js.map +1 -1
- package/build/components/post-pingbacks/index.js +1 -0
- package/build/components/post-pingbacks/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +11 -2
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-panel/index.js +1 -0
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-category-panel.js +1 -7
- package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js +1 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js +1 -7
- package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build/components/post-saved-state/index.js +19 -5
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/index.js +13 -16
- package/build/components/post-schedule/index.js.map +1 -1
- package/build/components/post-sticky/index.js +1 -0
- package/build/components/post-sticky/index.js.map +1 -1
- package/build/components/post-taxonomies/check.js +1 -7
- package/build/components/post-taxonomies/check.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +3 -1
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +3 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/index.js +1 -1
- package/build/components/post-taxonomies/index.js.map +1 -1
- package/build/components/post-title/index.js +4 -2
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-type-support-check/index.js +1 -7
- package/build/components/post-type-support-check/index.js.map +1 -1
- package/build/components/theme-support-check/index.js +2 -2
- package/build/components/theme-support-check/index.js.map +1 -1
- package/build/components/time-to-read/index.js +2 -6
- package/build/components/time-to-read/index.js.map +1 -1
- package/build/store/selectors.js +1 -6
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils/notice-builder.js +2 -2
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +1 -0
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js +1 -6
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +2 -2
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/index.js +3 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/post-comments/index.js +1 -0
- package/build-module/components/post-comments/index.js.map +1 -1
- package/build-module/components/post-format/index.js +2 -2
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-pending-status/index.js +1 -0
- package/build-module/components/post-pending-status/index.js.map +1 -1
- package/build-module/components/post-pingbacks/index.js +1 -0
- package/build-module/components/post-pingbacks/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +12 -3
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +1 -0
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-category-panel.js +1 -6
- package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js +2 -2
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js +1 -6
- package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +19 -5
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/index.js +12 -17
- package/build-module/components/post-schedule/index.js.map +1 -1
- package/build-module/components/post-sticky/index.js +1 -0
- package/build-module/components/post-sticky/index.js.map +1 -1
- package/build-module/components/post-taxonomies/check.js +1 -6
- package/build-module/components/post-taxonomies/check.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +3 -2
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +4 -3
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/index.js +2 -2
- package/build-module/components/post-taxonomies/index.js.map +1 -1
- package/build-module/components/post-title/index.js +3 -2
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-type-support-check/index.js +1 -6
- package/build-module/components/post-type-support-check/index.js.map +1 -1
- package/build-module/components/theme-support-check/index.js +3 -3
- package/build-module/components/theme-support-check/index.js.map +1 -1
- package/build-module/components/time-to-read/index.js +2 -6
- package/build-module/components/time-to-read/index.js.map +1 -1
- package/build-module/store/selectors.js +1 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils/notice-builder.js +3 -3
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/build-style/style-rtl.css +0 -4
- package/build-style/style.css +0 -4
- package/package.json +31 -28
- package/src/components/editor-help/test/index.native.js +2 -2
- package/src/components/entities-saved-states/entity-record-item.js +1 -0
- package/src/components/entities-saved-states/entity-type-list.js +1 -7
- package/src/components/entities-saved-states/index.js +2 -3
- package/src/components/index.js +2 -0
- package/src/components/post-comments/index.js +1 -0
- package/src/components/post-format/index.js +2 -2
- package/src/components/post-pending-status/index.js +1 -0
- package/src/components/post-pingbacks/index.js +1 -0
- package/src/components/post-publish-button/index.js +13 -4
- package/src/components/post-publish-panel/index.js +1 -0
- package/src/components/post-publish-panel/maybe-category-panel.js +1 -6
- package/src/components/post-publish-panel/maybe-post-format-panel.js +2 -2
- package/src/components/post-publish-panel/maybe-tags-panel.js +1 -6
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +11 -15
- package/src/components/post-saved-state/index.js +15 -3
- package/src/components/post-saved-state/style.scss +0 -4
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +1 -1
- package/src/components/post-schedule/index.js +16 -20
- package/src/components/post-sticky/index.js +1 -0
- package/src/components/post-taxonomies/check.js +2 -7
- package/src/components/post-taxonomies/flat-term-selector.js +3 -2
- package/src/components/post-taxonomies/hierarchical-term-selector.js +4 -3
- package/src/components/post-taxonomies/index.js +2 -2
- package/src/components/post-text-editor/test/index.js +7 -3
- package/src/components/post-title/index.js +6 -2
- package/src/components/post-type-support-check/index.js +3 -9
- package/src/components/theme-support-check/index.js +5 -3
- package/src/components/time-to-read/index.js +2 -2
- package/src/store/selectors.js +1 -10
- package/src/store/test/selectors.js +2 -56
- package/src/store/utils/notice-builder.js +3 -3
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { some } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -67,8 +62,7 @@ export default function EntityTypeList( {
|
|
|
67
62
|
key={ record.key || record.property }
|
|
68
63
|
record={ record }
|
|
69
64
|
checked={
|
|
70
|
-
! some(
|
|
71
|
-
unselectedEntities,
|
|
65
|
+
! unselectedEntities.some(
|
|
72
66
|
( elt ) =>
|
|
73
67
|
elt.kind === record.kind &&
|
|
74
68
|
elt.name === record.name &&
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { groupBy } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -127,8 +127,7 @@ export default function EntitiesSavedStates( { close } ) {
|
|
|
127
127
|
const saveCheckedEntities = () => {
|
|
128
128
|
const entitiesToSave = dirtyEntityRecords.filter(
|
|
129
129
|
( { kind, name, key, property } ) => {
|
|
130
|
-
return ! some(
|
|
131
|
-
unselectedEntities,
|
|
130
|
+
return ! unselectedEntities.some(
|
|
132
131
|
( elt ) =>
|
|
133
132
|
elt.kind === kind &&
|
|
134
133
|
elt.name === name &&
|
package/src/components/index.js
CHANGED
|
@@ -72,6 +72,8 @@ export { default as TableOfContents } from './table-of-contents';
|
|
|
72
72
|
export { default as ThemeSupportCheck } from './theme-support-check';
|
|
73
73
|
export { default as UnsavedChangesWarning } from './unsaved-changes-warning';
|
|
74
74
|
export { default as WordCount } from './word-count';
|
|
75
|
+
export { default as TimeToRead } from './time-to-read';
|
|
76
|
+
export { default as CharacterCount } from './character-count';
|
|
75
77
|
|
|
76
78
|
// State Related Components.
|
|
77
79
|
export { default as EditorProvider } from './provider';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { find
|
|
4
|
+
import { find } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -66,7 +66,7 @@ export default function PostFormat() {
|
|
|
66
66
|
// Ensure current format is always in the set.
|
|
67
67
|
// The current format may not be a format supported by the theme.
|
|
68
68
|
return (
|
|
69
|
-
includes(
|
|
69
|
+
supportedFormats?.includes( format.id ) || postFormat === format.id
|
|
70
70
|
);
|
|
71
71
|
} );
|
|
72
72
|
const suggestion = find(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { get
|
|
4
|
+
import { get } from 'lodash';
|
|
5
5
|
import classnames from 'classnames';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -34,12 +34,22 @@ export class PostPublishButton extends Component {
|
|
|
34
34
|
entitiesSavedStatesCallback: false,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
|
|
37
38
|
componentDidMount() {
|
|
38
39
|
if ( this.props.focusOnMount ) {
|
|
39
|
-
|
|
40
|
+
// This timeout is necessary to make sure the `useEffect` hook of
|
|
41
|
+
// `useFocusReturn` gets the correct element (the button that opens the
|
|
42
|
+
// PostPublishPanel) otherwise it will get this button.
|
|
43
|
+
this.timeoutID = setTimeout( () => {
|
|
44
|
+
this.buttonNode.current.focus();
|
|
45
|
+
}, 0 );
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
48
|
|
|
49
|
+
componentWillUnmount() {
|
|
50
|
+
clearTimeout( this.timeoutID );
|
|
51
|
+
}
|
|
52
|
+
|
|
43
53
|
createOnClick( callback ) {
|
|
44
54
|
return ( ...args ) => {
|
|
45
55
|
const { hasNonPostEntityChanges, setEntitiesSavedStatesCallback } =
|
|
@@ -77,8 +87,7 @@ export class PostPublishButton extends Component {
|
|
|
77
87
|
this.setState( { entitiesSavedStatesCallback: false }, () => {
|
|
78
88
|
if (
|
|
79
89
|
savedEntities &&
|
|
80
|
-
some(
|
|
81
|
-
savedEntities,
|
|
90
|
+
savedEntities.some(
|
|
82
91
|
( elt ) =>
|
|
83
92
|
elt.kind === 'postType' &&
|
|
84
93
|
elt.name === postType &&
|
|
@@ -125,6 +125,7 @@ export class PostPublishPanel extends Component {
|
|
|
125
125
|
</div>
|
|
126
126
|
<div className="editor-post-publish-panel__footer">
|
|
127
127
|
<CheckboxControl
|
|
128
|
+
__nextHasNoMarginBottom
|
|
128
129
|
label={ __( 'Always show pre-publish checks.' ) }
|
|
129
130
|
checked={ isPublishSidebarEnabled }
|
|
130
131
|
onChange={ onTogglePublishSidebar }
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { some } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -34,7 +29,7 @@ function MaybeCategoryPanel() {
|
|
|
34
29
|
);
|
|
35
30
|
const postTypeSupportsCategories =
|
|
36
31
|
categoriesTaxonomy &&
|
|
37
|
-
|
|
32
|
+
categoriesTaxonomy.types.some( ( type ) => type === postType );
|
|
38
33
|
const categories =
|
|
39
34
|
categoriesTaxonomy &&
|
|
40
35
|
select( editorStore ).getEditedPostAttribute(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { find, get
|
|
4
|
+
import { find, get } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -19,7 +19,7 @@ import { store as editorStore } from '../../store';
|
|
|
19
19
|
|
|
20
20
|
const getSuggestion = ( supportedFormats, suggestedPostFormat ) => {
|
|
21
21
|
const formats = POST_FORMATS.filter( ( format ) =>
|
|
22
|
-
includes(
|
|
22
|
+
supportedFormats?.includes( format.id )
|
|
23
23
|
);
|
|
24
24
|
return find( formats, ( format ) => format.id === suggestedPostFormat );
|
|
25
25
|
};
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { some } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -79,7 +74,7 @@ export default compose(
|
|
|
79
74
|
areTagsFetched: tagsTaxonomy !== undefined,
|
|
80
75
|
isPostTypeSupported:
|
|
81
76
|
tagsTaxonomy &&
|
|
82
|
-
|
|
77
|
+
tagsTaxonomy.types.some( ( type ) => type === postType ),
|
|
83
78
|
hasTags: tags && tags.length,
|
|
84
79
|
};
|
|
85
80
|
} ),
|
|
@@ -31,6 +31,10 @@ exports[`PostPublishPanel should render the post-publish panel if the post is pu
|
|
|
31
31
|
padding: 0;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
.components-panel__row .emotion-8 {
|
|
35
|
+
margin-bottom: inherit;
|
|
36
|
+
}
|
|
37
|
+
|
|
34
38
|
<div>
|
|
35
39
|
<div
|
|
36
40
|
class="editor-post-publish-panel"
|
|
@@ -141,7 +145,7 @@ exports[`PostPublishPanel should render the post-publish panel if the post is pu
|
|
|
141
145
|
class="components-base-control components-checkbox-control emotion-0 emotion-1"
|
|
142
146
|
>
|
|
143
147
|
<div
|
|
144
|
-
class="components-base-control__field emotion-
|
|
148
|
+
class="components-base-control__field emotion-8 emotion-3"
|
|
145
149
|
>
|
|
146
150
|
<span
|
|
147
151
|
class="components-checkbox-control__input-container"
|
|
@@ -197,6 +201,10 @@ exports[`PostPublishPanel should render the post-publish panel if the post is sc
|
|
|
197
201
|
padding: 0;
|
|
198
202
|
}
|
|
199
203
|
|
|
204
|
+
.components-panel__row .emotion-8 {
|
|
205
|
+
margin-bottom: inherit;
|
|
206
|
+
}
|
|
207
|
+
|
|
200
208
|
<div>
|
|
201
209
|
<div
|
|
202
210
|
class="editor-post-publish-panel"
|
|
@@ -307,7 +315,7 @@ exports[`PostPublishPanel should render the post-publish panel if the post is sc
|
|
|
307
315
|
class="components-base-control components-checkbox-control emotion-0 emotion-1"
|
|
308
316
|
>
|
|
309
317
|
<div
|
|
310
|
-
class="components-base-control__field emotion-
|
|
318
|
+
class="components-base-control__field emotion-8 emotion-3"
|
|
311
319
|
>
|
|
312
320
|
<span
|
|
313
321
|
class="components-checkbox-control__input-container"
|
|
@@ -345,10 +353,6 @@ exports[`PostPublishPanel should render the pre-publish panel if post status is
|
|
|
345
353
|
box-sizing: inherit;
|
|
346
354
|
}
|
|
347
355
|
|
|
348
|
-
.emotion-2 {
|
|
349
|
-
margin-bottom: calc(4px * 2);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
356
|
.components-panel__row .emotion-2 {
|
|
353
357
|
margin-bottom: inherit;
|
|
354
358
|
}
|
|
@@ -472,10 +476,6 @@ exports[`PostPublishPanel should render the pre-publish panel if the post is not
|
|
|
472
476
|
box-sizing: inherit;
|
|
473
477
|
}
|
|
474
478
|
|
|
475
|
-
.emotion-2 {
|
|
476
|
-
margin-bottom: calc(4px * 2);
|
|
477
|
-
}
|
|
478
|
-
|
|
479
479
|
.components-panel__row .emotion-2 {
|
|
480
480
|
margin-bottom: inherit;
|
|
481
481
|
}
|
|
@@ -609,7 +609,7 @@ exports[`PostPublishPanel should render the spinner if the post is being saved 1
|
|
|
609
609
|
display: inline-block;
|
|
610
610
|
margin: 5px 11px 0;
|
|
611
611
|
position: relative;
|
|
612
|
-
color: var( --wp-admin-theme-color );
|
|
612
|
+
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
613
613
|
overflow: visible;
|
|
614
614
|
}
|
|
615
615
|
|
|
@@ -641,10 +641,6 @@ exports[`PostPublishPanel should render the spinner if the post is being saved 1
|
|
|
641
641
|
box-sizing: inherit;
|
|
642
642
|
}
|
|
643
643
|
|
|
644
|
-
.emotion-8 {
|
|
645
|
-
margin-bottom: calc(4px * 2);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
644
|
.components-panel__row .emotion-8 {
|
|
649
645
|
margin-bottom: inherit;
|
|
650
646
|
}
|
|
@@ -151,10 +151,22 @@ export default function PostSavedState( {
|
|
|
151
151
|
: undefined
|
|
152
152
|
}
|
|
153
153
|
onClick={ isDisabled ? undefined : () => savePost() }
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
/*
|
|
155
|
+
* We want the tooltip to show the keyboard shortcut only when the
|
|
156
|
+
* button does something, i.e. when it's not disabled.
|
|
157
|
+
*/
|
|
158
|
+
shortcut={ isDisabled ? undefined : displayShortcut.primary( 's' ) }
|
|
159
|
+
/*
|
|
160
|
+
* Displaying the keyboard shortcut conditionally makes the tooltip
|
|
161
|
+
* itself show conditionally. This would trigger a full-rerendering
|
|
162
|
+
* of the button that we want to avoid. By setting `showTooltip`,
|
|
163
|
+
& the tooltip is always rendered even when there's no keyboard shortcut.
|
|
164
|
+
*/
|
|
165
|
+
showTooltip
|
|
166
|
+
variant="tertiary"
|
|
156
167
|
icon={ isLargeViewport ? undefined : cloudUpload }
|
|
157
|
-
label
|
|
168
|
+
// Make sure the aria-label has always a value, as the default `text` is undefined on small screens.
|
|
169
|
+
label={ text || label }
|
|
158
170
|
aria-disabled={ isDisabled }
|
|
159
171
|
>
|
|
160
172
|
{ isSavedState && <Icon icon={ isSaved ? check : cloud } /> }
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { parseISO, endOfMonth, startOfMonth } from 'date-fns';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -12,15 +17,6 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
12
17
|
*/
|
|
13
18
|
import { store as editorStore } from '../../store';
|
|
14
19
|
|
|
15
|
-
function getDayOfTheMonth( date = new Date(), firstDay = true ) {
|
|
16
|
-
const d = new Date( date );
|
|
17
|
-
return new Date(
|
|
18
|
-
d.getFullYear(),
|
|
19
|
-
d.getMonth() + ( firstDay ? 0 : 1 ),
|
|
20
|
-
firstDay ? 1 : 0
|
|
21
|
-
).toISOString();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
20
|
export default function PostSchedule( { onClose } ) {
|
|
25
21
|
const { postDate, postType } = useSelect(
|
|
26
22
|
( select ) => ( {
|
|
@@ -34,7 +30,7 @@ export default function PostSchedule( { onClose } ) {
|
|
|
34
30
|
const onUpdateDate = ( date ) => editPost( { date } );
|
|
35
31
|
|
|
36
32
|
const [ previewedMonth, setPreviewedMonth ] = useState(
|
|
37
|
-
|
|
33
|
+
startOfMonth( new Date( postDate ) )
|
|
38
34
|
);
|
|
39
35
|
|
|
40
36
|
// Pick up published and schduled site posts.
|
|
@@ -42,22 +38,20 @@ export default function PostSchedule( { onClose } ) {
|
|
|
42
38
|
( select ) =>
|
|
43
39
|
select( coreStore ).getEntityRecords( 'postType', postType, {
|
|
44
40
|
status: 'publish,future',
|
|
45
|
-
after:
|
|
46
|
-
before:
|
|
41
|
+
after: startOfMonth( previewedMonth ).toISOString(),
|
|
42
|
+
before: endOfMonth( previewedMonth ).toISOString(),
|
|
47
43
|
exclude: [ select( editorStore ).getCurrentPostId() ],
|
|
44
|
+
per_page: 100,
|
|
45
|
+
_fields: 'id,date',
|
|
48
46
|
} ),
|
|
49
47
|
[ previewedMonth, postType ]
|
|
50
48
|
);
|
|
51
49
|
|
|
52
50
|
const events = useMemo(
|
|
53
51
|
() =>
|
|
54
|
-
( eventsByPostType || [] ).map(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
type,
|
|
58
|
-
date: new Date( eventDate ),
|
|
59
|
-
} )
|
|
60
|
-
),
|
|
52
|
+
( eventsByPostType || [] ).map( ( { date: eventDate } ) => ( {
|
|
53
|
+
date: new Date( eventDate ),
|
|
54
|
+
} ) ),
|
|
61
55
|
[ eventsByPostType ]
|
|
62
56
|
);
|
|
63
57
|
|
|
@@ -80,7 +74,9 @@ export default function PostSchedule( { onClose } ) {
|
|
|
80
74
|
onChange={ onUpdateDate }
|
|
81
75
|
is12Hour={ is12HourTime }
|
|
82
76
|
events={ events }
|
|
83
|
-
onMonthPreviewed={
|
|
77
|
+
onMonthPreviewed={ ( date ) =>
|
|
78
|
+
setPreviewedMonth( parseISO( date ) )
|
|
79
|
+
}
|
|
84
80
|
onClose={ onClose }
|
|
85
81
|
/>
|
|
86
82
|
);
|
|
@@ -16,6 +16,7 @@ export function PostSticky( { onUpdateSticky, postSticky = false } ) {
|
|
|
16
16
|
return (
|
|
17
17
|
<PostStickyCheck>
|
|
18
18
|
<CheckboxControl
|
|
19
|
+
__nextHasNoMarginBottom
|
|
19
20
|
label={ __( 'Stick to the top of the blog' ) }
|
|
20
21
|
checked={ postSticky }
|
|
21
22
|
onChange={ () => onUpdateSticky( ! postSticky ) }
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { some, includes } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -16,8 +11,8 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
16
11
|
import { store as editorStore } from '../../store';
|
|
17
12
|
|
|
18
13
|
export function PostTaxonomiesCheck( { postType, taxonomies, children } ) {
|
|
19
|
-
const hasTaxonomies = some(
|
|
20
|
-
|
|
14
|
+
const hasTaxonomies = taxonomies?.some( ( taxonomy ) =>
|
|
15
|
+
taxonomy.types.includes( postType )
|
|
21
16
|
);
|
|
22
17
|
if ( ! hasTaxonomies ) {
|
|
23
18
|
return null;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { find, get } from 'lodash';
|
|
5
|
+
import escapeHtml from 'escape-html';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* WordPress dependencies
|
|
@@ -55,7 +56,7 @@ const termNamesToIds = ( names, terms ) => {
|
|
|
55
56
|
|
|
56
57
|
// Tries to create a term or fetch it if it already exists.
|
|
57
58
|
function findOrCreateTerm( termName, restBase, namespace ) {
|
|
58
|
-
const escapedTermName =
|
|
59
|
+
const escapedTermName = escapeHtml( termName );
|
|
59
60
|
|
|
60
61
|
return apiFetch( {
|
|
61
62
|
path: `/${ namespace }/${ restBase }`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { find, get,
|
|
4
|
+
import { find, get, unescape as unescapeString } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -258,7 +258,7 @@ export function HierarchicalTermSelector( { slug } ) {
|
|
|
258
258
|
const onChange = ( termId ) => {
|
|
259
259
|
const hasTerm = terms.includes( termId );
|
|
260
260
|
const newTerms = hasTerm
|
|
261
|
-
?
|
|
261
|
+
? terms.filter( ( id ) => id !== termId )
|
|
262
262
|
: [ ...terms, termId ];
|
|
263
263
|
onUpdateTerms( newTerms );
|
|
264
264
|
};
|
|
@@ -290,7 +290,7 @@ export function HierarchicalTermSelector( { slug } ) {
|
|
|
290
290
|
const existingTerm = findTerm( availableTerms, formParent, formName );
|
|
291
291
|
if ( existingTerm ) {
|
|
292
292
|
// If the term we are adding exists but is not selected select it.
|
|
293
|
-
if ( ! some(
|
|
293
|
+
if ( ! terms.some( ( term ) => term === existingTerm.id ) ) {
|
|
294
294
|
onUpdateTerms( [ ...terms, existingTerm.id ] );
|
|
295
295
|
}
|
|
296
296
|
|
|
@@ -358,6 +358,7 @@ export function HierarchicalTermSelector( { slug } ) {
|
|
|
358
358
|
className="editor-post-taxonomies__hierarchical-terms-choice"
|
|
359
359
|
>
|
|
360
360
|
<CheckboxControl
|
|
361
|
+
__nextHasNoMarginBottom
|
|
361
362
|
checked={ terms.indexOf( term.id ) !== -1 }
|
|
362
363
|
onChange={ () => {
|
|
363
364
|
const termId = parseInt( term.id, 10 );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { filter
|
|
4
|
+
import { filter } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -26,7 +26,7 @@ export function PostTaxonomies( {
|
|
|
26
26
|
taxonomyWrapper = identity,
|
|
27
27
|
} ) {
|
|
28
28
|
const availableTaxonomies = filter( taxonomies, ( taxonomy ) =>
|
|
29
|
-
|
|
29
|
+
taxonomy.types.includes( postType )
|
|
30
30
|
);
|
|
31
31
|
const visibleTaxonomies = filter(
|
|
32
32
|
availableTaxonomies,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { act, render, screen } from '@testing-library/react';
|
|
5
5
|
import userEvent from '@testing-library/user-event';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -117,7 +117,9 @@ describe( 'PostTextEditor', () => {
|
|
|
117
117
|
await user.clear( textarea );
|
|
118
118
|
|
|
119
119
|
// Stop editing.
|
|
120
|
-
|
|
120
|
+
act( () => {
|
|
121
|
+
textarea.blur();
|
|
122
|
+
} );
|
|
121
123
|
|
|
122
124
|
expect( mockResetEditorBlocks ).toHaveBeenCalledWith( [] );
|
|
123
125
|
} );
|
|
@@ -147,7 +149,9 @@ describe( 'PostTextEditor', () => {
|
|
|
147
149
|
|
|
148
150
|
rerender( <PostTextEditor /> );
|
|
149
151
|
|
|
150
|
-
|
|
152
|
+
act( () => {
|
|
153
|
+
textarea.blur();
|
|
154
|
+
} );
|
|
151
155
|
|
|
152
156
|
expect( textarea ).toHaveValue( 'Goodbye World' );
|
|
153
157
|
} );
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
insert,
|
|
27
27
|
} from '@wordpress/rich-text';
|
|
28
28
|
import { useMergeRefs } from '@wordpress/compose';
|
|
29
|
+
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Internal dependencies
|
|
@@ -166,7 +167,7 @@ function PostTitle( _, forwardedRef ) {
|
|
|
166
167
|
( firstBlock.name === 'core/heading' ||
|
|
167
168
|
firstBlock.name === 'core/paragraph' )
|
|
168
169
|
) {
|
|
169
|
-
onUpdate( firstBlock.attributes.content );
|
|
170
|
+
onUpdate( stripHTML( firstBlock.attributes.content ) );
|
|
170
171
|
onInsertBlockAfter( content.slice( 1 ) );
|
|
171
172
|
} else {
|
|
172
173
|
onInsertBlockAfter( content );
|
|
@@ -176,7 +177,10 @@ function PostTitle( _, forwardedRef ) {
|
|
|
176
177
|
...create( { html: title } ),
|
|
177
178
|
...selection,
|
|
178
179
|
};
|
|
179
|
-
const newValue = insert(
|
|
180
|
+
const newValue = insert(
|
|
181
|
+
value,
|
|
182
|
+
create( { html: stripHTML( content ) } )
|
|
183
|
+
);
|
|
180
184
|
onUpdate( toHTMLString( { value: newValue } ) );
|
|
181
185
|
setSelection( {
|
|
182
186
|
start: newValue.start,
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { some, castArray } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -30,10 +25,9 @@ import { store as editorStore } from '../../store';
|
|
|
30
25
|
export function PostTypeSupportCheck( { postType, children, supportKeys } ) {
|
|
31
26
|
let isSupported = true;
|
|
32
27
|
if ( postType ) {
|
|
33
|
-
isSupported =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
28
|
+
isSupported = (
|
|
29
|
+
Array.isArray( supportKeys ) ? supportKeys : [ supportKeys ]
|
|
30
|
+
).some( ( key ) => !! postType.supports[ key ] );
|
|
37
31
|
}
|
|
38
32
|
|
|
39
33
|
if ( ! isSupported ) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { get } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -20,14 +20,16 @@ export function ThemeSupportCheck( {
|
|
|
20
20
|
postType,
|
|
21
21
|
supportKeys,
|
|
22
22
|
} ) {
|
|
23
|
-
const isSupported =
|
|
23
|
+
const isSupported = (
|
|
24
|
+
Array.isArray( supportKeys ) ? supportKeys : [ supportKeys ]
|
|
25
|
+
).some( ( key ) => {
|
|
24
26
|
const supported = get( themeSupports, [ key ], false );
|
|
25
27
|
// 'post-thumbnails' can be boolean or an array of post types.
|
|
26
28
|
// In the latter case, we need to verify `postType` exists
|
|
27
29
|
// within `supported`. If `postType` isn't passed, then the check
|
|
28
30
|
// should fail.
|
|
29
31
|
if ( 'post-thumbnails' === key && Array.isArray( supported ) ) {
|
|
30
|
-
return includes(
|
|
32
|
+
return supported.includes( postType );
|
|
31
33
|
}
|
|
32
34
|
return supported;
|
|
33
35
|
} );
|
|
@@ -38,7 +38,7 @@ export default function TimeToRead() {
|
|
|
38
38
|
const minutesToReadString =
|
|
39
39
|
minutesToRead === 0
|
|
40
40
|
? createInterpolateElement( __( '<span>< 1</span> minute' ), {
|
|
41
|
-
span: <span
|
|
41
|
+
span: <span />,
|
|
42
42
|
} )
|
|
43
43
|
: createInterpolateElement(
|
|
44
44
|
sprintf(
|
|
@@ -51,7 +51,7 @@ export default function TimeToRead() {
|
|
|
51
51
|
minutesToRead
|
|
52
52
|
),
|
|
53
53
|
{
|
|
54
|
-
span: <span
|
|
54
|
+
span: <span />,
|
|
55
55
|
}
|
|
56
56
|
);
|
|
57
57
|
|
package/src/store/selectors.js
CHANGED
|
@@ -95,16 +95,7 @@ export function isEditedPostNew( state ) {
|
|
|
95
95
|
*/
|
|
96
96
|
export function hasChangedContent( state ) {
|
|
97
97
|
const edits = getPostEdits( state );
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
'blocks' in edits ||
|
|
101
|
-
// `edits` is intended to contain only values which are different from
|
|
102
|
-
// the saved post, so the mere presence of a property is an indicator
|
|
103
|
-
// that the value is different than what is known to be saved. While
|
|
104
|
-
// content in Visual mode is represented by the blocks state, in Text
|
|
105
|
-
// mode it is tracked by `edits.content`.
|
|
106
|
-
'content' in edits
|
|
107
|
-
);
|
|
98
|
+
return 'content' in edits;
|
|
108
99
|
}
|
|
109
100
|
|
|
110
101
|
/**
|