@wordpress/editor 12.2.1 → 12.4.0-next.e230fbab09.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 (152) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/deprecated.js +1 -1
  3. package/build/components/deprecated.js.map +1 -1
  4. package/build/components/deprecated.native.js.map +1 -1
  5. package/build/components/editor-help/index.native.js.map +1 -1
  6. package/build/components/entities-saved-states/entity-record-item.js +1 -1
  7. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  8. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
  9. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  10. package/build/components/index.js.map +1 -1
  11. package/build/components/index.native.js.map +1 -1
  12. package/build/components/local-autosave-monitor/index.js +5 -5
  13. package/build/components/local-autosave-monitor/index.js.map +1 -1
  14. package/build/components/post-featured-image/index.js +4 -4
  15. package/build/components/post-featured-image/index.js.map +1 -1
  16. package/build/components/post-last-revision/index.js +3 -3
  17. package/build/components/post-last-revision/index.js.map +1 -1
  18. package/build/components/post-locked-modal/index.js +1 -3
  19. package/build/components/post-locked-modal/index.js.map +1 -1
  20. package/build/components/post-saved-state/index.js +1 -1
  21. package/build/components/post-saved-state/index.js.map +1 -1
  22. package/build/components/post-schedule/index.js +3 -3
  23. package/build/components/post-schedule/index.js.map +1 -1
  24. package/build/components/post-slug/index.js +2 -4
  25. package/build/components/post-slug/index.js.map +1 -1
  26. package/build/components/post-switch-to-draft-button/index.js +19 -14
  27. package/build/components/post-switch-to-draft-button/index.js.map +1 -1
  28. package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  29. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  30. package/build/components/post-title/index.native.js +2 -2
  31. package/build/components/post-title/index.native.js.map +1 -1
  32. package/build/components/post-trash/index.js +15 -29
  33. package/build/components/post-trash/index.js.map +1 -1
  34. package/build/components/provider/index.js +1 -1
  35. package/build/components/provider/index.js.map +1 -1
  36. package/build/components/provider/index.native.js +24 -15
  37. package/build/components/provider/index.native.js.map +1 -1
  38. package/build/components/provider/use-block-editor-settings.js +3 -8
  39. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  40. package/build/store/actions.js +231 -225
  41. package/build/store/actions.js.map +1 -1
  42. package/build/store/actions.native.js +6 -4
  43. package/build/store/actions.native.js.map +1 -1
  44. package/build/store/index.js +1 -8
  45. package/build/store/index.js.map +1 -1
  46. package/build/store/{controls.js → local-autosave.js} +1 -18
  47. package/build/store/local-autosave.js.map +1 -0
  48. package/build/store/reducer.js +0 -2
  49. package/build/store/reducer.js.map +1 -1
  50. package/build/store/selectors.js +8 -10
  51. package/build/store/selectors.js.map +1 -1
  52. package/build/store/utils/notice-builder.js +9 -4
  53. package/build/store/utils/notice-builder.js.map +1 -1
  54. package/build/utils/url.js +9 -26
  55. package/build/utils/url.js.map +1 -1
  56. package/build-module/components/deprecated.js +1 -1
  57. package/build-module/components/deprecated.js.map +1 -1
  58. package/build-module/components/deprecated.native.js +1 -1
  59. package/build-module/components/deprecated.native.js.map +1 -1
  60. package/build-module/components/editor-help/index.native.js.map +1 -1
  61. package/build-module/components/entities-saved-states/entity-record-item.js +1 -1
  62. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  63. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
  64. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  65. package/build-module/components/index.js +3 -3
  66. package/build-module/components/index.js.map +1 -1
  67. package/build-module/components/index.native.js +3 -3
  68. package/build-module/components/index.native.js.map +1 -1
  69. package/build-module/components/local-autosave-monitor/index.js +1 -1
  70. package/build-module/components/local-autosave-monitor/index.js.map +1 -1
  71. package/build-module/components/post-featured-image/index.js +4 -4
  72. package/build-module/components/post-featured-image/index.js.map +1 -1
  73. package/build-module/components/post-last-revision/index.js +2 -2
  74. package/build-module/components/post-last-revision/index.js.map +1 -1
  75. package/build-module/components/post-locked-modal/index.js +1 -2
  76. package/build-module/components/post-locked-modal/index.js.map +1 -1
  77. package/build-module/components/post-saved-state/index.js +1 -1
  78. package/build-module/components/post-saved-state/index.js.map +1 -1
  79. package/build-module/components/post-schedule/index.js +3 -3
  80. package/build-module/components/post-schedule/index.js.map +1 -1
  81. package/build-module/components/post-slug/index.js +1 -2
  82. package/build-module/components/post-slug/index.js.map +1 -1
  83. package/build-module/components/post-switch-to-draft-button/index.js +22 -16
  84. package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
  85. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  86. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  87. package/build-module/components/post-title/index.native.js +2 -2
  88. package/build-module/components/post-title/index.native.js.map +1 -1
  89. package/build-module/components/post-trash/index.js +15 -27
  90. package/build-module/components/post-trash/index.js.map +1 -1
  91. package/build-module/components/provider/index.js +1 -1
  92. package/build-module/components/provider/index.js.map +1 -1
  93. package/build-module/components/provider/index.native.js +26 -17
  94. package/build-module/components/provider/index.native.js.map +1 -1
  95. package/build-module/components/provider/use-block-editor-settings.js +3 -8
  96. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  97. package/build-module/store/actions.js +208 -207
  98. package/build-module/store/actions.js.map +1 -1
  99. package/build-module/store/actions.native.js +3 -3
  100. package/build-module/store/actions.native.js.map +1 -1
  101. package/build-module/store/index.js +1 -6
  102. package/build-module/store/index.js.map +1 -1
  103. package/build-module/store/{controls.js → local-autosave.js} +1 -15
  104. package/build-module/store/local-autosave.js.map +1 -0
  105. package/build-module/store/reducer.js +0 -2
  106. package/build-module/store/reducer.js.map +1 -1
  107. package/build-module/store/selectors.js +8 -9
  108. package/build-module/store/selectors.js.map +1 -1
  109. package/build-module/store/utils/notice-builder.js +9 -4
  110. package/build-module/store/utils/notice-builder.js.map +1 -1
  111. package/build-module/utils/url.js +8 -25
  112. package/build-module/utils/url.js.map +1 -1
  113. package/package.json +26 -27
  114. package/src/components/deprecated.js +1 -1
  115. package/src/components/deprecated.native.js +1 -1
  116. package/src/components/document-outline/test/index.js +1 -1
  117. package/src/components/editor-help/index.native.js +2 -2
  118. package/src/components/entities-saved-states/entity-record-item.js +1 -1
  119. package/src/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
  120. package/src/components/index.js +3 -3
  121. package/src/components/index.native.js +3 -3
  122. package/src/components/local-autosave-monitor/index.js +4 -1
  123. package/src/components/post-author/test/check.js +1 -1
  124. package/src/components/post-featured-image/index.js +4 -4
  125. package/src/components/post-last-revision/index.js +2 -2
  126. package/src/components/post-locked-modal/index.js +1 -2
  127. package/src/components/post-saved-state/index.js +1 -1
  128. package/src/components/post-saved-state/test/index.js +2 -2
  129. package/src/components/post-schedule/index.js +3 -3
  130. package/src/components/post-slug/index.js +1 -2
  131. package/src/components/post-switch-to-draft-button/index.js +35 -24
  132. package/src/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  133. package/src/components/post-text-editor/test/index.js +1 -1
  134. package/src/components/post-title/index.native.js +2 -2
  135. package/src/components/post-trash/index.js +12 -24
  136. package/src/components/provider/index.js +1 -1
  137. package/src/components/provider/index.native.js +27 -23
  138. package/src/components/provider/use-block-editor-settings.js +3 -14
  139. package/src/store/actions.js +137 -249
  140. package/src/store/actions.native.js +3 -3
  141. package/src/store/index.js +0 -6
  142. package/src/store/{controls.js → local-autosave.js} +0 -8
  143. package/src/store/reducer.js +0 -2
  144. package/src/store/selectors.js +8 -9
  145. package/src/store/test/actions.js +244 -416
  146. package/src/store/test/selectors.js +1 -1
  147. package/src/store/utils/notice-builder.js +9 -4
  148. package/src/store/utils/test/notice-builder.js +1 -0
  149. package/src/utils/url.js +8 -30
  150. package/build/store/controls.js.map +0 -1
  151. package/build-module/store/controls.js.map +0 -1
  152. package/src/utils/test/url.js +0 -22
