@ndlib/component-library 1.0.9 → 1.0.10

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.
@@ -82,6 +82,8 @@ const htmlContent = `
82
82
  ## HTML Content
83
83
  <p style='color: red;'>hello world </p>
84
84
 
85
+ https://www.youtube.com/embed/dQw4w9WgXcQ?si=mzI8wJ8NkHgn9RUy
86
+
85
87
  > Block quote [block quote link](test.com)
86
88
 
87
89
  <img
@@ -60,6 +60,20 @@ const parseBlockquotes = (content) => {
60
60
  });
61
61
  return newString;
62
62
  };
63
+ const youtubeRegex = /^(?:https?:\/\/)?(?:www\.)?youtube\.com/;
64
+ const pullOutVideos = (content) => {
65
+ const lines = content.split('\n');
66
+ const mapped = lines.map((line) => {
67
+ const lineText = line.trim();
68
+ if (youtubeRegex.test(lineText)) {
69
+ return `<iframe src="${lineText}" width="560" height="315" style="margin-top:24px;"></iframe>`;
70
+ }
71
+ else {
72
+ return line;
73
+ }
74
+ });
75
+ return mapped.join('\n');
76
+ };
63
77
  const defaultFloatImageStyles = {
64
78
  float: 'right',
65
79
  margin: '16px',
@@ -76,6 +90,7 @@ export const Markdown = (_a) => {
76
90
  let sanitizedContent = content;
77
91
  if (enableHtml) {
78
92
  sanitizedContent = parseBlockquotes(content);
93
+ sanitizedContent = pullOutVideos(sanitizedContent);
79
94
  sanitizedContent = sanitizeHtml(sanitizedContent);
80
95
  }
81
96
  return (_jsx("div", Object.assign({}, rest, { children: _jsx(ReactMarkdown, Object.assign({ rehypePlugins: enableHtml ? [rehypeRaw, remarkGfm] : [remarkGfm], components: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/component-library",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [