@mintlify/common 1.0.619 → 1.0.621
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.
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { u } from 'unist-builder';
|
|
2
2
|
import { visit } from 'unist-util-visit';
|
|
3
|
+
const isInsideTile = (parent) => {
|
|
4
|
+
if (parent && 'name' in parent && parent.name === 'Tile') {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
return false;
|
|
8
|
+
};
|
|
3
9
|
export const rehypeZoomImages = () => (tree) => {
|
|
4
10
|
visit(tree, 'mdxJsxFlowElement', (node, index, parent) => {
|
|
5
11
|
if (node.name === 'img' ||
|
|
@@ -7,16 +13,17 @@ export const rehypeZoomImages = () => (tree) => {
|
|
|
7
13
|
node.name === 'figure' ||
|
|
8
14
|
node.name === 'iframe') {
|
|
9
15
|
const noZoom = node.attributes.find((attr) => attr.type === 'mdxJsxAttribute' && attr.name === 'noZoom');
|
|
16
|
+
const shouldSkipZoom = noZoom || isInsideTile(parent);
|
|
10
17
|
if (parent && index != null) {
|
|
11
18
|
// For img elements, replace with OptimizedImage (it applies Zoom internally)
|
|
12
|
-
if (node.name === 'img') {
|
|
19
|
+
if (node.name === 'img' && !shouldSkipZoom) {
|
|
13
20
|
const optimizedImg = u('mdxJsxFlowElement', {
|
|
14
21
|
name: 'OptimizedImage',
|
|
15
22
|
attributes: node.attributes,
|
|
16
23
|
}, []);
|
|
17
24
|
parent.children.splice(index, 1, optimizedImg);
|
|
18
25
|
}
|
|
19
|
-
else if (!
|
|
26
|
+
else if (!shouldSkipZoom) {
|
|
20
27
|
parent.children.splice(index, 1, u('element', {
|
|
21
28
|
tagName: 'ZoomImage',
|
|
22
29
|
properties: {},
|