@ndlib/component-library 1.0.14 → 1.0.15

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.
@@ -62,7 +62,7 @@ const htmlMarkdown = `
62
62
  `;
63
63
  describe('Markdown', () => {
64
64
  it('renders markdown content', () => {
65
- const { getAllByRole, getByRole, container } = render(_jsx(Markdown, { content: testMarkdown }));
65
+ const { getAllByRole, getByRole } = render(_jsx(Markdown, { content: testMarkdown }));
66
66
  expect(() => {
67
67
  getByRole('heading', {
68
68
  name: 'Heading 2',
@@ -95,14 +95,6 @@ describe('Markdown', () => {
95
95
  expect(getByRole('link', {
96
96
  name: 'block quote link',
97
97
  })).toBeInTheDocument();
98
- const images = container.getElementsByTagName('img');
99
- let inlineImageCount = 0;
100
- for (const image of images) {
101
- if (image.style.float === 'right') {
102
- inlineImageCount++;
103
- }
104
- }
105
- expect(inlineImageCount).toBe(1);
106
98
  expect(getAllByRole('list')).toHaveLength(3);
107
99
  });
108
100
  it('renders allowed html when included', () => {
@@ -46,10 +46,10 @@ const parseBlockquotes = (content) => {
46
46
  newContent.push('</blockquote>');
47
47
  }
48
48
  let newString = newContent.join('\n');
49
- const blockquoteRegex = /<blockquote>(.*?)<\/blockquote>/gs;
49
+ const blockquoteRegex = /<blockquote>(.*?)<\/blockquote>/g;
50
50
  const blockquotes = newString.match(blockquoteRegex);
51
51
  blockquotes === null || blockquotes === void 0 ? void 0 : blockquotes.forEach((blockquote) => {
52
- const linkRegex = /\[(.*?)\]\((.*?)\)/gs;
52
+ const linkRegex = /\[(.*?)\]\((.*?)\)/g;
53
53
  const links = blockquote.match(linkRegex);
54
54
  let newBlockquote = blockquote;
55
55
  links === null || links === void 0 ? void 0 : links.forEach((link) => {
@@ -74,12 +74,6 @@ const pullOutVideos = (content) => {
74
74
  });
75
75
  return mapped.join('\n');
76
76
  };
77
- const defaultFloatImageStyles = {
78
- float: 'right',
79
- margin: '16px',
80
- marginTop: '0px',
81
- maxWidth: '400px',
82
- };
83
77
  const dynamicTopMarginStyles = {
84
78
  [firstChildAltSelector]: {
85
79
  mt: 0,
@@ -111,14 +105,9 @@ export const Markdown = (_a) => {
111
105
  strong: (props) => _jsx(Bold, Object.assign({}, props, { sx: customStyles.strong })),
112
106
  em: (props) => _jsx(Italic, Object.assign({}, props, { sx: customStyles.em })),
113
107
  img: (props) => {
114
- const altProp = props.alt || '';
115
- const [alt, customPropString] = altProp.split('!!');
116
- const customProps = customPropString
117
- ? customPropString.split(',')
118
- : [];
119
- const isInline = customProps.includes('inline');
120
- const inlineStyles = isInline ? defaultFloatImageStyles : {};
121
- const styles = Object.assign(Object.assign({}, imageStyles), inlineStyles);
108
+ const alt = props.alt || '';
109
+ const inlineStyles = {};
110
+ const styles = Object.assign(Object.assign({}, inlineStyles), imageStyles);
122
111
  return _jsx("img", Object.assign({}, props, { style: styles, alt: alt }));
123
112
  },
124
113
  blockquote: (props) => (_jsx(BlockQuote, Object.assign({}, props, { sx: Object.assign(Object.assign(Object.assign({}, dynamicTopMarginStyles), { my: 5 }), customStyles.blockquote) }))),
@@ -2,6 +2,7 @@ import sanitize from 'sanitize-html';
2
2
  export declare const DEFAULT_ALLOWED_TAGS: string[];
3
3
  export declare const DEFAULT_ALLOWED_ATTRIBUTES: {
4
4
  iframe: string[];
5
+ figure: string[];
5
6
  a: sanitize.AllowedAttribute[];
6
7
  };
7
8
  export declare const sanitizeHtml: (content: string) => string;
@@ -2,8 +2,9 @@ import sanitize from 'sanitize-html';
2
2
  export const DEFAULT_ALLOWED_TAGS = sanitize.defaults.allowedTags.concat([
3
3
  'iframe',
4
4
  'img',
5
+ 'figure',
5
6
  ]);
6
- export const DEFAULT_ALLOWED_ATTRIBUTES = Object.assign(Object.assign({}, sanitize.defaults.allowedAttributes), { iframe: ['*'], a: sanitize.defaults.allowedAttributes.a.concat([
7
+ export const DEFAULT_ALLOWED_ATTRIBUTES = Object.assign(Object.assign({}, sanitize.defaults.allowedAttributes), { iframe: ['*'], figure: ['class'], a: sanitize.defaults.allowedAttributes.a.concat([
7
8
  'id',
8
9
  'class',
9
10
  'data-card-width',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/component-library",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [