@readme/markdown 14.2.6 → 14.3.0
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/components/Embed/index.tsx +24 -4
- package/components/TailwindStyle/index.tsx +19 -6
- package/dist/components/Embed/index.d.ts +2 -2
- package/dist/main.js +465 -49
- package/dist/main.node.js +495 -49
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/mdxish/evaluate-exports.d.ts +27 -0
- package/dist/processor/transform/mdxish/evaluate-expressions.d.ts +4 -3
- package/dist/processor/utils.d.ts +10 -2
- package/package.json +7 -2
|
@@ -14,7 +14,7 @@ const Favicon = ({ src, alt = 'favicon', ...attr }: FaviconProps) => (
|
|
|
14
14
|
interface EmbedProps {
|
|
15
15
|
favicon?: string;
|
|
16
16
|
html?: string;
|
|
17
|
-
iframe?: boolean;
|
|
17
|
+
iframe?: boolean | string;
|
|
18
18
|
image?: string;
|
|
19
19
|
lazy?: boolean;
|
|
20
20
|
providerName?: string;
|
|
@@ -24,6 +24,11 @@ interface EmbedProps {
|
|
|
24
24
|
url: string;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const IFRAME_DERIVABLE_TYPES = new Set(['youtube', 'jsfiddle', 'pdf']);
|
|
28
|
+
|
|
29
|
+
// HTML width/height attrs accept bare numbers (interpreted as px), but CSS does not, convert.
|
|
30
|
+
const toCssSize = (v: string | undefined, fallback: string) => (v ? (/^\d+$/.test(v) ? `${v}px` : v) : fallback);
|
|
31
|
+
|
|
27
32
|
const Embed = ({
|
|
28
33
|
lazy = true,
|
|
29
34
|
url,
|
|
@@ -34,9 +39,11 @@ const Embed = ({
|
|
|
34
39
|
iframe,
|
|
35
40
|
image,
|
|
36
41
|
favicon,
|
|
42
|
+
typeOfEmbed,
|
|
37
43
|
...attrs
|
|
38
44
|
}: EmbedProps) => {
|
|
39
|
-
|
|
45
|
+
const explicitOptOut = iframe === false || iframe === 'false';
|
|
46
|
+
if (typeof iframe !== 'boolean') iframe = iframe === 'true' || typeOfEmbed === 'iframe';
|
|
40
47
|
|
|
41
48
|
if (html) {
|
|
42
49
|
try {
|
|
@@ -51,8 +58,21 @@ const Embed = ({
|
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
60
|
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
const { height, width, ...spreadAttrs } = attrs as { height?: string; width?: string };
|
|
62
|
+
const iframeStyle = {
|
|
63
|
+
border: 'none',
|
|
64
|
+
display: 'flex',
|
|
65
|
+
margin: 'auto',
|
|
66
|
+
width: toCssSize(width, '100%'),
|
|
67
|
+
height: toCssSize(height, '480px'),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// Fall back to a direct iframe for URL-derivable embed types when html is missing.
|
|
71
|
+
const renderTypeAsIframe =
|
|
72
|
+
!html && !explicitOptOut && url && typeOfEmbed && IFRAME_DERIVABLE_TYPES.has(typeOfEmbed);
|
|
73
|
+
|
|
74
|
+
if (iframe || renderTypeAsIframe) {
|
|
75
|
+
return <iframe {...spreadAttrs} src={url} style={iframeStyle} title={title} />;
|
|
56
76
|
}
|
|
57
77
|
|
|
58
78
|
if (!providerUrl && url)
|
|
@@ -75,18 +75,31 @@ const TailwindStyle = ({ children, darkModeDataAttribute }: Props) => {
|
|
|
75
75
|
records.forEach(record => {
|
|
76
76
|
if (record.type === 'childList') {
|
|
77
77
|
record.addedNodes.forEach(node => {
|
|
78
|
-
if (!(node instanceof HTMLElement)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
if (!(node instanceof HTMLElement)) return;
|
|
79
|
+
|
|
80
|
+
const sizeBefore = classesSet.current.size;
|
|
81
|
+
|
|
82
|
+
if (node.classList.contains(tailwindPrefix)) {
|
|
83
|
+
// traverse visits all descendants recursively, no need to querySelectorAll
|
|
84
|
+
traverse(node, addClasses);
|
|
85
|
+
} else {
|
|
86
|
+
// Node isn't a TailwindRoot itself — check descendants.
|
|
87
|
+
// React may insert a parent wrapper during navigation whose
|
|
88
|
+
// children contain TailwindRoot elements.
|
|
89
|
+
node.querySelectorAll(`.${tailwindPrefix}`).forEach(child => {
|
|
90
|
+
traverse(child, addClasses);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (classesSet.current.size > sizeBefore) shouldUpdate = true;
|
|
82
95
|
});
|
|
83
96
|
} else if (record.type === 'attributes') {
|
|
84
97
|
if (record.attributeName !== 'class' || !(record.target instanceof HTMLElement)) return;
|
|
85
98
|
|
|
99
|
+
const sizeBefore = classesSet.current.size;
|
|
86
100
|
addClasses(record.target);
|
|
87
|
-
shouldUpdate = true;
|
|
101
|
+
if (classesSet.current.size > sizeBefore) shouldUpdate = true;
|
|
88
102
|
}
|
|
89
|
-
|
|
90
103
|
});
|
|
91
104
|
|
|
92
105
|
if (shouldUpdate) {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
interface EmbedProps {
|
|
3
3
|
favicon?: string;
|
|
4
4
|
html?: string;
|
|
5
|
-
iframe?: boolean;
|
|
5
|
+
iframe?: boolean | string;
|
|
6
6
|
image?: string;
|
|
7
7
|
lazy?: boolean;
|
|
8
8
|
providerName?: string;
|
|
@@ -11,5 +11,5 @@ interface EmbedProps {
|
|
|
11
11
|
typeOfEmbed?: string;
|
|
12
12
|
url: string;
|
|
13
13
|
}
|
|
14
|
-
declare const Embed: ({ lazy, url, html, providerName, providerUrl, title, iframe, image, favicon, ...attrs }: EmbedProps) => React.JSX.Element;
|
|
14
|
+
declare const Embed: ({ lazy, url, html, providerName, providerUrl, title, iframe, image, favicon, typeOfEmbed, ...attrs }: EmbedProps) => React.JSX.Element;
|
|
15
15
|
export default Embed;
|