@wordpress/editor 12.1.0 → 12.2.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 +14 -0
- package/README.md +7 -1
- package/build/components/deprecated.js +1 -3
- package/build/components/deprecated.js.map +1 -1
- package/build/components/editor-help/index.native.js +3 -3
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/index.js +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/post-format/index.js +6 -4
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-taxonomies/most-used-terms.js +3 -3
- package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build/components/post-title/index.native.js +1 -0
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-visibility/index.js +30 -14
- package/build/components/post-visibility/index.js.map +1 -1
- package/build/store/actions.js +19 -14
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +2 -32
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/deprecated.js +1 -2
- package/build-module/components/deprecated.js.map +1 -1
- package/build-module/components/editor-help/index.native.js +4 -4
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/index.js +2 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/post-format/index.js +7 -5
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-taxonomies/most-used-terms.js +3 -3
- package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build-module/components/post-title/index.native.js +1 -0
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-visibility/index.js +31 -15
- package/build-module/components/post-visibility/index.js.map +1 -1
- package/build-module/store/actions.js +19 -14
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +0 -28
- package/build-module/store/selectors.js.map +1 -1
- package/package.json +27 -30
- package/src/components/deprecated.js +0 -5
- package/src/components/editor-help/index.native.js +6 -6
- package/src/components/index.js +2 -0
- package/src/components/post-format/index.js +9 -10
- package/src/components/post-taxonomies/README.md +25 -1
- package/src/components/post-taxonomies/most-used-terms.js +3 -3
- package/src/components/post-title/index.native.js +1 -0
- package/src/components/post-visibility/index.js +25 -11
- package/src/store/actions.js +17 -23
- package/src/store/selectors.js +0 -35
- package/src/store/test/actions.js +0 -40
|
@@ -15,9 +15,9 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
15
15
|
*/
|
|
16
16
|
import { unescapeTerms } from '../../utils/terms';
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const MIN_MOST_USED_TERMS = 3;
|
|
19
19
|
const DEFAULT_QUERY = {
|
|
20
|
-
per_page:
|
|
20
|
+
per_page: 10,
|
|
21
21
|
orderby: 'count',
|
|
22
22
|
order: 'desc',
|
|
23
23
|
hide_empty: true,
|
|
@@ -34,7 +34,7 @@ export default function MostUsedTerms( { onSelect, taxonomy } ) {
|
|
|
34
34
|
);
|
|
35
35
|
return {
|
|
36
36
|
_terms: mostUsedTerms,
|
|
37
|
-
showTerms: mostUsedTerms?.length
|
|
37
|
+
showTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS,
|
|
38
38
|
};
|
|
39
39
|
}, [] );
|
|
40
40
|
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { Component } from '@wordpress/element';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
VisuallyHidden,
|
|
8
|
+
__experimentalConfirmDialog as ConfirmDialog,
|
|
9
|
+
} from '@wordpress/components';
|
|
7
10
|
import { withInstanceId, compose } from '@wordpress/compose';
|
|
8
11
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
9
12
|
|
|
@@ -24,6 +27,7 @@ export class PostVisibility extends Component {
|
|
|
24
27
|
|
|
25
28
|
this.state = {
|
|
26
29
|
hasPassword: !! props.password,
|
|
30
|
+
showPrivateConfirmDialog: false,
|
|
27
31
|
};
|
|
28
32
|
}
|
|
29
33
|
|
|
@@ -35,21 +39,23 @@ export class PostVisibility extends Component {
|
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
setPrivate() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
! window.confirm(
|
|
41
|
-
__( 'Would you like to privately publish this post now?' )
|
|
42
|
-
)
|
|
43
|
-
) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
42
|
+
this.setState( { showPrivateConfirmDialog: true } );
|
|
43
|
+
}
|
|
46
44
|
|
|
45
|
+
confirmPrivate = () => {
|
|
47
46
|
const { onUpdateVisibility, onSave } = this.props;
|
|
48
47
|
|
|
49
48
|
onUpdateVisibility( 'private' );
|
|
50
|
-
this.setState( {
|
|
49
|
+
this.setState( {
|
|
50
|
+
hasPassword: false,
|
|
51
|
+
showPrivateConfirmDialog: false,
|
|
52
|
+
} );
|
|
51
53
|
onSave();
|
|
52
|
-
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
handleDialogCancel = () => {
|
|
57
|
+
this.setState( { showPrivateConfirmDialog: false } );
|
|
58
|
+
};
|
|
53
59
|
|
|
54
60
|
setPasswordProtected() {
|
|
55
61
|
const { visibility, onUpdateVisibility, status, password } = this.props;
|
|
@@ -145,6 +151,14 @@ export class PostVisibility extends Component {
|
|
|
145
151
|
/>
|
|
146
152
|
</div>
|
|
147
153
|
),
|
|
154
|
+
<ConfirmDialog
|
|
155
|
+
key="private-publish-confirmation"
|
|
156
|
+
isOpen={ this.state.showPrivateConfirmDialog }
|
|
157
|
+
onConfirm={ this.confirmPrivate }
|
|
158
|
+
onCancel={ this.handleDialogCancel }
|
|
159
|
+
>
|
|
160
|
+
{ __( 'Would you like to privately publish this post now?' ) }
|
|
161
|
+
</ConfirmDialog>,
|
|
148
162
|
];
|
|
149
163
|
}
|
|
150
164
|
}
|
package/src/store/actions.js
CHANGED
|
@@ -280,27 +280,17 @@ export function* savePost( options = {} ) {
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
/**
|
|
283
|
-
* Action
|
|
283
|
+
* Action for refreshing the current post.
|
|
284
|
+
*
|
|
285
|
+
* @deprecated Since WordPress 6.0.
|
|
284
286
|
*/
|
|
285
|
-
export function
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
'
|
|
290
|
-
);
|
|
291
|
-
const postType = yield controls.resolveSelect(
|
|
292
|
-
coreStore,
|
|
293
|
-
'getPostType',
|
|
294
|
-
postTypeSlug
|
|
295
|
-
);
|
|
296
|
-
const newPost = yield apiFetch( {
|
|
297
|
-
// Timestamp arg allows caller to bypass browser caching, which is
|
|
298
|
-
// expected for this specific function.
|
|
299
|
-
path:
|
|
300
|
-
`/wp/v2/${ postType.rest_base }/${ post.id }` +
|
|
301
|
-
`?context=edit&_timestamp=${ Date.now() }`,
|
|
287
|
+
export function refreshPost() {
|
|
288
|
+
deprecated( "wp.data.dispatch( 'core/editor' ).refreshPost", {
|
|
289
|
+
since: '6.0',
|
|
290
|
+
version: '6.3',
|
|
291
|
+
alternative: 'Use the core entities store instead',
|
|
302
292
|
} );
|
|
303
|
-
|
|
293
|
+
return { type: 'DO_NOTHING' };
|
|
304
294
|
}
|
|
305
295
|
|
|
306
296
|
/**
|
|
@@ -404,13 +394,17 @@ export function* undo() {
|
|
|
404
394
|
}
|
|
405
395
|
|
|
406
396
|
/**
|
|
407
|
-
*
|
|
408
|
-
* be created.
|
|
397
|
+
* Action that creates an undo history record.
|
|
409
398
|
*
|
|
410
|
-
* @
|
|
399
|
+
* @deprecated Since WordPress 6.0
|
|
411
400
|
*/
|
|
412
401
|
export function createUndoLevel() {
|
|
413
|
-
|
|
402
|
+
deprecated( "wp.data.dispatch( 'core/editor' ).createUndoLevel", {
|
|
403
|
+
since: '6.0',
|
|
404
|
+
version: '6.3',
|
|
405
|
+
alternative: 'Use the core entities store instead',
|
|
406
|
+
} );
|
|
407
|
+
return { type: 'DO_NOTHING' };
|
|
414
408
|
}
|
|
415
409
|
|
|
416
410
|
/**
|
package/src/store/selectors.js
CHANGED
|
@@ -277,41 +277,6 @@ export const getPostEdits = createRegistrySelector( ( select ) => ( state ) => {
|
|
|
277
277
|
);
|
|
278
278
|
} );
|
|
279
279
|
|
|
280
|
-
/**
|
|
281
|
-
* Returns a new reference when edited values have changed. This is useful in
|
|
282
|
-
* inferring where an edit has been made between states by comparison of the
|
|
283
|
-
* return values using strict equality.
|
|
284
|
-
*
|
|
285
|
-
* @deprecated since Gutenberg 6.5.0.
|
|
286
|
-
*
|
|
287
|
-
* @example
|
|
288
|
-
*
|
|
289
|
-
* ```
|
|
290
|
-
* const hasEditOccurred = (
|
|
291
|
-
* getReferenceByDistinctEdits( beforeState ) !==
|
|
292
|
-
* getReferenceByDistinctEdits( afterState )
|
|
293
|
-
* );
|
|
294
|
-
* ```
|
|
295
|
-
*
|
|
296
|
-
* @param {Object} state Editor state.
|
|
297
|
-
*
|
|
298
|
-
* @return {*} A value whose reference will change only when an edit occurs.
|
|
299
|
-
*/
|
|
300
|
-
export const getReferenceByDistinctEdits = createRegistrySelector(
|
|
301
|
-
( select ) => (/* state */) => {
|
|
302
|
-
deprecated(
|
|
303
|
-
"`wp.data.select( 'core/editor' ).getReferenceByDistinctEdits`",
|
|
304
|
-
{
|
|
305
|
-
since: '5.4',
|
|
306
|
-
alternative:
|
|
307
|
-
"`wp.data.select( 'core' ).getReferenceByDistinctEdits`",
|
|
308
|
-
}
|
|
309
|
-
);
|
|
310
|
-
|
|
311
|
-
return select( coreStore ).getReferenceByDistinctEdits();
|
|
312
|
-
}
|
|
313
|
-
);
|
|
314
|
-
|
|
315
280
|
/**
|
|
316
281
|
* Returns an attribute value of the saved post.
|
|
317
282
|
*
|
|
@@ -358,46 +358,6 @@ describe( 'Post generator actions', () => {
|
|
|
358
358
|
} );
|
|
359
359
|
} );
|
|
360
360
|
} );
|
|
361
|
-
describe( 'refreshPost()', () => {
|
|
362
|
-
let fulfillment;
|
|
363
|
-
const currentPost = { id: 10, content: 'foo' };
|
|
364
|
-
const reset = () => ( fulfillment = actions.refreshPost() );
|
|
365
|
-
it( 'yields expected action for selecting the currentPost', () => {
|
|
366
|
-
reset();
|
|
367
|
-
const { value } = fulfillment.next();
|
|
368
|
-
expect( value ).toEqual(
|
|
369
|
-
controls.select( STORE_NAME, 'getCurrentPost' )
|
|
370
|
-
);
|
|
371
|
-
} );
|
|
372
|
-
it( 'yields expected action for selecting the current post type', () => {
|
|
373
|
-
const { value } = fulfillment.next( currentPost );
|
|
374
|
-
expect( value ).toEqual(
|
|
375
|
-
controls.select( STORE_NAME, 'getCurrentPostType' )
|
|
376
|
-
);
|
|
377
|
-
} );
|
|
378
|
-
it( 'yields expected action for selecting the post type object', () => {
|
|
379
|
-
const { value } = fulfillment.next( postTypeSlug );
|
|
380
|
-
expect( value ).toEqual(
|
|
381
|
-
controls.resolveSelect( 'core', 'getPostType', postTypeSlug )
|
|
382
|
-
);
|
|
383
|
-
} );
|
|
384
|
-
it( 'yields expected action for the api fetch call', () => {
|
|
385
|
-
const { value } = fulfillment.next( postType );
|
|
386
|
-
// since the timestamp is a computed value we can't do a direct comparison.
|
|
387
|
-
// so we'll just see if the path has most of the value.
|
|
388
|
-
expect( value.request.path ).toEqual(
|
|
389
|
-
expect.stringContaining(
|
|
390
|
-
`/wp/v2/${ postType.rest_base }/${ currentPost.id }?context=edit&_timestamp=`
|
|
391
|
-
)
|
|
392
|
-
);
|
|
393
|
-
} );
|
|
394
|
-
it( 'yields expected action for dispatching the reset of the post', () => {
|
|
395
|
-
const { value } = fulfillment.next( currentPost );
|
|
396
|
-
expect( value ).toEqual(
|
|
397
|
-
controls.dispatch( STORE_NAME, 'resetPost', currentPost )
|
|
398
|
-
);
|
|
399
|
-
} );
|
|
400
|
-
} );
|
|
401
361
|
} );
|
|
402
362
|
|
|
403
363
|
describe( 'Editor actions', () => {
|