@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
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-locked-modal/index.js"],"names":["PostLockedModal","instanceId","hookName","autosave","updatePostLock","editorStore","isLocked","isTakeover","user","postId","postLockUtils","activePostLock","postType","previewLink","select","isPostLocked","isPostLockTakeover","getPostLockUser","getCurrentPostId","getActivePostLock","getEditedPostAttribute","getEditedPostPreviewLink","getEditorSettings","getPostType","coreStore","sendPostLock","data","lock","post_id","receivePostLock","received","lock_error","name","avatar","avatar_src_2x","new_lock","releasePostLock","window","FormData","append","unlockNonce","navigator","sendBeacon","ajaxUrl","xhr","XMLHttpRequest","open","send","addEventListener","removeEventListener","userDisplayName","userAvatar","unlockUrl","lockKey","post","action","_wpnonce","nonce","allPostsUrl","post_type","allPostsLabel","strong","PreviewLink"],"mappings":";;;;;;;AAkBA;;AAfA;;AAKA;;AACA;;AAOA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AA3BA;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;AACA;AACA;AAIe,SAASA,eAAT,GAA2B;AACzC,QAAMC,UAAU,GAAG,4BAAeD,eAAf,CAAnB;AACA,QAAME,QAAQ,GAAG,mCAAmCD,UAApD;AACA,QAAM;AAAEE,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAA+B,uBAAaC,YAAb,CAArC;AACA,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,UAFK;AAGLC,IAAAA,IAHK;AAILC,IAAAA,MAJK;AAKLC,IAAAA,aALK;AAMLC,IAAAA,cANK;AAOLC,IAAAA,QAPK;AAQLC,IAAAA;AARK,MASF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,kBAFK;AAGLC,MAAAA,eAHK;AAILC,MAAAA,gBAJK;AAKLC,MAAAA,iBALK;AAMLC,MAAAA,sBANK;AAOLC,MAAAA,wBAPK;AAQLC,MAAAA;AARK,QASFR,MAAM,CAAET,YAAF,CATV;AAUA,UAAM;AAAEkB,MAAAA;AAAF,QAAkBT,MAAM,CAAEU,eAAF,CAA9B;AACA,WAAO;AACNlB,MAAAA,QAAQ,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mIADA,CATF,EAYD;AACCW,IAAAA,MAAM,EAAE,2CADT;AAECC,IAAAA,WAAW,EACV,4BAAC,wBAAD;AAAc,MAAA,IAAI,EAAGjD;AAArB,OACG,cAAI,SAAJ,CADH;AAHF,GAZC,CADH,CAFF,EA0BG,CAAEN,UAAF,IACD,qDACC,uCACG,uCACD2C,eAAe,GACZ;AACA;AACA,gBACC,qIADD,CAFA,EAKAA,eALA,CADY,GAQZ,cACA,8HADA,CATF,EAYD;AACCW,IAAAA,MAAM,EAAE,2CADT;AAECC,IAAAA,WAAW,EACV,4BAAC,wBAAD;AAAc,MAAA,IAAI,EAAGjD;AAArB,OACG,cAAI,SAAJ,CADH;AAHF,GAZC,CADH,CADD,EAwBC,uCACG,cACD,0GADC,CADH,CAxBD,CA3BF,EA2DC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,IAAA,QAAQ,EAAG;AAHZ,KAKG,CAAEN,UAAF,IACD,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,IAAI,EAAG6C;AAAlC,KACG,cAAI,WAAJ,CADH,CADD,CANF,EAYC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAGM;AAAjC,KACGE,aADH,CADD,CAZD,CA3DD,CArBD,CADD;AAsGA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tModal,\n\tButton,\n\tExternalLink,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useEffect, createInterpolateElement } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getWPAdminURL } from '../../utils/url';\nimport { store as editorStore } from '../../store';\n\nexport default function PostLockedModal() {\n\tconst instanceId = useInstanceId( PostLockedModal );\n\tconst hookName = 'core/editor/post-locked-modal-' + instanceId;\n\tconst { autosave, updatePostLock } = useDispatch( editorStore );\n\tconst {\n\t\tisLocked,\n\t\tisTakeover,\n\t\tuser,\n\t\tpostId,\n\t\tpostLockUtils,\n\t\tactivePostLock,\n\t\tpostType,\n\t\tpreviewLink,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPostLocked,\n\t\t\tisPostLockTakeover,\n\t\t\tgetPostLockUser,\n\t\t\tgetCurrentPostId,\n\t\t\tgetActivePostLock,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostPreviewLink,\n\t\t\tgetEditorSettings,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn {\n\t\t\tisLocked: isPostLocked(),\n\t\t\tisTakeover: isPostLockTakeover(),\n\t\t\tuser: getPostLockUser(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostLockUtils: getEditorSettings().postLockUtils,\n\t\t\tactivePostLock: getActivePostLock(),\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t\tpreviewLink: getEditedPostPreviewLink(),\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Keep the lock refreshed.\n\t\t *\n\t\t * When the user does not send a heartbeat in a heartbeat-tick\n\t\t * the user is no longer editing and another user can start editing.\n\t\t *\n\t\t * @param {Object} data Data to send in the heartbeat request.\n\t\t */\n\t\tfunction sendPostLock( data ) {\n\t\t\tif ( isLocked ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdata[ 'wp-refresh-post-lock' ] = {\n\t\t\t\tlock: activePostLock,\n\t\t\t\tpost_id: postId,\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.\n\t\t *\n\t\t * @param {Object} data Data received in the heartbeat request\n\t\t */\n\t\tfunction receivePostLock( data ) {\n\t\t\tif ( ! data[ 'wp-refresh-post-lock' ] ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst received = data[ 'wp-refresh-post-lock' ];\n\t\t\tif ( received.lock_error ) {\n\t\t\t\t// Auto save and display the takeover modal.\n\t\t\t\tautosave();\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: true,\n\t\t\t\t\tisTakeover: true,\n\t\t\t\t\tuser: {\n\t\t\t\t\t\tname: received.lock_error.name,\n\t\t\t\t\t\tavatar: received.lock_error.avatar_src_2x,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t} else if ( received.new_lock ) {\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: false,\n\t\t\t\t\tactivePostLock: received.new_lock,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Unlock the post before the window is exited.\n\t\t */\n\t\tfunction releasePostLock() {\n\t\t\tif ( isLocked || ! activePostLock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst data = new window.FormData();\n\t\t\tdata.append( 'action', 'wp-remove-post-lock' );\n\t\t\tdata.append( '_wpnonce', postLockUtils.unlockNonce );\n\t\t\tdata.append( 'post_ID', postId );\n\t\t\tdata.append( 'active_post_lock', activePostLock );\n\n\t\t\tif ( window.navigator.sendBeacon ) {\n\t\t\t\twindow.navigator.sendBeacon( postLockUtils.ajaxUrl, data );\n\t\t\t} else {\n\t\t\t\tconst xhr = new window.XMLHttpRequest();\n\t\t\t\txhr.open( 'POST', postLockUtils.ajaxUrl, false );\n\t\t\t\txhr.send( data );\n\t\t\t}\n\t\t}\n\n\t\t// Details on these events on the Heartbeat API docs\n\t\t// https://developer.wordpress.org/plugins/javascript/heartbeat-api/\n\t\taddAction( 'heartbeat.send', hookName, sendPostLock );\n\t\taddAction( 'heartbeat.tick', hookName, receivePostLock );\n\t\twindow.addEventListener( 'beforeunload', releasePostLock );\n\n\t\treturn () => {\n\t\t\tremoveAction( 'heartbeat.send', hookName );\n\t\t\tremoveAction( 'heartbeat.tick', hookName );\n\t\t\twindow.removeEventListener( 'beforeunload', releasePostLock );\n\t\t};\n\t}, [] );\n\n\tif ( ! isLocked ) {\n\t\treturn null;\n\t}\n\n\tconst userDisplayName = user.name;\n\tconst userAvatar = user.avatar;\n\n\tconst unlockUrl = addQueryArgs( 'post.php', {\n\t\t'get-post-lock': '1',\n\t\tlockKey: true,\n\t\tpost: postId,\n\t\taction: 'edit',\n\t\t_wpnonce: postLockUtils.nonce,\n\t} );\n\tconst allPostsUrl = getWPAdminURL( 'edit.php', {\n\t\tpost_type: get( postType, [ 'slug' ] ),\n\t} );\n\tconst allPostsLabel = __( 'Exit editor' );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\tisTakeover\n\t\t\t\t\t? __( 'Someone else has taken over this post' )\n\t\t\t\t\t: __( 'This post is already being edited' )\n\t\t\t}\n\t\t\tfocusOnMount={ true }\n\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\tshouldCloseOnEsc={ false }\n\t\t\tisDismissible={ false }\n\t\t\tclassName=\"editor-post-locked-modal\"\n\t\t>\n\t\t\t{ !! userAvatar && (\n\t\t\t\t<img\n\t\t\t\t\tsrc={ userAvatar }\n\t\t\t\t\talt={ __( 'Avatar' ) }\n\t\t\t\t\tclassName=\"editor-post-locked-modal__avatar\"\n\t\t\t\t\twidth={ 64 }\n\t\t\t\t\theight={ 64 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div>\n\t\t\t\t{ !! isTakeover && (\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> now has editing control of this posts (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t'Another user now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'If you take over, the other user will lose editing control to the post, but their changes will be saved.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"editor-post-locked-modal__buttons\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<Button variant=\"tertiary\" href={ unlockUrl }>\n\t\t\t\t\t\t\t\t{ __( 'Take over' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" href={ allPostsUrl }>\n\t\t\t\t\t\t\t{ allPostsLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-locked-modal/index.js"],"names":["PostLockedModal","instanceId","hookName","autosave","updatePostLock","editorStore","isLocked","isTakeover","user","postId","postLockUtils","activePostLock","postType","previewLink","select","isPostLocked","isPostLockTakeover","getPostLockUser","getCurrentPostId","getActivePostLock","getEditedPostAttribute","getEditedPostPreviewLink","getEditorSettings","getPostType","coreStore","sendPostLock","data","lock","post_id","receivePostLock","received","lock_error","name","avatar","avatar_src_2x","new_lock","releasePostLock","window","FormData","append","unlockNonce","navigator","sendBeacon","ajaxUrl","xhr","XMLHttpRequest","open","send","addEventListener","removeEventListener","userDisplayName","userAvatar","unlockUrl","lockKey","post","action","_wpnonce","nonce","allPostsUrl","post_type","allPostsLabel","strong","PreviewLink"],"mappings":";;;;;;;AAkBA;;AAfA;;AAKA;;AACA;;AAOA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;AACA;AACA;AAGe,SAASA,eAAT,GAA2B;AACzC,QAAMC,UAAU,GAAG,4BAAeD,eAAf,CAAnB;AACA,QAAME,QAAQ,GAAG,mCAAmCD,UAApD;AACA,QAAM;AAAEE,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAA+B,uBAAaC,YAAb,CAArC;AACA,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,UAFK;AAGLC,IAAAA,IAHK;AAILC,IAAAA,MAJK;AAKLC,IAAAA,aALK;AAMLC,IAAAA,cANK;AAOLC,IAAAA,QAPK;AAQLC,IAAAA;AARK,MASF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,kBAFK;AAGLC,MAAAA,eAHK;AAILC,MAAAA,gBAJK;AAKLC,MAAAA,iBALK;AAMLC,MAAAA,sBANK;AAOLC,MAAAA,wBAPK;AAQLC,MAAAA;AARK,QASFR,MAAM,CAAET,YAAF,CATV;AAUA,UAAM;AAAEkB,MAAAA;AAAF,QAAkBT,MAAM,CAAEU,eAAF,CAA9B;AACA,WAAO;AACNlB,MAAAA,QAAQ,EAAES,YAAY,EADhB;AAENR,MAAAA,UAAU,EAAES,kBAAkB,EAFxB;AAGNR,MAAAA,IAAI,EAAES,eAAe,EAHf;AAINR,MAAAA,MAAM,EAAES,gBAAgB,EAJlB;AAKNR,MAAAA,aAAa,EAAEY,iBAAiB,GAAGZ,aAL7B;AAMNC,MAAAA,cAAc,EAAEQ,iBAAiB,E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ACA,gBACC,qIADD,CAFA,EAKAA,eALA,CADY,GAQZ,cACA,8HADA,CATF,EAYD;AACCW,IAAAA,MAAM,EAAE,2CADT;AAECC,IAAAA,WAAW,EACV,4BAAC,wBAAD;AAAc,MAAA,IAAI,EAAGjD;AAArB,OACG,cAAI,SAAJ,CADH;AAHF,GAZC,CADH,CADD,EAwBC,uCACG,cACD,0GADC,CADH,CAxBD,CA3BF,EA2DC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,IAAA,QAAQ,EAAG;AAHZ,KAKG,CAAEN,UAAF,IACD,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,IAAI,EAAG6C;AAAlC,KACG,cAAI,WAAJ,CADH,CADD,CANF,EAYC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAGM;AAAjC,KACGE,aADH,CADD,CAZD,CA3DD,CArBD,CADD;AAsGA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tModal,\n\tButton,\n\tExternalLink,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useEffect, createInterpolateElement } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostLockedModal() {\n\tconst instanceId = useInstanceId( PostLockedModal );\n\tconst hookName = 'core/editor/post-locked-modal-' + instanceId;\n\tconst { autosave, updatePostLock } = useDispatch( editorStore );\n\tconst {\n\t\tisLocked,\n\t\tisTakeover,\n\t\tuser,\n\t\tpostId,\n\t\tpostLockUtils,\n\t\tactivePostLock,\n\t\tpostType,\n\t\tpreviewLink,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPostLocked,\n\t\t\tisPostLockTakeover,\n\t\t\tgetPostLockUser,\n\t\t\tgetCurrentPostId,\n\t\t\tgetActivePostLock,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostPreviewLink,\n\t\t\tgetEditorSettings,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn {\n\t\t\tisLocked: isPostLocked(),\n\t\t\tisTakeover: isPostLockTakeover(),\n\t\t\tuser: getPostLockUser(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostLockUtils: getEditorSettings().postLockUtils,\n\t\t\tactivePostLock: getActivePostLock(),\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t\tpreviewLink: getEditedPostPreviewLink(),\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Keep the lock refreshed.\n\t\t *\n\t\t * When the user does not send a heartbeat in a heartbeat-tick\n\t\t * the user is no longer editing and another user can start editing.\n\t\t *\n\t\t * @param {Object} data Data to send in the heartbeat request.\n\t\t */\n\t\tfunction sendPostLock( data ) {\n\t\t\tif ( isLocked ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdata[ 'wp-refresh-post-lock' ] = {\n\t\t\t\tlock: activePostLock,\n\t\t\t\tpost_id: postId,\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.\n\t\t *\n\t\t * @param {Object} data Data received in the heartbeat request\n\t\t */\n\t\tfunction receivePostLock( data ) {\n\t\t\tif ( ! data[ 'wp-refresh-post-lock' ] ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst received = data[ 'wp-refresh-post-lock' ];\n\t\t\tif ( received.lock_error ) {\n\t\t\t\t// Auto save and display the takeover modal.\n\t\t\t\tautosave();\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: true,\n\t\t\t\t\tisTakeover: true,\n\t\t\t\t\tuser: {\n\t\t\t\t\t\tname: received.lock_error.name,\n\t\t\t\t\t\tavatar: received.lock_error.avatar_src_2x,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t} else if ( received.new_lock ) {\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: false,\n\t\t\t\t\tactivePostLock: received.new_lock,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Unlock the post before the window is exited.\n\t\t */\n\t\tfunction releasePostLock() {\n\t\t\tif ( isLocked || ! activePostLock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst data = new window.FormData();\n\t\t\tdata.append( 'action', 'wp-remove-post-lock' );\n\t\t\tdata.append( '_wpnonce', postLockUtils.unlockNonce );\n\t\t\tdata.append( 'post_ID', postId );\n\t\t\tdata.append( 'active_post_lock', activePostLock );\n\n\t\t\tif ( window.navigator.sendBeacon ) {\n\t\t\t\twindow.navigator.sendBeacon( postLockUtils.ajaxUrl, data );\n\t\t\t} else {\n\t\t\t\tconst xhr = new window.XMLHttpRequest();\n\t\t\t\txhr.open( 'POST', postLockUtils.ajaxUrl, false );\n\t\t\t\txhr.send( data );\n\t\t\t}\n\t\t}\n\n\t\t// Details on these events on the Heartbeat API docs\n\t\t// https://developer.wordpress.org/plugins/javascript/heartbeat-api/\n\t\taddAction( 'heartbeat.send', hookName, sendPostLock );\n\t\taddAction( 'heartbeat.tick', hookName, receivePostLock );\n\t\twindow.addEventListener( 'beforeunload', releasePostLock );\n\n\t\treturn () => {\n\t\t\tremoveAction( 'heartbeat.send', hookName );\n\t\t\tremoveAction( 'heartbeat.tick', hookName );\n\t\t\twindow.removeEventListener( 'beforeunload', releasePostLock );\n\t\t};\n\t}, [] );\n\n\tif ( ! isLocked ) {\n\t\treturn null;\n\t}\n\n\tconst userDisplayName = user.name;\n\tconst userAvatar = user.avatar;\n\n\tconst unlockUrl = addQueryArgs( 'post.php', {\n\t\t'get-post-lock': '1',\n\t\tlockKey: true,\n\t\tpost: postId,\n\t\taction: 'edit',\n\t\t_wpnonce: postLockUtils.nonce,\n\t} );\n\tconst allPostsUrl = addQueryArgs( 'edit.php', {\n\t\tpost_type: get( postType, [ 'slug' ] ),\n\t} );\n\tconst allPostsLabel = __( 'Exit editor' );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\tisTakeover\n\t\t\t\t\t? __( 'Someone else has taken over this post' )\n\t\t\t\t\t: __( 'This post is already being edited' )\n\t\t\t}\n\t\t\tfocusOnMount={ true }\n\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\tshouldCloseOnEsc={ false }\n\t\t\tisDismissible={ false }\n\t\t\tclassName=\"editor-post-locked-modal\"\n\t\t>\n\t\t\t{ !! userAvatar && (\n\t\t\t\t<img\n\t\t\t\t\tsrc={ userAvatar }\n\t\t\t\t\talt={ __( 'Avatar' ) }\n\t\t\t\t\tclassName=\"editor-post-locked-modal__avatar\"\n\t\t\t\t\twidth={ 64 }\n\t\t\t\t\theight={ 64 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div>\n\t\t\t\t{ !! isTakeover && (\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> now has editing control of this posts (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t'Another user now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'If you take over, the other user will lose editing control to the post, but their changes will be saved.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"editor-post-locked-modal__buttons\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<Button variant=\"tertiary\" href={ unlockUrl }>\n\t\t\t\t\t\t\t\t{ __( 'Take over' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" href={ allPostsUrl }>\n\t\t\t\t\t\t\t{ allPostsLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
@@ -159,7 +159,7 @@ function PostSavedState(_ref) {
159
159
  shortcut: _keycodes.displayShortcut.primary('s'),
160
160
  variant: isLargeViewport ? 'tertiary' : undefined,
161
161
  icon: isLargeViewport ? undefined : _icons.cloudUpload,
162
- label: label,
162
+ label: showIconLabels ? undefined : label,
163
163
  "aria-disabled": isDisabled
164
164
  }, isSavedState && (0, _element.createElement)(_icons.Icon, {
165
165
  icon: isSaved ? _icons.check : _icons.cloud
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-saved-state/index.js"],"names":["PostSavedState","forceIsDirty","forceIsSaving","showIconLabels","forceSavedMessage","setForceSavedMessage","isLargeViewport","isAutosaving","isDirty","isNew","isPending","isPublished","isSaveable","isSaving","isScheduled","hasPublishAction","select","isEditedPostNew","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostDirty","isSavingPost","isEditedPostSaveable","getCurrentPost","isAutosavingPost","getEditedPostAttribute","editorStore","_links","savePost","wasSaving","timeoutId","setTimeout","clearTimeout","label","shortLabel","isSaved","isSavedState","isDisabled","text","type","undefined","displayShortcut","primary","cloudUpload","check","cloud"],"mappings":";;;;;;;;;AAcA;;AAXA;;AAKA;;AAIA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,OAIX;AAAA,MAJoC;AACvCC,IAAAA,YADuC;AAEvCC,IAAAA,aAFuC;AAGvCC,IAAAA,cAAc,GAAG;AAHsB,GAIpC;AACH,QAAM,CAAEC,iBAAF,EAAqBC,oBAArB,IAA8C,uBAAU,KAAV,CAApD;AACA,QAAMC,eAAe,GAAG,+BAAkB,OAAlB,CAAxB;AAEA,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,OAFK;AAGLC,IAAAA,KAHK;AAILC,IAAAA,SAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA,UANK;AAOLC,IAAAA,QAPK;AAQLC,IAAAA,WARK;AASLC,IAAAA;AATK,MAUF,qBACDC,MAAF,IAAc;AAAA;;AACb,UAAM;AACLC,MAAAA,eADK;AAELC,MAAAA,sBAFK;AAGLC,MAAAA,sBAHK;AAILC,MAAAA,iBAJK;AAKLC,MAAAA,YALK;AAMLC,MAAAA,oBANK;AAOLC,MAAAA,cAPK;AAQLC,MAAAA,gBARK;AASLC,MAAAA;AATK,QAUFT,MAAM,CAAEU,YAAF,CAVV;AAYA,WAAO;AACNnB,MAAAA,YAAY,EAAEiB,gBAAgB,EADxB;AAENhB,MAAAA,OAAO,EAAEP,YAAY,IAAImB,iBAAiB,EAFpC;AAGNX,MAAAA,KAAK,EAAEQ,eAAe,EAHhB;AAINP,MAAAA,SAAS,EAAE,cAAce,sBAAsB,CAAE,QAAF,CAJzC;AA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ADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tButton,\n} from '@wordpress/components';\nimport { usePrevious, useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, check, cloud, cloudUpload } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport PostSwitchToDraftButton from '../post-switch-to-draft-button';\nimport { store as editorStore } from '../../store';\n\n/**\n * Component showing whether the post is saved or not and providing save\n * buttons.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.forceIsDirty Whether to force the post to be marked\n * as dirty.\n * @param {?boolean} props.forceIsSaving Whether to force the post to be marked\n * as being saved.\n * @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons\n * @return {import('@wordpress/element').WPComponent} The component.\n */\nexport default function PostSavedState( {\n\tforceIsDirty,\n\tforceIsSaving,\n\tshowIconLabels = false,\n} ) {\n\tconst [ forceSavedMessage, setForceSavedMessage ] = useState( false );\n\tconst isLargeViewport = useViewportMatch( 'small' );\n\n\tconst {\n\t\tisAutosaving,\n\t\tisDirty,\n\t\tisNew,\n\t\tisPending,\n\t\tisPublished,\n\t\tisSaveable,\n\t\tisSaving,\n\t\tisScheduled,\n\t\thasPublishAction,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisEditedPostNew,\n\t\t\t\tisCurrentPostPublished,\n\t\t\t\tisCurrentPostScheduled,\n\t\t\t\tisEditedPostDirty,\n\t\t\t\tisSavingPost,\n\t\t\t\tisEditedPostSaveable,\n\t\t\t\tgetCurrentPost,\n\t\t\t\tisAutosavingPost,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t} = select( editorStore );\n\n\t\t\treturn {\n\t\t\t\tisAutosaving: isAutosavingPost(),\n\t\t\t\tisDirty: forceIsDirty || isEditedPostDirty(),\n\t\t\t\tisNew: isEditedPostNew(),\n\t\t\t\tisPending: 'pending' === getEditedPostAttribute( 'status' ),\n\t\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\t\tisSaving: forceIsSaving || isSavingPost(),\n\t\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t\t\thasPublishAction:\n\t\t\t\t\tgetCurrentPost()?._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t};\n\t\t},\n\t\t[ forceIsDirty, forceIsSaving ]\n\t);\n\n\tconst { savePost } = useDispatch( editorStore );\n\n\tconst wasSaving = usePrevious( isSaving );\n\n\tuseEffect( () => {\n\t\tlet timeoutId;\n\n\t\tif ( wasSaving && ! isSaving ) {\n\t\t\tsetForceSavedMessage( true );\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tsetForceSavedMessage( false );\n\t\t\t}, 1000 );\n\t\t}\n\n\t\treturn () => clearTimeout( timeoutId );\n\t}, [ isSaving ] );\n\n\t// Once the post has been submitted for review this button\n\t// is not needed for the contributor role.\n\tif ( ! hasPublishAction && isPending ) {\n\t\treturn null;\n\t}\n\n\tif ( isPublished || isScheduled ) {\n\t\treturn <PostSwitchToDraftButton />;\n\t}\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst label = isPending ? __( 'Save as pending' ) : __( 'Save draft' );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst shortLabel = __( 'Save' );\n\n\tconst isSaved = forceSavedMessage || ( ! isNew && ! isDirty );\n\tconst isSavedState = isSaving || isSaved;\n\tconst isDisabled = isSaving || isSaved || ! isSaveable;\n\n\tlet text;\n\n\tif ( isSaving ) {\n\t\ttext = isAutosaving ? __( 'Autosaving' ) : __( 'Saving' );\n\t} else if ( isSaved ) {\n\t\ttext = __( 'Saved' );\n\t} else if ( isLargeViewport ) {\n\t\ttext = label;\n\t} else if ( showIconLabels ) {\n\t\ttext = shortLabel;\n\t}\n\n\t// Use common Button instance for all saved states so that focus is not\n\t// lost.\n\treturn (\n\t\t<Button\n\t\t\tclassName={\n\t\t\t\tisSaveable || isSaving\n\t\t\t\t\t? classnames( {\n\t\t\t\t\t\t\t'editor-post-save-draft': ! isSavedState,\n\t\t\t\t\t\t\t'editor-post-saved-state': isSavedState,\n\t\t\t\t\t\t\t'is-saving': isSaving,\n\t\t\t\t\t\t\t'is-autosaving': isAutosaving,\n\t\t\t\t\t\t\t'is-saved': isSaved,\n\t\t\t\t\t\t\t[ getAnimateClassName( {\n\t\t\t\t\t\t\t\ttype: 'loading',\n\t\t\t\t\t\t\t} ) ]: isSaving,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonClick={ isDisabled ? undefined : () => savePost() }\n\t\t\tshortcut={ displayShortcut.primary( 's' ) }\n\t\t\tvariant={ isLargeViewport ? 'tertiary' : undefined }\n\t\t\ticon={ isLargeViewport ? undefined : cloudUpload }\n\t\t\tlabel={ label }\n\t\t\taria-disabled={ isDisabled }\n\t\t>\n\t\t\t{ isSavedState && <Icon icon={ isSaved ? check : cloud } /> }\n\t\t\t{ text }\n\t\t</Button>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-saved-state/index.js"],"names":["PostSavedState","forceIsDirty","forceIsSaving","showIconLabels","forceSavedMessage","setForceSavedMessage","isLargeViewport","isAutosaving","isDirty","isNew","isPending","isPublished","isSaveable","isSaving","isScheduled","hasPublishAction","select","isEditedPostNew","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostDirty","isSavingPost","isEditedPostSaveable","getCurrentPost","isAutosavingPost","getEditedPostAttribute","editorStore","_links","savePost","wasSaving","timeoutId","setTimeout","clearTimeout","label","shortLabel","isSaved","isSavedState","isDisabled","text","type","undefined","displayShortcut","primary","cloudUpload","check","cloud"],"mappings":";;;;;;;;;AAcA;;AAXA;;AAKA;;AAIA;;A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AAH,GAAwB,cAAI,QAAJ,CAA3C;AACA,GAFD,MAEO,IAAK4B,OAAL,EAAe;AACrBG,IAAAA,IAAI,GAAG,cAAI,OAAJ,CAAP;AACA,GAFM,MAEA,IAAKhC,eAAL,EAAuB;AAC7BgC,IAAAA,IAAI,GAAGL,KAAP;AACA,GAFM,MAEA,IAAK9B,cAAL,EAAsB;AAC5BmC,IAAAA,IAAI,GAAGJ,UAAP;AACA,GA3FE,CA6FH;AACA;;;AACA,SACC,4BAAC,kBAAD;AACC,IAAA,SAAS,EACRtB,UAAU,IAAIC,QAAd,GACG,yBAAY;AACZ,gCAA0B,CAAEuB,YADhB;AAEZ,iCAA2BA,YAFf;AAGZ,mBAAavB,QAHD;AAIZ,uBAAiBN,YAJL;AAKZ,kBAAY4B,OALA;AAMZ,OAAE,+CAAqB;AACtBI,QAAAA,IAAI,EAAE;AADgB,OAArB,CAAF,GAEO1B;AARK,KAAZ,CADH,GAWG2B,SAbL;AAeC,IAAA,OAAO,EAAGH,UAAU,GAAGG,SAAH,GAAe,MAAMZ,QAAQ,EAflD;AAgBC,IAAA,QAAQ,EAAGa,0BAAgBC,OAAhB,CAAyB,GAAzB,CAhBZ;AAiBC,IAAA,OAAO,EAAGpC,eAAe,GAAG,UAAH,GAAgBkC,SAjB1C;AAkBC,IAAA,IAAI,EAAGlC,eAAe,GAAGkC,SAAH,GAAeG,kBAlBtC;AAmBC,IAAA,KAAK,EAAGxC,cAAc,GAAGqC,SAAH,GAAeP,KAnBtC;AAoBC,qBAAgBI;AApBjB,KAsBGD,YAAY,IAAI,4BAAC,WAAD;AAAM,IAAA,IAAI,EAAGD,OAAO,GAAGS,YAAH,GAAWC;AAA/B,IAtBnB,EAuBGP,IAvBH,CADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tButton,\n} from '@wordpress/components';\nimport { usePrevious, useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, check, cloud, cloudUpload } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport PostSwitchToDraftButton from '../post-switch-to-draft-button';\nimport { store as editorStore } from '../../store';\n\n/**\n * Component showing whether the post is saved or not and providing save\n * buttons.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.forceIsDirty Whether to force the post to be marked\n * as dirty.\n * @param {?boolean} props.forceIsSaving Whether to force the post to be marked\n * as being saved.\n * @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons\n * @return {import('@wordpress/element').WPComponent} The component.\n */\nexport default function PostSavedState( {\n\tforceIsDirty,\n\tforceIsSaving,\n\tshowIconLabels = false,\n} ) {\n\tconst [ forceSavedMessage, setForceSavedMessage ] = useState( false );\n\tconst isLargeViewport = useViewportMatch( 'small' );\n\n\tconst {\n\t\tisAutosaving,\n\t\tisDirty,\n\t\tisNew,\n\t\tisPending,\n\t\tisPublished,\n\t\tisSaveable,\n\t\tisSaving,\n\t\tisScheduled,\n\t\thasPublishAction,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisEditedPostNew,\n\t\t\t\tisCurrentPostPublished,\n\t\t\t\tisCurrentPostScheduled,\n\t\t\t\tisEditedPostDirty,\n\t\t\t\tisSavingPost,\n\t\t\t\tisEditedPostSaveable,\n\t\t\t\tgetCurrentPost,\n\t\t\t\tisAutosavingPost,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t} = select( editorStore );\n\n\t\t\treturn {\n\t\t\t\tisAutosaving: isAutosavingPost(),\n\t\t\t\tisDirty: forceIsDirty || isEditedPostDirty(),\n\t\t\t\tisNew: isEditedPostNew(),\n\t\t\t\tisPending: 'pending' === getEditedPostAttribute( 'status' ),\n\t\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\t\tisSaving: forceIsSaving || isSavingPost(),\n\t\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t\t\thasPublishAction:\n\t\t\t\t\tgetCurrentPost()?._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t};\n\t\t},\n\t\t[ forceIsDirty, forceIsSaving ]\n\t);\n\n\tconst { savePost } = useDispatch( editorStore );\n\n\tconst wasSaving = usePrevious( isSaving );\n\n\tuseEffect( () => {\n\t\tlet timeoutId;\n\n\t\tif ( wasSaving && ! isSaving ) {\n\t\t\tsetForceSavedMessage( true );\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tsetForceSavedMessage( false );\n\t\t\t}, 1000 );\n\t\t}\n\n\t\treturn () => clearTimeout( timeoutId );\n\t}, [ isSaving ] );\n\n\t// Once the post has been submitted for review this button\n\t// is not needed for the contributor role.\n\tif ( ! hasPublishAction && isPending ) {\n\t\treturn null;\n\t}\n\n\tif ( isPublished || isScheduled ) {\n\t\treturn <PostSwitchToDraftButton />;\n\t}\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst label = isPending ? __( 'Save as pending' ) : __( 'Save draft' );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst shortLabel = __( 'Save' );\n\n\tconst isSaved = forceSavedMessage || ( ! isNew && ! isDirty );\n\tconst isSavedState = isSaving || isSaved;\n\tconst isDisabled = isSaving || isSaved || ! isSaveable;\n\n\tlet text;\n\n\tif ( isSaving ) {\n\t\ttext = isAutosaving ? __( 'Autosaving' ) : __( 'Saving' );\n\t} else if ( isSaved ) {\n\t\ttext = __( 'Saved' );\n\t} else if ( isLargeViewport ) {\n\t\ttext = label;\n\t} else if ( showIconLabels ) {\n\t\ttext = shortLabel;\n\t}\n\n\t// Use common Button instance for all saved states so that focus is not\n\t// lost.\n\treturn (\n\t\t<Button\n\t\t\tclassName={\n\t\t\t\tisSaveable || isSaving\n\t\t\t\t\t? classnames( {\n\t\t\t\t\t\t\t'editor-post-save-draft': ! isSavedState,\n\t\t\t\t\t\t\t'editor-post-saved-state': isSavedState,\n\t\t\t\t\t\t\t'is-saving': isSaving,\n\t\t\t\t\t\t\t'is-autosaving': isAutosaving,\n\t\t\t\t\t\t\t'is-saved': isSaved,\n\t\t\t\t\t\t\t[ getAnimateClassName( {\n\t\t\t\t\t\t\t\ttype: 'loading',\n\t\t\t\t\t\t\t} ) ]: isSaving,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonClick={ isDisabled ? undefined : () => savePost() }\n\t\t\tshortcut={ displayShortcut.primary( 's' ) }\n\t\t\tvariant={ isLargeViewport ? 'tertiary' : undefined }\n\t\t\ticon={ isLargeViewport ? undefined : cloudUpload }\n\t\t\tlabel={ showIconLabels ? undefined : label }\n\t\t\taria-disabled={ isDisabled }\n\t\t>\n\t\t\t{ isSavedState && <Icon icon={ isSaved ? check : cloud } /> }\n\t\t\t{ text }\n\t\t</Button>\n\t);\n}\n"]}
@@ -71,9 +71,9 @@ function PostSchedule() {
71
71
  const settings = (0, _date.__experimentalGetSettings)(); // To know if the current timezone is a 12 hour time with look for "a" in the time format
72
72
  // We also make sure this a is not escaped by a "/"
73
73
 
74
- const is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase() // Test only the lower case a
75
- .replace(/\\\\/g, '') // Replace "//" with empty strings
76
- .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash
74
+ const is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase() // Test only the lower case a.
75
+ .replace(/\\\\/g, '') // Replace "//" with empty strings.
76
+ .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash.
77
77
  );
78
78
 
79
79
  function onChange(newDate) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-schedule/index.js"],"names":["getDayOfTheMonth","date","Date","firstDay","d","getFullYear","getMonth","toISOString","PostSchedule","postDate","postType","select","editorStore","getEditedPostAttribute","getCurrentPostType","editPost","onUpdateDate","previewedMonth","setPreviewedMonth","eventsByPostType","coreStore","getEntityRecords","status","after","before","exclude","getCurrentPostId","events","map","title","type","eventDate","rendered","ref","settings","is12HourTime","test","formats","time","toLowerCase","replace","split","reverse","join","onChange","newDate","ownerDocument","current","activeElement","blur"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGA,SAASA,gBAAT,GAAgE;AAAA,MAArCC,IAAqC,uEAA9B,IAAIC,IAAJ,EAA8B;AAAA,MAAlBC,QAAkB,uEAAP,IAAO;AAC/D,QAAMC,CAAC,GAAG,IAAIF,IAAJ,CAAUD,IAAV,CAAV;AACA,SAAO,IAAIC,IAAJ,CACNE,CAAC,CAACC,WAAF,EADM,EAEND,CAAC,CAACE,QAAF,MAAiBH,QAAQ,GAAG,CAAH,GAAO,CAAhC,CAFM,EAGNA,QAAQ,GAAG,CAAH,GAAO,CAHT,EAILI,WAJK,EAAP;AAKA;;AAEc,SAASC,YAAT,GAAwB;AACtC,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyB,qBAC5BC,MAAF,KAAgB;AACfF,IAAAA,QAAQ,EAAEE,MAAM,CAAEC,YAAF,CAAN,CAAsBC,sBAAtB,CAA8C,MAA9C,CADK;AAEfH,IAAAA,QAAQ,EAAEC,MAAM,CAAEC,YAAF,CAAN,CAAsBE,kBAAtB;AAFK,GAAhB,CAD8B,EAK9B,EAL8B,CAA/B;AAQA,QAAM;AAAEC,IAAAA;AAAF,MAAe,uBAAaH,YAAb,CAArB;;AACA,QAAMI,YAAY,GAAKf,IAAF,IAAYc,QAAQ,CAAE;AAAEd,IAAAA;AAAF,GAAF,CAAzC;;AAEA,QAAM,CAAEgB,cAAF,EAAkBC,iBAAlB,IAAwC,uBAC7ClB,gBAAgB,CAAES,QAAF,CAD6B,CAA9C,CAZsC,CAgBtC;;AACA,QAAMU,gBAA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AAY,CAAE6B,OAAF,CAAZ;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAoBb,GAAG,CAACc,OAA9B;AACAD,IAAAA,aAAa,CAACE,aAAd,CAA4BC,IAA5B;AACA;;AAED,SACC,4BAAC,0BAAD;AACC,IAAA,GAAG,EAAGhB,GADP;AAEC,IAAA,WAAW,EAAGxB,QAFf;AAGC,IAAA,QAAQ,EAAGmC,QAHZ;AAIC,IAAA,QAAQ,EAAGT,YAJZ;AAKC,IAAA,MAAM,EAAGR,MALV;AAMC,IAAA,gBAAgB,EAAGT;AANpB,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalGetSettings } from '@wordpress/date';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { DateTimePicker } from '@wordpress/components';\nimport { useRef, useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction getDayOfTheMonth( date = new Date(), firstDay = true ) {\n\tconst d = new Date( date );\n\treturn new Date(\n\t\td.getFullYear(),\n\t\td.getMonth() + ( firstDay ? 0 : 1 ),\n\t\tfirstDay ? 1 : 0\n\t).toISOString();\n}\n\nexport default function PostSchedule() {\n\tconst { postDate, postType } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostDate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst onUpdateDate = ( date ) => editPost( { date } );\n\n\tconst [ previewedMonth, setPreviewedMonth ] = useState(\n\t\tgetDayOfTheMonth( postDate )\n\t);\n\n\t// Pick up published and schduled site posts.\n\tconst eventsByPostType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', postType, {\n\t\t\t\tstatus: 'publish,future',\n\t\t\t\tafter: getDayOfTheMonth( previewedMonth ),\n\t\t\t\tbefore: getDayOfTheMonth( previewedMonth, false ),\n\t\t\t\texclude: [ select( editorStore ).getCurrentPostId() ],\n\t\t\t} ),\n\t\t[ previewedMonth, postType ]\n\t);\n\n\tconst events = useMemo(\n\t\t() =>\n\t\t\t( eventsByPostType || [] ).map(\n\t\t\t\t( { title, type, date: eventDate } ) => ( {\n\t\t\t\t\ttitle: title?.rendered,\n\t\t\t\t\ttype,\n\t\t\t\t\tdate: new Date( eventDate ),\n\t\t\t\t} )\n\t\t\t),\n\t\t[ eventsByPostType ]\n\t);\n\n\tconst ref = useRef();\n\tconst settings = __experimentalGetSettings();\n\n\t// To know if the current timezone is a 12 hour time with look for \"a\" in the time format\n\t// We also make sure this a is not escaped by a \"/\"\n\tconst is12HourTime = /a(?!\\\\)/i.test(\n\t\tsettings.formats.time\n\t\t\t.toLowerCase() // Test only the lower case a\n\t\t\t.replace( /\\\\\\\\/g, '' ) // Replace \"//\" with empty strings\n\t\t\t.split( '' )\n\t\t\t.reverse()\n\t\t\t.join( '' ) // Reverse the string and test for \"a\" not followed by a slash\n\t);\n\n\tfunction onChange( newDate ) {\n\t\tonUpdateDate( newDate );\n\t\tconst { ownerDocument } = ref.current;\n\t\townerDocument.activeElement.blur();\n\t}\n\n\treturn (\n\t\t<DateTimePicker\n\t\t\tref={ ref }\n\t\t\tcurrentDate={ postDate }\n\t\t\tonChange={ onChange }\n\t\t\tis12Hour={ is12HourTime }\n\t\t\tevents={ events }\n\t\t\tonMonthPreviewed={ setPreviewedMonth }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-schedule/index.js"],"names":["getDayOfTheMonth","date","Date","firstDay","d","getFullYear","getMonth","toISOString","PostSchedule","postDate","postType","select","editorStore","getEditedPostAttribute","getCurrentPostType","editPost","onUpdateDate","previewedMonth","setPreviewedMonth","eventsByPostType","coreStore","getEntityRecords","status","after","before","exclude","getCurrentPostId","events","map","title","type","eventDate","rendered","ref","settings","is12HourTime","test","formats","time","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,SACC,4BAAC,0BAAD;AACC,IAAA,GAAG,EAAGhB,GADP;AAEC,IAAA,WAAW,EAAGxB,QAFf;AAGC,IAAA,QAAQ,EAAGmC,QAHZ;AAIC,IAAA,QAAQ,EAAGT,YAJZ;AAKC,IAAA,MAAM,EAAGR,MALV;AAMC,IAAA,gBAAgB,EAAGT;AANpB,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalGetSettings } from '@wordpress/date';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { DateTimePicker } from '@wordpress/components';\nimport { useRef, useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction getDayOfTheMonth( date = new Date(), firstDay = true ) {\n\tconst d = new Date( date );\n\treturn new Date(\n\t\td.getFullYear(),\n\t\td.getMonth() + ( firstDay ? 0 : 1 ),\n\t\tfirstDay ? 1 : 0\n\t).toISOString();\n}\n\nexport default function PostSchedule() {\n\tconst { postDate, postType } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostDate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst onUpdateDate = ( date ) => editPost( { date } );\n\n\tconst [ previewedMonth, setPreviewedMonth ] = useState(\n\t\tgetDayOfTheMonth( postDate )\n\t);\n\n\t// Pick up published and schduled site posts.\n\tconst eventsByPostType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', postType, {\n\t\t\t\tstatus: 'publish,future',\n\t\t\t\tafter: getDayOfTheMonth( previewedMonth ),\n\t\t\t\tbefore: getDayOfTheMonth( previewedMonth, false ),\n\t\t\t\texclude: [ select( editorStore ).getCurrentPostId() ],\n\t\t\t} ),\n\t\t[ previewedMonth, postType ]\n\t);\n\n\tconst events = useMemo(\n\t\t() =>\n\t\t\t( eventsByPostType || [] ).map(\n\t\t\t\t( { title, type, date: eventDate } ) => ( {\n\t\t\t\t\ttitle: title?.rendered,\n\t\t\t\t\ttype,\n\t\t\t\t\tdate: new Date( eventDate ),\n\t\t\t\t} )\n\t\t\t),\n\t\t[ eventsByPostType ]\n\t);\n\n\tconst ref = useRef();\n\tconst settings = __experimentalGetSettings();\n\n\t// To know if the current timezone is a 12 hour time with look for \"a\" in the time format\n\t// We also make sure this a is not escaped by a \"/\"\n\tconst is12HourTime = /a(?!\\\\)/i.test(\n\t\tsettings.formats.time\n\t\t\t.toLowerCase() // Test only the lower case a.\n\t\t\t.replace( /\\\\\\\\/g, '' ) // Replace \"//\" with empty strings.\n\t\t\t.split( '' )\n\t\t\t.reverse()\n\t\t\t.join( '' ) // Reverse the string and test for \"a\" not followed by a slash.\n\t);\n\n\tfunction onChange( newDate ) {\n\t\tonUpdateDate( newDate );\n\t\tconst { ownerDocument } = ref.current;\n\t\townerDocument.activeElement.blur();\n\t}\n\n\treturn (\n\t\t<DateTimePicker\n\t\t\tref={ ref }\n\t\t\tcurrentDate={ postDate }\n\t\t\tonChange={ onChange }\n\t\t\tis12Hour={ is12HourTime }\n\t\t\tevents={ events }\n\t\t\tonMonthPreviewed={ setPreviewedMonth }\n\t\t/>\n\t);\n}\n"]}
@@ -19,8 +19,6 @@ var _url = require("@wordpress/url");
19
19
 
20
20
  var _check = _interopRequireDefault(require("./check"));
21
21
 
22
- var _url2 = require("../../utils/url");
23
-
24
22
  var _store = require("../../store");
25
23
 
26
24
  /**
@@ -39,7 +37,7 @@ class PostSlug extends _element.Component {
39
37
  } = _ref;
40
38
  super(...arguments);
41
39
  this.state = {
42
- editedSlug: (0, _url.safeDecodeURIComponent)(postSlug) || (0, _url2.cleanForSlug)(postTitle) || postID
40
+ editedSlug: (0, _url.safeDecodeURIComponent)(postSlug) || (0, _url.cleanForSlug)(postTitle) || postID
43
41
  };
44
42
  this.setSlug = this.setSlug.bind(this);
45
43
  }
@@ -52,7 +50,7 @@ class PostSlug extends _element.Component {
52
50
  const {
53
51
  value
54
52
  } = event.target;
55
- const editedSlug = (0, _url2.cleanForSlug)(value);
53
+ const editedSlug = (0, _url.cleanForSlug)(value);
56
54
 
57
55
  if (editedSlug === postSlug) {
58
56
  return;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-slug/index.js"],"names":["PostSlug","Component","constructor","postSlug","postTitle","postID","arguments","state","editedSlug","setSlug","bind","event","onUpdateSlug","props","value","target","render","instanceId","inputId","setState","select","getCurrentPost","getEditedPostAttribute","editorStore","id","dispatch","editPost","slug","withInstanceId"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAdA;AACA;AACA;;AAOA;AACA;AACA;AAKO,MAAMA,QAAN,SAAuBC,kBAAvB,CAAiC;AACvCC,EAAAA,WAAW,OAAoC;AAAA,QAAlC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,SAAZ;AAAuBC,MAAAA;AAAvB,KAAkC;AAC9C,UAAO,GAAGC,SAAV;AAEA,SAAKC,KAAL,GAAa;AACZC,MAAAA,UAAU,EACT,iCAAwBL,QAAxB,KACA,wBAAcC,SAAd,CADA,IAEAC;AAJW,KAAb;AAOA,SAAKI,OAAL,GAAe,KAAKA,OAAL,CAAaC,IAAb,CAAmB,IAAnB,CAAf;AACA;;AAEDD,EAAAA,OAAO,CAAEE,KAAF,EAAU;AAChB,UAAM;AAAER,MAAAA,QAAF;AAAYS,MAAAA;AAAZ,QAA6B,KAAKC,KAAxC;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAYH,KAAK,CAACI,MAAxB;AAEA,UAAMP,UAAU,GAAG,wBAAcM,KAAd,CAAnB;;AAEA,QAAKN,UAAU,KAAKL,QAApB,EAA+B;AAC9B;AACA;;AAEDS,IAAAA,YAAY,CAAEJ,UAAF,CAAZ;AACA;;AAEDQ,EAAAA,MAAM,GAAG;AACR,UAAM;AAA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C,uBArBuB,CAAT,EAsBV5B,QAtBU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { withInstanceId, compose } from '@wordpress/compose';\nimport { safeDecodeURIComponent } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostSlugCheck from './check';\nimport { cleanForSlug } from '../../utils/url';\nimport { store as editorStore } from '../../store';\n\nexport class PostSlug extends Component {\n\tconstructor( { postSlug, postTitle, postID } ) {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\teditedSlug:\n\t\t\t\tsafeDecodeURIComponent( postSlug ) ||\n\t\t\t\tcleanForSlug( postTitle ) ||\n\t\t\t\tpostID,\n\t\t};\n\n\t\tthis.setSlug = this.setSlug.bind( this );\n\t}\n\n\tsetSlug( event ) {\n\t\tconst { postSlug, onUpdateSlug } = this.props;\n\t\tconst { value } = event.target;\n\n\t\tconst editedSlug = cleanForSlug( value );\n\n\t\tif ( editedSlug === postSlug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonUpdateSlug( editedSlug );\n\t}\n\n\trender() {\n\t\tconst { instanceId } = this.props;\n\t\tconst { editedSlug } = this.state;\n\n\t\tconst inputId = 'editor-post-slug-' + instanceId;\n\n\t\treturn (\n\t\t\t<PostSlugCheck>\n\t\t\t\t<label htmlFor={ inputId }>{ __( 'Slug' ) }</label>\n\t\t\t\t<input\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\tspellCheck=\"false\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tid={ inputId }\n\t\t\t\t\tvalue={ editedSlug }\n\t\t\t\t\tonChange={ ( event ) =>\n\t\t\t\t\t\tthis.setState( { editedSlug: event.target.value } )\n\t\t\t\t\t}\n\t\t\t\t\tonBlur={ this.setSlug }\n\t\t\t\t\tclassName=\"editor-post-slug__input\"\n\t\t\t\t/>\n\t\t\t</PostSlugCheck>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getCurrentPost, getEditedPostAttribute } = select(\n\t\t\teditorStore\n\t\t);\n\n\t\tconst { id } = getCurrentPost();\n\t\treturn {\n\t\t\tpostSlug: getEditedPostAttribute( 'slug' ),\n\t\t\tpostTitle: getEditedPostAttribute( 'title' ),\n\t\t\tpostID: id,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateSlug( slug ) {\n\t\t\t\teditPost( { slug } );\n\t\t\t},\n\t\t};\n\t} ),\n\twithInstanceId,\n] )( PostSlug );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-slug/index.js"],"names":["PostSlug","Component","constructor","postSlug","postTitle","postID","arguments","state","editedSlug","setSlug","bind","event","onUpdateSlug","props","value","target","render","instanceId","inputId","setState","select","getCurrentPost","getEditedPostAttribute","editorStore","id","dispatch","editPost","slug","withInstanceId"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIO,MAAMA,QAAN,SAAuBC,kBAAvB,CAAiC;AACvCC,EAAAA,WAAW,OAAoC;AAAA,QAAlC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,SAAZ;AAAuBC,MAAAA;AAAvB,KAAkC;AAC9C,UAAO,GAAGC,SAAV;AAEA,SAAKC,KAAL,GAAa;AACZC,MAAAA,UAAU,EACT,iCAAwBL,QAAxB,KACA,uBAAcC,SAAd,CADA,IAEAC;AAJW,KAAb;AAOA,SAAKI,OAAL,GAAe,KAAKA,OAAL,CAAaC,IAAb,CAAmB,IAAnB,CAAf;AACA;;AAEDD,EAAAA,OAAO,CAAEE,KAAF,EAAU;AAChB,UAAM;AAAER,MAAAA,QAAF;AAAYS,MAAAA;AAAZ,QAA6B,KAAKC,KAAxC;AACA,UAAM;AAAEC,MA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AAgB;AAC7B,QAAM;AAAEC,IAAAA;AAAF,MAAeD,QAAQ,CAAEF,YAAF,CAA7B;AACA,SAAO;AACNX,IAAAA,YAAY,CAAEe,IAAF,EAAS;AACpBD,MAAAA,QAAQ,CAAE;AAAEC,QAAAA;AAAF,OAAF,CAAR;AACA;;AAHK,GAAP;AAKA,CAPD,CAbuB,EAqBvBC,uBArBuB,CAAT,EAsBV5B,QAtBU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { withInstanceId, compose } from '@wordpress/compose';\nimport { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostSlugCheck from './check';\nimport { store as editorStore } from '../../store';\n\nexport class PostSlug extends Component {\n\tconstructor( { postSlug, postTitle, postID } ) {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\teditedSlug:\n\t\t\t\tsafeDecodeURIComponent( postSlug ) ||\n\t\t\t\tcleanForSlug( postTitle ) ||\n\t\t\t\tpostID,\n\t\t};\n\n\t\tthis.setSlug = this.setSlug.bind( this );\n\t}\n\n\tsetSlug( event ) {\n\t\tconst { postSlug, onUpdateSlug } = this.props;\n\t\tconst { value } = event.target;\n\n\t\tconst editedSlug = cleanForSlug( value );\n\n\t\tif ( editedSlug === postSlug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonUpdateSlug( editedSlug );\n\t}\n\n\trender() {\n\t\tconst { instanceId } = this.props;\n\t\tconst { editedSlug } = this.state;\n\n\t\tconst inputId = 'editor-post-slug-' + instanceId;\n\n\t\treturn (\n\t\t\t<PostSlugCheck>\n\t\t\t\t<label htmlFor={ inputId }>{ __( 'Slug' ) }</label>\n\t\t\t\t<input\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\tspellCheck=\"false\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\tid={ inputId }\n\t\t\t\t\tvalue={ editedSlug }\n\t\t\t\t\tonChange={ ( event ) =>\n\t\t\t\t\t\tthis.setState( { editedSlug: event.target.value } )\n\t\t\t\t\t}\n\t\t\t\t\tonBlur={ this.setSlug }\n\t\t\t\t\tclassName=\"editor-post-slug__input\"\n\t\t\t\t/>\n\t\t\t</PostSlugCheck>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getCurrentPost, getEditedPostAttribute } = select(\n\t\t\teditorStore\n\t\t);\n\n\t\tconst { id } = getCurrentPost();\n\t\treturn {\n\t\t\tpostSlug: getEditedPostAttribute( 'slug' ),\n\t\t\tpostTitle: getEditedPostAttribute( 'title' ),\n\t\t\tpostID: id,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateSlug( slug ) {\n\t\t\t\teditPost( { slug } );\n\t\t\t},\n\t\t};\n\t} ),\n\twithInstanceId,\n] )( PostSlug );\n"]}
@@ -32,32 +32,37 @@ function PostSwitchToDraftButton(_ref) {
32
32
  onClick
33
33
  } = _ref;
34
34
  const isMobileViewport = (0, _compose.useViewportMatch)('small', '<');
35
+ const [showConfirmDialog, setShowConfirmDialog] = (0, _element.useState)(false);
35
36
 
36
37
  if (!isPublished && !isScheduled) {
37
38
  return null;
38
39
  }
39
40
 
40
- const onSwitch = () => {
41
- let alertMessage;
42
-
43
- if (isPublished) {
44
- alertMessage = (0, _i18n.__)('Are you sure you want to unpublish this post?');
45
- } else if (isScheduled) {
46
- alertMessage = (0, _i18n.__)('Are you sure you want to unschedule this post?');
47
- } // eslint-disable-next-line no-alert
41
+ let alertMessage;
48
42
 
43
+ if (isPublished) {
44
+ alertMessage = (0, _i18n.__)('Are you sure you want to unpublish this post?');
45
+ } else if (isScheduled) {
46
+ alertMessage = (0, _i18n.__)('Are you sure you want to unschedule this post?');
47
+ }
49
48
 
50
- if (window.confirm(alertMessage)) {
51
- onClick();
52
- }
49
+ const handleConfirm = () => {
50
+ setShowConfirmDialog(false);
51
+ onClick();
53
52
  };
54
53
 
55
- return (0, _element.createElement)(_components.Button, {
54
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.Button, {
56
55
  className: "editor-post-switch-to-draft",
57
- onClick: onSwitch,
56
+ onClick: () => {
57
+ setShowConfirmDialog(true);
58
+ },
58
59
  disabled: isSaving,
59
60
  variant: "tertiary"
60
- }, isMobileViewport ? (0, _i18n.__)('Draft') : (0, _i18n.__)('Switch to draft'));
61
+ }, isMobileViewport ? (0, _i18n.__)('Draft') : (0, _i18n.__)('Switch to draft')), (0, _element.createElement)(_components.__experimentalConfirmDialog, {
62
+ isOpen: showConfirmDialog,
63
+ onConfirm: handleConfirm,
64
+ onCancel: () => setShowConfirmDialog(false)
65
+ }, alertMessage));
61
66
  }
62
67
 
63
68
  var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-switch-to-draft-button/index.js"],"names":["PostSwitchToDraftButton","isSaving","isPublished","isScheduled","onClick","isMobileViewport","onSwitch","alertMessage","window","confirm","select","isSavingPost","isCurrentPostPublished","isCurrentPostScheduled","editorStore","dispatch","editPost","savePost","status"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGA,SAASA,uBAAT,OAKI;AAAA,MAL8B;AACjCC,IAAAA,QADiC;AAEjCC,IAAAA,WAFiC;AAGjCC,IAAAA,WAHiC;AAIjCC,IAAAA;AAJiC,GAK9B;AACH,QAAMC,gBAAgB,GAAG,+BAAkB,OAAlB,EAA2B,GAA3B,CAAzB;;AAEA,MAAK,CAAEH,WAAF,IAAiB,CAAEC,WAAxB,EAAsC;AACrC,WAAO,IAAP;AACA;;AAED,QAAMG,QAAQ,GAAG,MAAM;AACtB,QAAIC,YAAJ;;AACA,QAAKL,WAAL,EAAmB;AAClBK,MAAAA,YAAY,GAAG,cACd,+CADc,CAAf;AAGA,KAJD,MAIO,IAAKJ,WAAL,EAAmB;AACzBI,MAAAA,YAAY,GAAG,cACd,gDADc,CAAf;AAGA,KAVqB,CAWtB;;;AACA,QAAKC,MAAM,CAACC,OAAP,CAAgBF,YAAhB,CAAL,EAAsC;AACrCH,MAAAA,OAAO;AACP;AACD,GAfD;;AAiBA,SACC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,6BADX;AAEC,IAAA,OAAO,EAAGE,QAFX;AAGC,IAAA,QAAQ,EAAGL,QAHZ;AAIC,IAAA,OAAO,EAAC;AAJT,KAMGI,gBAAgB,GAAG,cAAI,OAAJ,CAAH,GAAmB,cAAI,iBAAJ,CANtC,CADD;AAUA;;eAEc,sBAAS,CACvB,sBAAcK,MAAF,IAAc;AACzB,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,sBAFK;AAGLC,IAAAA;AAHK,MAIFH,MAAM,CAAEI,YAAF,CAJV;AAKA,SAAO;AACNb,IAAAA,QAAQ,EAAEU,YAAY,EADhB;AAENT,IAAAA,WAAW,EAAEU,sBAAsB,EAF7B;AAGNT,IAAAA,WAAW,EAAEU,sBAAsB;AAH7B,GAAP;AAKA,CAXD,CADuB,EAavB,wBAAgBE,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyBF,QAAQ,CAAED,YAAF,CAAvC;AACA,SAAO;AACNV,IAAAA,OAAO,EAAE,MAAM;AACdY,MAAAA,QAAQ,CAAE;AAAEE,QAAAA,MAAM,EAAE;AAAV,OAAF,CAAR;AACAD,MAAAA,QAAQ;AACR;AAJK,GAAP;AAMA,CARD,CAbuB,CAAT,EAsBVjB,uBAtBU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose, useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction PostSwitchToDraftButton( {\n\tisSaving,\n\tisPublished,\n\tisScheduled,\n\tonClick,\n} ) {\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\n\tif ( ! isPublished && ! isScheduled ) {\n\t\treturn null;\n\t}\n\n\tconst onSwitch = () => {\n\t\tlet alertMessage;\n\t\tif ( isPublished ) {\n\t\t\talertMessage = __(\n\t\t\t\t'Are you sure you want to unpublish this post?'\n\t\t\t);\n\t\t} else if ( isScheduled ) {\n\t\t\talertMessage = __(\n\t\t\t\t'Are you sure you want to unschedule this post?'\n\t\t\t);\n\t\t}\n\t\t// eslint-disable-next-line no-alert\n\t\tif ( window.confirm( alertMessage ) ) {\n\t\t\tonClick();\n\t\t}\n\t};\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"editor-post-switch-to-draft\"\n\t\t\tonClick={ onSwitch }\n\t\t\tdisabled={ isSaving }\n\t\t\tvariant=\"tertiary\"\n\t\t>\n\t\t\t{ isMobileViewport ? __( 'Draft' ) : __( 'Switch to draft' ) }\n\t\t</Button>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisSavingPost,\n\t\t\tisCurrentPostPublished,\n\t\t\tisCurrentPostScheduled,\n\t\t} = select( editorStore );\n\t\treturn {\n\t\t\tisSaving: isSavingPost(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost, savePost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonClick: () => {\n\t\t\t\teditPost( { status: 'draft' } );\n\t\t\t\tsavePost();\n\t\t\t},\n\t\t};\n\t} ),\n] )( PostSwitchToDraftButton );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-switch-to-draft-button/index.js"],"names":["PostSwitchToDraftButton","isSaving","isPublished","isScheduled","onClick","isMobileViewport","showConfirmDialog","setShowConfirmDialog","alertMessage","handleConfirm","select","isSavingPost","isCurrentPostPublished","isCurrentPostScheduled","editorStore","dispatch","editPost","savePost","status"],"mappings":";;;;;;;AAUA;;AAPA;;AAIA;;AACA;;AACA;;AAMA;;AAfA;AACA;AACA;;AAUA;AACA;AACA;AAGA,SAASA,uBAAT,OAKI;AAAA,MAL8B;AACjCC,IAAAA,QADiC;AAEjCC,IAAAA,WAFiC;AAGjCC,IAAAA,WAHiC;AAIjCC,IAAAA;AAJiC,GAK9B;AACH,QAAMC,gBAAgB,GAAG,+BAAkB,OAAlB,EAA2B,GAA3B,CAAzB;AACA,QAAM,CAAEC,iBAAF,EAAqBC,oBAArB,IAA8C,uBAAU,KAAV,CAApD;;AAEA,MAAK,CAAEL,WAAF,IAAiB,CAAEC,WAAxB,EAAsC;AACrC,WAAO,IAAP;AACA;;AAED,MAAIK,YAAJ;;AACA,MAAKN,WAAL,EAAmB;AAClBM,IAAAA,YAAY,GAAG,cAAI,+CAAJ,CAAf;AACA,GAFD,MAEO,IAAKL,WAAL,EAAmB;AACzBK,IAAAA,YAAY,GAAG,cAAI,gDAAJ,CAAf;AACA;;AAED,QAAMC,aAAa,GAAG,MAAM;AAC3BF,IAAAA,oBAAoB,CAAE,KAAF,CAApB;AACAH,IAAAA,OAAO;AACP,GAHD;;AAKA,SACC,qDACC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,6BADX;AAEC,IAAA,OAAO,EAAG,MAAM;AACfG,MAAAA,oBAAoB,CAAE,IAAF,CAApB;AACA,KAJF;AAKC,IAAA,QAAQ,EAAGN,QALZ;AAMC,IAAA,OAAO,EAAC;AANT,KAQGI,gBAAgB,GAAG,cAAI,OAAJ,CAAH,GAAmB,cAAI,iBAAJ,CARtC,CADD,EAWC,4BAAC,uCAAD;AACC,IAAA,MAAM,EAAGC,iBADV;AAEC,IAAA,SAAS,EAAGG,aAFb;AAGC,IAAA,QAAQ,EAAG,MAAMF,oBAAoB,CAAE,KAAF;AAHtC,KAKGC,YALH,CAXD,CADD;AAqBA;;eAEc,sBAAS,CACvB,sBAAcE,MAAF,IAAc;AACzB,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,sBAFK;AAGLC,IAAAA;AAHK,MAIFH,MAAM,CAAEI,YAAF,CAJV;AAKA,SAAO;AACNb,IAAAA,QAAQ,EAAEU,YAAY,EADhB;AAENT,IAAAA,WAAW,EAAEU,sBAAsB,EAF7B;AAGNT,IAAAA,WAAW,EAAEU,sBAAsB;AAH7B,GAAP;AAKA,CAXD,CADuB,EAavB,wBAAgBE,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyBF,QAAQ,CAAED,YAAF,CAAvC;AACA,SAAO;AACNV,IAAAA,OAAO,EAAE,MAAM;AACdY,MAAAA,QAAQ,CAAE;AAAEE,QAAAA,MAAM,EAAE;AAAV,OAAF,CAAR;AACAD,MAAAA,QAAQ;AACR;AAJK,GAAP;AAMA,CARD,CAbuB,CAAT,EAsBVjB,uBAtBU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose, useViewportMatch } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction PostSwitchToDraftButton( {\n\tisSaving,\n\tisPublished,\n\tisScheduled,\n\tonClick,\n} ) {\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tif ( ! isPublished && ! isScheduled ) {\n\t\treturn null;\n\t}\n\n\tlet alertMessage;\n\tif ( isPublished ) {\n\t\talertMessage = __( 'Are you sure you want to unpublish this post?' );\n\t} else if ( isScheduled ) {\n\t\talertMessage = __( 'Are you sure you want to unschedule this post?' );\n\t}\n\n\tconst handleConfirm = () => {\n\t\tsetShowConfirmDialog( false );\n\t\tonClick();\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-post-switch-to-draft\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t\t} }\n\t\t\t\tdisabled={ isSaving }\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t>\n\t\t\t\t{ isMobileViewport ? __( 'Draft' ) : __( 'Switch to draft' ) }\n\t\t\t</Button>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\tonConfirm={ handleConfirm }\n\t\t\t\tonCancel={ () => setShowConfirmDialog( false ) }\n\t\t\t>\n\t\t\t\t{ alertMessage }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisSavingPost,\n\t\t\tisCurrentPostPublished,\n\t\t\tisCurrentPostScheduled,\n\t\t} = select( editorStore );\n\t\treturn {\n\t\t\tisSaving: isSavingPost(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost, savePost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonClick: () => {\n\t\t\t\teditPost( { status: 'draft' } );\n\t\t\t\tsavePost();\n\t\t\t},\n\t\t};\n\t} ),\n] )( PostSwitchToDraftButton );\n"]}
@@ -274,13 +274,13 @@ function HierarchicalTermSelector(_ref) {
274
274
 
275
275
  if (formName === '' || adding) {
276
276
  return;
277
- } // check if the term we are adding already exists
277
+ } // Check if the term we are adding already exists.
278
278
 
279
279
 
280
280
  const existingTerm = findTerm(availableTerms, formParent, formName);
281
281
 
282
282
  if (existingTerm) {
283
- // if the term we are adding exists but is not selected select it
283
+ // If the term we are adding exists but is not selected select it.
284
284
  if (!(0, _lodash.some)(terms, term => term === existingTerm.id)) {
285
285
  onUpdateTerms([...terms, existingTerm.id]);
286
286
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/hierarchical-term-selector.js"],"names":["DEFAULT_QUERY","per_page","orderby","order","_fields","context","MIN_TERMS_COUNT_FOR_FILTER","EMPTY_ARRAY","sortBySelected","termsTree","terms","treeHasSelection","termTree","indexOf","id","undefined","children","map","filter","child","length","termOrChildIsSelected","termA","termB","termASelected","termBSelected","newTermTree","sort","findTerm","parent","name","term","parseInt","toLowerCase","getFilterMatcher","filterValue","matchTermsForFilter","originalTerm","HierarchicalTermSelector","slug","adding","setAdding","formName","setFormName","formParent","setFormParent","showForm","setShowForm","setFilterValue","filteredTermsTree","setFilteredTermsTree","debouncedSpeak","speak","hasCreateAction","hasAssignAction","loading","availableTerms","taxonomy","select","getCurrentPost","getEditedPostAttribute","editorStore","getTaxonomy","getEntityRecords","isResolving","coreStore","_taxonomy","rest_base","editPost","saveEntityRecord","availableTermsTree","addTerm","onUpdateTerms","termIds","onChange","termId","hasTerm","includes","newTerms","onChangeFormName","value","onChangeFormParent","parentId","onToggleForm","onAddTerm","event","preventDefault","existingTerm","newTerm","termAddedMessage","setFilter","newFilteredTermsTree","getResultCount","count","i","resultCount","resultsFoundMessage","renderTerms","renderedTerms","labelWithFallback","labelProperty","fallbackIsCategory","fallbackIsNotCategory","newTermButtonLabel","newTermLabel","parentSelectLabel","noParentOption","newTermSubmitLabel","filterLabel","groupLabel","showFilter"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAOA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAE,CAAC,CADU;AAErBC,EAAAA,OAAO,EAAE,MAFY;AAGrBC,EAA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,QAAQ;AALT,IADD,EAQG,CAAC,CAAEvB,cAAc,CAACpC,MAAlB,IACD,4BAAC,sBAAD;AACC,IAAA,KAAK,EAAGqF,iBADT;AAEC,IAAA,aAAa,EAAGC,cAFjB;AAGC,IAAA,QAAQ,EAAGzB,kBAHZ;AAIC,IAAA,UAAU,EAAGrC,UAJd;AAKC,IAAA,IAAI,EAAG0B;AALR,IATF,EAiBC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,SAAS,EAAC;AAHX,KAKGqC,kBALH,CAjBD,CA9BF,CADD;AA2DA;;eAEc,6BAAa,yBAAb,EACdrE,wBADc,C","sourcesContent":["/**\n * External dependencies\n */\nimport { find, get, some, unescape as unescapeString, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, _x, sprintf } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tTextControl,\n\tTreeSelect,\n\twithFilters,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useDebounce } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module Constants\n */\nconst DEFAULT_QUERY = {\n\tper_page: -1,\n\torderby: 'name',\n\torder: 'asc',\n\t_fields: 'id,name,parent',\n\tcontext: 'view',\n};\n\nconst MIN_TERMS_COUNT_FOR_FILTER = 8;\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Sort Terms by Selected.\n *\n * @param {Object[]} termsTree Array of terms in tree format.\n * @param {number[]} terms Selected terms.\n *\n * @return {Object[]} Sorted array of terms.\n */\nexport function sortBySelected( termsTree, terms ) {\n\tconst treeHasSelection = ( termTree ) => {\n\t\tif ( terms.indexOf( termTree.id ) !== -1 ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( undefined === termTree.children ) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\ttermTree.children\n\t\t\t\t.map( treeHasSelection )\n\t\t\t\t.filter( ( child ) => child ).length > 0\n\t\t);\n\t};\n\tconst termOrChildIsSelected = ( termA, termB ) => {\n\t\tconst termASelected = treeHasSelection( termA );\n\t\tconst termBSelected = treeHasSelection( termB );\n\n\t\tif ( termASelected === termBSelected ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tif ( termASelected && ! termBSelected ) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif ( ! termASelected && termBSelected ) {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn 0;\n\t};\n\tconst newTermTree = [ ...termsTree ];\n\tnewTermTree.sort( termOrChildIsSelected );\n\treturn newTermTree;\n}\n\n/**\n * Find term by parent id or name.\n *\n * @param {Object[]} terms Array of Terms.\n * @param {number|string} parent id.\n * @param {string} name Term name.\n * @return {Object} Term object.\n */\nexport function findTerm( terms, parent, name ) {\n\treturn find( terms, ( term ) => {\n\t\treturn (\n\t\t\t( ( ! term.parent && ! parent ) ||\n\t\t\t\tparseInt( term.parent ) === parseInt( parent ) ) &&\n\t\t\tterm.name.toLowerCase() === name.toLowerCase()\n\t\t);\n\t} );\n}\n\n/**\n * Get filter matcher function.\n *\n * @param {string} filterValue Filter value.\n * @return {(function(Object): (Object|boolean))} Matcher function.\n */\nexport function getFilterMatcher( filterValue ) {\n\tconst matchTermsForFilter = ( originalTerm ) => {\n\t\tif ( '' === filterValue ) {\n\t\t\treturn originalTerm;\n\t\t}\n\n\t\t// Shallow clone, because we'll be filtering the term's children and\n\t\t// don't want to modify the original term.\n\t\tconst term = { ...originalTerm };\n\n\t\t// Map and filter the children, recursive so we deal with grandchildren\n\t\t// and any deeper levels.\n\t\tif ( term.children.length > 0 ) {\n\t\t\tterm.children = term.children\n\t\t\t\t.map( matchTermsForFilter )\n\t\t\t\t.filter( ( child ) => child );\n\t\t}\n\n\t\t// If the term's name contains the filterValue, or it has children\n\t\t// (i.e. some child matched at some point in the tree) then return it.\n\t\tif (\n\t\t\t-1 !==\n\t\t\t\tterm.name.toLowerCase().indexOf( filterValue.toLowerCase() ) ||\n\t\t\tterm.children.length > 0\n\t\t) {\n\t\t\treturn term;\n\t\t}\n\n\t\t// Otherwise, return false. After mapping, the list of terms will need\n\t\t// to have false values filtered out.\n\t\treturn false;\n\t};\n\treturn matchTermsForFilter;\n}\n\n/**\n * Hierarchical term selector.\n *\n * @param {Object} props Component props.\n * @param {string} props.slug Taxonomy slug.\n * @return {WPElement} Hierarchical term selector component.\n */\nfunction HierarchicalTermSelector( { slug } ) {\n\tconst [ adding, setAdding ] = useState( false );\n\tconst [ formName, setFormName ] = useState( '' );\n\t/**\n\t * @type {[number|'', Function]}\n\t */\n\tconst [ formParent, setFormParent ] = useState( '' );\n\tconst [ showForm, setShowForm ] = useState( false );\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ filteredTermsTree, setFilteredTermsTree ] = useState( [] );\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst {\n\t\thasCreateAction,\n\t\thasAssignAction,\n\t\tterms,\n\t\tloading,\n\t\tavailableTerms,\n\t\ttaxonomy,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } = select(\n\t\t\t\teditorStore\n\t\t\t);\n\t\t\tconst { getTaxonomy, getEntityRecords, isResolving } = select(\n\t\t\t\tcoreStore\n\t\t\t);\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tgetCurrentPost(),\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tgetCurrentPost(),\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\tterms: _taxonomy\n\t\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\tloading: isResolving( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tDEFAULT_QUERY,\n\t\t\t\t] ),\n\t\t\t\tavailableTerms:\n\t\t\t\t\tgetEntityRecords( 'taxonomy', slug, DEFAULT_QUERY ) ||\n\t\t\t\t\tEMPTY_ARRAY,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tconst availableTermsTree = useMemo(\n\t\t() => sortBySelected( buildTermsTree( availableTerms ), terms ),\n\t\t// Remove `terms` from the dependency list to avoid reordering every time\n\t\t// checking or unchecking a term.\n\t\t[ availableTerms ]\n\t);\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Append new term.\n\t *\n\t * @param {Object} term Term object.\n\t * @return {Promise} A promise that resolves to save term object.\n\t */\n\tconst addTerm = ( term ) => {\n\t\treturn saveEntityRecord( 'taxonomy', slug, term );\n\t};\n\n\t/**\n\t * Update terms for post.\n\t *\n\t * @param {number[]} termIds Term ids.\n\t */\n\tconst onUpdateTerms = ( termIds ) => {\n\t\teditPost( { [ taxonomy.rest_base ]: termIds } );\n\t};\n\n\t/**\n\t * Handler for checking term.\n\t *\n\t * @param {number} termId\n\t */\n\tconst onChange = ( termId ) => {\n\t\tconst hasTerm = terms.includes( termId );\n\t\tconst newTerms = hasTerm\n\t\t\t? without( terms, termId )\n\t\t\t: [ ...terms, termId ];\n\t\tonUpdateTerms( newTerms );\n\t};\n\n\tconst onChangeFormName = ( value ) => {\n\t\tsetFormName( value );\n\t};\n\n\t/**\n\t * Handler for changing form parent.\n\t *\n\t * @param {number|''} parentId Parent post id.\n\t */\n\tconst onChangeFormParent = ( parentId ) => {\n\t\tsetFormParent( parentId );\n\t};\n\n\tconst onToggleForm = () => {\n\t\tsetShowForm( ! showForm );\n\t};\n\n\tconst onAddTerm = async ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( formName === '' || adding ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// check if the term we are adding already exists\n\t\tconst existingTerm = findTerm( availableTerms, formParent, formName );\n\t\tif ( existingTerm ) {\n\t\t\t// if the term we are adding exists but is not selected select it\n\t\t\tif ( ! some( terms, ( term ) => term === existingTerm.id ) ) {\n\t\t\t\tonUpdateTerms( [ ...terms, existingTerm.id ] );\n\t\t\t}\n\n\t\t\tsetFormName( '' );\n\t\t\tsetFormParent( '' );\n\n\t\t\treturn;\n\t\t}\n\t\tsetAdding( true );\n\n\t\tconst newTerm = await addTerm( {\n\t\t\tname: formName,\n\t\t\tparent: formParent ? formParent : undefined,\n\t\t} );\n\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: taxonomy name */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\tget(\n\t\t\t\ttaxonomy,\n\t\t\t\t[ 'labels', 'singular_name' ],\n\t\t\t\tslug === 'category' ? __( 'Category' ) : __( 'Term' )\n\t\t\t)\n\t\t);\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tsetAdding( false );\n\t\tsetFormName( '' );\n\t\tsetFormParent( '' );\n\t\tonUpdateTerms( [ ...terms, newTerm.id ] );\n\t};\n\n\tconst setFilter = ( value ) => {\n\t\tconst newFilteredTermsTree = availableTermsTree\n\t\t\t.map( getFilterMatcher( value ) )\n\t\t\t.filter( ( term ) => term );\n\t\tconst getResultCount = ( termsTree ) => {\n\t\t\tlet count = 0;\n\t\t\tfor ( let i = 0; i < termsTree.length; i++ ) {\n\t\t\t\tcount++;\n\t\t\t\tif ( undefined !== termsTree[ i ].children ) {\n\t\t\t\t\tcount += getResultCount( termsTree[ i ].children );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn count;\n\t\t};\n\n\t\tsetFilterValue( value );\n\t\tsetFilteredTermsTree( newFilteredTermsTree );\n\n\t\tconst resultCount = getResultCount( newFilteredTermsTree );\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results */\n\t\t\t_n( '%d result found.', '%d results found.', resultCount ),\n\t\t\tresultCount\n\t\t);\n\n\t\tdebouncedSpeak( resultsFoundMessage, 'assertive' );\n\t};\n\n\tconst renderTerms = ( renderedTerms ) => {\n\t\treturn renderedTerms.map( ( term ) => {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tkey={ term.id }\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-choice\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tchecked={ terms.indexOf( term.id ) !== -1 }\n\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\tconst termId = parseInt( term.id, 10 );\n\t\t\t\t\t\t\tonChange( termId );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ unescapeString( term.name ) }\n\t\t\t\t\t/>\n\t\t\t\t\t{ !! term.children.length && (\n\t\t\t\t\t\t<div className=\"editor-post-taxonomies__hierarchical-terms-subchoices\">\n\t\t\t\t\t\t\t{ renderTerms( term.children ) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t);\n\t\t} );\n\t};\n\n\tconst labelWithFallback = (\n\t\tlabelProperty,\n\t\tfallbackIsCategory,\n\t\tfallbackIsNotCategory\n\t) =>\n\t\tget(\n\t\t\ttaxonomy,\n\t\t\t[ 'labels', labelProperty ],\n\t\t\tslug === 'category' ? fallbackIsCategory : fallbackIsNotCategory\n\t\t);\n\tconst newTermButtonLabel = labelWithFallback(\n\t\t'add_new_item',\n\t\t__( 'Add new category' ),\n\t\t__( 'Add new term' )\n\t);\n\tconst newTermLabel = labelWithFallback(\n\t\t'new_item_name',\n\t\t__( 'Add new category' ),\n\t\t__( 'Add new term' )\n\t);\n\tconst parentSelectLabel = labelWithFallback(\n\t\t'parent_item',\n\t\t__( 'Parent Category' ),\n\t\t__( 'Parent Term' )\n\t);\n\tconst noParentOption = `— ${ parentSelectLabel } —`;\n\tconst newTermSubmitLabel = newTermButtonLabel;\n\tconst filterLabel = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'search_items' ],\n\t\t__( 'Search Terms' )\n\t);\n\tconst groupLabel = get( taxonomy, [ 'name' ], __( 'Terms' ) );\n\tconst showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;\n\n\treturn (\n\t\t<>\n\t\t\t{ showFilter && (\n\t\t\t\t<TextControl\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-filter\"\n\t\t\t\t\tlabel={ filterLabel }\n\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\tonChange={ setFilter }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div\n\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-list\"\n\t\t\t\ttabIndex=\"0\"\n\t\t\t\trole=\"group\"\n\t\t\t\taria-label={ groupLabel }\n\t\t\t>\n\t\t\t\t{ renderTerms(\n\t\t\t\t\t'' !== filterValue ? filteredTermsTree : availableTermsTree\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ ! loading && hasCreateAction && (\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ onToggleForm }\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-add\"\n\t\t\t\t\taria-expanded={ showForm }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t>\n\t\t\t\t\t{ newTermButtonLabel }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ showForm && (\n\t\t\t\t<form onSubmit={ onAddTerm }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-input\"\n\t\t\t\t\t\tlabel={ newTermLabel }\n\t\t\t\t\t\tvalue={ formName }\n\t\t\t\t\t\tonChange={ onChangeFormName }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t\t{ !! availableTerms.length && (\n\t\t\t\t\t\t<TreeSelect\n\t\t\t\t\t\t\tlabel={ parentSelectLabel }\n\t\t\t\t\t\t\tnoOptionLabel={ noParentOption }\n\t\t\t\t\t\t\tonChange={ onChangeFormParent }\n\t\t\t\t\t\t\tselectedId={ formParent }\n\t\t\t\t\t\t\ttree={ availableTermsTree }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-submit\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ newTermSubmitLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</form>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )(\n\tHierarchicalTermSelector\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/hierarchical-term-selector.js"],"names":["DEFAULT_QUERY","per_page","orderby","order","_fields","context","MIN_TERMS_COUNT_FOR_FILTER","EMPTY_ARRAY","sortBySelected","termsTree","terms","treeHasSelection","termTree","indexOf","id","undefined","children","map","filter","child","length","termOrChildIsSelected","termA","termB","termASelected","termBSelected","newTermTree","sort","findTerm","parent","name","term","parseInt","toLowerCase","getFilterMatcher","filterValue","matchTermsForFilter","originalTerm","HierarchicalTermSelector","slug","adding","setAdding","formName","setFormName","formParent","setFormParent","showForm","setShowForm","setFilterValue","filteredTermsTree","setFilteredTermsTree","debouncedSpeak","speak","hasCreateAction","hasAssignAction","loading","availableTerms","taxonomy","select","getCurrentPost","getEditedPostAttribute","editorStore","getTaxonomy","getEntityRecords","isResolving","coreStore","_taxonomy","rest_base","editPost","saveEntityRecord","availableTermsTree","addTerm","onUpdateTerms","termIds","onChange","termId","hasTerm","includes","newTerms","onChangeFormName","value","onChangeFormParent","parentId","onToggleForm","onAddTerm","event","preventDefault","existingTerm","newTerm","termAddedMessage","setFilter","newFilteredTermsTree","getResultCount","count","i","resultCount","resultsFoundMessage","renderTerms","renderedTerms","labelWithFallback","labelProperty","fallbackIsCategory","fallbackIsNotCategory","newTermButtonLabel","newTermLabel","parentSelectLabel","noParentOption","newTermSubmitLabel","filterLabel","groupLabel","showFilter"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAOA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAE,CAAC,CADU;AAErBC,EAAAA,OAAO,EAAE,MAFY;AAGrBC,EAAAA,KAAK,EAAE,KAHc;AAIrBC,EAAAA,OAAO,EAAE,gBAJY;AAKrBC,EAAAA,OAAO,EAAE;AALY,CAAtB;AAQA,MAAMC,0BAA0B,GAAG,CAAnC;AAEA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,cAAT,CAAyBC,SAAzB,EAAoCC,KAApC,EAA4C;AAClD,QAAMC,gBAAgB,GAAKC,QAAF,IAAgB;AACxC,QAAKF,KAAK,CAACG,OAAN,CAAeD,QAAQ,CAACE,EAAxB,MAAiC,CAAC,CAAvC,EAA2C;AAC1C,aAAO,IAAP;AACA;;AACD,QAAKC,SA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wBADc,C","sourcesContent":["/**\n * External dependencies\n */\nimport { find, get, some, unescape as unescapeString, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, _x, sprintf } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tTextControl,\n\tTreeSelect,\n\twithFilters,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useDebounce } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module Constants\n */\nconst DEFAULT_QUERY = {\n\tper_page: -1,\n\torderby: 'name',\n\torder: 'asc',\n\t_fields: 'id,name,parent',\n\tcontext: 'view',\n};\n\nconst MIN_TERMS_COUNT_FOR_FILTER = 8;\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Sort Terms by Selected.\n *\n * @param {Object[]} termsTree Array of terms in tree format.\n * @param {number[]} terms Selected terms.\n *\n * @return {Object[]} Sorted array of terms.\n */\nexport function sortBySelected( termsTree, terms ) {\n\tconst treeHasSelection = ( termTree ) => {\n\t\tif ( terms.indexOf( termTree.id ) !== -1 ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( undefined === termTree.children ) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\ttermTree.children\n\t\t\t\t.map( treeHasSelection )\n\t\t\t\t.filter( ( child ) => child ).length > 0\n\t\t);\n\t};\n\tconst termOrChildIsSelected = ( termA, termB ) => {\n\t\tconst termASelected = treeHasSelection( termA );\n\t\tconst termBSelected = treeHasSelection( termB );\n\n\t\tif ( termASelected === termBSelected ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tif ( termASelected && ! termBSelected ) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif ( ! termASelected && termBSelected ) {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn 0;\n\t};\n\tconst newTermTree = [ ...termsTree ];\n\tnewTermTree.sort( termOrChildIsSelected );\n\treturn newTermTree;\n}\n\n/**\n * Find term by parent id or name.\n *\n * @param {Object[]} terms Array of Terms.\n * @param {number|string} parent id.\n * @param {string} name Term name.\n * @return {Object} Term object.\n */\nexport function findTerm( terms, parent, name ) {\n\treturn find( terms, ( term ) => {\n\t\treturn (\n\t\t\t( ( ! term.parent && ! parent ) ||\n\t\t\t\tparseInt( term.parent ) === parseInt( parent ) ) &&\n\t\t\tterm.name.toLowerCase() === name.toLowerCase()\n\t\t);\n\t} );\n}\n\n/**\n * Get filter matcher function.\n *\n * @param {string} filterValue Filter value.\n * @return {(function(Object): (Object|boolean))} Matcher function.\n */\nexport function getFilterMatcher( filterValue ) {\n\tconst matchTermsForFilter = ( originalTerm ) => {\n\t\tif ( '' === filterValue ) {\n\t\t\treturn originalTerm;\n\t\t}\n\n\t\t// Shallow clone, because we'll be filtering the term's children and\n\t\t// don't want to modify the original term.\n\t\tconst term = { ...originalTerm };\n\n\t\t// Map and filter the children, recursive so we deal with grandchildren\n\t\t// and any deeper levels.\n\t\tif ( term.children.length > 0 ) {\n\t\t\tterm.children = term.children\n\t\t\t\t.map( matchTermsForFilter )\n\t\t\t\t.filter( ( child ) => child );\n\t\t}\n\n\t\t// If the term's name contains the filterValue, or it has children\n\t\t// (i.e. some child matched at some point in the tree) then return it.\n\t\tif (\n\t\t\t-1 !==\n\t\t\t\tterm.name.toLowerCase().indexOf( filterValue.toLowerCase() ) ||\n\t\t\tterm.children.length > 0\n\t\t) {\n\t\t\treturn term;\n\t\t}\n\n\t\t// Otherwise, return false. After mapping, the list of terms will need\n\t\t// to have false values filtered out.\n\t\treturn false;\n\t};\n\treturn matchTermsForFilter;\n}\n\n/**\n * Hierarchical term selector.\n *\n * @param {Object} props Component props.\n * @param {string} props.slug Taxonomy slug.\n * @return {WPElement} Hierarchical term selector component.\n */\nfunction HierarchicalTermSelector( { slug } ) {\n\tconst [ adding, setAdding ] = useState( false );\n\tconst [ formName, setFormName ] = useState( '' );\n\t/**\n\t * @type {[number|'', Function]}\n\t */\n\tconst [ formParent, setFormParent ] = useState( '' );\n\tconst [ showForm, setShowForm ] = useState( false );\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ filteredTermsTree, setFilteredTermsTree ] = useState( [] );\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst {\n\t\thasCreateAction,\n\t\thasAssignAction,\n\t\tterms,\n\t\tloading,\n\t\tavailableTerms,\n\t\ttaxonomy,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } = select(\n\t\t\t\teditorStore\n\t\t\t);\n\t\t\tconst { getTaxonomy, getEntityRecords, isResolving } = select(\n\t\t\t\tcoreStore\n\t\t\t);\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tgetCurrentPost(),\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tgetCurrentPost(),\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\tterms: _taxonomy\n\t\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\tloading: isResolving( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tDEFAULT_QUERY,\n\t\t\t\t] ),\n\t\t\t\tavailableTerms:\n\t\t\t\t\tgetEntityRecords( 'taxonomy', slug, DEFAULT_QUERY ) ||\n\t\t\t\t\tEMPTY_ARRAY,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tconst availableTermsTree = useMemo(\n\t\t() => sortBySelected( buildTermsTree( availableTerms ), terms ),\n\t\t// Remove `terms` from the dependency list to avoid reordering every time\n\t\t// checking or unchecking a term.\n\t\t[ availableTerms ]\n\t);\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Append new term.\n\t *\n\t * @param {Object} term Term object.\n\t * @return {Promise} A promise that resolves to save term object.\n\t */\n\tconst addTerm = ( term ) => {\n\t\treturn saveEntityRecord( 'taxonomy', slug, term );\n\t};\n\n\t/**\n\t * Update terms for post.\n\t *\n\t * @param {number[]} termIds Term ids.\n\t */\n\tconst onUpdateTerms = ( termIds ) => {\n\t\teditPost( { [ taxonomy.rest_base ]: termIds } );\n\t};\n\n\t/**\n\t * Handler for checking term.\n\t *\n\t * @param {number} termId\n\t */\n\tconst onChange = ( termId ) => {\n\t\tconst hasTerm = terms.includes( termId );\n\t\tconst newTerms = hasTerm\n\t\t\t? without( terms, termId )\n\t\t\t: [ ...terms, termId ];\n\t\tonUpdateTerms( newTerms );\n\t};\n\n\tconst onChangeFormName = ( value ) => {\n\t\tsetFormName( value );\n\t};\n\n\t/**\n\t * Handler for changing form parent.\n\t *\n\t * @param {number|''} parentId Parent post id.\n\t */\n\tconst onChangeFormParent = ( parentId ) => {\n\t\tsetFormParent( parentId );\n\t};\n\n\tconst onToggleForm = () => {\n\t\tsetShowForm( ! showForm );\n\t};\n\n\tconst onAddTerm = async ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( formName === '' || adding ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if the term we are adding already exists.\n\t\tconst existingTerm = findTerm( availableTerms, formParent, formName );\n\t\tif ( existingTerm ) {\n\t\t\t// If the term we are adding exists but is not selected select it.\n\t\t\tif ( ! some( terms, ( term ) => term === existingTerm.id ) ) {\n\t\t\t\tonUpdateTerms( [ ...terms, existingTerm.id ] );\n\t\t\t}\n\n\t\t\tsetFormName( '' );\n\t\t\tsetFormParent( '' );\n\n\t\t\treturn;\n\t\t}\n\t\tsetAdding( true );\n\n\t\tconst newTerm = await addTerm( {\n\t\t\tname: formName,\n\t\t\tparent: formParent ? formParent : undefined,\n\t\t} );\n\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: taxonomy name */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\tget(\n\t\t\t\ttaxonomy,\n\t\t\t\t[ 'labels', 'singular_name' ],\n\t\t\t\tslug === 'category' ? __( 'Category' ) : __( 'Term' )\n\t\t\t)\n\t\t);\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tsetAdding( false );\n\t\tsetFormName( '' );\n\t\tsetFormParent( '' );\n\t\tonUpdateTerms( [ ...terms, newTerm.id ] );\n\t};\n\n\tconst setFilter = ( value ) => {\n\t\tconst newFilteredTermsTree = availableTermsTree\n\t\t\t.map( getFilterMatcher( value ) )\n\t\t\t.filter( ( term ) => term );\n\t\tconst getResultCount = ( termsTree ) => {\n\t\t\tlet count = 0;\n\t\t\tfor ( let i = 0; i < termsTree.length; i++ ) {\n\t\t\t\tcount++;\n\t\t\t\tif ( undefined !== termsTree[ i ].children ) {\n\t\t\t\t\tcount += getResultCount( termsTree[ i ].children );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn count;\n\t\t};\n\n\t\tsetFilterValue( value );\n\t\tsetFilteredTermsTree( newFilteredTermsTree );\n\n\t\tconst resultCount = getResultCount( newFilteredTermsTree );\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results */\n\t\t\t_n( '%d result found.', '%d results found.', resultCount ),\n\t\t\tresultCount\n\t\t);\n\n\t\tdebouncedSpeak( resultsFoundMessage, 'assertive' );\n\t};\n\n\tconst renderTerms = ( renderedTerms ) => {\n\t\treturn renderedTerms.map( ( term ) => {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tkey={ term.id }\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-choice\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tchecked={ terms.indexOf( term.id ) !== -1 }\n\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\tconst termId = parseInt( term.id, 10 );\n\t\t\t\t\t\t\tonChange( termId );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ unescapeString( term.name ) }\n\t\t\t\t\t/>\n\t\t\t\t\t{ !! term.children.length && (\n\t\t\t\t\t\t<div className=\"editor-post-taxonomies__hierarchical-terms-subchoices\">\n\t\t\t\t\t\t\t{ renderTerms( term.children ) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t);\n\t\t} );\n\t};\n\n\tconst labelWithFallback = (\n\t\tlabelProperty,\n\t\tfallbackIsCategory,\n\t\tfallbackIsNotCategory\n\t) =>\n\t\tget(\n\t\t\ttaxonomy,\n\t\t\t[ 'labels', labelProperty ],\n\t\t\tslug === 'category' ? fallbackIsCategory : fallbackIsNotCategory\n\t\t);\n\tconst newTermButtonLabel = labelWithFallback(\n\t\t'add_new_item',\n\t\t__( 'Add new category' ),\n\t\t__( 'Add new term' )\n\t);\n\tconst newTermLabel = labelWithFallback(\n\t\t'new_item_name',\n\t\t__( 'Add new category' ),\n\t\t__( 'Add new term' )\n\t);\n\tconst parentSelectLabel = labelWithFallback(\n\t\t'parent_item',\n\t\t__( 'Parent Category' ),\n\t\t__( 'Parent Term' )\n\t);\n\tconst noParentOption = `— ${ parentSelectLabel } —`;\n\tconst newTermSubmitLabel = newTermButtonLabel;\n\tconst filterLabel = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'search_items' ],\n\t\t__( 'Search Terms' )\n\t);\n\tconst groupLabel = get( taxonomy, [ 'name' ], __( 'Terms' ) );\n\tconst showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;\n\n\treturn (\n\t\t<>\n\t\t\t{ showFilter && (\n\t\t\t\t<TextControl\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-filter\"\n\t\t\t\t\tlabel={ filterLabel }\n\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\tonChange={ setFilter }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div\n\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-list\"\n\t\t\t\ttabIndex=\"0\"\n\t\t\t\trole=\"group\"\n\t\t\t\taria-label={ groupLabel }\n\t\t\t>\n\t\t\t\t{ renderTerms(\n\t\t\t\t\t'' !== filterValue ? filteredTermsTree : availableTermsTree\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ ! loading && hasCreateAction && (\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ onToggleForm }\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-add\"\n\t\t\t\t\taria-expanded={ showForm }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t>\n\t\t\t\t\t{ newTermButtonLabel }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ showForm && (\n\t\t\t\t<form onSubmit={ onAddTerm }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-input\"\n\t\t\t\t\t\tlabel={ newTermLabel }\n\t\t\t\t\t\tvalue={ formName }\n\t\t\t\t\t\tonChange={ onChangeFormName }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t\t{ !! availableTerms.length && (\n\t\t\t\t\t\t<TreeSelect\n\t\t\t\t\t\t\tlabel={ parentSelectLabel }\n\t\t\t\t\t\t\tnoOptionLabel={ noParentOption }\n\t\t\t\t\t\t\tonChange={ onChangeFormParent }\n\t\t\t\t\t\t\tselectedId={ formParent }\n\t\t\t\t\t\t\ttree={ availableTermsTree }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-submit\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ newTermSubmitLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</form>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )(\n\tHierarchicalTermSelector\n);\n"]}
@@ -51,7 +51,7 @@ class PostTitle extends _element.Component {
51
51
  }
52
52
 
53
53
  componentDidUpdate(prevProps) {
54
- // Unselect if any other block is selected and blur the RichText
54
+ // Unselect if any other block is selected and blur the RichText.
55
55
  if (this.props.isSelected && !prevProps.isAnyBlockSelected && this.props.isAnyBlockSelected) {
56
56
  if (this.richTextRef) {
57
57
  this.richTextRef.blur();
@@ -147,7 +147,7 @@ class PostTitle extends _element.Component {
147
147
  tagName: 'p',
148
148
  tagsToEliminate: ['strong'],
149
149
  unstableOnFocus: this.props.onSelect,
150
- onBlur: this.props.onBlur // always assign onBlur as a props
150
+ onBlur: this.props.onBlur // Always assign onBlur as a props.
151
151
  ,
152
152
  multiline: false,
153
153
  style: titleStyles,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-title/index.native.js"],"names":["PostTitle","Component","constructor","props","setRef","bind","componentDidUpdate","prevProps","isSelected","isAnyBlockSelected","richTextRef","blur","onUnselect","componentDidMount","innerRef","handleFocusOutside","focus","onSelect","onPaste","value","onChange","plainText","content","mode","tagName","valueToInsert","html","richText","getTitle","title","postType","render","placeholder","style","focusedBorderColor","borderStyle","isDimmed","globalStyles","decodedPlaceholder","borderColor","titleStyles","text","color","placeholderColor","styles","titleContainer","dimmed","onBlur","onUpdate","onEnterPress","select","isPostTitleSelected","getEditedPostAttribute","editorStore","getSelectedBlockClientId","getBlockRootClientId","getSettings","blockEditorStore","selectedId","selectionIsNested","__experimentalGlobalStylesBaseStyles","dispatch","undo","redo","togglePostTitleSelection","clearSelectedBlock","insertDefaultBlock","undefined","onUndo","onRedo","withInstanceId","withFocusOutside"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AA3BA;AACA;AACA;;AAIA;AACA;AACA;;AAgBA;AACA;AACA;AAGA,MAAMA,SAAN,SAAwBC,kBAAxB,CAAkC;AACjCC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AAEA,SAAKC,MAAL,GAAc,KAAKA,MAAL,CAAYC,IAAZ,CAAkB,IAAlB,CAAd;AACA;;AACDC,EAAAA,kBAAkB,CAAEC,SAAF,EAAc;AAC/B;AACA,QACC,KAAKJ,KAAL,CAAWK,UAAX,IACA,CAAED,SAAS,CAACE,kBADZ,IAEA,KAAKN,KAAL,CAAWM,kBAHZ,EAIE;AACD,UAAK,KAAKC,WAAV,EAAwB;AACvB,aAAKA,WAAL,CAAiBC,IAAjB;AACA;;AACD,WAAKR,KAAL,CAAWS,UAAX;AACA;AACD;;AAEDC,EAAAA,iBAAiB,GAAG;AACnB,QAAK,KAAKV,KAAL,CAAWW,QAAhB,EAA2B;AAC1B,WAAKX,KAAL,CAAWW,QAAX,CAAqB,IAArB;AACA;AACD;;AAEDC,EAAAA,kBAAkB,GAAG;AACpB,SAAKZ,KAAL,CAAWS,UAAX;AACA;;AAEDI,EAAAA,KAAK,GAAG;AACP,SAAKb,KAAL,CAAWc,QAAX;AACA;;AAEDC,EAAAA,OAAO,OAAmC;AAAA,QAAjC;AAAEC,MAAAA,KAAF;AAASC,MAAAA,QAAT;AAAm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YAAY,GAAG;AACdiB,MAAAA,kBAAkB,CAAEC,SAAF,EAAaA,SAAb,EAAwB,CAAxB,CAAlB;AACA,KAHK;;AAINC,IAAAA,MAAM,EAAEN,IAJF;AAKNO,IAAAA,MAAM,EAAEN,IALF;;AAMN9C,IAAAA,QAAQ,GAAG;AACV+C,MAAAA,wBAAwB,CAAE,IAAF,CAAxB;AACAC,MAAAA,kBAAkB;AAClB,KATK;;AAUNrD,IAAAA,UAAU,GAAG;AACZoD,MAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA;;AAZK,GAAP;AAcA,CAvBD,CAxBc,EAgDdM,uBAhDc,EAiDdC,4BAjDc,EAkDZvE,SAlDY,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport {\n\t__experimentalRichText as RichText,\n\tcreate,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { withFocusOutside } from '@wordpress/components';\nimport { withInstanceId, compose } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nclass PostTitle extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.setRef = this.setRef.bind( this );\n\t}\n\tcomponentDidUpdate( prevProps ) {\n\t\t// Unselect if any other block is selected and blur the RichText\n\t\tif (\n\t\t\tthis.props.isSelected &&\n\t\t\t! prevProps.isAnyBlockSelected &&\n\t\t\tthis.props.isAnyBlockSelected\n\t\t) {\n\t\t\tif ( this.richTextRef ) {\n\t\t\t\tthis.richTextRef.blur();\n\t\t\t}\n\t\t\tthis.props.onUnselect();\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.innerRef ) {\n\t\t\tthis.props.innerRef( this );\n\t\t}\n\t}\n\n\thandleFocusOutside() {\n\t\tthis.props.onUnselect();\n\t}\n\n\tfocus() {\n\t\tthis.props.onSelect();\n\t}\n\n\tonPaste( { value, onChange, plainText } ) {\n\t\tconst content = pasteHandler( {\n\t\t\tplainText,\n\t\t\tmode: 'INLINE',\n\t\t\ttagName: 'p',\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t}\n\t}\n\n\tsetRef( richText ) {\n\t\tthis.richTextRef = richText;\n\t}\n\n\tgetTitle( title, postType ) {\n\t\tif ( 'page' === postType ) {\n\t\t\treturn isEmpty( title )\n\t\t\t\t? /* translators: accessibility text. empty page title. */\n\t\t\t\t __( 'Page title. Empty' )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: text content of the page title. */\n\t\t\t\t\t\t__( 'Page title. %s' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t );\n\t\t}\n\n\t\treturn isEmpty( title )\n\t\t\t? /* translators: accessibility text. empty post title. */\n\t\t\t __( 'Post title. Empty' )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: accessibility text. %s: text content of the post title. */\n\t\t\t\t\t__( 'Post title. %s' ),\n\t\t\t\t\ttitle\n\t\t\t );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tplaceholder,\n\t\t\tstyle,\n\t\t\ttitle,\n\t\t\tfocusedBorderColor,\n\t\t\tborderStyle,\n\t\t\tisDimmed,\n\t\t\tpostType,\n\t\t\tglobalStyles,\n\t\t} = this.props;\n\n\t\tconst decodedPlaceholder = decodeEntities( placeholder );\n\t\tconst borderColor = this.props.isSelected\n\t\t\t? focusedBorderColor\n\t\t\t: 'transparent';\n\t\tconst titleStyles = {\n\t\t\t...style,\n\t\t\t...( globalStyles?.text && {\n\t\t\t\tcolor: globalStyles.text,\n\t\t\t\tplaceholderColor: globalStyles.text,\n\t\t\t} ),\n\t\t};\n\n\t\treturn (\n\t\t\t<View\n\t\t\t\tstyle={ [\n\t\t\t\t\tstyles.titleContainer,\n\t\t\t\t\tborderStyle,\n\t\t\t\t\t{ borderColor },\n\t\t\t\t\tisDimmed && styles.dimmed,\n\t\t\t\t] }\n\t\t\t\taccessible={ ! this.props.isSelected }\n\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\taccessibilityHint={ __( 'Updates the title.' ) }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tsetRef={ this.setRef }\n\t\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\t\ttagName={ 'p' }\n\t\t\t\t\ttagsToEliminate={ [ 'strong' ] }\n\t\t\t\t\tunstableOnFocus={ this.props.onSelect }\n\t\t\t\t\tonBlur={ this.props.onBlur } // always assign onBlur as a props\n\t\t\t\t\tmultiline={ false }\n\t\t\t\t\tstyle={ titleStyles }\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tfontSize={ 24 }\n\t\t\t\t\tlineHeight={ 1 }\n\t\t\t\t\tfontWeight={ 'bold' }\n\t\t\t\t\tdeleteEnter={ true }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tthis.props.onUpdate( value );\n\t\t\t\t\t} }\n\t\t\t\t\tonPaste={ this.onPaste }\n\t\t\t\t\tplaceholder={ decodedPlaceholder }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonSelectionChange={ () => {} }\n\t\t\t\t\tonEnter={ this.props.onEnterPress }\n\t\t\t\t\tdisableEditingMenu={ true }\n\t\t\t\t\t__unstableIsSelected={ this.props.isSelected }\n\t\t\t\t\t__unstableOnCreateUndoLevel={ () => {} }\n\t\t\t\t></RichText>\n\t\t\t</View>\n\t\t);\n\t}\n}\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst { isPostTitleSelected, getEditedPostAttribute } = select(\n\t\t\teditorStore\n\t\t);\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst selectedId = getSelectedBlockClientId();\n\t\tconst selectionIsNested = !! getBlockRootClientId( selectedId );\n\t\tconst globalStyles = getSettings()?.__experimentalGlobalStylesBaseStyles\n\t\t\t?.color;\n\n\t\treturn {\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t\tisAnyBlockSelected: !! selectedId,\n\t\t\tisSelected: isPostTitleSelected(),\n\t\t\tisDimmed: selectionIsNested,\n\t\t\tglobalStyles,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { undo, redo, togglePostTitleSelection } = dispatch(\n\t\t\teditorStore\n\t\t);\n\n\t\tconst { clearSelectedBlock, insertDefaultBlock } = dispatch(\n\t\t\tblockEditorStore\n\t\t);\n\n\t\treturn {\n\t\t\tonEnterPress() {\n\t\t\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t\t\t},\n\t\t\tonUndo: undo,\n\t\t\tonRedo: redo,\n\t\t\tonSelect() {\n\t\t\t\ttogglePostTitleSelection( true );\n\t\t\t\tclearSelectedBlock();\n\t\t\t},\n\t\t\tonUnselect() {\n\t\t\t\ttogglePostTitleSelection( false );\n\t\t\t},\n\t\t};\n\t} ),\n\twithInstanceId,\n\twithFocusOutside\n)( PostTitle );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-title/index.native.js"],"names":["PostTitle","Component","constructor","props","setRef","bind","componentDidUpdate","prevProps","isSelected","isAnyBlockSelected","richTextRef","blur","onUnselect","componentDidMount","innerRef","handleFocusOutside","focus","onSelect","onPaste","value","onChange","plainText","content","mode","tagName","valueToInsert","html","richText","getTitle","title","postType","render","placeholder","style","focusedBorderColor","borderStyle","isDimmed","globalStyles","decodedPlaceholder","borderColor","titleStyles","text","color","placeholderColor","styles","titleContainer","dimmed","onBlur","onUpdate","onEnterPress","select","isPostTitleSelected","getEditedPostAttribute","editorStore","getSelectedBlockClientId","getBlockRootClientId","getSettings","blockEditorStore","selectedId","selectionIsNested","__experimentalGlobalStylesBaseStyles","dispatch","undo","redo","togglePostTitleSelection","clearSelectedBlock","insertDefaultBlock","undefined","onUndo","onRedo","withInstanceId","withFocusOutside"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AA3BA;AACA;AACA;;AAIA;AACA;AACA;;AAgBA;AACA;AACA;AAGA,MAAMA,SAAN,SAAwBC,kBAAxB,CAAkC;AACjCC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AAEA,SAAKC,MAAL,GAAc,KAAKA,MAAL,CAAYC,IAAZ,CAAkB,IAAlB,CAAd;AACA;;AACDC,EAAAA,kBAAkB,CAAEC,SAAF,EAAc;AAC/B;AACA,QACC,KAAKJ,KAAL,CAAWK,UAAX,IACA,CAAED,SAAS,CAACE,kBADZ,IAEA,KAAKN,KAAL,CAAWM,kBAHZ,EAIE;AACD,UAAK,KAAKC,WAAV,EAAwB;AACvB,aAAKA,WAAL,CAAiBC,IAAjB;AACA;;AACD,WAAKR,KAAL,CAAWS,UAAX;AACA;AACD;;AAEDC,EAAAA,iBAAiB,GAAG;AACnB,QAAK,KAAKV,KAAL,CAAWW,QAAhB,EAA2B;AAC1B,WAAKX,KAAL,CAAWW,QAAX,CAAqB,IAArB;AACA;AACD;;AAEDC,EAAAA,kBAAkB,GAAG;AACpB,SAAKZ,KAAL,CAAWS,UAAX;AACA;;AAEDI,EAAAA,KAAK,GAAG;AACP,SAAKb,KAAL,CAAWc,QAAX;AACA;;AAEDC,EAAAA,OAAO,OAAmC;AAAA,QAAjC;AAAEC,MAAAA,KAAF;AAASC,MAAAA,QAAT;AAAmBC,MAAAA;AAAnB,KAAiC;AACzC,UAAMC,OAAO,GAAG,0BAAc;A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b,EAAwB,CAAxB,CAAlB;AACA,KAHK;;AAINC,IAAAA,MAAM,EAAEN,IAJF;AAKNO,IAAAA,MAAM,EAAEN,IALF;;AAMN9C,IAAAA,QAAQ,GAAG;AACV+C,MAAAA,wBAAwB,CAAE,IAAF,CAAxB;AACAC,MAAAA,kBAAkB;AAClB,KATK;;AAUNrD,IAAAA,UAAU,GAAG;AACZoD,MAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA;;AAZK,GAAP;AAcA,CAvBD,CAxBc,EAgDdM,uBAhDc,EAiDdC,4BAjDc,EAkDZvE,SAlDY,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport {\n\t__experimentalRichText as RichText,\n\tcreate,\n\tinsert,\n} from '@wordpress/rich-text';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { withFocusOutside } from '@wordpress/components';\nimport { withInstanceId, compose } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nclass PostTitle extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.setRef = this.setRef.bind( this );\n\t}\n\tcomponentDidUpdate( prevProps ) {\n\t\t// Unselect if any other block is selected and blur the RichText.\n\t\tif (\n\t\t\tthis.props.isSelected &&\n\t\t\t! prevProps.isAnyBlockSelected &&\n\t\t\tthis.props.isAnyBlockSelected\n\t\t) {\n\t\t\tif ( this.richTextRef ) {\n\t\t\t\tthis.richTextRef.blur();\n\t\t\t}\n\t\t\tthis.props.onUnselect();\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.innerRef ) {\n\t\t\tthis.props.innerRef( this );\n\t\t}\n\t}\n\n\thandleFocusOutside() {\n\t\tthis.props.onUnselect();\n\t}\n\n\tfocus() {\n\t\tthis.props.onSelect();\n\t}\n\n\tonPaste( { value, onChange, plainText } ) {\n\t\tconst content = pasteHandler( {\n\t\t\tplainText,\n\t\t\tmode: 'INLINE',\n\t\t\ttagName: 'p',\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t}\n\t}\n\n\tsetRef( richText ) {\n\t\tthis.richTextRef = richText;\n\t}\n\n\tgetTitle( title, postType ) {\n\t\tif ( 'page' === postType ) {\n\t\t\treturn isEmpty( title )\n\t\t\t\t? /* translators: accessibility text. empty page title. */\n\t\t\t\t __( 'Page title. Empty' )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: text content of the page title. */\n\t\t\t\t\t\t__( 'Page title. %s' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t );\n\t\t}\n\n\t\treturn isEmpty( title )\n\t\t\t? /* translators: accessibility text. empty post title. */\n\t\t\t __( 'Post title. Empty' )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: accessibility text. %s: text content of the post title. */\n\t\t\t\t\t__( 'Post title. %s' ),\n\t\t\t\t\ttitle\n\t\t\t );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tplaceholder,\n\t\t\tstyle,\n\t\t\ttitle,\n\t\t\tfocusedBorderColor,\n\t\t\tborderStyle,\n\t\t\tisDimmed,\n\t\t\tpostType,\n\t\t\tglobalStyles,\n\t\t} = this.props;\n\n\t\tconst decodedPlaceholder = decodeEntities( placeholder );\n\t\tconst borderColor = this.props.isSelected\n\t\t\t? focusedBorderColor\n\t\t\t: 'transparent';\n\t\tconst titleStyles = {\n\t\t\t...style,\n\t\t\t...( globalStyles?.text && {\n\t\t\t\tcolor: globalStyles.text,\n\t\t\t\tplaceholderColor: globalStyles.text,\n\t\t\t} ),\n\t\t};\n\n\t\treturn (\n\t\t\t<View\n\t\t\t\tstyle={ [\n\t\t\t\t\tstyles.titleContainer,\n\t\t\t\t\tborderStyle,\n\t\t\t\t\t{ borderColor },\n\t\t\t\t\tisDimmed && styles.dimmed,\n\t\t\t\t] }\n\t\t\t\taccessible={ ! this.props.isSelected }\n\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\taccessibilityHint={ __( 'Updates the title.' ) }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tsetRef={ this.setRef }\n\t\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\t\ttagName={ 'p' }\n\t\t\t\t\ttagsToEliminate={ [ 'strong' ] }\n\t\t\t\t\tunstableOnFocus={ this.props.onSelect }\n\t\t\t\t\tonBlur={ this.props.onBlur } // Always assign onBlur as a props.\n\t\t\t\t\tmultiline={ false }\n\t\t\t\t\tstyle={ titleStyles }\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tfontSize={ 24 }\n\t\t\t\t\tlineHeight={ 1 }\n\t\t\t\t\tfontWeight={ 'bold' }\n\t\t\t\t\tdeleteEnter={ true }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tthis.props.onUpdate( value );\n\t\t\t\t\t} }\n\t\t\t\t\tonPaste={ this.onPaste }\n\t\t\t\t\tplaceholder={ decodedPlaceholder }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonSelectionChange={ () => {} }\n\t\t\t\t\tonEnter={ this.props.onEnterPress }\n\t\t\t\t\tdisableEditingMenu={ true }\n\t\t\t\t\t__unstableIsSelected={ this.props.isSelected }\n\t\t\t\t\t__unstableOnCreateUndoLevel={ () => {} }\n\t\t\t\t></RichText>\n\t\t\t</View>\n\t\t);\n\t}\n}\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst { isPostTitleSelected, getEditedPostAttribute } = select(\n\t\t\teditorStore\n\t\t);\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst selectedId = getSelectedBlockClientId();\n\t\tconst selectionIsNested = !! getBlockRootClientId( selectedId );\n\t\tconst globalStyles = getSettings()?.__experimentalGlobalStylesBaseStyles\n\t\t\t?.color;\n\n\t\treturn {\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t\tisAnyBlockSelected: !! selectedId,\n\t\t\tisSelected: isPostTitleSelected(),\n\t\t\tisDimmed: selectionIsNested,\n\t\t\tglobalStyles,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { undo, redo, togglePostTitleSelection } = dispatch(\n\t\t\teditorStore\n\t\t);\n\n\t\tconst { clearSelectedBlock, insertDefaultBlock } = dispatch(\n\t\t\tblockEditorStore\n\t\t);\n\n\t\treturn {\n\t\t\tonEnterPress() {\n\t\t\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t\t\t},\n\t\t\tonUndo: undo,\n\t\t\tonRedo: redo,\n\t\t\tonSelect() {\n\t\t\t\ttogglePostTitleSelection( true );\n\t\t\t\tclearSelectedBlock();\n\t\t\t},\n\t\t\tonUnselect() {\n\t\t\t\ttogglePostTitleSelection( false );\n\t\t\t},\n\t\t};\n\t} ),\n\twithInstanceId,\n\twithFocusOutside\n)( PostTitle );\n"]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = PostTrash;
7
7
 
8
8
  var _element = require("@wordpress/element");
9
9
 
@@ -13,8 +13,6 @@ var _components = require("@wordpress/components");
13
13
 
14
14
  var _data = require("@wordpress/data");
15
15
 
16
- var _compose = require("@wordpress/compose");
17
-
18
16
  var _store = require("../../store");
19
17
 
20
18
  /**
@@ -24,42 +22,30 @@ var _store = require("../../store");
24
22
  /**
25
23
  * Internal dependencies
26
24
  */
27
- function PostTrash(_ref) {
28
- let {
25
+ function PostTrash() {
26
+ const {
29
27
  isNew,
30
- postId,
31
- postType,
32
- ...props
33
- } = _ref;
28
+ postId
29
+ } = (0, _data.useSelect)(select => {
30
+ const store = select(_store.store);
31
+ return {
32
+ isNew: store.isEditedPostNew(),
33
+ postId: store.getCurrentPostId()
34
+ };
35
+ }, []);
36
+ const {
37
+ trashPost
38
+ } = (0, _data.useDispatch)(_store.store);
34
39
 
35
40
  if (isNew || !postId) {
36
41
  return null;
37
42
  }
38
43
 
39
- const onClick = () => props.trashPost(postId, postType);
40
-
41
44
  return (0, _element.createElement)(_components.Button, {
42
45
  className: "editor-post-trash",
43
46
  isDestructive: true,
44
47
  variant: "secondary",
45
- onClick: onClick
48
+ onClick: () => trashPost()
46
49
  }, (0, _i18n.__)('Move to trash'));
47
50
  }
48
-
49
- var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
50
- const {
51
- isEditedPostNew,
52
- getCurrentPostId,
53
- getCurrentPostType
54
- } = select(_store.store);
55
- return {
56
- isNew: isEditedPostNew(),
57
- postId: getCurrentPostId(),
58
- postType: getCurrentPostType()
59
- };
60
- }), (0, _data.withDispatch)(dispatch => ({
61
- trashPost: dispatch(_store.store).trashPost
62
- }))])(PostTrash);
63
-
64
- exports.default = _default;
65
51
  //# sourceMappingURL=index.js.map