@@ -39,7 +39,7 @@ type ExportSignalKind = ACSExportOptions['signalKind'];
3939const validationSchema = z . object ( {
4040 signalKind : z . enum ( [ 'all' , 'signal' ] ) ,
4141 ascending : z . boolean ( ) ,
42- format : z . enum ( [ 'IMJA' , 'IMJ' , 'D' ] ) ,
42+ format : z . string ( ) ,
4343 couplingFormat : z . string ( ) ,
4444 deltaFormat : z . string ( ) ,
4545 textStyle : svgTextStyleFieldsSchema ,
@@ -101,23 +101,16 @@ function InnerPublicationStringModal(props: InnerPublicationStringModalProps) {
101101 const { dispatch } = usePreferences ( ) ;
102102 const currentACSOptions = useACSSettings ( ) ;
103103 const form = useForm ( {
104- defaultValues : {
105- ...currentACSOptions ,
106- textStyle : {
107- fill : '#000000' ,
108- fontSize : '16' ,
109- fontStyle : 'normal' ,
110- fontWeight : 'normal' ,
111- } as z . input < typeof svgTextStyleFieldsSchema > ,
112- } ,
104+ defaultValues : validationSchema . encode ( currentACSOptions ) ,
113105 validators : { onChange : validationSchema } ,
114106 onSubmit : ( { value } ) => {
115107 assert ( spectrum && isSpectrum1D ( spectrum ) ) ;
116108 const nucleus = spectrum . info . nucleus ;
117109
110+ const options = validationSchema . parse ( value ) ;
118111 dispatch ( {
119112 type : 'CHANGE_EXPORT_ACS_SETTINGS' ,
120- payload : { options : value , nucleus } ,
113+ payload : { options, nucleus } ,
121114 } ) ;
122115 onClose ( ) ;
123116 } ,
@@ -169,9 +162,9 @@ function InnerPublicationStringModal(props: InnerPublicationStringModalProps) {
169162
170163 < Body >
171164 < form . Subscribe selector = { ( s ) => s . values } >
172- { ( acs ) => (
165+ { ( values ) => (
173166 < PublicationStringPreview
174- acs = { acs }
167+ values = { values }
175168 spectrum = { spectrum }
176169 onCopy = { onCopyClick }
177170 />
@@ -210,21 +203,22 @@ const PublicationStringCheckbox = styled(Checkbox)`
210203
211204interface PublicationStringPreviewProps {
212205 spectrum : Spectrum1D ;
213- acs : ACSExportOptions ;
206+ values : z . input < typeof validationSchema > ;
214207 onCopy : ( value : string ) => void ;
215208}
216209
217210function PublicationStringPreview ( props : PublicationStringPreviewProps ) {
218- const { spectrum, acs , onCopy } = props ;
211+ const { spectrum, values , onCopy } = props ;
219212
213+ const acs = validationSchema . parse ( values ) ;
220214 const value = buildPublicationString ( { spectrum, acs } ) ;
221215
222216 if ( ! value ) return < EmptyText text = "No publication string" /> ;
223217
224218 return (
225219 < >
226220 < CopyPreviewButton onClick = { ( ) => onCopy ( value ) } icon = "duplicate" />
227- { /*eslint-disable-next-line react/no-danger*/ }
221+ { /* eslint-disable-next-line react/no-danger */ }
228222 < div dangerouslySetInnerHTML = { { __html : value } } />
229223 </ >
230224 ) ;
0 commit comments