@@ -1913,7 +1913,7 @@ describe( 'selectors', () => {
1913
1913
 
1914
1914
  describe( 'isEditedPostBeingScheduled', () => {
1915
1915
  it( 'should return true for posts with a future date', () => {
1916
- const time = Date.now() + 1000 * 3600 * 24 * 7; // 7 days in the future
1916
+ const time = Date.now() + 1000 * 3600 * 24 * 7; // 7 days in the future.
1917
1917
  const date = new Date( time );
1918
1918
  const state = {
1919
1919
  editor: {
@@ -28,6 +28,11 @@ export function getNotificationArgumentsForSaveSuccess( data ) {
28
28
  return [];
29
29
  }
30
30
 
31
+ // No notice is shown after trashing a post
32
+ if ( post.status === 'trash' && previousPost.status !== 'trash' ) {
33
+ return [];
34
+ }
35
+
31
36
  const publishStatus = [ 'publish', 'private', 'future' ];
32
37
  const isPublished = includes( publishStatus, previousPost.status );
33
38
  const willPublish = includes( publishStatus, post.status );
@@ -41,19 +46,19 @@ export function getNotificationArgumentsForSaveSuccess( data ) {
41
46
  noticeMessage = __( 'Draft saved' );
42
47
  shouldShowLink = false;
43
48
  } else if ( isPublished && ! willPublish ) {
44
- // If undoing publish status, show specific notice
49
+ // If undoing publish status, show specific notice.
45
50
  noticeMessage = postType.labels.item_reverted_to_draft;
46
51
  shouldShowLink = false;
47
52
  } else if ( ! isPublished && willPublish ) {
48
53
  // If publishing or scheduling a post, show the corresponding
49
- // publish message
54
+ // publish message.
50
55
  noticeMessage = {
51
56
  publish: postType.labels.item_published,
52
57
  private: postType.labels.item_published_privately,
53
58
  future: postType.labels.item_scheduled,
54
59
  }[ post.status ];
55
60
  } else {
56
- // Generic fallback notice
61
+ // Generic fallback notice.
57
62
  noticeMessage = postType.labels.item_updated;
58
63
  }
59
64
 
@@ -93,7 +98,7 @@ export function getNotificationArgumentsForSaveFail( data ) {
93
98
  const publishStatus = [ 'publish', 'private', 'future' ];
94
99
  const isPublished = publishStatus.indexOf( post.status ) !== -1;
95
100
  // If the post was being published, we show the corresponding publish error message
96
- // Unless we publish an "updating failed" message
101
+ // Unless we publish an "updating failed" message.
97
102
  const messages = {
98
103
  publish: __( 'Publishing failed.' ),
99
104
  private: __( 'Publishing failed.' ),
@@ -74,6 +74,7 @@ describe( 'getNotificationArgumentsForSaveSuccess()', () => {
74
74
  },
75
75
  ],
76
76
  ],
77
+ [ 'when post will be trashed', [ 'publish', 'trash', true ], [] ],
77
78
  ].forEach(
78
79
  ( [
79
80
  description,
package/src/utils/url.js CHANGED
@@ -1,26 +1,8 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { deburr, trim } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
9
- import { addQueryArgs } from '@wordpress/url';
10
-
11
- /**
12
- * Returns the URL of a WPAdmin Page.
13
- *
14
- * TODO: This should be moved to a module less specific to the editor.
15
- *
16
- * @param {string} page Page to navigate to.
17
- * @param {Object} query Query Args.
18
- *
19
- * @return {string} WPAdmin URL.
20
- */
21
- export function getWPAdminURL( page, query ) {
22
- return addQueryArgs( page, query );
23
- }
4
+ import { cleanForSlug as urlCleanForSlug } from '@wordpress/url';
5
+ import deprecated from '@wordpress/deprecated';
24
6
 
25
7
  /**
26
8
  * Performs some basic cleanup of a string for use as a post slug
@@ -39,14 +21,10 @@ export function getWPAdminURL( page, query ) {
39
21
  * @return {string} Processed string
40
22
  */
41
23
  export function cleanForSlug( string ) {
42
- if ( ! string ) {
43
- return '';
44
- }
45
- return trim(
46
- deburr( string )
47
- .replace( /[\s\./]+/g, '-' )
48
- .replace( /[^\p{L}\p{N}_-]+/gu, '' )
49
- .toLowerCase(),
50
- '-'
51
- );
24
+ deprecated( 'wp.editor.cleanForSlug', {
25
+ since: '12.7',
26
+ plugin: 'Gutenberg',
27
+ alternative: 'wp.url.cleanForSlug',
28
+ } );
29
+ return urlCleanForSlug( string );
52
30
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/editor/src/store/controls.js"],"names":["postKey","postId","isPostNew","localAutosaveGet","window","sessionStorage","getItem","localAutosaveSet","title","content","excerpt","setItem","JSON","stringify","post_title","localAutosaveClear","removeItem","controls","LOCAL_AUTOSAVE_SET"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAT,CAAkBC,MAAlB,EAA0BC,SAA1B,EAAsC;AACrC,SAAQ,iCACPA,SAAS,GAAG,YAAH,GAAkBD,MAC3B,EAFD;AAGA;;AAEM,SAASE,gBAAT,CAA2BF,MAA3B,EAAmCC,SAAnC,EAA+C;AACrD,SAAOE,MAAM,CAACC,cAAP,CAAsBC,OAAtB,CAA+BN,OAAO,CAAEC,MAAF,EAAUC,SAAV,CAAtC,CAAP;AACA;;AAEM,SAASK,gBAAT,CAA2BN,MAA3B,EAAmCC,SAAnC,EAA8CM,KAA9C,EAAqDC,OAArD,EAA8DC,OAA9D,EAAwE;AAC9EN,EAAAA,MAAM,CAACC,cAAP,CAAsBM,OAAtB,CACCX,OAAO,CAAEC,MAAF,EAAUC,SAAV,CADR,EAECU,IAAI,CAACC,SAAL,CAAgB;AACfC,IAAAA,UAAU,EAAEN,KADG;AAEfC,IAAAA,OAFe;AAGfC,IAAAA;AAHe,GAAhB,CAFD;AAQA;;AAEM,SAASK,kBAAT,CAA6Bd,MAA7B,EAAqCC,SAArC,EAAiD;AACvDE,EAAAA,MAAM,CAACC,cAAP,CAAsBW,UAAtB,CAAkChB,OAAO,CAAEC,MAAF,EAAUC,SAAV,CAAzC;AACA;;AAED,MAAMe,QAAQ,GAAG;AAChBC,EAAAA,kBAAkB,OAAmD;AAAA,QAAjD;AAAEjB,MAAAA,MAAF;AAAUC,MAAAA,SAAV;AAAqBM,MAAAA,KAArB;AAA4BC,MAAAA,OAA5B;AAAqCC,MAAAA;AAArC,KAAiD;AACpEH,IAAAA,gBAAgB,CAAEN,MAAF,EAAUC,SAAV,EAAqBM,KAArB,EAA4BC,OAA5B,EAAqCC,OAArC,CAAhB;AACA;;AAHe,CAAjB;eAMeO,Q","sourcesContent":["/**\n * Function returning a sessionStorage key to set or retrieve a given post's\n * automatic session backup.\n *\n * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's\n * `loggedout` handler can clear sessionStorage of any user-private content.\n *\n * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103\n *\n * @param {string} postId Post ID.\n * @param {boolean} isPostNew Whether post new.\n *\n * @return {string} sessionStorage key\n */\nfunction postKey( postId, isPostNew ) {\n\treturn `wp-autosave-block-editor-post-${\n\t\tisPostNew ? 'auto-draft' : postId\n\t}`;\n}\n\nexport function localAutosaveGet( postId, isPostNew ) {\n\treturn window.sessionStorage.getItem( postKey( postId, isPostNew ) );\n}\n\nexport function localAutosaveSet( postId, isPostNew, title, content, excerpt ) {\n\twindow.sessionStorage.setItem(\n\t\tpostKey( postId, isPostNew ),\n\t\tJSON.stringify( {\n\t\t\tpost_title: title,\n\t\t\tcontent,\n\t\t\texcerpt,\n\t\t} )\n\t);\n}\n\nexport function localAutosaveClear( postId, isPostNew ) {\n\twindow.sessionStorage.removeItem( postKey( postId, isPostNew ) );\n}\n\nconst controls = {\n\tLOCAL_AUTOSAVE_SET( { postId, isPostNew, title, content, excerpt } ) {\n\t\tlocalAutosaveSet( postId, isPostNew, title, content, excerpt );\n\t},\n};\n\nexport default controls;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/editor/src/store/controls.js"],"names":["postKey","postId","isPostNew","localAutosaveGet","window","sessionStorage","getItem","localAutosaveSet","title","content","excerpt","setItem","JSON","stringify","post_title","localAutosaveClear","removeItem","controls","LOCAL_AUTOSAVE_SET"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAT,CAAkBC,MAAlB,EAA0BC,SAA1B,EAAsC;AACrC,SAAQ,iCACPA,SAAS,GAAG,YAAH,GAAkBD,MAC3B,EAFD;AAGA;;AAED,OAAO,SAASE,gBAAT,CAA2BF,MAA3B,EAAmCC,SAAnC,EAA+C;AACrD,SAAOE,MAAM,CAACC,cAAP,CAAsBC,OAAtB,CAA+BN,OAAO,CAAEC,MAAF,EAAUC,SAAV,CAAtC,CAAP;AACA;AAED,OAAO,SAASK,gBAAT,CAA2BN,MAA3B,EAAmCC,SAAnC,EAA8CM,KAA9C,EAAqDC,OAArD,EAA8DC,OAA9D,EAAwE;AAC9EN,EAAAA,MAAM,CAACC,cAAP,CAAsBM,OAAtB,CACCX,OAAO,CAAEC,MAAF,EAAUC,SAAV,CADR,EAECU,IAAI,CAACC,SAAL,CAAgB;AACfC,IAAAA,UAAU,EAAEN,KADG;AAEfC,IAAAA,OAFe;AAGfC,IAAAA;AAHe,GAAhB,CAFD;AAQA;AAED,OAAO,SAASK,kBAAT,CAA6Bd,MAA7B,EAAqCC,SAArC,EAAiD;AACvDE,EAAAA,MAAM,CAACC,cAAP,CAAsBW,UAAtB,CAAkChB,OAAO,CAAEC,MAAF,EAAUC,SAAV,CAAzC;AACA;AAED,MAAMe,QAAQ,GAAG;AAChBC,EAAAA,kBAAkB,OAAmD;AAAA,QAAjD;AAAEjB,MAAAA,MAAF;AAAUC,MAAAA,SAAV;AAAqBM,MAAAA,KAArB;AAA4BC,MAAAA,OAA5B;AAAqCC,MAAAA;AAArC,KAAiD;AACpEH,IAAAA,gBAAgB,CAAEN,MAAF,EAAUC,SAAV,EAAqBM,KAArB,EAA4BC,OAA5B,EAAqCC,OAArC,CAAhB;AACA;;AAHe,CAAjB;AAMA,eAAeO,QAAf","sourcesContent":["/**\n * Function returning a sessionStorage key to set or retrieve a given post's\n * automatic session backup.\n *\n * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's\n * `loggedout` handler can clear sessionStorage of any user-private content.\n *\n * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103\n *\n * @param {string} postId Post ID.\n * @param {boolean} isPostNew Whether post new.\n *\n * @return {string} sessionStorage key\n */\nfunction postKey( postId, isPostNew ) {\n\treturn `wp-autosave-block-editor-post-${\n\t\tisPostNew ? 'auto-draft' : postId\n\t}`;\n}\n\nexport function localAutosaveGet( postId, isPostNew ) {\n\treturn window.sessionStorage.getItem( postKey( postId, isPostNew ) );\n}\n\nexport function localAutosaveSet( postId, isPostNew, title, content, excerpt ) {\n\twindow.sessionStorage.setItem(\n\t\tpostKey( postId, isPostNew ),\n\t\tJSON.stringify( {\n\t\t\tpost_title: title,\n\t\t\tcontent,\n\t\t\texcerpt,\n\t\t} )\n\t);\n}\n\nexport function localAutosaveClear( postId, isPostNew ) {\n\twindow.sessionStorage.removeItem( postKey( postId, isPostNew ) );\n}\n\nconst controls = {\n\tLOCAL_AUTOSAVE_SET( { postId, isPostNew, title, content, excerpt } ) {\n\t\tlocalAutosaveSet( postId, isPostNew, title, content, excerpt );\n\t},\n};\n\nexport default controls;\n"]}
@@ -1,22 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { cleanForSlug } from '../url';
5
-
6
- describe( 'cleanForSlug()', () => {
7
- it( 'Should return string prepared for use as url slug', () => {
8
- expect( cleanForSlug( '/Is th@t Déjà_vu? ' ) ).toBe( 'is-tht-deja_vu' );
9
- } );
10
-
11
- it( 'Should allow non-latin characters', () => {
12
- expect( cleanForSlug( 'Καλημέρα Κόσμε' ) ).toBe( 'καλημέρα-κόσμε' );
13
- } );
14
-
15
- it( 'Should return an empty string for missing argument', () => {
16
- expect( cleanForSlug() ).toBe( '' );
17
- } );
18
-
19
- it( 'Should return an empty string for falsy argument', () => {
20
- expect( cleanForSlug( null ) ).toBe( '' );
21
- } );
22
- } );