@@ -16,9 +16,10 @@ import {ContextSep} from 'nice-ui/lib/4-card/ContextMenu';
16
16
17
17
export interface InlineConfigCardProps {
18
18
config : SliceConfigState < any > ;
19
+ onSave : ( ) => void ;
19
20
}
20
21
21
- export const InlineConfigCard : React . FC < InlineConfigCardProps > = ( { config} ) => {
22
+ export const InlineConfigCard : React . FC < InlineConfigCardProps > = ( { config, onSave } ) => {
22
23
const { toolbar} = useToolbarPlugin ( ) ;
23
24
const api = config . conf ( ) ;
24
25
const href = React . useMemo ( ( ) => ( ) => config . conf ( ) . str ( [ 'href' ] ) , [ config ] ) ;
@@ -30,42 +31,52 @@ export const InlineConfigCard: React.FC<InlineConfigCardProps> = ({config}) => {
30
31
31
32
return (
32
33
< ContextPane style = { { display : 'block' , minWidth : 'calc(min(600px, max(50vw, 260px)))' } } >
33
- < ContextPaneHeader onCloseClick = { ( ) => toolbar . newSliceConfig . next ( void 0 ) } >
34
- { icon ? (
35
- < Flex style = { { alignItems : 'center' , display : 'flex' , fontSize : '14px' } } >
36
- { /* <Avatar width={24} height={24} badge={icon} /> */ }
37
- < div style = { { transform : 'scale(.8)' , width : 28 , height : 28 , borderRadius : 6 , display : 'flex' , alignItems : 'center' , justifyContent : 'center' , background : 'rgba(0,0,0,.1)' , opacity : .7 , margin : '0 6px 0 8px' } } >
38
- { icon }
39
- </ div >
40
- { name }
41
- { /* <Breadcrumbs crumbs={[<Breadcrumb compact>{name}</Breadcrumb>]} /> */ }
42
- </ Flex >
43
- ) : (
44
- < Breadcrumbs crumbs = { [ < Breadcrumb compact > { name } </ Breadcrumb > ] } />
45
- ) }
46
- </ ContextPaneHeader >
47
- < div style = { { padding : '8px 16px' } } >
48
- < FormRow title = { 'Address' } >
49
- < CollaborativeInput str = { href }
50
- input = { ( ref ) => < Input focus inp = { ref } type = { 'text' } size = { - 1 } placeholder = { 'https://' } /> } />
51
- </ FormRow >
52
- { /* <FormRow title={'Title'}>
53
- <CollaborativeInput str={title}
54
- input={(ref) => <Input inp={ref} type={'text'} size={-1} placeholder={'Title'} />} />
55
- </FormRow> */ }
56
- </ div >
34
+ < form onSubmit = { ( e ) => {
35
+ e . preventDefault ( ) ;
36
+ onSave ( ) ;
37
+ } } >
38
+ < ContextPaneHeader onCloseClick = { ( ) => toolbar . newSliceConfig . next ( void 0 ) } >
39
+ { icon ? (
40
+ < Flex style = { { alignItems : 'center' , display : 'flex' , fontSize : '14px' } } >
41
+ { /* <Avatar width={24} height={24} badge={icon} /> */ }
42
+ < div style = { { transform : 'scale(.8)' , width : 28 , height : 28 , borderRadius : 6 , display : 'flex' , alignItems : 'center' , justifyContent : 'center' , background : 'rgba(0,0,0,.1)' , opacity : .7 , margin : '0 6px 0 8px' } } >
43
+ { icon }
44
+ </ div >
45
+ { name }
46
+ { /* <Breadcrumbs crumbs={[<Breadcrumb compact>{name}</Breadcrumb>]} /> */ }
47
+ </ Flex >
48
+ ) : (
49
+ < Breadcrumbs crumbs = { [ < Breadcrumb compact > { name } </ Breadcrumb > ] } />
50
+ ) }
51
+ </ ContextPaneHeader >
52
+ < div style = { { padding : '8px 16px' } } >
53
+ < FormRow title = { 'Address' } >
54
+ < CollaborativeInput str = { href }
55
+ input = { ( ref ) => < Input focus inp = { ref } type = { 'text' } size = { - 1 } placeholder = { 'https://' } onKeyDown = { ( e ) => {
56
+ if ( e . key === 'Enter' ) {
57
+ e . preventDefault ( ) ;
58
+ onSave ( ) ;
59
+ }
60
+ } } /> } />
61
+ </ FormRow >
62
+ { /* <FormRow title={'Title'}>
63
+ <CollaborativeInput str={title}
64
+ input={(ref) => <Input inp={ref} type={'text'} size={-1} placeholder={'Title'} />} />
65
+ </FormRow> */ }
66
+ </ div >
57
67
58
- < ContextSep line />
59
- < ContextTitle > Preview</ ContextTitle >
60
- < EmptyState emoji = ' ' title = ' ' />
61
- < ContextSep line />
62
-
63
- { /* <div style={{padding: '4px 16px'}}> */ }
64
- < div style = { { padding : '0px 16px' } } >
65
- < FormRow >
66
- < Button lite block disabled = { ! hrefView } > Save</ Button >
67
- </ FormRow >
68
- </ div >
68
+ < ContextSep line />
69
+ < ContextTitle > Preview</ ContextTitle >
70
+ < EmptyState emoji = ' ' title = ' ' />
71
+ < ContextSep line />
72
+
73
+ { /* <div style={{padding: '4px 16px'}}> */ }
74
+ < div style = { { padding : '0px 16px' } } >
75
+ < FormRow >
76
+ < Button small lite block disabled = { ! hrefView } submit > Save</ Button >
77
+ </ FormRow >
78
+ </ div >
79
+ </ form >
69
80
</ ContextPane >
70
81
) ;
71
82
} ;
0 commit comments