@ndlib/component-library 0.0.108 → 0.0.110
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.
|
@@ -57,6 +57,11 @@ nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
|
57
57
|
reprehenderit in voluptate velit esse cillum dolore eu fugiat
|
|
58
58
|
nulla pariatur.
|
|
59
59
|
|
|
60
|
+

|
|
61
|
+
|
|
62
|
+
An inline images should appear to the right of this paragraph
|
|
63
|
+
|
|
64
|
+
|
|
60
65
|
https://this-should-be-auto-linked.nd.edu
|
|
61
66
|
|
|
62
67
|
While Gura says that the exhibit was inspired by the themes of the Medieval conference and will appeal to its attendees, the displays are curated to interest Notre Dame students and faculty across various disciplines, as well as the general public.
|
|
@@ -45,6 +45,10 @@ While Gura says that the exhibit was inspired by the themes of the Medieval conf
|
|
|
45
45
|
To tell that story, Gura decided to give each of the seven cases housing this exhibit a theme.
|
|
46
46
|
|
|
47
47
|
> “I think it's an exciting way to create a journey through time and space using the objects themselves as the primary storyteller,” he said. “They will drive the narrative from case to case. You can be exposed to different things that the average person never really thought about.”
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
An inline images should appear to the right of this paragraph
|
|
48
52
|
`;
|
|
49
53
|
const htmlMarkdown = `
|
|
50
54
|
## HTML Content
|
|
@@ -58,7 +62,7 @@ const htmlMarkdown = `
|
|
|
58
62
|
`;
|
|
59
63
|
describe('Markdown', () => {
|
|
60
64
|
it('renders alert content', () => {
|
|
61
|
-
const { getAllByRole, getByRole } = render(_jsx(Markdown, { content: testMarkdown }));
|
|
65
|
+
const { getAllByRole, getByRole, container } = render(_jsx(Markdown, { content: testMarkdown }));
|
|
62
66
|
expect(() => {
|
|
63
67
|
getByRole('heading', {
|
|
64
68
|
name: 'Heading 1',
|
|
@@ -88,6 +92,14 @@ describe('Markdown', () => {
|
|
|
88
92
|
expect(getByRole('link', {
|
|
89
93
|
name: 'https://this-should-be-auto-linked.nd.edu',
|
|
90
94
|
})).toBeInTheDocument();
|
|
95
|
+
const images = container.getElementsByTagName('img');
|
|
96
|
+
let inlineImageCount = 0;
|
|
97
|
+
for (const image of images) {
|
|
98
|
+
if (image.style.float === 'right') {
|
|
99
|
+
inlineImageCount++;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
expect(inlineImageCount).toBe(1);
|
|
91
103
|
expect(getAllByRole('list')).toHaveLength(3);
|
|
92
104
|
});
|
|
93
105
|
it('renders allowed html when included', () => {
|
|
@@ -96,7 +108,7 @@ describe('Markdown', () => {
|
|
|
96
108
|
expect(getAllByRole('link')).toBeDefined();
|
|
97
109
|
expect(() => getByText(' ')).toThrow();
|
|
98
110
|
expect(container.getElementsByTagName('script')).toHaveLength(0);
|
|
99
|
-
expect(container.getElementsByTagName('img')).toHaveLength(
|
|
111
|
+
expect(container.getElementsByTagName('img')).toHaveLength(3);
|
|
100
112
|
expect(container.getElementsByTagName('iframe')).toHaveLength(1);
|
|
101
113
|
});
|
|
102
114
|
it('does not render html when disabled', () => {
|
|
@@ -55,6 +55,12 @@ const parseBlockquotes = (content) => {
|
|
|
55
55
|
}
|
|
56
56
|
return newContent.join('\n');
|
|
57
57
|
};
|
|
58
|
+
const defaultFloatImageStyles = {
|
|
59
|
+
float: 'right',
|
|
60
|
+
margin: '16px',
|
|
61
|
+
marginTop: '0px',
|
|
62
|
+
width: '400px',
|
|
63
|
+
};
|
|
58
64
|
const dynamicTopMarginStyles = {
|
|
59
65
|
[firstChildAltSelector]: {
|
|
60
66
|
mt: 0,
|
|
@@ -86,7 +92,17 @@ export const Markdown = (_a) => {
|
|
|
86
92
|
p: (props) => (_jsx(Paragraph, Object.assign({}, props, { sx: Object.assign(Object.assign(Object.assign({}, dynamicTopMarginStyles), { fontSize: 'inherit' }), customStyles.p) }))),
|
|
87
93
|
strong: (props) => _jsx(Bold, Object.assign({}, props, { sx: customStyles.strong })),
|
|
88
94
|
em: (props) => _jsx(Italic, Object.assign({}, props, { sx: customStyles.em })),
|
|
89
|
-
img: (props) =>
|
|
95
|
+
img: (props) => {
|
|
96
|
+
const altProp = props.alt || '';
|
|
97
|
+
const [alt, customPropString] = altProp.split('!!');
|
|
98
|
+
const customProps = customPropString
|
|
99
|
+
? customPropString.split(',')
|
|
100
|
+
: [];
|
|
101
|
+
const isInline = customProps.includes('inline');
|
|
102
|
+
const baseStyles = isInline ? defaultFloatImageStyles : {};
|
|
103
|
+
const styles = Object.assign(Object.assign({}, baseStyles), imageStyles);
|
|
104
|
+
return _jsx("img", Object.assign({}, props, { style: styles, alt: alt }));
|
|
105
|
+
},
|
|
90
106
|
blockquote: (props) => (_jsx(BlockQuote, Object.assign({}, props, { sx: Object.assign(Object.assign(Object.assign({}, dynamicTopMarginStyles), { my: 5 }), customStyles.blockquote) }))),
|
|
91
107
|
} }, { children: sanitizedContent })) })));
|
|
92
108
|
};
|