@wordpress/editor 11.0.2 → 12.0.3

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 (123) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -1
  3. package/build/components/autosave-monitor/index.js +5 -0
  4. package/build/components/autosave-monitor/index.js.map +1 -1
  5. package/build/components/character-count/index.js +1 -1
  6. package/build/components/character-count/index.js.map +1 -1
  7. package/build/components/editor-help/help-get-support-button.native.js +46 -0
  8. package/build/components/editor-help/help-get-support-button.native.js.map +1 -0
  9. package/build/components/editor-help/index.native.js +24 -5
  10. package/build/components/editor-help/index.native.js.map +1 -1
  11. package/build/components/entities-saved-states/entity-type-list.js +22 -13
  12. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  13. package/build/components/entities-saved-states/index.js +23 -4
  14. package/build/components/entities-saved-states/index.js.map +1 -1
  15. package/build/components/global-keyboard-shortcuts/save-shortcut.js +12 -14
  16. package/build/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
  17. package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -4
  18. package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +1 -1
  19. package/build/components/post-format/index.js +3 -1
  20. package/build/components/post-format/index.js.map +1 -1
  21. package/build/components/post-locked-modal/index.js +1 -1
  22. package/build/components/post-locked-modal/index.js.map +1 -1
  23. package/build/components/post-saved-state/index.js +37 -46
  24. package/build/components/post-saved-state/index.js.map +1 -1
  25. package/build/components/post-taxonomies/flat-term-selector.js +154 -211
  26. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  27. package/build/components/post-title/index.js +5 -3
  28. package/build/components/post-title/index.js.map +1 -1
  29. package/build/components/provider/index.native.js +3 -1
  30. package/build/components/provider/index.native.js.map +1 -1
  31. package/build/components/provider/use-block-editor-settings.js +32 -5
  32. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  33. package/build/components/word-count/index.js +1 -1
  34. package/build/components/word-count/index.js.map +1 -1
  35. package/build/store/actions.js +0 -25
  36. package/build/store/actions.js.map +1 -1
  37. package/build/store/selectors.js +3 -84
  38. package/build/store/selectors.js.map +1 -1
  39. package/build/store/utils/notice-builder.js +15 -18
  40. package/build/store/utils/notice-builder.js.map +1 -1
  41. package/build/{store/utils → utils}/get-template-part-icon.js +1 -1
  42. package/build/utils/get-template-part-icon.js.map +1 -0
  43. package/build/utils/index.js +8 -0
  44. package/build/utils/index.js.map +1 -1
  45. package/build-module/components/autosave-monitor/index.js +5 -0
  46. package/build-module/components/autosave-monitor/index.js.map +1 -1
  47. package/build-module/components/character-count/index.js +1 -1
  48. package/build-module/components/character-count/index.js.map +1 -1
  49. package/build-module/components/editor-help/help-get-support-button.native.js +34 -0
  50. package/build-module/components/editor-help/help-get-support-button.native.js.map +1 -0
  51. package/build-module/components/editor-help/index.native.js +22 -6
  52. package/build-module/components/editor-help/index.native.js.map +1 -1
  53. package/build-module/components/entities-saved-states/entity-type-list.js +24 -13
  54. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  55. package/build-module/components/entities-saved-states/index.js +23 -4
  56. package/build-module/components/entities-saved-states/index.js.map +1 -1
  57. package/build-module/components/global-keyboard-shortcuts/save-shortcut.js +12 -14
  58. package/build-module/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
  59. package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -4
  60. package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +1 -1
  61. package/build-module/components/post-format/index.js +4 -2
  62. package/build-module/components/post-format/index.js.map +1 -1
  63. package/build-module/components/post-locked-modal/index.js +1 -1
  64. package/build-module/components/post-locked-modal/index.js.map +1 -1
  65. package/build-module/components/post-saved-state/index.js +38 -46
  66. package/build-module/components/post-saved-state/index.js.map +1 -1
  67. package/build-module/components/post-taxonomies/flat-term-selector.js +156 -214
  68. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  69. package/build-module/components/post-title/index.js +5 -3
  70. package/build-module/components/post-title/index.js.map +1 -1
  71. package/build-module/components/provider/index.native.js +3 -1
  72. package/build-module/components/provider/index.native.js.map +1 -1
  73. package/build-module/components/provider/use-block-editor-settings.js +31 -5
  74. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  75. package/build-module/components/word-count/index.js +1 -1
  76. package/build-module/components/word-count/index.js.map +1 -1
  77. package/build-module/store/actions.js +0 -23
  78. package/build-module/store/actions.js.map +1 -1
  79. package/build-module/store/selectors.js +3 -80
  80. package/build-module/store/selectors.js.map +1 -1
  81. package/build-module/store/utils/notice-builder.js +15 -18
  82. package/build-module/store/utils/notice-builder.js.map +1 -1
  83. package/build-module/{store/utils → utils}/get-template-part-icon.js +2 -2
  84. package/build-module/utils/get-template-part-icon.js.map +1 -0
  85. package/build-module/utils/index.js +1 -0
  86. package/build-module/utils/index.js.map +1 -1
  87. package/build-style/style-rtl.css +6 -1
  88. package/build-style/style.css +6 -1
  89. package/package.json +28 -28
  90. package/src/components/autosave-monitor/index.js +5 -0
  91. package/src/components/autosave-monitor/test/index.js +10 -4
  92. package/src/components/character-count/index.js +3 -2
  93. package/src/components/editor-help/help-get-support-button.native.js +38 -0
  94. package/src/components/editor-help/index.native.js +130 -80
  95. package/src/components/editor-help/style.android.scss +6 -0
  96. package/src/components/editor-help/style.ios.scss +6 -0
  97. package/src/components/editor-help/style.scss +25 -0
  98. package/src/components/editor-help/test/index.native.js +80 -0
  99. package/src/components/entities-saved-states/entity-type-list.js +29 -10
  100. package/src/components/entities-saved-states/index.js +38 -8
  101. package/src/components/global-keyboard-shortcuts/save-shortcut.js +34 -42
  102. package/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +8 -16
  103. package/src/components/post-format/index.js +6 -2
  104. package/src/components/post-format/style.scss +1 -0
  105. package/src/components/post-locked-modal/index.js +1 -1
  106. package/src/components/post-saved-state/index.js +41 -55
  107. package/src/components/post-saved-state/style.scss +10 -1
  108. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +20 -0
  109. package/src/components/post-saved-state/test/index.js +2 -2
  110. package/src/components/post-taxonomies/flat-term-selector.js +220 -254
  111. package/src/components/post-title/index.js +5 -3
  112. package/src/components/provider/index.native.js +2 -0
  113. package/src/components/provider/use-block-editor-settings.js +24 -2
  114. package/src/components/word-count/index.js +3 -2
  115. package/src/store/actions.js +0 -28
  116. package/src/store/selectors.js +2 -105
  117. package/src/store/test/actions.js +4 -2
  118. package/src/store/utils/notice-builder.js +17 -19
  119. package/src/store/utils/test/notice-builder.js +1 -1
  120. package/src/{store/utils → utils}/get-template-part-icon.js +2 -2
  121. package/src/utils/index.js +1 -0
  122. package/build/store/utils/get-template-part-icon.js.map +0 -1
  123. package/build-module/store/utils/get-template-part-icon.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-locked-modal/index.js"],"names":["get","__","sprintf","Modal","Button","useSelect","useDispatch","addQueryArgs","useEffect","addAction","removeAction","useInstanceId","store","coreStore","getWPAdminURL","PostPreviewButton","editorStore","PostLockedModal","instanceId","hookName","autosave","updatePostLock","isLocked","isTakeover","user","postId","postLockUtils","activePostLock","postType","select","isPostLocked","isPostLockTakeover","getPostLockUser","getCurrentPostId","getActivePostLock","getEditedPostAttribute","getEditorSettings","getPostType","sendPostLock","data","lock","post_id","receivePostLock","received","lock_error","avatar","avatar_src","new_lock","releasePostLock","window","FormData","append","unlockNonce","navigator","sendBeacon","ajaxUrl","xhr","XMLHttpRequest","open","send","addEventListener","removeEventListener","userDisplayName","name","userAvatar","unlockUrl","lockKey","post","action","_wpnonce","nonce","allPostsUrl","post_type","allPostsLabel"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAT,EAAgBC,MAAhB,QAA8B,uBAA9B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iB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AA,EAAE,CACD,kGADC,CAFK,EAKP6D,eALO,CADO,GAQd7D,EAAE,CACF,4GADE,CATN,CADD,EAeC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,WAAhB;AAA4B,IAAA,IAAI,EAAGsE;AAAnC,KACGE,aADH,CADD,EAIC,cAAC,iBAAD,OAJD,EAKC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAGR;AAAjC,KACGhE,EAAE,CAAE,WAAF,CADL,CALD,CAfD,CA3CF,CADD;AAwEA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Modal, Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useEffect } 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 PostPreviewButton from '../post-preview-button';\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} = 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\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};\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\tavatar: received.lock_error.avatar_src,\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 the 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/>\n\t\t\t) }\n\t\t\t{ !! isTakeover && (\n\t\t\t\t<div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t{ userDisplayName\n\t\t\t\t\t\t\t? sprintf(\n\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__(\n\t\t\t\t\t\t\t\t\t\t'%s now has editing control of this post. Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Another user now has editing control of this post. Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className=\"editor-post-locked-modal__buttons\">\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</div>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! isTakeover && (\n\t\t\t\t<div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t{ userDisplayName\n\t\t\t\t\t\t\t? sprintf(\n\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__(\n\t\t\t\t\t\t\t\t\t\t'%s is currently working on this post, 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\tuserDisplayName\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Another user is currently working on this post, which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className=\"editor-post-locked-modal__buttons\">\n\t\t\t\t\t\t<Button variant=\"secondary\" 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\t<PostPreviewButton />\n\t\t\t\t\t\t<Button variant=\"primary\" href={ unlockUrl }>\n\t\t\t\t\t\t\t{ __( 'Take Over' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</Modal>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-locked-modal/index.js"],"names":["get","__","sprintf","Modal","Button","useSelect","useDispatch","addQueryArgs","useEffect","addAction","removeAction","useInstanceId","store","coreStore","getWPAdminURL","PostPreviewButton","editorStore","PostLockedModal","instanceId","hookName","autosave","updatePostLock","isLocked","isTakeover","user","postId","postLockUtils","activePostLock","postType","select","isPostLocked","isPostLockTakeover","getPostLockUser","getCurrentPostId","getActivePostLock","getEditedPostAttribute","getEditorSettings","getPostType","sendPostLock","data","lock","post_id","receivePostLock","received","lock_error","avatar","avatar_src","new_lock","releasePostLock","window","FormData","append","unlockNonce","navigator","sendBeacon","ajaxUrl","xhr","XMLHttpRequest","open","send","addEventListener","removeEventListener","userDisplayName","name","userAvatar","unlockUrl","lockKey","post","action","_wpnonce","nonce","allPostsUrl","post_type","allPostsLabel"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAT,EAAgBC,MAAhB,QAA8B,uBAA9B;AACA,SAASC,SAAT,EAAoBC,WA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ACd5D,OAAO;AACP;AACAD,EAAAA,EAAE,CACD,kGADC,CAFK,EAKP6D,eALO,CADO,GAQd7D,EAAE,CACF,4GADE,CATN,CADD,EAeC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,WAAhB;AAA4B,IAAA,IAAI,EAAGsE;AAAnC,KACGE,aADH,CADD,EAIC,cAAC,iBAAD,OAJD,EAKC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAGR;AAAjC,KACGhE,EAAE,CAAE,WAAF,CADL,CALD,CAfD,CA3CF,CADD;AAwEA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Modal, Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useEffect } 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 PostPreviewButton from '../post-preview-button';\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} = 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\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};\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\tavatar: received.lock_error.avatar_src,\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 the 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/>\n\t\t\t) }\n\t\t\t{ !! isTakeover && (\n\t\t\t\t<div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t{ userDisplayName\n\t\t\t\t\t\t\t? sprintf(\n\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__(\n\t\t\t\t\t\t\t\t\t\t'%s now has editing control of this post. Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Another user now has editing control of this post. Don’t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className=\"editor-post-locked-modal__buttons\">\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</div>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! isTakeover && (\n\t\t\t\t<div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t{ userDisplayName\n\t\t\t\t\t\t\t? sprintf(\n\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__(\n\t\t\t\t\t\t\t\t\t\t'%s is currently working on this post, 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\tuserDisplayName\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Another user is currently working on this post, which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className=\"editor-post-locked-modal__buttons\">\n\t\t\t\t\t\t<Button variant=\"secondary\" 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\t<PostPreviewButton />\n\t\t\t\t\t\t<Button variant=\"primary\" href={ unlockUrl }>\n\t\t\t\t\t\t\t{ __( 'Take Over' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</Modal>\n\t);\n}\n"]}
@@ -92,45 +92,16 @@ export default function PostSavedState({
92
92
  }
93
93
 
94
94
  return () => clearTimeout(timeoutId);
95
- }, [isSaving]);
95
+ }, [isSaving]); // Once the post has been submitted for review this button
96
+ // is not needed for the contributor role.
96
97
 
