File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
packages/ui/src/elements/PublishButton Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -4,21 +4,33 @@ import React, { useCallback } from 'react'
4
4
5
5
import { useForm , useFormModified } from '../../forms/Form/context.js'
6
6
import { FormSubmit } from '../../forms/Submit/index.js'
7
+ import { useHotkey } from '../../hooks/useHotkey.js'
7
8
import { useDocumentInfo } from '../../providers/DocumentInfo/index.js'
9
+ import { useEditDepth } from '../../providers/EditDepth/index.js'
8
10
import { useTranslation } from '../../providers/Translation/index.js'
9
11
10
12
export const DefaultPublishButton : React . FC < { label ?: string } > = ( { label : labelProp } ) => {
11
13
const { hasPublishPermission, publishedDoc, unpublishedVersions } = useDocumentInfo ( )
12
14
13
15
const { submit } = useForm ( )
14
16
const modified = useFormModified ( )
17
+ const editDepth = useEditDepth ( )
15
18
16
19
const { t } = useTranslation ( )
17
20
const label = labelProp || t ( 'version:publishChanges' )
18
21
19
22
const hasNewerVersions = unpublishedVersions ?. totalDocs > 0
20
23
const canPublish = hasPublishPermission && ( modified || hasNewerVersions || ! publishedDoc )
21
24
25
+ useHotkey ( { cmdCtrlKey : true , editDepth, keyCodes : [ 's' ] } , ( e ) => {
26
+ e . preventDefault ( )
27
+ e . stopPropagation ( )
28
+
29
+ if ( submit ) {
30
+ void submit ( )
31
+ }
32
+ } )
33
+
22
34
const publish = useCallback ( ( ) => {
23
35
void submit ( {
24
36
overrides : {
You can’t perform that action at this time.
0 commit comments