@openmrs/esm-form-engine-lib 3.1.5-pre.1967 → 3.1.5-pre.1969
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -1,22 +1,12 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import ReactMarkdown from 'react-markdown';
|
3
3
|
|
4
|
-
const MarkdownWrapper: React.FC<{ markdown: string
|
4
|
+
const MarkdownWrapper: React.FC<{ markdown: string }> = ({ markdown }) => {
|
5
5
|
return (
|
6
6
|
<ReactMarkdown
|
7
|
-
children={
|
7
|
+
children={markdown}
|
8
8
|
unwrapDisallowed={true}
|
9
|
-
allowedElements={[
|
10
|
-
'h1',
|
11
|
-
'h2',
|
12
|
-
'h3',
|
13
|
-
'h4',
|
14
|
-
'h5',
|
15
|
-
'h6',
|
16
|
-
'p',
|
17
|
-
'strong',
|
18
|
-
'em',
|
19
|
-
]}
|
9
|
+
allowedElements={['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'strong', 'em']}
|
20
10
|
/>
|
21
11
|
);
|
22
12
|
};
|
@@ -5,12 +5,20 @@ import MarkdownWrapper from './markdown-wrapper.component';
|
|
5
5
|
|
6
6
|
const Markdown: React.FC<FormFieldInputProps> = ({ field }) => {
|
7
7
|
const { t } = useTranslation();
|
8
|
-
const markdownContent =
|
9
|
-
typeof field.value === 'string'
|
10
|
-
? t(field.value, { defaultValue: field.value, interpolation: { escapeValue: false } })
|
11
|
-
: field.value;
|
12
8
|
|
13
|
-
|
9
|
+
const translateMarkdown = (markdownContent: string | string[]): string => {
|
10
|
+
if (Array.isArray(markdownContent)) {
|
11
|
+
return markdownContent
|
12
|
+
.map((line) => t(line, { defaultValue: line, interpolation: { escapeValue: false } }))
|
13
|
+
.join('\n\n');
|
14
|
+
}
|
15
|
+
|
16
|
+
return typeof markdownContent === 'string'
|
17
|
+
? t(markdownContent, { defaultValue: markdownContent, interpolation: { escapeValue: false } })
|
18
|
+
: markdownContent;
|
19
|
+
};
|
20
|
+
|
21
|
+
return !field.isHidden && <MarkdownWrapper markdown={translateMarkdown(field.value)} />;
|
14
22
|
};
|
15
23
|
|
16
24
|
export default Markdown;
|
@@ -148,7 +148,7 @@ const FormEngine = ({
|
|
148
148
|
<Sidebar
|
149
149
|
isFormSubmitting={isSubmitting}
|
150
150
|
sessionMode={mode}
|
151
|
-
defaultPage={
|
151
|
+
defaultPage={refinedFormJson.defaultPage}
|
152
152
|
onCancel={onCancel}
|
153
153
|
handleClose={handleClose}
|
154
154
|
hideFormCollapseToggle={hideFormCollapseToggle}
|