97
- if (isSaving) {
98
- // TODO: Classes generation should be common across all return
99
- // paths of this function, including proper naming convention for
100
- // the "Save Draft" button.
101
- const classes = classnames('editor-post-saved-state', 'is-saving', getAnimateClassName({
102
- type: 'loading'
103
- }), {
104
- 'is-autosaving': isAutosaving
105
- });
106
- return createElement("span", {
107
- className: classes
108
- }, createElement(Icon, {
109
- icon: cloud
110
- }), isAutosaving ? __('Autosaving') : __('Saving'));
98
+ if (!hasPublishAction && isPending) {
99
+ return null;
111
100
  }
112
101
 
113
102
  if (isPublished || isScheduled) {
114
103
  return createElement(PostSwitchToDraftButton, null);
115
104
  }
116
-
117
- if (!isSaveable) {
118
- return null;
119
- }
120
-
121
- if (forceSavedMessage || !isNew && !isDirty) {
122
- return createElement("span", {
123
- className: "editor-post-saved-state is-saved"
124
- }, createElement(Icon, {
125
- icon: check
126
- }), __('Saved'));
127
- } // Once the post has been submitted for review this button
128
- // is not needed for the contributor role.
129
-
130
-
131
- if (!hasPublishAction && isPending) {
132
- return null;
133
- }
134
105
  /* translators: button label text should, if possible, be under 16 characters. */
135
106
 
136
107
 
@@ -139,21 +110,42 @@ export default function PostSavedState({
139
110
 
140
111
  const shortLabel = __('Save');
141
112
 
142
- if (!isLargeViewport) {
143
- return createElement(Button, {
144
- className: "editor-post-save-draft",
145
- label: label,
146
- onClick: () => savePost(),
147
- shortcut: displayShortcut.primary('s'),
148
- icon: cloudUpload
149
- }, showIconLabels && shortLabel);
150
- }
113
+ const isSaved = forceSavedMessage || !isNew && !isDirty;
114
+ const isSavedState = isSaving || isSaved;
115
+ const isDisabled = isSaving || isSaved || !isSaveable;
116
+ let text;
117
+
118
+ if (isSaving) {
119
+ text = isAutosaving ? __('Autosaving') : __('Saving');
120
+ } else if (isSaved) {
121
+ text = __('Saved');
122
+ } else if (isLargeViewport) {
123
+ text = label;
124
+ } else if (showIconLabels) {
125
+ text = shortLabel;
126
+ } // Use common Button instance for all saved states so that focus is not
127
+ // lost.
128
+
151
129
 
152
130
  return createElement(Button, {
153
- className: "editor-post-save-draft",
154
- onClick: () => savePost(),
131
+ className: isSaveable || isSaving ? classnames({
132
+ 'editor-post-save-draft': !isSavedState,
133
+ 'editor-post-saved-state': isSavedState,
134
+ 'is-saving': isSaving,
135
+ 'is-autosaving': isAutosaving,
136
+ 'is-saved': isSaved,
137
+ [getAnimateClassName({
138
+ type: 'loading'
139
+ })]: isSaving
140
+ }) : undefined,
141
+ onClick: isDisabled ? undefined : () => savePost(),
155
142
  shortcut: displayShortcut.primary('s'),
156
- variant: "tertiary"
157
- }, label);
143
+ variant: isLargeViewport ? 'tertiary' : undefined,
144
+ icon: isLargeViewport ? undefined : cloudUpload,
145
+ label: label,
146
+ "aria-disabled": isDisabled
147
+ }, isSavedState && createElement(Icon, {
148
+ icon: isSaved ? check : cloud
149
+ }), text);
158
150
  }
