-
Notifications
You must be signed in to change notification settings - Fork 396
/
EditForm.js
73 lines (71 loc) · 1.89 KB
/
EditForm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import React from 'react'
import PropTypes from 'prop-types'
import FormBuilder from 'part:@sanity/form-builder'
import styles from '../styles/Editor.css'
const preventDefault = ev => ev.preventDefault()
export default class EditForm extends React.PureComponent {
static propTypes = {
draft: PropTypes.object,
filterField: PropTypes.func.isRequired,
focusPath: PropTypes.array.isRequired,
// isLiveEditEnabled: PropTypes.bool,
markers: PropTypes.arrayOf(
PropTypes.shape({
path: PropTypes.array
})
).isRequired,
onBlur: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired,
onFocus: PropTypes.func.isRequired,
// onShowHistory: PropTypes.func.isRequired,
patchChannel: PropTypes.object.isRequired,
published: PropTypes.object,
initialValue: PropTypes.object,
readOnly: PropTypes.bool.isRequired,
schema: PropTypes.object.isRequired,
type: PropTypes.object.isRequired
}
render() {
const {
draft,
published,
filterField,
focusPath,
initialValue,
// isLiveEditEnabled,
markers,
onBlur,
onChange,
onFocus,
// onShowHistory,
patchChannel,
readOnly,
schema,
type
} = this.props
const value = draft || published || initialValue
return (
<>
<form
className={styles.editor}
onSubmit={preventDefault}
id="Sanity_Default_DeskTool_Editor_ScrollContainer"
>
<FormBuilder
schema={schema}
patchChannel={patchChannel}
value={value || {_type: type}}
type={type}
filterField={filterField}
readOnly={readOnly}
onBlur={onBlur}
onFocus={onFocus}
focusPath={focusPath}
onChange={onChange}
markers={markers}
/>
</form>
</>
)
}
}