@ndlib/component-library 1.0.9 → 1.0.11
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.
|
@@ -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: {
|
|
@@ -124,7 +124,7 @@ export const AlertsProvider = ({ domain = ALERT_DOMAIN.LIBRARY, endpoint, startT
|
|
|
124
124
|
};
|
|
125
125
|
export const useAlerts = (pageAlerts) => {
|
|
126
126
|
const { alerts: allAlerts, dismiss } = React.useContext(AlertsContext);
|
|
127
|
-
const alerts = pageAlerts
|
|
127
|
+
const alerts = pageAlerts && (pageAlerts === null || pageAlerts === void 0 ? void 0 : pageAlerts.length) > 0
|
|
128
128
|
? allAlerts.filter((alert) => alert.global || pageAlerts.includes(alert.uuid))
|
|
129
129
|
: allAlerts.filter((alert) => alert.global);
|
|
130
130
|
return {
|
package/package.json
CHANGED