159
151
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-saved-state/index.js"],"names":["classnames","__unstableGetAnimateClassName","getAnimateClassName","Button","usePrevious","useViewportMatch","useDispatch","useSelect","useEffect","useState","__","Icon","check","cloud","cloudUpload","displayShortcut","PostSwitchToDraftButton","store","editorStore","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","_links","savePost","wasSaving","timeoutId","setTimeout","clearTimeout","classes","type","label","shortLabel","primary"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,6BAA6B,IAAIC,mBADlC,EAECC,MAFD,QAGO,uBAHP;AAIA,SAASC,WAAT,EAAsBC,gBAAtB,QAA8C,oBAA9C;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,EAAeC,KAAf,EAAsBC,KAAtB,EAA6BC,WAA7B,QAAgD,kBAAhD;AACA,SAASC,eAAT,QAAgC,qBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,gCAApC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,cAAT,CAAyB;AACvCC,EAAAA,YADuC;AAEvCC,EAAAA,aAFuC;AAGvCC,EAAAA,cAAc,GAAG;AAHsB,CAAzB,EAIX;AACH,QAAM,CAAEC,iBAAF,EAAqBC,oBAArB,IAA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AGxB,SAAS,GAAGnB,EAAE,CAAE,iBAAF,CAAL,GAA6BA,EAAE,CAAE,YAAF,CAAtD;AAEA;;AACA,QAAM4C,UAAU,GAAG5C,EAAE,CAAE,MAAF,CAArB;;AAEA,MAAK,CAAEe,eAAP,EAAyB;AACxB,WACC,cAAC,MAAD;AACC,MAAA,SAAS,EAAC,wBADX;AAEC,MAAA,KAAK,EAAG4B,KAFT;AAGC,MAAA,OAAO,EAAG,MAAMP,QAAQ,EAHzB;AAIC,MAAA,QAAQ,EAAG/B,eAAe,CAACwC,OAAhB,CAAyB,GAAzB,CAJZ;AAKC,MAAA,IAAI,EAAGzC;AALR,OAOGQ,cAAc,IAAIgC,UAPrB,CADD;AAWA;;AAED,SACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,wBADX;AAEC,IAAA,OAAO,EAAG,MAAMR,QAAQ,EAFzB;AAGC,IAAA,QAAQ,EAAG/B,eAAe,CAACwC,OAAhB,CAAyB,GAAzB,CAHZ;AAIC,IAAA,OAAO,EAAC;AAJT,KAMGF,KANH,CADD;AAUA","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\tif ( isSaving ) {\n\t\t// TODO: Classes generation should be common across all return\n\t\t// paths of this function, including proper naming convention for\n\t\t// the \"Save Draft\" button.\n\t\tconst classes = classnames(\n\t\t\t'editor-post-saved-state',\n\t\t\t'is-saving',\n\t\t\tgetAnimateClassName( { type: 'loading' } ),\n\t\t\t{\n\t\t\t\t'is-autosaving': isAutosaving,\n\t\t\t}\n\t\t);\n\n\t\treturn (\n\t\t\t<span className={ classes }>\n\t\t\t\t<Icon icon={ cloud } />\n\t\t\t\t{ isAutosaving ? __( 'Autosaving' ) : __( 'Saving' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\tif ( isPublished || isScheduled ) {\n\t\treturn <PostSwitchToDraftButton />;\n\t}\n\n\tif ( ! isSaveable ) {\n\t\treturn null;\n\t}\n\n\tif ( forceSavedMessage || ( ! isNew && ! isDirty ) ) {\n\t\treturn (\n\t\t\t<span className=\"editor-post-saved-state is-saved\">\n\t\t\t\t<Icon icon={ check } />\n\t\t\t\t{ __( 'Saved' ) }\n\t\t\t</span>\n\t\t);\n\t}\n\n\t// Once the post has been submitted for review this button\n\t// is not needed for the contributor role.\n\n\tif ( ! hasPublishAction && isPending ) {\n\t\treturn null;\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\tif ( ! isLargeViewport ) {\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-post-save-draft\"\n\t\t\t\tlabel={ label }\n\t\t\t\tonClick={ () => savePost() }\n\t\t\t\tshortcut={ displayShortcut.primary( 's' ) }\n\t\t\t\ticon={ cloudUpload }\n\t\t\t>\n\t\t\t\t{ showIconLabels && shortLabel }\n\t\t\t</Button>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"editor-post-save-draft\"\n\t\t\tonClick={ () => savePost() }\n\t\t\tshortcut={ displayShortcut.primary( 's' ) }\n\t\t\tvariant=\"tertiary\"\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-saved-state/index.js"],"names":["classnames","__unstableGetAnimateClassName","getAnimateClassName","Button","usePrevious","useViewportMatch","useDispatch","useSelect","useEffect","useState","__","Icon","check","cloud","cloudUpload","displayShortcut","PostSwitchToDraftButton","store","editorStore","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","_links","savePost","wasSaving","timeoutId","setTimeout","clearTimeout","label","shortLabel","isSaved","isSavedState","isDisabled","text","type","undefined","primary"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,6BAA6B,IAAIC,mBADlC,EAECC,MAFD,QAGO,uBAHP;AAIA,SAASC,WAAT,EAAsBC,gBAAtB,QAA8C,oBAA9C;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,EAAeC,KAAf,EAAsBC,KAAtB,EAA6BC,WAA7B,QAAgD,kBAAhD;AACA,SAASC,eAAT,QAAgC,qBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,gCAApC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;AAEA;AAC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AL,GAAwBA,EAAE,CAAE,QAAF,CAA7C;AACA,GAFD,MAEO,IAAK2C,OAAL,EAAe;AACrBG,IAAAA,IAAI,GAAG9C,EAAE,CAAE,OAAF,CAAT;AACA,GAFM,MAEA,IAAKe,eAAL,EAAuB;AAC7B+B,IAAAA,IAAI,GAAGL,KAAP;AACA,GAFM,MAEA,IAAK7B,cAAL,EAAsB;AAC5BkC,IAAAA,IAAI,GAAGJ,UAAP;AACA,GA3FE,CA6FH;AACA;;;AACA,SACC,cAAC,MAAD;AACC,IAAA,SAAS,EACRrB,UAAU,IAAIC,QAAd,GACGhC,UAAU,CAAE;AACZ,gCAA0B,CAAEsD,YADhB;AAEZ,iCAA2BA,YAFf;AAGZ,mBAAatB,QAHD;AAIZ,uBAAiBN,YAJL;AAKZ,kBAAY2B,OALA;AAMZ,OAAEnD,mBAAmB,CAAE;AACtBuD,QAAAA,IAAI,EAAE;AADgB,OAAF,CAArB,GAEOzB;AARK,KAAF,CADb,GAWG0B,SAbL;AAeC,IAAA,OAAO,EAAGH,UAAU,GAAGG,SAAH,GAAe,MAAMZ,QAAQ,EAflD;AAgBC,IAAA,QAAQ,EAAG/B,eAAe,CAAC4C,OAAhB,CAAyB,GAAzB,CAhBZ;AAiBC,IAAA,OAAO,EAAGlC,eAAe,GAAG,UAAH,GAAgBiC,SAjB1C;AAkBC,IAAA,IAAI,EAAGjC,eAAe,GAAGiC,SAAH,GAAe5C,WAlBtC;AAmBC,IAAA,KAAK,EAAGqC,KAnBT;AAoBC,qBAAgBI;AApBjB,KAsBGD,YAAY,IAAI,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGD,OAAO,GAAGzC,KAAH,GAAWC;AAA/B,IAtBnB,EAuBG2C,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={ 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"]}