Feature/markdown error fix (#498)
* added widget to edit markdown with rjsf * build spiffcrm * updated docker images to build w/ burnettk --------- Co-authored-by: jasquat <jasquat@users.noreply.github.com> Co-authored-by: burnettk <burnettk@users.noreply.github.com>
This commit is contained in:
parent
1b18cb88c1
commit
db7f6a64a1
|
@ -31,9 +31,9 @@ export default function CustomForm({
|
||||||
noValidate = false,
|
noValidate = false,
|
||||||
}: OwnProps) {
|
}: OwnProps) {
|
||||||
const rjsfWidgets = {
|
const rjsfWidgets = {
|
||||||
typeahead: TypeaheadWidget,
|
|
||||||
'date-range': DateRangePickerWidget,
|
'date-range': DateRangePickerWidget,
|
||||||
markdown: MarkDownFieldWidget,
|
markdown: MarkDownFieldWidget,
|
||||||
|
typeahead: TypeaheadWidget,
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatDateString = (dateString?: string) => {
|
const formatDateString = (dateString?: string) => {
|
||||||
|
|
|
@ -327,6 +327,10 @@ dl dd {
|
||||||
margin-bottom: .5rem;
|
margin-bottom: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.with-half-rem-top-margin {
|
||||||
|
margin-top: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.diagram-viewer-canvas {
|
.diagram-viewer-canvas {
|
||||||
border:1px solid #000000;
|
border:1px solid #000000;
|
||||||
height:70vh;
|
height:70vh;
|
||||||
|
|
|
@ -16,6 +16,7 @@ interface widgetArgs {
|
||||||
label?: string;
|
label?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||||
export default function MarkDownFieldWidget({
|
export default function MarkDownFieldWidget({
|
||||||
id,
|
id,
|
||||||
value,
|
value,
|
||||||
|
@ -40,9 +41,11 @@ export default function MarkDownFieldWidget({
|
||||||
|
|
||||||
const onChangeLocal = useCallback(
|
const onChangeLocal = useCallback(
|
||||||
(newValue: any) => {
|
(newValue: any) => {
|
||||||
onChange(newValue);
|
if (!disabled && !readonly) {
|
||||||
|
onChange(newValue);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[onChange]
|
[onChange, disabled, readonly]
|
||||||
);
|
);
|
||||||
|
|
||||||
let helperText = null;
|
let helperText = null;
|
||||||
|
@ -61,12 +64,34 @@ export default function MarkDownFieldWidget({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cds-- items come from carbon and how it displays helper text and errors.
|
||||||
|
// carbon also removes helper text when error so doing that here as well.
|
||||||
|
// TODO: highlight the MDEditor in some way - we are only showing red text atm.
|
||||||
return (
|
return (
|
||||||
<MDEditor
|
<div className="with-half-rem-top-margin">
|
||||||
height={500}
|
<div
|
||||||
highlightEnable={false}
|
className="cds--text-input__field-wrapper"
|
||||||
value={value}
|
data-invalid={invalid}
|
||||||
onChange={onChangeLocal}
|
style={{ display: 'inline' }}
|
||||||
/>
|
>
|
||||||
|
<div data-color-mode="light" id={id}>
|
||||||
|
<MDEditor
|
||||||
|
height={500}
|
||||||
|
highlightEnable={false}
|
||||||
|
value={value}
|
||||||
|
onChange={onChangeLocal}
|
||||||
|
autoFocus={autofocus}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id={`${id}-error-msg`} className="cds--form-requirement">
|
||||||
|
{errorMessageForField}
|
||||||
|
</div>
|
||||||
|
{invalid ? null : (
|
||||||
|
<div id="root-helper-text" className="cds--form__helper-text">
|
||||||
|
{helperText}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue