@texonom/nreact 1.1.1 → 1.1.3

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.
Files changed (97) hide show
  1. package/build/.tsbuildinfo +1 -1
  2. package/build/block.d.ts +20 -20
  3. package/build/chunk-N3C4YBY7.js +1378 -0
  4. package/build/components/asset-wrapper.d.ts +6 -6
  5. package/build/components/asset.d.ts +7 -7
  6. package/build/components/audio.d.ts +6 -6
  7. package/build/components/checkbox.d.ts +5 -5
  8. package/build/components/eoi.d.ts +7 -7
  9. package/build/components/file.d.ts +6 -6
  10. package/build/components/google-drive.d.ts +6 -6
  11. package/build/components/graceful-image.d.ts +3 -3
  12. package/build/components/header.d.ts +15 -15
  13. package/build/components/lazy-image.d.ts +13 -13
  14. package/build/components/lite-youtube-embed.d.ts +13 -13
  15. package/build/components/page-aside.d.ts +11 -11
  16. package/build/components/page-icon.d.ts +16 -16
  17. package/build/components/page-title.d.ts +12 -12
  18. package/build/components/search-dialog.d.ts +25 -25
  19. package/build/components/sync-pointer-block.d.ts +6 -6
  20. package/build/components/text.d.ts +17 -17
  21. package/build/context.d.ts +62 -61
  22. package/build/context.d.ts.map +1 -1
  23. package/build/dev/chunk-XOMF4TSV.js +1379 -0
  24. package/build/dev/chunk-XOMF4TSV.js.map +1 -0
  25. package/build/dev/index.js +697 -3
  26. package/build/dev/index.js.map +1 -1
  27. package/build/dev/third-party/code.js +1 -1
  28. package/build/dev/third-party/collection.js +1 -1
  29. package/build/dev/third-party/collection.js.map +1 -1
  30. package/build/dev/third-party/equation.js +1 -1
  31. package/build/icons/check.d.ts +3 -3
  32. package/build/icons/chevron-down-icon.d.ts +2 -2
  33. package/build/icons/clear-icon.d.ts +2 -2
  34. package/build/icons/collection-view-board.d.ts +3 -3
  35. package/build/icons/collection-view-calendar.d.ts +3 -3
  36. package/build/icons/collection-view-gallery.d.ts +3 -3
  37. package/build/icons/collection-view-icon.d.ts +8 -8
  38. package/build/icons/collection-view-list.d.ts +3 -3
  39. package/build/icons/collection-view-table.d.ts +3 -3
  40. package/build/icons/copy.d.ts +3 -3
  41. package/build/icons/default-page-icon.d.ts +2 -2
  42. package/build/icons/empty-icon.d.ts +2 -2
  43. package/build/icons/file-icon.d.ts +2 -2
  44. package/build/icons/link-icon.d.ts +2 -2
  45. package/build/icons/loading-icon.d.ts +2 -2
  46. package/build/icons/property-icon.d.ts +8 -8
  47. package/build/icons/search-icon.d.ts +2 -2
  48. package/build/icons/type-checkbox.d.ts +3 -3
  49. package/build/icons/type-date.d.ts +3 -3
  50. package/build/icons/type-email.d.ts +3 -3
  51. package/build/icons/type-file.d.ts +3 -3
  52. package/build/icons/type-formula.d.ts +3 -3
  53. package/build/icons/type-github.d.ts +3 -3
  54. package/build/icons/type-multi-select.d.ts +3 -3
  55. package/build/icons/type-number.d.ts +3 -3
  56. package/build/icons/type-person-2.d.ts +3 -3
  57. package/build/icons/type-person.d.ts +3 -3
  58. package/build/icons/type-phone-number.d.ts +3 -3
  59. package/build/icons/type-relation.d.ts +3 -3
  60. package/build/icons/type-select.d.ts +3 -3
  61. package/build/icons/type-text.d.ts +3 -3
  62. package/build/icons/type-timestamp.d.ts +3 -3
  63. package/build/icons/type-title.d.ts +3 -3
  64. package/build/icons/type-url.d.ts +3 -3
  65. package/build/index.d.ts +7 -7
  66. package/build/index.js +697 -3
  67. package/build/map-image-url.d.ts +2 -2
  68. package/build/map-page-url.d.ts +1 -1
  69. package/build/next.d.ts +3 -3
  70. package/build/renderer.d.ts +49 -49
  71. package/build/third-party/code.d.ts +16 -16
  72. package/build/third-party/code.js +1 -1
  73. package/build/third-party/collection-card.d.ts +3 -3
  74. package/build/third-party/collection-column-title.d.ts +5 -5
  75. package/build/third-party/collection-group.d.ts +3 -3
  76. package/build/third-party/collection-row.d.ts +7 -7
  77. package/build/third-party/collection-utils.d.ts +1 -1
  78. package/build/third-party/collection-view-board.d.ts +3 -3
  79. package/build/third-party/collection-view-gallery.d.ts +3 -3
  80. package/build/third-party/collection-view-list.d.ts +3 -3
  81. package/build/third-party/collection-view-table.d.ts +3 -3
  82. package/build/third-party/collection-view.d.ts +4 -4
  83. package/build/third-party/collection.d.ts +10 -10
  84. package/build/third-party/collection.js +1 -1
  85. package/build/third-party/equation.d.ts +8 -8
  86. package/build/third-party/equation.js +1 -1
  87. package/build/third-party/eval-formula.d.ts +20 -20
  88. package/build/third-party/modal.d.ts +2 -2
  89. package/build/third-party/pdf.d.ts +4 -4
  90. package/build/third-party/property.d.ts +21 -21
  91. package/build/types.d.ts +71 -71
  92. package/build/utils.d.ts +9 -9
  93. package/package.json +9 -9
  94. package/readme.md +3 -3
  95. package/build/chunk-RGP7M4NM.js +0 -2064
  96. package/build/dev/chunk-HLFRY3QP.js +0 -2065
  97. package/build/dev/chunk-HLFRY3QP.js.map +0 -1
