@wordpress/editor 12.1.0 → 12.2.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +7 -1
  3. package/build/components/deprecated.js +1 -3
  4. package/build/components/deprecated.js.map +1 -1
  5. package/build/components/index.js +18 -0
  6. package/build/components/index.js.map +1 -1
  7. package/build/components/post-format/index.js +6 -4
  8. package/build/components/post-format/index.js.map +1 -1
  9. package/build/components/post-taxonomies/most-used-terms.js +3 -3
  10. package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
  11. package/build/components/post-title/index.native.js +1 -0
  12. package/build/components/post-title/index.native.js.map +1 -1
  13. package/build/components/post-visibility/index.js +30 -14
  14. package/build/components/post-visibility/index.js.map +1 -1
  15. package/build/store/actions.js +19 -14
  16. package/build/store/actions.js.map +1 -1
  17. package/build/store/selectors.js +2 -32
  18. package/build/store/selectors.js.map +1 -1
  19. package/build-module/components/deprecated.js +1 -2
  20. package/build-module/components/deprecated.js.map +1 -1
  21. package/build-module/components/index.js +2 -0
  22. package/build-module/components/index.js.map +1 -1
  23. package/build-module/components/post-format/index.js +7 -5
  24. package/build-module/components/post-format/index.js.map +1 -1
  25. package/build-module/components/post-taxonomies/most-used-terms.js +3 -3
  26. package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
  27. package/build-module/components/post-title/index.native.js +1 -0
  28. package/build-module/components/post-title/index.native.js.map +1 -1
  29. package/build-module/components/post-visibility/index.js +31 -15
  30. package/build-module/components/post-visibility/index.js.map +1 -1
  31. package/build-module/store/actions.js +19 -14
  32. package/build-module/store/actions.js.map +1 -1
  33. package/build-module/store/selectors.js +0 -28
  34. package/build-module/store/selectors.js.map +1 -1
  35. package/package.json +27 -30
  36. package/src/components/deprecated.js +0 -5
  37. package/src/components/index.js +2 -0
  38. package/src/components/post-format/index.js +9 -10
  39. package/src/components/post-taxonomies/README.md +25 -1
  40. package/src/components/post-taxonomies/most-used-terms.js +3 -3
  41. package/src/components/post-title/index.native.js +1 -0
  42. package/src/components/post-visibility/index.js +25 -11
  43. package/src/store/actions.js +17 -23
  44. package/src/store/selectors.js +0 -35
  45. package/src/store/test/actions.js +0 -40
@@ -3,7 +3,10 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { Component } from '@wordpress/element';
6
- import { VisuallyHidden } from '@wordpress/components';
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
- if (
39
- // eslint-disable-next-line no-alert
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( { hasPassword: false } );
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
  }
@@ -280,27 +280,17 @@ export function* savePost( options = {} ) {
280
280
  }
281
281
 
282
282
  /**
283
- * Action generator for handling refreshing the current post.
283
+ * Action for refreshing the current post.
284
+ *
285
+ * @deprecated Since WordPress 6.0.
284
286
  */
285
- export function* refreshPost() {
286
- const post = yield controls.select( STORE_NAME, 'getCurrentPost' );
287
- const postTypeSlug = yield controls.select(
288
- STORE_NAME,
289
- 'getCurrentPostType'
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
- yield controls.dispatch( STORE_NAME, 'resetPost', newPost );
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
- * Returns an action object used in signalling that undo history record should
408
- * be created.
397
+ * Action that creates an undo history record.
409
398
  *
410
- * @return {Object} Action object.
399
+ * @deprecated Since WordPress 6.0
411
400
  */
412
401
  export function createUndoLevel() {
413
- return { type: 'CREATE_UNDO_LEVEL' };
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
  /**
@@ -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', () => {