@openmrs/esm-form-engine-lib 4.1.1-pre.2369 → 4.1.1-pre.2374
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/dist/components/inputs/markdown/markdown-wrapper.component.d.ts.map +1 -1
- package/dist/components/inputs/markdown/markdown-wrapper.component.js +25 -4
- package/dist/components/inputs/markdown/markdown-wrapper.scss +60 -0
- package/package.json +1 -1
- package/src/components/inputs/markdown/markdown-wrapper.component.tsx +33 -6
- package/src/components/inputs/markdown/markdown-wrapper.scss +60 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-wrapper.component.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/markdown/markdown-wrapper.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown-wrapper.component.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/markdown/markdown-wrapper.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CA8BnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import ReactMarkdown from "react-markdown";
|
|
3
|
+
import styles from "./markdown-wrapper.scss";
|
|
4
|
+
const components = {
|
|
5
|
+
a: ({ node, ...props })=>/*#__PURE__*/ React.createElement("a", {
|
|
6
|
+
...props,
|
|
7
|
+
target: "_blank",
|
|
8
|
+
rel: "noopener noreferrer",
|
|
9
|
+
referrerPolicy: "no-referrer"
|
|
10
|
+
})
|
|
11
|
+
};
|
|
3
12
|
const MarkdownWrapper = ({ markdown })=>{
|
|
4
|
-
return /*#__PURE__*/ React.createElement(
|
|
13
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
14
|
+
className: styles.markdownWrapper
|
|
15
|
+
}, /*#__PURE__*/ React.createElement(ReactMarkdown, {
|
|
5
16
|
children: markdown,
|
|
6
17
|
unwrapDisallowed: true,
|
|
7
18
|
allowedElements: [
|
|
@@ -13,8 +24,18 @@ const MarkdownWrapper = ({ markdown })=>{
|
|
|
13
24
|
'h6',
|
|
14
25
|
'p',
|
|
15
26
|
'strong',
|
|
16
|
-
'em'
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
'em',
|
|
28
|
+
'code',
|
|
29
|
+
'pre',
|
|
30
|
+
'ul',
|
|
31
|
+
'ol',
|
|
32
|
+
'li',
|
|
33
|
+
'a',
|
|
34
|
+
'blockquote',
|
|
35
|
+
'hr',
|
|
36
|
+
'br'
|
|
37
|
+
],
|
|
38
|
+
components: components
|
|
39
|
+
}));
|
|
19
40
|
};
|
|
20
41
|
export default MarkdownWrapper;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
@use '@carbon/colors';
|
|
2
|
+
@use '@carbon/layout';
|
|
3
|
+
|
|
4
|
+
.markdownWrapper {
|
|
5
|
+
ul,
|
|
6
|
+
ol {
|
|
7
|
+
margin: layout.$spacing-03 0 layout.$spacing-03 layout.$spacing-06;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
ul {
|
|
11
|
+
list-style: disc;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
ol {
|
|
15
|
+
list-style: decimal;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
li {
|
|
19
|
+
margin-bottom: layout.$spacing-02;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
blockquote {
|
|
23
|
+
margin: layout.$spacing-03 0;
|
|
24
|
+
padding: layout.$spacing-02 layout.$spacing-04;
|
|
25
|
+
border-left: 3px solid colors.$gray-30;
|
|
26
|
+
color: colors.$gray-70;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
pre {
|
|
30
|
+
margin: layout.$spacing-03 0;
|
|
31
|
+
padding: layout.$spacing-03;
|
|
32
|
+
background: colors.$gray-10;
|
|
33
|
+
border-radius: 4px;
|
|
34
|
+
overflow-x: auto;
|
|
35
|
+
|
|
36
|
+
code {
|
|
37
|
+
background: none;
|
|
38
|
+
padding: 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
code {
|
|
43
|
+
background: colors.$gray-10;
|
|
44
|
+
padding: 0 layout.$spacing-02;
|
|
45
|
+
border-radius: 2px;
|
|
46
|
+
font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
47
|
+
font-size: 0.875em;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
hr {
|
|
51
|
+
margin: layout.$spacing-04 0;
|
|
52
|
+
border: 0;
|
|
53
|
+
border-top: 1px solid colors.$gray-30;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
a {
|
|
57
|
+
color: colors.$blue-60;
|
|
58
|
+
text-decoration: underline;
|
|
59
|
+
}
|
|
60
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,40 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import ReactMarkdown from 'react-markdown';
|
|
2
|
+
import ReactMarkdown, { type Components } from 'react-markdown';
|
|
3
|
+
import styles from './markdown-wrapper.scss';
|
|
4
|
+
|
|
5
|
+
const components: Components = {
|
|
6
|
+
a: ({ node, ...props }) => <a {...props} target="_blank" rel="noopener noreferrer" referrerPolicy="no-referrer" />,
|
|
7
|
+
};
|
|
3
8
|
|
|
4
9
|
const MarkdownWrapper: React.FC<{ markdown: string }> = ({ markdown }) => {
|
|
5
10
|
return (
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
<div className={styles.markdownWrapper}>
|
|
12
|
+
<ReactMarkdown
|
|
13
|
+
children={markdown}
|
|
14
|
+
unwrapDisallowed={true}
|
|
15
|
+
allowedElements={[
|
|
16
|
+
'h1',
|
|
17
|
+
'h2',
|
|
18
|
+
'h3',
|
|
19
|
+
'h4',
|
|
20
|
+
'h5',
|
|
21
|
+
'h6',
|
|
22
|
+
'p',
|
|
23
|
+
'strong',
|
|
24
|
+
'em',
|
|
25
|
+
'code',
|
|
26
|
+
'pre',
|
|
27
|
+
'ul',
|
|
28
|
+
'ol',
|
|
29
|
+
'li',
|
|
30
|
+
'a',
|
|
31
|
+
'blockquote',
|
|
32
|
+
'hr',
|
|
33
|
+
'br',
|
|
34
|
+
]}
|
|
35
|
+
components={components}
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
11
38
|
);
|
|
12
39
|
};
|
|
13
40
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
@use '@carbon/colors';
|
|
2
|
+
@use '@carbon/layout';
|
|
3
|
+
|
|
4
|
+
.markdownWrapper {
|
|
5
|
+
ul,
|
|
6
|
+
ol {
|
|
7
|
+
margin: layout.$spacing-03 0 layout.$spacing-03 layout.$spacing-06;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
ul {
|
|
11
|
+
list-style: disc;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
ol {
|
|
15
|
+
list-style: decimal;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
li {
|
|
19
|
+
margin-bottom: layout.$spacing-02;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
blockquote {
|
|
23
|
+
margin: layout.$spacing-03 0;
|
|
24
|
+
padding: layout.$spacing-02 layout.$spacing-04;
|
|
25
|
+
border-left: 3px solid colors.$gray-30;
|
|
26
|
+
color: colors.$gray-70;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
pre {
|
|
30
|
+
margin: layout.$spacing-03 0;
|
|
31
|
+
padding: layout.$spacing-03;
|
|
32
|
+
background: colors.$gray-10;
|
|
33
|
+
border-radius: 4px;
|
|
34
|
+
overflow-x: auto;
|
|
35
|
+
|
|
36
|
+
code {
|
|
37
|
+
background: none;
|
|
38
|
+
padding: 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
code {
|
|
43
|
+
background: colors.$gray-10;
|
|
44
|
+
padding: 0 layout.$spacing-02;
|
|
45
|
+
border-radius: 2px;
|
|
46
|
+
font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
47
|
+
font-size: 0.875em;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
hr {
|
|
51
|
+
margin: layout.$spacing-04 0;
|
|
52
|
+
border: 0;
|
|
53
|
+
border-top: 1px solid colors.$gray-30;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
a {
|
|
57
|
+
color: colors.$blue-60;
|
|
58
|
+
text-decoration: underline;
|
|
59
|
+
}
|
|
60
|
+
}
|