package/build/index.js CHANGED
@@ -1,11 +1,15 @@
1
1
  import {
2
+ AssetWrapper,
2
3
  Breadcrumbs,
4
+ EOI,
5
+ GracefulImage,
3
6
  Header,
7
+ LazyImage,
4
8
  NotionContextConsumer,
5
9
  NotionContextProvider,
6
- NotionRenderer,
7
10
  PageIcon,
8
11
  PageIconImpl,
12
+ PageTitle,
9
13
  Search,
10
14
  Text,
11
15
  cs,
@@ -19,9 +23,699 @@ import {
19
23
  getYoutubeId,
20
24
  isBrowser,
21
25
  isUrl,
26
+ require_lodash,
22
27
  useNotionContext
23
- } from "./chunk-RGP7M4NM.js";
24
- import "./chunk-723T62SD.js";
28
+ } from "./chunk-N3C4YBY7.js";
29
+ import {
30
+ __objRest,
31
+ __spreadProps,
32
+ __spreadValues,
33
+ __toESM
34
+ } from "./chunk-723T62SD.js";
35
+
36
+ // src/renderer.tsx
37
+ import * as React9 from "react";
38
+ import mediumZoom from "@fisch0920/medium-zoom";
39
+
40
+ // src/block.tsx
41
+ import * as React8 from "react";
42
+ import {
43
+ getBlockCollectionId,
44
+ getBlockIcon,
45
+ getBlockParentPage,
46
+ getPageTableOfContents,
47
+ getTextContent,
48
+ uuidToId as uuidToId2
49
+ } from "@texonom/nutils";
50
+
51
+ // src/components/audio.tsx
52
+ import * as React from "react";
53
+ var Audio = ({ block, className }) => {
54
+ var _a, _b, _c;
55
+ const { recordMap } = useNotionContext();
56
+ const source = recordMap.signed_urls[block.id] || ((_c = (_b = (_a = block.properties) == null ? void 0 : _a.source) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]);
57
+ return /* @__PURE__ */ React.createElement("div", { className: cs("notion-audio", className) }, /* @__PURE__ */ React.createElement("audio", { controls: true, preload: "none", src: source }));
58
+ };
59
+
60
+ // src/components/file.tsx
61
+ import * as React3 from "react";
62
+
63
+ // src/icons/file-icon.tsx
64
+ import * as React2 from "react";
65
+ var FileIcon = (props) => {
66
+ const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
67
+ return /* @__PURE__ */ React2.createElement("svg", __spreadProps(__spreadValues({ className }, rest), { viewBox: "0 0 30 30" }), /* @__PURE__ */ React2.createElement("path", { d: "M22,8v12c0,3.866-3.134,7-7,7s-7-3.134-7-7V8c0-2.762,2.238-5,5-5s5,2.238,5,5v12c0,1.657-1.343,3-3,3s-3-1.343-3-3V8h-2v12c0,2.762,2.238,5,5,5s5-2.238,5-5V8c0-3.866-3.134-7-7-7S6,4.134,6,8v12c0,4.971,4.029,9,9,9s9-4.029,9-9V8H22z" }));
68
+ };
69
+
70
+ // src/components/file.tsx
71
+ var File = ({ block, className }) => {
72
+ var _a, _b, _c, _d, _e;
73
+ const { components, recordMap } = useNotionContext();
74
+ const source = recordMap.signed_urls[block.id] || ((_c = (_b = (_a = block.properties) == null ? void 0 : _a.source) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]);
75
+ return /* @__PURE__ */ React3.createElement("div", { className: cs("notion-file", className) }, /* @__PURE__ */ React3.createElement(components.Link, { className: "notion-file-link", href: source, target: "_blank", rel: "noopener noreferrer" }, /* @__PURE__ */ React3.createElement(FileIcon, { className: "notion-file-icon" }), /* @__PURE__ */ React3.createElement("div", { className: "notion-file-info" }, /* @__PURE__ */ React3.createElement("div", { className: "notion-file-title" }, /* @__PURE__ */ React3.createElement(Text, { value: ((_d = block.properties) == null ? void 0 : _d.title) || [["File"]], block })), ((_e = block.properties) == null ? void 0 : _e.size) && /* @__PURE__ */ React3.createElement("div", { className: "notion-file-size" }, /* @__PURE__ */ React3.createElement(Text, { value: block.properties.size, block })))));
76
+ };
77
+
78
+ // src/components/google-drive.tsx
79
+ import * as React4 from "react";
80
+ var GoogleDrive = ({ block, className }) => {
81
+ var _a;
82
+ const { components, mapImageUrl } = useNotionContext();
83
+ const properties = (_a = block.format) == null ? void 0 : _a.drive_properties;
84
+ if (!properties)
85
+ return null;
86
+ let domain;
87
+ try {
88
+ const url = new URL(properties.url);
89
+ domain = url.hostname;
90
+ } catch (err) {
91
+ }
92
+ return /* @__PURE__ */ React4.createElement("div", { className: cs("notion-google-drive", className) }, /* @__PURE__ */ React4.createElement(components.Link, { className: "notion-google-drive-link", href: properties.url, target: "_blank", rel: "noopener noreferrer" }, /* @__PURE__ */ React4.createElement("div", { className: "notion-google-drive-preview" }, /* @__PURE__ */ React4.createElement(
93
+ GracefulImage,
94
+ {
95
+ src: mapImageUrl(properties.thumbnail, block),
96
+ alt: properties.title || "Google Drive Document",
97
+ loading: "lazy"
98
+ }
99
+ )), /* @__PURE__ */ React4.createElement("div", { className: "notion-google-drive-body" }, properties.title && /* @__PURE__ */ React4.createElement("div", { className: "notion-google-drive-body-title" }, properties.title), properties.icon && domain && /* @__PURE__ */ React4.createElement("div", { className: "notion-google-drive-body-source" }, properties.icon && /* @__PURE__ */ React4.createElement(
100
+ "div",
101
+ {
102
+ className: "notion-google-drive-body-source-icon",
103
+ style: {
104
+ backgroundImage: `url(${properties.icon})`
105
+ }
106
+ }
107
+ ), domain && /* @__PURE__ */ React4.createElement("div", { className: "notion-google-drive-body-source-domain" }, domain)))));
108
+ };
109
+
110
+ // src/components/page-aside.tsx
111
+ var import_lodash = __toESM(require_lodash(), 1);
112
+ import * as React5 from "react";
113
+ import { uuidToId } from "@texonom/nutils";
114
+ var PageAside = ({ toc, activeSection, setActiveSection, pageAside, hasToc, hasAside, className }) => {
115
+ const throttleMs = 100;
116
+ const actionSectionScrollSpy = React5.useMemo(
117
+ () => (0, import_lodash.default)(() => {
118
+ const sections = document.getElementsByClassName("notion-h");
119
+ let prevBBox = null;
120
+ let currentSectionId = activeSection;
121
+ for (let i = 0; i < sections.length; ++i) {
122
+ const section = sections[i];
123
+ if (!section || !(section instanceof Element))
124
+ continue;
125
+ if (!currentSectionId)
126
+ currentSectionId = section.getAttribute("data-id");
127
+ const bbox = section.getBoundingClientRect();
128
+ const prevHeight = prevBBox ? bbox.top - prevBBox.bottom : 0;
129
+ const offset = Math.max(150, prevHeight / 4);
130
+ if (bbox.top - offset < 0) {
131
+ currentSectionId = section.getAttribute("data-id");
132
+ prevBBox = bbox;
133
+ continue;
134
+ }
135
+ break;
136
+ }
137
+ setActiveSection(currentSectionId);
138
+ }, throttleMs),
139
+ // eslint-disable-next-line react-hooks/exhaustive-deps
140
+ [
141
+ // explicitly not taking a dependency on activeSection
142
+ setActiveSection
143
+ ]
144
+ );
145
+ React5.useEffect(() => {
146
+ if (!hasToc)
147
+ return;
148
+ window.addEventListener("scroll", actionSectionScrollSpy);
149
+ actionSectionScrollSpy();
150
+ return () => {
151
+ window.removeEventListener("scroll", actionSectionScrollSpy);
152
+ };
153
+ }, [hasToc, actionSectionScrollSpy]);
154
+ if (!hasAside)
155
+ return null;
156
+ return /* @__PURE__ */ React5.createElement("aside", { className: cs("notion-aside", className) }, hasToc && /* @__PURE__ */ React5.createElement("div", { className: "notion-aside-table-of-contents" }, /* @__PURE__ */ React5.createElement("div", { className: "notion-aside-table-of-contents-header" }, "Table of Contents"), /* @__PURE__ */ React5.createElement("nav", { className: "notion-table-of-contents" }, toc.map((tocItem) => {
157
+ const id = uuidToId(tocItem.id);
158
+ return /* @__PURE__ */ React5.createElement(
159
+ "a",
160
+ {
161
+ key: id,
162
+ href: `#${id}`,
163
+ className: cs(
164
+ "notion-table-of-contents-item",
165
+ `notion-table-of-contents-item-indent-level-${tocItem.indentLevel}`,
166
+ activeSection === id && "notion-table-of-contents-active-item"
167
+ )
168
+ },
169
+ /* @__PURE__ */ React5.createElement(
170
+ "span",
171
+ {
172
+ className: "notion-table-of-contents-item-body",
173
+ style: {
174
+ display: "inline-block",
175
+ marginLeft: tocItem.indentLevel * 16
176
+ }
177
+ },
178
+ tocItem.text
179
+ )
180
+ );
181
+ }))), pageAside);
182
+ };
183
+
184
+ // src/components/sync-pointer-block.tsx
185
+ import * as React6 from "react";
186
+ var SyncPointerBlock = ({ block, level }) => {
187
+ var _a, _b;
188
+ if (!block) {
189
+ if (true)
190
+ console.warn("missing sync pointer block", block.id);
191
+ return null;
192
+ }
193
+ const syncPointerBlock = block;
194
+ const referencePointerId = (_b = (_a = syncPointerBlock == null ? void 0 : syncPointerBlock.format) == null ? void 0 : _a.transclusion_reference_pointer) == null ? void 0 : _b.id;
195
+ if (!referencePointerId)
196
+ return null;
197
+ return /* @__PURE__ */ React6.createElement(NotionBlockRenderer, { key: referencePointerId, level, blockId: referencePointerId });
198
+ };
199
+
200
+ // src/icons/link-icon.tsx
201
+ import * as React7 from "react";
202
+ var LinkIcon = (props) => {
203
+ const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
204
+ return /* @__PURE__ */ React7.createElement("svg", __spreadProps(__spreadValues({ className }, rest), { viewBox: "0 0 16 16", width: "16", height: "16" }), /* @__PURE__ */ React7.createElement(
205
+ "path",
206
+ {
207
+ fillRule: "evenodd",
208
+ d: "M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"
209
+ }
210
+ ));
211
+ };
212
+
213
+ // src/block.tsx
214
+ var tocIndentLevelCache = {};
215
+ var pageCoverStyleCache = {};
216
+ var Block = (props) => {
217
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q;
218
+ const ctx = useNotionContext();
219
+ const {
220
+ components,
221
+ fullPage,
222
+ darkMode,
223
+ recordMap,
224
+ mapPageUrl,
225
+ mapImageUrl,
226
+ showTableOfContents,
227
+ minTableOfContentsItems,
228
+ defaultPageIcon,
229
+ defaultPageCover,
230
+ defaultPageCoverPosition
231
+ } = ctx;
232
+ const [activeSection, setActiveSection] = React8.useState(null);
233
+ const {
234
+ block,
235
+ children,
236
+ level,
237
+ className,
238
+ bodyClassName,
239
+ header,
240
+ footer,
241
+ pageHeader,
242
+ pageFooter,
243
+ pageTitle,
244
+ pageAside,
245
+ pageCover,
246
+ hideBlockId,
247
+ disableHeader
248
+ } = props;
249
+ if (!block)
250
+ return null;
251
+ if (level === 0 && block.type === "collection_view") {
252
+ ;
253
+ block.type = "collection_view_page";
254
+ }
255
+ const blockId = hideBlockId ? "notion-block" : `notion-block-${uuidToId2(block.id)}`;
256
+ switch (block.type) {
257
+ case "collection_view_page":
258
+ case "page":
259
+ if (level === 0) {
260
+ const {
261
+ page_icon = defaultPageIcon,
262
+ page_cover = defaultPageCover,
263
+ page_cover_position = defaultPageCoverPosition,
264
+ page_full_width,
265
+ page_small_text
266
+ } = block.format || {};
267
+ if (fullPage) {
268
+ const properties = block.type === "page" ? block.properties : {
269
+ title: (_b = (_a = recordMap.collection[getBlockCollectionId(block, recordMap)]) == null ? void 0 : _a.value) == null ? void 0 : _b.name
270
+ };
271
+ const coverPosition = (1 - (page_cover_position || 0.5)) * 100;
272
+ const pageCoverObjectPosition = `center ${coverPosition}%`;
273
+ let pageCoverStyle = pageCoverStyleCache[pageCoverObjectPosition];
274
+ if (!pageCoverStyle)
275
+ pageCoverStyle = pageCoverStyleCache[pageCoverObjectPosition] = {
276
+ objectPosition: pageCoverObjectPosition
277
+ };
278
+ const pageIcon = (_c = getBlockIcon(block, recordMap)) != null ? _c : defaultPageIcon;
279
+ const isPageIconUrl = pageIcon && isUrl(pageIcon);
280
+ const toc = getPageTableOfContents(block, recordMap);
281
+ const hasToc = showTableOfContents && toc.length >= minTableOfContentsItems;
282
+ const hasAside = (hasToc || pageAside) && !page_full_width;
283
+ const hasPageCover = pageCover || page_cover;
284
+ return /* @__PURE__ */ React8.createElement("div", { className: cs("notion", "notion-app", darkMode ? "dark" : "light", blockId, className) }, /* @__PURE__ */ React8.createElement("div", { className: "notion-viewport" }), /* @__PURE__ */ React8.createElement("div", { className: "notion-frame" }, !disableHeader && /* @__PURE__ */ React8.createElement(components.Header, { block }), header, /* @__PURE__ */ React8.createElement("div", { className: "notion-page-scroller" }, hasPageCover && (pageCover ? pageCover : /* @__PURE__ */ React8.createElement("div", { className: "notion-page-cover-wrapper" }, /* @__PURE__ */ React8.createElement(
285
+ LazyImage,
286
+ {
287
+ src: mapImageUrl(page_cover, block),
288
+ alt: getTextContent(properties == null ? void 0 : properties.title),
289
+ priority: true,
290
+ className: "notion-page-cover",
291
+ style: pageCoverStyle
292
+ }
293
+ ))), /* @__PURE__ */ React8.createElement(
294
+ "main",
295
+ {
296
+ className: cs(
297
+ "notion-page",
298
+ hasPageCover ? "notion-page-has-cover" : "notion-page-no-cover",
299
+ page_icon ? "notion-page-has-icon" : "notion-page-no-icon",
300
+ isPageIconUrl ? "notion-page-has-image-icon" : "notion-page-has-text-icon",
301
+ "notion-full-page",
302
+ page_full_width && "notion-full-width",
303
+ page_small_text && "notion-small-text",
304
+ bodyClassName
305
+ )
306
+ },
307
+ page_icon && /* @__PURE__ */ React8.createElement(PageIcon, { block, defaultIcon: defaultPageIcon, inline: false }),
308
+ pageHeader,
309
+ /* @__PURE__ */ React8.createElement("h1", { className: "notion-title" }, pageTitle != null ? pageTitle : /* @__PURE__ */ React8.createElement(Text, { value: properties == null ? void 0 : properties.title, block })),
310
+ (block.type === "collection_view_page" || block.type === "page" && block.parent_table === "collection") && /* @__PURE__ */ React8.createElement(components.Collection, { block, ctx }),
311
+ block.type !== "collection_view_page" && /* @__PURE__ */ React8.createElement(
312
+ "div",
313
+ {
314
+ className: cs(
315
+ "notion-page-content",
316
+ hasAside && "notion-page-content-has-aside",
317
+ hasToc && "notion-page-content-has-toc"
318
+ )
319
+ },
320
+ /* @__PURE__ */ React8.createElement("article", { className: "notion-page-content-inner" }, children),
321
+ hasAside && /* @__PURE__ */ React8.createElement(
322
+ PageAside,
323
+ {
324
+ toc,
325
+ activeSection,
326
+ setActiveSection,
327
+ hasToc,
328
+ hasAside,
329
+ pageAside
330
+ }
331
+ )
332
+ ),
333
+ pageFooter
334
+ ), footer)));
335
+ } else {
336
+ return /* @__PURE__ */ React8.createElement(
337
+ "main",
338
+ {
339
+ className: cs(
340
+ "notion",
341
+ darkMode ? "dark" : "light",
342
+ "notion-page",
343
+ page_full_width && "notion-full-width",
344
+ page_small_text && "notion-small-text",
345
+ blockId,
346
+ className,
347
+ bodyClassName
348
+ )
349
+ },
350
+ /* @__PURE__ */ React8.createElement("div", { className: "notion-viewport" }),
351
+ pageHeader,
352
+ (block.type === "collection_view_page" || block.type === "page" && block.parent_table === "collection") && /* @__PURE__ */ React8.createElement(components.Collection, { block, ctx }),
353
+ block.type !== "collection_view_page" && children,
354
+ pageFooter
355
+ );
356
+ }
357
+ } else {
358
+ const blockColor = (_d = block.format) == null ? void 0 : _d.block_color;
359
+ return /* @__PURE__ */ React8.createElement(
360
+ components.PageLink,
361
+ {
362
+ className: cs("notion-page-link", blockColor && `notion-${blockColor}`, blockId),
363
+ href: mapPageUrl(block.id)
364
+ },
365
+ /* @__PURE__ */ React8.createElement(PageTitle, { block })
366
+ );
367
+ }
368
+ case "header":
369
+ case "sub_header":
370
+ case "sub_sub_header": {
371
+ if (!block.properties)
372
+ return null;
373
+ const blockColor = (_e = block.format) == null ? void 0 : _e.block_color;
374
+ const id = uuidToId2(block.id);
375
+ const title = getTextContent(block.properties.title) || `Notion Header ${id}`;
376
+ let indentLevel = tocIndentLevelCache[block.id];
377
+ let indentLevelClass;
378
+ if (indentLevel === void 0) {
379
+ const page = getBlockParentPage(block, recordMap);
380
+ if (page) {
381
+ const toc = getPageTableOfContents(page, recordMap);
382
+ const tocItem = toc.find((tocItem2) => tocItem2.id === block.id);
383
+ if (tocItem) {
384
+ indentLevel = tocItem.indentLevel;
385
+ tocIndentLevelCache[block.id] = indentLevel;
386
+ }
387
+ }
388
+ }
389
+ if (indentLevel !== void 0)
390
+ indentLevelClass = `notion-h-indent-${indentLevel}`;
391
+ const isH1 = block.type === "header";
392
+ const isH2 = block.type === "sub_header";
393
+ const isH3 = block.type === "sub_sub_header";
394
+ const classNameStr = cs(
395
+ isH1 && "notion-h notion-h1",
396
+ isH2 && "notion-h notion-h2",
397
+ isH3 && "notion-h notion-h3",
398
+ blockColor && `notion-${blockColor}`,
399
+ indentLevelClass,
400
+ blockId
401
+ );
402
+ const innerHeader = /* @__PURE__ */ React8.createElement("span", null, /* @__PURE__ */ React8.createElement("div", { id, className: "notion-header-anchor" }), !((_f = block.format) == null ? void 0 : _f.toggleable) && /* @__PURE__ */ React8.createElement("a", { className: "notion-hash-link", href: `#${id}`, title }, /* @__PURE__ */ React8.createElement(LinkIcon, null)), /* @__PURE__ */ React8.createElement("span", { className: "notion-h-title" }, /* @__PURE__ */ React8.createElement(Text, { value: block.properties.title, block })));
403
+ let headerBlock = null;
404
+ if (isH1)
405
+ headerBlock = /* @__PURE__ */ React8.createElement("h2", { className: classNameStr, "data-id": id }, innerHeader);
406
+ else if (isH2)
407
+ headerBlock = /* @__PURE__ */ React8.createElement("h3", { className: classNameStr, "data-id": id }, innerHeader);
408
+ else
409
+ headerBlock = /* @__PURE__ */ React8.createElement("h4", { className: classNameStr, "data-id": id }, innerHeader);
410
+ if ((_g = block.format) == null ? void 0 : _g.toggleable)
411
+ return /* @__PURE__ */ React8.createElement("details", { className: cs("notion-toggle", blockId) }, /* @__PURE__ */ React8.createElement("summary", null, headerBlock), /* @__PURE__ */ React8.createElement("div", null, children));
412
+ else
413
+ return headerBlock;
414
+ }
415
+ case "divider":
416
+ return /* @__PURE__ */ React8.createElement("hr", { className: cs("notion-hr", blockId) });
417
+ case "text": {
418
+ if (!block.properties && !((_h = block.content) == null ? void 0 : _h.length))
419
+ return /* @__PURE__ */ React8.createElement("div", { className: cs("notion-blank", blockId) }, "\xA0");
420
+ const blockColor = (_i = block.format) == null ? void 0 : _i.block_color;
421
+ return /* @__PURE__ */ React8.createElement("div", { className: cs("notion-text", blockColor && `notion-${blockColor}`, blockId) }, ((_j = block.properties) == null ? void 0 : _j.title) && /* @__PURE__ */ React8.createElement(Text, { value: block.properties.title, block }), children && /* @__PURE__ */ React8.createElement("div", { className: "notion-text-children" }, children));
422
+ }
423
+ case "bulleted_list":
424
+ case "numbered_list": {
425
+ const wrapList = (content, start2) => block.type === "bulleted_list" ? /* @__PURE__ */ React8.createElement("ul", { className: cs("notion-list", "notion-list-disc", blockId) }, content) : /* @__PURE__ */ React8.createElement("ol", { start: start2, className: cs("notion-list", "notion-list-numbered", blockId) }, content);
426
+ let output = null;
427
+ if (block.content)
428
+ output = /* @__PURE__ */ React8.createElement(React8.Fragment, null, block.properties && /* @__PURE__ */ React8.createElement("li", null, /* @__PURE__ */ React8.createElement(Text, { value: block.properties.title, block })), wrapList(children));
429
+ else
430
+ output = block.properties ? /* @__PURE__ */ React8.createElement("li", null, /* @__PURE__ */ React8.createElement(Text, { value: block.properties.title, block })) : null;
431
+ const isTopLevel = block.type !== ((_l = (_k = recordMap.block[block.parent_id]) == null ? void 0 : _k.value) == null ? void 0 : _l.type);
432
+ const start = getListNumber(block.id, recordMap.block);
433
+ return isTopLevel ? wrapList(output, start) : output;
434
+ }
435
+ case "embed":
436
+ return /* @__PURE__ */ React8.createElement(components.Embed, { blockId, block });
437
+ case "tweet":
438
+ case "maps":
439
+ case "pdf":
440
+ case "figma":
441
+ case "typeform":
442
+ case "codepen":
443
+ case "excalidraw":
444
+ case "image":
445
+ case "gist":
446
+ case "video":
447
+ return /* @__PURE__ */ React8.createElement(AssetWrapper, { blockId, block });
448
+ case "drive": {
449
+ const properties = (_m = block.format) == null ? void 0 : _m.drive_properties;
450
+ if (!properties) {
451
+ if ((_n = block.format) == null ? void 0 : _n.display_source)
452
+ return /* @__PURE__ */ React8.createElement(AssetWrapper, { blockId, block });
453
+ }
454
+ return /* @__PURE__ */ React8.createElement(GoogleDrive, { block, className: blockId });
455
+ }
456
+ case "audio":
457
+ return /* @__PURE__ */ React8.createElement(Audio, { block, className: blockId });
458
+ case "file":
459
+ return /* @__PURE__ */ React8.createElement(File, { block, className: blockId });
460
+ case "equation":
461
+ return /* @__PURE__ */ React8.createElement(components.Equation, { block, inline: false, className: blockId });
462
+ case "code":
463
+ return /* @__PURE__ */ React8.createElement(components.Code, { block });
464
+ case "column_list":
465
+ return /* @__PURE__ */ React8.createElement("div", { className: cs("notion-row", blockId) }, children);
466
+ case "column": {
467
+ const spacerWidth = `min(32px, 4vw)`;
468
+ const ratio = ((_o = block.format) == null ? void 0 : _o.column_ratio) || 0.5;
469
+ const parent = (_p = recordMap.block[block.parent_id]) == null ? void 0 : _p.value;
470
+ const columns = ((_q = parent == null ? void 0 : parent.content) == null ? void 0 : _q.length) || Math.max(2, Math.ceil(1 / ratio));
471
+ const width = `calc((100% - (${columns - 1} * ${spacerWidth})) * ${ratio})`;
472
+ const style = { width };
473
+ return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement("div", { className: cs("notion-column", blockId), style }, children), /* @__PURE__ */ React8.createElement("div", { className: "notion-spacer" }));
474
+ }
475
+ case "quote": {
476
+ if (!block.properties)
477
+ return null;
478
+ const blockColor = (_r = block.format) == null ? void 0 : _r.block_color;
479
+ return /* @__PURE__ */ React8.createElement("blockquote", { className: cs("notion-quote", blockColor && `notion-${blockColor}`, blockId) }, /* @__PURE__ */ React8.createElement("div", null, /* @__PURE__ */ React8.createElement(Text, { value: block.properties.title, block })), children);
480
+ }
481
+ case "collection_view":
482
+ return /* @__PURE__ */ React8.createElement(components.Collection, { block, className: blockId, ctx });
483
+ case "callout":
484
+ if (components.Callout)
485
+ return /* @__PURE__ */ React8.createElement(components.Callout, { block, className: blockId });
486
+ else
487
+ return /* @__PURE__ */ React8.createElement(
488
+ "div",
489
+ {
490
+ className: cs("notion-callout", ((_s = block.format) == null ? void 0 : _s.block_color) && `notion-${(_t = block.format) == null ? void 0 : _t.block_color}_co`, blockId)
491
+ },
492
+ /* @__PURE__ */ React8.createElement(PageIcon, { block }),
493
+ /* @__PURE__ */ React8.createElement("div", { className: "notion-callout-text" }, /* @__PURE__ */ React8.createElement(Text, { value: (_u = block.properties) == null ? void 0 : _u.title, block }), children)
494
+ );
495
+ case "bookmark": {
496
+ if (!block.properties)
497
+ return null;
498
+ const link = block.properties.link;
499
+ if (!link || !((_v = link[0]) == null ? void 0 : _v[0]))
500
+ return null;
501
+ let title = getTextContent(block.properties.title);
502
+ if (!title)
503
+ title = getTextContent(link);
504
+ if (title) {
505
+ if (title.startsWith("http"))
506
+ try {
507
+ const url = new URL(title);
508
+ title = url.hostname;
509
+ } catch (err) {
510
+ }
511
+ }
512
+ return /* @__PURE__ */ React8.createElement("div", { className: "notion-row" }, /* @__PURE__ */ React8.createElement(
513
+ components.Link,
514
+ {
515
+ target: "_blank",
516
+ rel: "noopener noreferrer",
517
+ className: cs("notion-bookmark", ((_w = block.format) == null ? void 0 : _w.block_color) && `notion-${block.format.block_color}`, blockId),
518
+ href: link[0][0]
519
+ },
520
+ /* @__PURE__ */ React8.createElement("div", null, title && /* @__PURE__ */ React8.createElement("div", { className: "notion-bookmark-title" }, /* @__PURE__ */ React8.createElement(Text, { value: [[title]], block })), ((_x = block.properties) == null ? void 0 : _x.description) && /* @__PURE__ */ React8.createElement("div", { className: "notion-bookmark-description" }, /* @__PURE__ */ React8.createElement(Text, { value: (_y = block.properties) == null ? void 0 : _y.description, block })), /* @__PURE__ */ React8.createElement("div", { className: "notion-bookmark-link" }, ((_z = block.format) == null ? void 0 : _z.bookmark_icon) && /* @__PURE__ */ React8.createElement("div", { className: "notion-bookmark-link-icon" }, /* @__PURE__ */ React8.createElement(LazyImage, { src: mapImageUrl((_A = block.format) == null ? void 0 : _A.bookmark_icon, block), alt: title })), /* @__PURE__ */ React8.createElement("div", { className: "notion-bookmark-link-text" }, /* @__PURE__ */ React8.createElement(Text, { value: link, block })))),
521
+ ((_B = block.format) == null ? void 0 : _B.bookmark_cover) && /* @__PURE__ */ React8.createElement("div", { className: "notion-bookmark-image" }, /* @__PURE__ */ React8.createElement(
522
+ LazyImage,
523
+ {
524
+ src: mapImageUrl((_C = block.format) == null ? void 0 : _C.bookmark_cover, block),
525
+ alt: getTextContent((_D = block.properties) == null ? void 0 : _D.title),
526
+ style: {
527
+ objectFit: "cover"
528
+ }
529
+ }
530
+ ))
531
+ ));
532
+ }
533
+ case "toggle":
534
+ return /* @__PURE__ */ React8.createElement("details", { className: cs("notion-toggle", blockId) }, /* @__PURE__ */ React8.createElement("summary", null, /* @__PURE__ */ React8.createElement(Text, { value: (_E = block.properties) == null ? void 0 : _E.title, block })), /* @__PURE__ */ React8.createElement("div", null, children));
535
+ case "table_of_contents": {
536
+ const page = getBlockParentPage(block, recordMap);
537
+ if (!page)
538
+ return null;
539
+ const toc = getPageTableOfContents(page, recordMap);
540
+ const blockColor = (_F = block.format) == null ? void 0 : _F.block_color;
541
+ return /* @__PURE__ */ React8.createElement("div", { className: cs("notion-table-of-contents", blockColor && `notion-${blockColor}`, blockId) }, toc.map((tocItem) => /* @__PURE__ */ React8.createElement("a", { key: tocItem.id, href: `#${uuidToId2(tocItem.id)}`, className: "notion-table-of-contents-item" }, /* @__PURE__ */ React8.createElement(
542
+ "span",
543
+ {
544
+ className: "notion-table-of-contents-item-body",
545
+ style: {
546
+ display: "inline-block",
547
+ marginLeft: tocItem.indentLevel * 24
548
+ }
549
+ },
550
+ tocItem.text
551
+ ))));
552
+ }
553
+ case "to_do": {
554
+ const isChecked = ((_I = (_H = (_G = block.properties) == null ? void 0 : _G.checked) == null ? void 0 : _H[0]) == null ? void 0 : _I[0]) === "Yes";
555
+ return /* @__PURE__ */ React8.createElement("div", { className: cs("notion-to-do", blockId) }, /* @__PURE__ */ React8.createElement("div", { className: "notion-to-do-item" }, /* @__PURE__ */ React8.createElement(components.Checkbox, { blockId, isChecked }), /* @__PURE__ */ React8.createElement("div", { className: cs("notion-to-do-body", isChecked && `notion-to-do-checked`) }, /* @__PURE__ */ React8.createElement(Text, { value: (_J = block.properties) == null ? void 0 : _J.title, block }))), /* @__PURE__ */ React8.createElement("div", { className: "notion-to-do-children" }, children));
556
+ }
557
+ case "transclusion_container":
558
+ return /* @__PURE__ */ React8.createElement("div", { className: cs("notion-sync-block", blockId) }, children);
559
+ case "transclusion_reference":
560
+ return /* @__PURE__ */ React8.createElement(SyncPointerBlock, __spreadValues({ block, level: level + 1 }, props));
561
+ case "alias": {
562
+ const blockPointerId = (_L = (_K = block == null ? void 0 : block.format) == null ? void 0 : _K.alias_pointer) == null ? void 0 : _L.id;
563
+ const linkedBlock = (_M = recordMap.block[blockPointerId]) == null ? void 0 : _M.value;
564
+ if (!linkedBlock) {
565
+ console.info('"alias" missing block', blockPointerId);
566
+ return null;
567
+ }
568
+ return /* @__PURE__ */ React8.createElement(components.PageLink, { className: cs("notion-page-link", blockPointerId), href: mapPageUrl(blockPointerId) }, /* @__PURE__ */ React8.createElement(PageTitle, { block: linkedBlock }));
569
+ }
570
+ case "table":
571
+ return /* @__PURE__ */ React8.createElement("table", { className: cs("notion-simple-table", blockId) }, /* @__PURE__ */ React8.createElement("tbody", null, children));
572
+ case "table_row": {
573
+ const tableBlock = (_N = recordMap.block[block.parent_id]) == null ? void 0 : _N.value;
574
+ const order = (_O = tableBlock.format) == null ? void 0 : _O.table_block_column_order;
575
+ const formatMap = (_P = tableBlock.format) == null ? void 0 : _P.table_block_column_format;
576
+ const backgroundColor = (_Q = block.format) == null ? void 0 : _Q.block_color;
577
+ if (!tableBlock || !order)
578
+ return null;
579
+ return /* @__PURE__ */ React8.createElement("tr", { className: cs("notion-simple-table-row", backgroundColor && `notion-${backgroundColor}`, blockId) }, order.map((column) => {
580
+ var _a2, _b2, _c2;
581
+ const color = (_a2 = formatMap == null ? void 0 : formatMap[column]) == null ? void 0 : _a2.color;
582
+ return /* @__PURE__ */ React8.createElement(
583
+ "td",
584
+ {
585
+ key: column,
586
+ className: color ? `notion-${color}` : "",
587
+ style: {
588
+ width: ((_b2 = formatMap == null ? void 0 : formatMap[column]) == null ? void 0 : _b2.width) || 120
589
+ }
590
+ },
591
+ /* @__PURE__ */ React8.createElement("div", { className: "notion-simple-table-cell" }, /* @__PURE__ */ React8.createElement(Text, { value: ((_c2 = block.properties) == null ? void 0 : _c2[column]) || [["\u3164"]], block }))
592
+ );
593
+ }));
594
+ }
595
+ case "external_object_instance":
596
+ return /* @__PURE__ */ React8.createElement(EOI, { block, className: blockId });
597
+ default:
598
+ if (true)
599
+ console.info("Unsupported type " + block.type, JSON.stringify(block, null, 2));
600
+ return /* @__PURE__ */ React8.createElement("div", null);
601
+ }
602
+ return null;
603
+ };
604
+
605
+ // src/renderer.tsx
606
+ var NotionRenderer = (_a) => {
607
+ var _b = _a, {
608
+ components,
609
+ recordMap,
610
+ mapPageUrl,
611
+ mapImageUrl,
612
+ searchNotion,
613
+ isShowingSearch,
614
+ onHideSearch,
615
+ fullPage,
616
+ rootPageId,
617
+ rootDomain,
618
+ darkMode,
619
+ previewImages,
620
+ forceCustomImages,
621
+ showCollectionViewDropdown,
622
+ linkTableTitleProperties,
623
+ isLinkCollectionToUrlProperty,
624
+ isImageZoomable = true,
625
+ showTableOfContents,
626
+ minTableOfContentsItems,
627
+ defaultPageIcon,
628
+ defaultPageCover,
629
+ defaultPageCoverPosition
630
+ } = _b, rest = __objRest(_b, [
631
+ "components",
632
+ "recordMap",
633
+ "mapPageUrl",
634
+ "mapImageUrl",
635
+ "searchNotion",
636
+ "isShowingSearch",
637
+ "onHideSearch",
638
+ "fullPage",
639
+ "rootPageId",
640
+ "rootDomain",
641
+ "darkMode",
642
+ "previewImages",
643
+ "forceCustomImages",
644
+ "showCollectionViewDropdown",
645
+ "linkTableTitleProperties",
646
+ "isLinkCollectionToUrlProperty",
647
+ "isImageZoomable",
648
+ "showTableOfContents",
649
+ "minTableOfContentsItems",
650
+ "defaultPageIcon",
651
+ "defaultPageCover",
652
+ "defaultPageCoverPosition"
653
+ ]);
654
+ const zoom = React9.useMemo(
655
+ () => typeof window !== "undefined" && mediumZoom({
656
+ background: "rgba(0, 0, 0, 0.8)",
657
+ minZoomScale: 2,
658
+ margin: getMediumZoomMargin()
659
+ }),
660
+ []
661
+ );
662
+ return /* @__PURE__ */ React9.createElement(
663
+ NotionContextProvider,
664
+ {
665
+ components,
666
+ recordMap,
667
+ mapPageUrl,
668
+ mapImageUrl,
669
+ searchNotion,
670
+ isShowingSearch,
671
+ onHideSearch,
672
+ fullPage,
673
+ rootPageId,
674
+ rootDomain,
675
+ darkMode,
676
+ previewImages,
677
+ forceCustomImages,
678
+ showCollectionViewDropdown,
679
+ linkTableTitleProperties,
680
+ isLinkCollectionToUrlProperty,
681
+ showTableOfContents,
682
+ minTableOfContentsItems,
683
+ defaultPageIcon,
684
+ defaultPageCover,
685
+ defaultPageCoverPosition,
686
+ zoom: isImageZoomable ? zoom : null
687
+ },
688
+ /* @__PURE__ */ React9.createElement(NotionBlockRenderer, __spreadValues({}, rest))
689
+ );
690
+ };
691
+ var NotionBlockRenderer = (_a) => {
692
+ var _b = _a, { level = 0, blockId } = _b, props = __objRest(_b, ["level", "blockId"]);
693
+ var _a2, _b2;
694
+ const { recordMap } = useNotionContext();
695
+ const id = blockId || Object.keys(recordMap.block)[0];
696
+ const block = (_a2 = recordMap.block[id]) == null ? void 0 : _a2.value;
697
+ if (!block) {
698
+ if (true)
699
+ console.warn("missing block", blockId);
700
+ return null;
701
+ }
702
+ return /* @__PURE__ */ React9.createElement(Block, __spreadValues({ key: id, level, block }, props), (_b2 = block == null ? void 0 : block.content) == null ? void 0 : _b2.map((contentBlockId) => /* @__PURE__ */ React9.createElement(NotionBlockRenderer, __spreadValues({ key: contentBlockId, blockId: contentBlockId, level: level + 1 }, props))));
703
+ };
704
+ function getMediumZoomMargin() {
705
+ const width = window.innerWidth;
706
+ if (width < 500)
707
+ return 8;
708
+ else if (width < 800)
709
+ return 20;
710
+ else if (width < 1280)
711
+ return 30;
712
+ else if (width < 1600)
713
+ return 40;
714
+ else if (width < 1920)
715
+ return 48;
716
+ else
717
+ return 72;
718
+ }
25
719
  export {
26
720
  Breadcrumbs,
27
721
  Header,