Skip to content

Commit 7facad7

Browse files
feat: remove medium-zoom temporarily
1 parent b82e2bd commit 7facad7

File tree

5 files changed

+4
-52
lines changed

5 files changed

+4
-52
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"typescript": "^3.9.7"
5959
},
6060
"dependencies": {
61-
"medium-zoom": "^1.0.5",
6261
"prismjs": "^1.20.0"
6362
}
6463
}

src/block.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ interface Block {
6161
mapImageUrl: MapImageUrl;
6262

6363
fullPage?: boolean;
64-
zoom?: any;
6564
}
6665

6766
export const Block: React.FC<Block> = props => {
@@ -71,7 +70,6 @@ export const Block: React.FC<Block> = props => {
7170
level,
7271
fullPage,
7372
blockMap,
74-
zoom,
7573
mapPageUrl,
7674
mapImageUrl
7775
} = props;
@@ -246,7 +244,7 @@ export const Block: React.FC<Block> = props => {
246244
className="notion-asset-wrapper"
247245
style={{ width: value.format.block_width }}
248246
>
249-
<Asset block={block} zoom={zoom} mapImageUrl={mapImageUrl} />
247+
<Asset block={block} mapImageUrl={mapImageUrl} />
250248

251249
{value.properties.caption && (
252250
<figcaption className="notion-image-caption">

src/components/asset.tsx

+2-11
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ const types = ["video", "image", "embed"];
66
const Asset: React.FC<{
77
block: BlockType;
88
mapImageUrl: MapImageUrl;
9-
zoom?: any;
10-
}> = ({ block, mapImageUrl, zoom }) => {
11-
const zoomRef = React.useRef(zoom ? zoom.clone() : null);
9+
}> = ({ block, mapImageUrl }) => {
1210
const value = block.value as ContentValueType;
1311
const type = block.value.type;
1412

@@ -41,12 +39,6 @@ const Asset: React.FC<{
4139

4240
const src = mapImageUrl(value.properties.source[0][0]);
4341

44-
function attachZoom(image: any) {
45-
if (zoomRef.current) {
46-
(zoomRef.current as any).attach(image);
47-
}
48-
}
49-
5042
if (type === "image") {
5143
const caption = value.properties.caption?.[0][0];
5244

@@ -62,12 +54,11 @@ const Asset: React.FC<{
6254
className="notion-image-inset"
6355
alt={caption || "notion image"}
6456
src={src}
65-
ref={attachZoom}
6657
/>
6758
</div>
6859
);
6960
} else {
70-
return <img alt={caption} src={src} ref={attachZoom} />;
61+
return <img alt={caption} src={src} />;
7162
}
7263
}
7364

src/renderer.tsx

+1-32
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React from "react";
2-
import mediumZoom from "medium-zoom";
32
import { BlockMapType, MapPageUrl, MapImageUrl } from "./types";
43
import { Block } from "./block";
5-
import { defaultMapImageUrl, defaultMapPageUrl } from "utils";
4+
import { defaultMapImageUrl, defaultMapPageUrl } from "./utils";
65

76
export interface NotionRendererProps {
87
blockMap: BlockMapType;
@@ -12,7 +11,6 @@ export interface NotionRendererProps {
1211

1312
currentId?: string;
1413
level?: number;
15-
zoom?: any;
1614
}
1715

1816
export const NotionRenderer: React.FC<NotionRendererProps> = ({
@@ -33,21 +31,11 @@ export const NotionRenderer: React.FC<NotionRendererProps> = ({
3331
return null;
3432
}
3533

36-
const zoom =
37-
props.zoom ||
38-
(typeof window !== "undefined" &&
39-
mediumZoom({
40-
container: ".notion",
41-
background: "rgba(0, 0, 0, 0.8)",
42-
margin: getMediumZoomMargin()
43-
}));
44-
4534
return (
4635
<Block
4736
key={id}
4837
level={level}
4938
block={currentBlock}
50-
zoom={zoom}
5139
mapPageUrl={mapPageUrl}
5240
mapImageUrl={mapImageUrl}
5341
{...props}
@@ -57,7 +45,6 @@ export const NotionRenderer: React.FC<NotionRendererProps> = ({
5745
key={contentId}
5846
currentId={contentId}
5947
level={level + 1}
60-
zoom={zoom}
6148
mapPageUrl={mapPageUrl}
6249
mapImageUrl={mapImageUrl}
6350
{...props}
@@ -66,21 +53,3 @@ export const NotionRenderer: React.FC<NotionRendererProps> = ({
6653
</Block>
6754
);
6855
};
69-
70-
function getMediumZoomMargin() {
71-
const width = window.innerWidth;
72-
73-
if (width < 500) {
74-
return 8;
75-
} else if (width < 800) {
76-
return 20;
77-
} else if (width < 1280) {
78-
return 30;
79-
} else if (width < 1600) {
80-
return 40;
81-
} else if (width < 1920) {
82-
return 48;
83-
} else {
84-
return 72;
85-
}
86-
}

yarn.lock

-5
Original file line numberDiff line numberDiff line change
@@ -4112,11 +4112,6 @@ map-visit@^1.0.0:
41124112
dependencies:
41134113
object-visit "^1.0.0"
41144114

4115-
medium-zoom@^1.0.5:
4116-
version "1.0.5"
4117-
resolved "https://registry.yarnpkg.com/medium-zoom/-/medium-zoom-1.0.5.tgz#81413dda20ccdd857141ff420cfab788dd32e20e"
4118-
integrity sha512-aLGa6WlTuFKWvH88bqTrY5ztJMN+D0hd8UX6BYc4YSoPayppzETjZUcdVcksgaoQEMg4cZSmXPg846fTp2rjRQ==
4119-
41204115
merge-stream@^2.0.0:
41214116
version "2.0.0"
41224117
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"

0 commit comments

Comments
 (0)