@texonom/nreact 1.4.7 → 1.5.1

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 (141) hide show
  1. package/build/_commonjsHelpers-bAxELxBV.js +9 -0
  2. package/build/_commonjsHelpers-bAxELxBV.js.map +1 -0
  3. package/build/asset-wrapper-CmbIDPIw.js +921 -0
  4. package/build/asset-wrapper-CmbIDPIw.js.map +1 -0
  5. package/build/block.d.ts +20 -20
  6. package/build/collection-column-title-l4hmVo49.js +99 -0
  7. package/build/collection-column-title-l4hmVo49.js.map +1 -0
  8. package/build/components/asset-wrapper.d.ts +6 -6
  9. package/build/components/asset.d.ts +7 -7
  10. package/build/components/audio.d.ts +6 -6
  11. package/build/components/checkbox.d.ts +5 -5
  12. package/build/components/eoi.d.ts +7 -7
  13. package/build/components/file.d.ts +6 -6
  14. package/build/components/google-drive.d.ts +6 -6
  15. package/build/components/graceful-image.d.ts +3 -3
  16. package/build/components/header.d.ts +15 -15
  17. package/build/components/lazy-image.d.ts +13 -13
  18. package/build/components/lite-youtube-embed.d.ts +13 -13
  19. package/build/components/page-aside.d.ts +11 -11
  20. package/build/components/page-icon.d.ts +16 -16
  21. package/build/components/page-title.d.ts +12 -12
  22. package/build/components/search-dialog.d.ts +26 -26
  23. package/build/components/search-dialog.d.ts.map +1 -1
  24. package/build/components/sync-pointer-block.d.ts +6 -6
  25. package/build/components/text.d.ts +19 -19
  26. package/build/context.d.ts +64 -64
  27. package/build/context.d.ts.map +1 -1
  28. package/build/icons/check.d.ts +3 -3
  29. package/build/icons/chevron-down-icon.d.ts +2 -2
  30. package/build/icons/clear-icon.d.ts +2 -2
  31. package/build/icons/collection-view-board.d.ts +3 -3
  32. package/build/icons/collection-view-calendar.d.ts +3 -3
  33. package/build/icons/collection-view-gallery.d.ts +3 -3
  34. package/build/icons/collection-view-icon.d.ts +8 -8
  35. package/build/icons/collection-view-list.d.ts +3 -3
  36. package/build/icons/collection-view-table.d.ts +3 -3
  37. package/build/icons/copy.d.ts +3 -3
  38. package/build/icons/default-page-icon.d.ts +2 -2
  39. package/build/icons/empty-icon.d.ts +2 -2
  40. package/build/icons/file-icon.d.ts +2 -2
  41. package/build/icons/link-icon.d.ts +2 -2
  42. package/build/icons/loading-icon.d.ts +2 -2
  43. package/build/icons/property-icon.d.ts +44 -44
  44. package/build/icons/search-icon.d.ts +2 -2
  45. package/build/icons/type-checkbox.d.ts +3 -3
  46. package/build/icons/type-date.d.ts +3 -3
  47. package/build/icons/type-email.d.ts +3 -3
  48. package/build/icons/type-file.d.ts +3 -3
  49. package/build/icons/type-formula.d.ts +3 -3
  50. package/build/icons/type-github.d.ts +3 -3
  51. package/build/icons/type-multi-select.d.ts +3 -3
  52. package/build/icons/type-number.d.ts +3 -3
  53. package/build/icons/type-person-2.d.ts +3 -3
  54. package/build/icons/type-person.d.ts +3 -3
  55. package/build/icons/type-phone-number.d.ts +3 -3
  56. package/build/icons/type-relation.d.ts +3 -3
  57. package/build/icons/type-select.d.ts +3 -3
  58. package/build/icons/type-text.d.ts +3 -3
  59. package/build/icons/type-timestamp.d.ts +3 -3
  60. package/build/icons/type-title.d.ts +3 -3
  61. package/build/icons/type-url.d.ts +3 -3
  62. package/build/index.d.ts +24 -24
  63. package/build/index.js +478 -691
  64. package/build/index.js.map +1 -0
  65. package/build/next.d.ts +1 -1
  66. package/build/renderer.d.ts +50 -50
  67. package/build/third-party/code.d.ts +7 -16
  68. package/build/third-party/code.js +174 -114
  69. package/build/third-party/code.js.map +1 -0
  70. package/build/third-party/collection-card.d.ts +3 -3
  71. package/build/third-party/collection-card.d.ts.map +1 -1
  72. package/build/third-party/collection-column-title.d.ts +5 -5
  73. package/build/third-party/collection-group.d.ts +3 -3
  74. package/build/third-party/collection-row.d.ts +7 -7
  75. package/build/third-party/collection-utils.d.ts +2 -2
  76. package/build/third-party/collection-view-board.d.ts +3 -3
  77. package/build/third-party/collection-view-gallery.d.ts +3 -3
  78. package/build/third-party/collection-view-list.d.ts +3 -3
  79. package/build/third-party/collection-view-table.d.ts +3 -3
  80. package/build/third-party/collection-view.d.ts +4 -4
  81. package/build/third-party/collection.d.ts +14 -14
  82. package/build/third-party/collection.js +2295 -3321
  83. package/build/third-party/collection.js.map +1 -0
  84. package/build/third-party/equation.d.ts +8 -8
  85. package/build/third-party/equation.js +35 -25
  86. package/build/third-party/equation.js.map +1 -0
  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/modal.js +3 -5
  90. package/build/third-party/modal.js.map +1 -0
  91. package/build/third-party/pdf.d.ts +4 -4
  92. package/build/third-party/property.d.ts +21 -21
  93. package/build/types.d.ts +93 -93
  94. package/build/utils.d.ts +6 -6
  95. package/package.json +13 -13
  96. package/readme.md +59 -0
  97. package/LICENSE +0 -21
  98. package/README.md +0 -19
  99. package/build/.tsbuildinfo +0 -1
  100. package/build/chunk-2U7I3XVC.js +0 -157
  101. package/build/chunk-72RHNPWF.js +0 -1307
  102. package/build/chunk-C6BUIPAM.js +0 -83
  103. package/build/chunk-FCO7MUK6.js +0 -83
  104. package/build/chunk-H4QYS6CQ.js +0 -1185
  105. package/build/chunk-IMWLLIUB.js +0 -1182
  106. package/build/chunk-P7HX4BAT.js +0 -156
  107. package/build/chunk-VP33CFNB.js +0 -1358
  108. package/build/chunk-YMM43AZ3.js +0 -1207
  109. package/build/dev/chunk-64UJZ76E.js +0 -1308
  110. package/build/dev/chunk-64UJZ76E.js.map +0 -1
  111. package/build/dev/chunk-ABDRHJEI.js +0 -157
  112. package/build/dev/chunk-ABDRHJEI.js.map +0 -1
  113. package/build/dev/chunk-N6EDMIQD.js +0 -1359
  114. package/build/dev/chunk-N6EDMIQD.js.map +0 -1
  115. package/build/dev/chunk-OAIRL2FN.js +0 -84
  116. package/build/dev/chunk-OAIRL2FN.js.map +0 -1
  117. package/build/dev/chunk-P3V5A3W4.js +0 -1183
  118. package/build/dev/chunk-P3V5A3W4.js.map +0 -1
  119. package/build/dev/chunk-PM5CWL6O.js +0 -158
  120. package/build/dev/chunk-PM5CWL6O.js.map +0 -1
  121. package/build/dev/chunk-Q4G2SZRD.js +0 -84
  122. package/build/dev/chunk-Q4G2SZRD.js.map +0 -1
  123. package/build/dev/chunk-SEA7YL2O.js +0 -1308
  124. package/build/dev/chunk-SEA7YL2O.js.map +0 -1
  125. package/build/dev/chunk-SVHGWLRK.js +0 -1208
  126. package/build/dev/chunk-SVHGWLRK.js.map +0 -1
  127. package/build/dev/chunk-ZJAJPWJX.js +0 -1186
  128. package/build/dev/chunk-ZJAJPWJX.js.map +0 -1
  129. package/build/dev/index.js +0 -890
  130. package/build/dev/index.js.map +0 -1
  131. package/build/dev/third-party/code.js +0 -140
  132. package/build/dev/third-party/code.js.map +0 -1
  133. package/build/dev/third-party/collection.js +0 -4382
  134. package/build/dev/third-party/collection.js.map +0 -1
  135. package/build/dev/third-party/equation.js +0 -35
  136. package/build/dev/third-party/equation.js.map +0 -1
  137. package/build/dev/third-party/modal.js +0 -8
  138. package/build/dev/third-party/modal.js.map +0 -1
  139. package/build/dev/third-party/pdf.js +0 -21
  140. package/build/dev/third-party/pdf.js.map +0 -1
  141. package/build/third-party/pdf.js +0 -20
@@ -1,1186 +0,0 @@
1
- import {
2
- __async,
3
- __objRest,
4
- __spreadProps,
5
- __spreadValues
6
- } from "./chunk-OAIRL2FN.js";
7
-
8
- // src/components/checkbox.tsx
9
- import React2 from "react";
10
-
11
- // src/icons/check.tsx
12
- import React from "react";
13
- function SvgCheck(props) {
14
- return /* @__PURE__ */ React.createElement("svg", __spreadValues({ viewBox: "0 0 14 14" }, props), /* @__PURE__ */ React.createElement("path", { d: "M5.5 12L14 3.5 12.5 2l-7 7-4-4.003L0 6.499z" }));
15
- }
16
- var check_default = SvgCheck;
17
-
18
- // src/components/checkbox.tsx
19
- var Checkbox = ({ isChecked }) => {
20
- let content = null;
21
- if (isChecked)
22
- content = /* @__PURE__ */ React2.createElement("div", { className: "notion-property-checkbox-checked" }, /* @__PURE__ */ React2.createElement(check_default, null));
23
- else content = /* @__PURE__ */ React2.createElement("div", { className: "notion-property-checkbox-unchecked" });
24
- return /* @__PURE__ */ React2.createElement("span", { className: "notion-property notion-property-checkbox" }, content);
25
- };
26
-
27
- // src/utils.ts
28
- import { isUrl, formatDate, formatNotionDateTime } from "@texonom/nutils";
29
- var groupBlockContent = (blockMap) => {
30
- const output = [];
31
- let lastType = void 0;
32
- let index = -1;
33
- Object.keys(blockMap).forEach((id) => {
34
- var _a, _b;
35
- const blockValue = (_a = blockMap[id]) == null ? void 0 : _a.value;
36
- if (blockValue)
37
- (_b = blockValue.content) == null ? void 0 : _b.forEach((blockId) => {
38
- var _a2, _b2;
39
- const blockType = (_b2 = (_a2 = blockMap[blockId]) == null ? void 0 : _a2.value) == null ? void 0 : _b2.type;
40
- if (blockType && blockType !== lastType) {
41
- index++;
42
- lastType = blockType;
43
- output[index] = [];
44
- }
45
- if (index > -1) output[index].push(blockId);
46
- });
47
- lastType = void 0;
48
- });
49
- return output;
50
- };
51
- var getListNumber = (blockId, blockMap) => {
52
- const groups = groupBlockContent(blockMap);
53
- const group = groups.find((g) => g.includes(blockId));
54
- if (!group) return;
55
- return group.indexOf(blockId) + 1;
56
- };
57
- var getHashFragmentValue = (url) => {
58
- return url.includes("#") ? url.replace(/^.+(#.+)$/, "$1") : "";
59
- };
60
- var isBrowser = typeof window !== "undefined";
61
- var youtubeDomains = /* @__PURE__ */ new Set([
62
- "youtu.be",
63
- "youtube.com",
64
- "www.youtube.com",
65
- "youtube-nocookie.com",
66
- "www.youtube-nocookie.com"
67
- ]);
68
- var getYoutubeId = (url) => {
69
- try {
70
- const { hostname } = new URL(url);
71
- if (!youtubeDomains.has(hostname)) return null;
72
- const regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/i;
73
- const match = url.match(regExp);
74
- if (match && match[2].length == 11) return match[2];
75
- } catch (e) {
76
- }
77
- return null;
78
- };
79
-
80
- // src/components/page-icon.tsx
81
- import React20 from "react";
82
- import { getBlockIcon, getBlockTitle as getBlockTitle3 } from "@texonom/nutils";
83
-
84
- // src/context.tsx
85
- import React18 from "react";
86
- import { defaultMapImageUrl, defaultMapPageUrl } from "@texonom/nutils";
87
-
88
- // src/components/asset-wrapper.tsx
89
- import React11 from "react";
90
- import { parsePageId as parsePageId2 } from "@texonom/nutils";
91
-
92
- // src/components/asset.tsx
93
- import React5 from "react";
94
- import { getTextContent } from "@texonom/nutils";
95
-
96
- // src/components/lazy-image.tsx
97
- import React3 from "react";
98
- import { normalizeUrl } from "@texonom/nutils";
99
- var LazyImage = (_a) => {
100
- var _b = _a, { src, alt, className, style, zoomable = false, priority = false, height } = _b, rest = __objRest(_b, ["src", "alt", "className", "style", "zoomable", "priority", "height"]);
101
- var _a2, _b2, _c;
102
- const { recordMap, zoom, previewImages, forceCustomImages, components } = useNotionContext();
103
- const zoomRef = React3.useRef(zoom ? zoom.clone() : null);
104
- const previewImage = previewImages ? (_c = (_a2 = recordMap == null ? void 0 : recordMap.preview_images) == null ? void 0 : _a2[src]) != null ? _c : (_b2 = recordMap == null ? void 0 : recordMap.preview_images) == null ? void 0 : _b2[normalizeUrl(src)] : null;
105
- const onLoad = React3.useCallback(
106
- (e) => {
107
- if (zoomable && (e.target.src || e.target.srcset)) {
108
- if (zoomRef.current) zoomRef.current.attach(e.target);
109
- }
110
- },
111
- [zoomRef, zoomable]
112
- );
113
- const attachZoom = React3.useCallback(
114
- (image) => {
115
- if (zoomRef.current && image) zoomRef.current.attach(image);
116
- },
117
- [zoomRef]
118
- );
119
- const attachZoomRef = React3.useMemo(() => zoomable ? attachZoom : void 0, [zoomable, attachZoom]);
120
- if (previewImage && components.Image) {
121
- return /* @__PURE__ */ React3.createElement(
122
- components.Image,
123
- {
124
- src,
125
- alt,
126
- style,
127
- className,
128
- width: previewImage.originalWidth,
129
- height: previewImage.originalHeight,
130
- blurDataURL: previewImage.dataURIBase64,
131
- placeholder: "blur",
132
- priority,
133
- onLoad
134
- }
135
- );
136
- } else {
137
- if (components.Image && forceCustomImages)
138
- return /* @__PURE__ */ React3.createElement(
139
- components.Image,
140
- {
141
- src,
142
- alt,
143
- className,
144
- style,
145
- width: null,
146
- height: height || null,
147
- priority,
148
- onLoad
149
- }
150
- );
151
- return /* @__PURE__ */ React3.createElement(
152
- "img",
153
- __spreadValues({
154
- className,
155
- style,
156
- src,
157
- alt,
158
- ref: attachZoomRef,
159
- loading: "lazy",
160
- decoding: "async"
161
- }, rest)
162
- );
163
- }
164
- };
165
-
166
- // src/components/lite-youtube-embed.tsx
167
- import React4 from "react";
168
- var qs = (params) => {
169
- return Object.keys(params).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`).join("&");
170
- };
171
- var LiteYouTubeEmbed = ({
172
- id,
173
- defaultPlay = false,
174
- mute = false,
175
- lazyImage = false,
176
- iframeTitle = "YouTube video",
177
- alt = "Video preview",
178
- params = {},
179
- adLinksPreconnect = true,
180
- style,
181
- className
182
- }) => {
183
- const muteParam = mute || defaultPlay ? "1" : "0";
184
- const queryString = React4.useMemo(() => qs(__spreadValues({ autoplay: "1", mute: muteParam }, params)), [muteParam, params]);
185
- const resolution = "hqdefault";
186
- const posterUrl = `https://i.ytimg.com/vi/${id}/${resolution}.jpg`;
187
- const ytUrl = "https://www.youtube-nocookie.com";
188
- const iframeSrc = `${ytUrl}/embed/${id}?${queryString}`;
189
- const [isPreconnected, setIsPreconnected] = React4.useState(false);
190
- const [iframeInitialized, setIframeInitialized] = React4.useState(defaultPlay);
191
- const [isIframeLoaded, setIsIframeLoaded] = React4.useState(false);
192
- const warmConnections = React4.useCallback(() => {
193
- if (isPreconnected) return;
194
- setIsPreconnected(true);
195
- }, [isPreconnected]);
196
- const onLoadIframe = React4.useCallback(() => {
197
- if (iframeInitialized) return;
198
- setIframeInitialized(true);
199
- }, [iframeInitialized]);
200
- const onIframeLoaded = React4.useCallback(() => {
201
- setIsIframeLoaded(true);
202
- }, []);
203
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("link", { rel: "preload", href: posterUrl, as: "image" }), isPreconnected && /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("link", { rel: "preconnect", href: ytUrl }), /* @__PURE__ */ React4.createElement("link", { rel: "preconnect", href: "https://www.google.com" })), isPreconnected && adLinksPreconnect && /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("link", { rel: "preconnect", href: "https://static.doubleclick.net" }), /* @__PURE__ */ React4.createElement("link", { rel: "preconnect", href: "https://googleads.g.doubleclick.net" })), /* @__PURE__ */ React4.createElement(
204
- "div",
205
- {
206
- onClick: onLoadIframe,
207
- onPointerOver: warmConnections,
208
- className: `notion-yt-lite
209
- ${isIframeLoaded && "notion-yt-loaded"}
210
- ${iframeInitialized && "notion-yt-initialized"}
211
- ${className || ""}`,
212
- style
213
- },
214
- /* @__PURE__ */ React4.createElement("img", { src: posterUrl, className: "notion-yt-thumbnail", loading: lazyImage ? "lazy" : void 0, alt }),
215
- /* @__PURE__ */ React4.createElement("div", { className: "notion-yt-playbtn" }),
216
- iframeInitialized && /* @__PURE__ */ React4.createElement(
217
- "iframe",
218
- {
219
- width: "560",
220
- height: "315",
221
- frameBorder: "0",
222
- allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
223
- allowFullScreen: true,
224
- title: iframeTitle,
225
- src: iframeSrc,
226
- onLoad: onIframeLoaded
227
- }
228
- )
229
- ));
230
- };
231
-
232
- // src/components/asset.tsx
233
- var isServer = typeof window === "undefined";
234
- var supportedAssetTypes = [
235
- "video",
236
- "image",
237
- "embed",
238
- "figma",
239
- "typeform",
240
- "excalidraw",
241
- "maps",
242
- "tweet",
243
- "pdf",
244
- "gist",
245
- "codepen",
246
- "drive"
247
- ];
248
- var Asset = ({ block, zoomable = true, children }) => {
249
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
250
- const { recordMap, mapImageUrl, components } = useNotionContext();
251
- if (!block || !supportedAssetTypes.includes(block.type)) return null;
252
- const style = {
253
- position: "relative",
254
- display: "flex",
255
- justifyContent: "center",
256
- alignSelf: "center",
257
- width: "100%",
258
- maxWidth: "100%",
259
- flexDirection: "column"
260
- };
261
- const assetStyle = {};
262
- if (block.format) {
263
- const { block_aspect_ratio, block_height, block_width, block_full_width, block_page_width, block_preserve_scale } = block.format;
264
- if (block_full_width || block_page_width) {
265
- if (block_full_width) style.width = "100vw";
266
- else style.width = "100%";
267
- if (block.type === "video") {
268
- if (block_height) style.height = block_height;
269
- else if (block_aspect_ratio) style.paddingBottom = `${block_aspect_ratio * 100}%`;
270
- else if (block_preserve_scale) style.objectFit = "contain";
271
- } else if (block_aspect_ratio && block.type !== "image") {
272
- style.paddingBottom = `${block_aspect_ratio * 100}%`;
273
- } else if (block_height) {
274
- style.height = block_height;
275
- } else if (block_preserve_scale) {
276
- if (block.type === "image") {
277
- style.height = "100%";
278
- } else {
279
- style.paddingBottom = "75%";
280
- style.minHeight = 100;
281
- }
282
- }
283
- } else {
284
- switch ((_a = block.format) == null ? void 0 : _a.block_alignment) {
285
- case "center": {
286
- style.alignSelf = "center";
287
- break;
288
- }
289
- case "left": {
290
- style.alignSelf = "start";
291
- break;
292
- }
293
- case "right": {
294
- style.alignSelf = "end";
295
- break;
296
- }
297
- }
298
- if (block_width) style.width = block_width;
299
- if (block_preserve_scale && block.type !== "image") {
300
- style.paddingBottom = "50%";
301
- style.minHeight = 100;
302
- } else {
303
- if (block_height && block.type !== "image") style.height = block_height;
304
- }
305
- }
306
- if (block.type === "image") assetStyle.objectFit = "cover";
307
- else if (block_preserve_scale) assetStyle.objectFit = "contain";
308
- }
309
- let source = ((_b = recordMap.signed_urls) == null ? void 0 : _b[block.id]) || ((_e = (_d = (_c = block.properties) == null ? void 0 : _c.source) == null ? void 0 : _d[0]) == null ? void 0 : _e[0]);
310
- let content = null;
311
- if (!source) return null;
312
- if (block.type === "tweet") {
313
- const src = source;
314
- if (!src) return null;
315
- const id = src.split("?")[0].split("/").pop();
316
- if (!id) return null;
317
- content = /* @__PURE__ */ React5.createElement(
318
- "div",
319
- {
320
- style: __spreadProps(__spreadValues({}, assetStyle), {
321
- maxWidth: 420,
322
- width: "100%",
323
- marginLeft: "auto",
324
- marginRight: "auto"
325
- })
326
- },
327
- /* @__PURE__ */ React5.createElement(components.Tweet, { id })
328
- );
329
- } else if (block.type === "pdf") {
330
- style.overflow = "auto";
331
- style.background = "rgb(226, 226, 226)";
332
- style.display = "block";
333
- if (!style.padding) style.padding = "8px 16px";
334
- if (!isServer) content = /* @__PURE__ */ React5.createElement(components.Pdf, { file: source });
335
- } else if (block.type === "embed" || block.type === "video" || block.type === "figma" || block.type === "typeform" || block.type === "gist" || block.type === "maps" || block.type === "excalidraw" || block.type === "codepen" || block.type === "drive") {
336
- if (block.type === "video" && source && source.indexOf("youtube") < 0 && source.indexOf("youtu.be") < 0 && source.indexOf("vimeo") < 0 && source.indexOf("wistia") < 0 && source.indexOf("loom") < 0 && source.indexOf("videoask") < 0 && source.indexOf("getcloudapp") < 0) {
337
- style.paddingBottom = void 0;
338
- content = /* @__PURE__ */ React5.createElement("video", { playsInline: true, controls: true, preload: "metadata", style: assetStyle, src: source, title: block.type });
339
- } else {
340
- let src = ((_f = block.format) == null ? void 0 : _f.display_source) || source;
341
- if (src) {
342
- const youtubeVideoId = block.type === "video" ? getYoutubeId(src) : null;
343
- if (youtubeVideoId) {
344
- content = /* @__PURE__ */ React5.createElement(LiteYouTubeEmbed, { id: youtubeVideoId, style: assetStyle, className: "notion-asset-object-fit" });
345
- } else if (block.type === "gist") {
346
- if (!src.endsWith(".pibb")) src = `${src}.pibb`;
347
- assetStyle.width = "100%";
348
- style.paddingBottom = "50%";
349
- content = /* @__PURE__ */ React5.createElement(
350
- "iframe",
351
- {
352
- style: assetStyle,
353
- className: "notion-asset-object-fit",
354
- src,
355
- title: "GitHub Gist",
356
- frameBorder: "0",
357
- loading: "lazy",
358
- scrolling: "auto"
359
- }
360
- );
361
- } else {
362
- content = /* @__PURE__ */ React5.createElement(
363
- "iframe",
364
- {
365
- className: "notion-asset-object-fit",
366
- style: assetStyle,
367
- src,
368
- title: `iframe ${block.type}`,
369
- frameBorder: "0",
370
- allowFullScreen: true,
371
- loading: "lazy",
372
- scrolling: "auto"
373
- }
374
- );
375
- }
376
- }
377
- }
378
- } else if (block.type === "image") {
379
- if (source.includes("file.notion.so")) source = (_i = (_h = (_g = block.properties) == null ? void 0 : _g.source) == null ? void 0 : _h[0]) == null ? void 0 : _i[0];
380
- const src = mapImageUrl(source, block);
381
- const caption = getTextContent((_j = block.properties) == null ? void 0 : _j.caption);
382
- const alt = caption || "notion image";
383
- content = /* @__PURE__ */ React5.createElement(LazyImage, { src, alt, zoomable, height: style.height, style: assetStyle });
384
- }
385
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { style }, content, block.type === "image" && children), block.type !== "image" && children);
386
- };
387
-
388
- // src/components/text.tsx
389
- import React10 from "react";
390
- import { parsePageId } from "@texonom/nutils";
391
-
392
- // src/components/eoi.tsx
393
- import React7 from "react";
394
-
395
- // src/icons/type-github.tsx
396
- import React6 from "react";
397
- function SvgTypeGitHub(props) {
398
- return /* @__PURE__ */ React6.createElement("svg", __spreadValues({ viewBox: "0 0 260 260" }, props), /* @__PURE__ */ React6.createElement("g", null, /* @__PURE__ */ React6.createElement(
399
- "path",
400
- {
401
- d: "M128.00106,0 C57.3172926,0 0,57.3066942 0,128.00106 C0,184.555281 36.6761997,232.535542 87.534937,249.460899 C93.9320223,250.645779 96.280588,246.684165 96.280588,243.303333 C96.280588,240.251045 96.1618878,230.167899 96.106777,219.472176 C60.4967585,227.215235 52.9826207,204.369712 52.9826207,204.369712 C47.1599584,189.574598 38.770408,185.640538 38.770408,185.640538 C27.1568785,177.696113 39.6458206,177.859325 39.6458206,177.859325 C52.4993419,178.762293 59.267365,191.04987 59.267365,191.04987 C70.6837675,210.618423 89.2115753,204.961093 96.5158685,201.690482 C97.6647155,193.417512 100.981959,187.77078 104.642583,184.574357 C76.211799,181.33766 46.324819,170.362144 46.324819,121.315702 C46.324819,107.340889 51.3250588,95.9223682 59.5132437,86.9583937 C58.1842268,83.7344152 53.8029229,70.715562 60.7532354,53.0843636 C60.7532354,53.0843636 71.5019501,49.6441813 95.9626412,66.2049595 C106.172967,63.368876 117.123047,61.9465949 128.00106,61.8978432 C138.879073,61.9465949 149.837632,63.368876 160.067033,66.2049595 C184.49805,49.6441813 195.231926,53.0843636 195.231926,53.0843636 C202.199197,70.715562 197.815773,83.7344152 196.486756,86.9583937 C204.694018,95.9223682 209.660343,107.340889 209.660343,121.315702 C209.660343,170.478725 179.716133,181.303747 151.213281,184.472614 C155.80443,188.444828 159.895342,196.234518 159.895342,208.176593 C159.895342,225.303317 159.746968,239.087361 159.746968,243.303333 C159.746968,246.709601 162.05102,250.70089 168.53925,249.443941 C219.370432,232.499507 256,184.536204 256,128.00106 C256,57.3066942 198.691187,0 128.00106,0 Z M47.9405593,182.340212 C47.6586465,182.976105 46.6581745,183.166873 45.7467277,182.730227 C44.8183235,182.312656 44.2968914,181.445722 44.5978808,180.80771 C44.8734344,180.152739 45.876026,179.97045 46.8023103,180.409216 C47.7328342,180.826786 48.2627451,181.702199 47.9405593,182.340212 Z M54.2367892,187.958254 C53.6263318,188.524199 52.4329723,188.261363 51.6232682,187.366874 C50.7860088,186.474504 50.6291553,185.281144 51.2480912,184.70672 C51.8776254,184.140775 53.0349512,184.405731 53.8743302,185.298101 C54.7115892,186.201069 54.8748019,187.38595 54.2367892,187.958254 Z M58.5562413,195.146347 C57.7719732,195.691096 56.4895886,195.180261 55.6968417,194.042013 C54.9125733,192.903764 54.9125733,191.538713 55.713799,190.991845 C56.5086651,190.444977 57.7719732,190.936735 58.5753181,192.066505 C59.3574669,193.22383 59.3574669,194.58888 58.5562413,195.146347 Z M65.8613592,203.471174 C65.1597571,204.244846 63.6654083,204.03712 62.5716717,202.981538 C61.4524999,201.94927 61.1409122,200.484596 61.8446341,199.710926 C62.5547146,198.935137 64.0575422,199.15346 65.1597571,200.200564 C66.2704506,201.230712 66.6095936,202.705984 65.8613592,203.471174 Z M75.3025151,206.281542 C74.9930474,207.284134 73.553809,207.739857 72.1039724,207.313809 C70.6562556,206.875043 69.7087748,205.700761 70.0012857,204.687571 C70.302275,203.678621 71.7478721,203.20382 73.2083069,203.659543 C74.6539041,204.09619 75.6035048,205.261994 75.3025151,206.281542 Z M86.046947,207.473627 C86.0829806,208.529209 84.8535871,209.404622 83.3316829,209.4237 C81.8013,209.457614 80.563428,208.603398 80.5464708,207.564772 C80.5464708,206.498591 81.7483088,205.631657 83.2786917,205.606221 C84.8005962,205.576546 86.046947,206.424403 86.046947,207.473627 Z M96.6021471,207.069023 C96.7844366,208.099171 95.7267341,209.156872 94.215428,209.438785 C92.7295577,209.710099 91.3539086,209.074206 91.1652603,208.052538 C90.9808515,206.996955 92.0576306,205.939253 93.5413813,205.66582 C95.054807,205.402984 96.4092596,206.021919 96.6021471,207.069023 Z",
402
- fill: "#161614"
403
- }
404
- )));
405
- }
406
- var type_github_default = SvgTypeGitHub;
407
-
408
- // src/components/eoi.tsx
409
- var EOI = ({ block, inline, className }) => {
410
- var _a, _b, _c;
411
- const { components } = useNotionContext();
412
- const { original_url, attributes, domain } = (block == null ? void 0 : block.format) || {};
413
- if (!original_url || !attributes) return null;
414
- const title = (_a = attributes.find((attr) => attr.id === "title")) == null ? void 0 : _a.values[0];
415
- let owner = (_b = attributes.find((attr) => attr.id === "owner")) == null ? void 0 : _b.values[0];
416
- const lastUpdatedAt = (_c = attributes.find((attr) => attr.id === "updated_at")) == null ? void 0 : _c.values[0];
417
- const lastUpdated = lastUpdatedAt ? formatNotionDateTime(lastUpdatedAt) : null;
418
- let externalImage;
419
- switch (domain) {
420
- case "github.com":
421
- externalImage = /* @__PURE__ */ React7.createElement(type_github_default, null);
422
- if (owner) {
423
- const parts = owner.split("/");
424
- owner = parts[parts.length - 1];
425
- }
426
- break;
427
- default:
428
- if (true)
429
- console.debug(`Unsupported external_object_instance domain "${domain}"`, JSON.stringify(block, null, 2));
430
- return null;
431
- }
432
- return /* @__PURE__ */ React7.createElement(
433
- components.Link,
434
- {
435
- target: "_blank",
436
- rel: "noopener noreferrer",
437
- href: original_url,
438
- className: `notion-external ${inline ? "notion-external-mention" : "notion-external-block notion-row"} ${className || ""}`
439
- },
440
- externalImage && /* @__PURE__ */ React7.createElement("div", { className: "notion-external-image" }, externalImage),
441
- /* @__PURE__ */ React7.createElement("div", { className: "notion-external-description" }, /* @__PURE__ */ React7.createElement("div", { className: "notion-external-title" }, title), (owner || lastUpdated) && /* @__PURE__ */ React7.createElement("div", { className: "notion-external-subtitle" }, owner && /* @__PURE__ */ React7.createElement("span", null, owner), owner && lastUpdated && /* @__PURE__ */ React7.createElement("span", null, " \u2022 "), lastUpdated && /* @__PURE__ */ React7.createElement("span", null, "Updated ", lastUpdated)))
442
- );
443
- };
444
-
445
- // src/components/graceful-image.tsx
446
- import React8 from "react";
447
- import { Img } from "react-image";
448
- var GracefulImage = (props) => {
449
- if (isBrowser) return /* @__PURE__ */ React8.createElement(Img, __spreadValues({}, props));
450
- else return /* @__PURE__ */ React8.createElement("img", __spreadValues({}, props));
451
- };
452
-
453
- // src/components/page-title.tsx
454
- import React9 from "react";
455
- import { getBlockTitle } from "@texonom/nutils";
456
- var PageTitleImpl = (_a) => {
457
- var _b = _a, { block, className, defaultIcon } = _b, rest = __objRest(_b, ["block", "className", "defaultIcon"]);
458
- var _a2, _b2;
459
- const { recordMap } = useNotionContext();
460
- if (!block) return null;
461
- if (block.type === "collection_view_page" || block.type === "collection_view") {
462
- const title = getBlockTitle(block, recordMap);
463
- if (!title) return null;
464
- const titleDecoration = [[title]];
465
- return /* @__PURE__ */ React9.createElement("span", __spreadValues({ className: `notion-page-title ${className || ""}` }, rest), /* @__PURE__ */ React9.createElement(PageIcon, { block, defaultIcon, className: "notion-page-title-icon" }), /* @__PURE__ */ React9.createElement("span", { className: "notion-page-title-text" }, /* @__PURE__ */ React9.createElement(Text, { value: titleDecoration, block })));
466
- }
467
- if (!((_a2 = block.properties) == null ? void 0 : _a2.title)) return null;
468
- return /* @__PURE__ */ React9.createElement("span", __spreadValues({ className: `notion-page-title ${className || ""}` }, rest), /* @__PURE__ */ React9.createElement(PageIcon, { block, defaultIcon, className: "notion-page-title-icon" }), /* @__PURE__ */ React9.createElement("span", { className: "notion-page-title-text" }, /* @__PURE__ */ React9.createElement(Text, { value: (_b2 = block.properties) == null ? void 0 : _b2.title, block })));
469
- };
470
- var PageTitle = React9.memo(PageTitleImpl);
471
-
472
- // src/components/text.tsx
473
- var Text = ({ value, block, linkProps, linkProtocol }) => {
474
- const { components, recordMap, mapPageUrl, mapImageUrl, rootDomain } = useNotionContext();
475
- return /* @__PURE__ */ React10.createElement(React10.Fragment, null, value == null ? void 0 : value.map((deco, index) => {
476
- const [text, decorations] = deco;
477
- if (!decorations)
478
- if (text === ",") return /* @__PURE__ */ React10.createElement("span", { key: index, style: { padding: "0.5em" } });
479
- else return /* @__PURE__ */ React10.createElement(React10.Fragment, { key: index }, text);
480
- const formatted = decorations.reduce(
481
- (element, decorator) => {
482
- var _a, _b, _c, _d, _e;
483
- switch (decorator[0]) {
484
- case "p": {
485
- const blockId = decorator[1];
486
- const linkedBlock = (_a = recordMap.block[blockId]) == null ? void 0 : _a.value;
487
- if (!linkedBlock) {
488
- console.debug('"p" missing block', blockId);
489
- return null;
490
- }
491
- return /* @__PURE__ */ React10.createElement(components.PageLink, { className: "notion-link", href: mapPageUrl(blockId) }, /* @__PURE__ */ React10.createElement(PageTitle, { block: linkedBlock }));
492
- }
493
- case "\u2023": {
494
- const linkType = decorator[1][0];
495
- const id = decorator[1][1];
496
- switch (linkType) {
497
- case "u": {
498
- const user = (_b = recordMap.notion_user[id]) == null ? void 0 : _b.value;
499
- if (!user) {
500
- console.debug('"\u2023" missing user', id);
501
- return null;
502
- }
503
- const name = [user.given_name, user.family_name].filter(Boolean).join(" ");
504
- const email = user.email;
505
- return /* @__PURE__ */ React10.createElement(components.Link, __spreadValues({ className: "notion-link", href: `mailto:${email}` }, linkProps), /* @__PURE__ */ React10.createElement(
506
- GracefulImage,
507
- {
508
- className: "notion-user",
509
- src: mapImageUrl(user.profile_photo, block),
510
- alt: name,
511
- style: { display: "inline", marginRight: "0.3em", marginBottom: "0.3em" }
512
- }
513
- ), name);
514
- }
515
- default: {
516
- const linkedBlock = (_c = recordMap.block[id]) == null ? void 0 : _c.value;
517
- if (!linkedBlock) {
518
- console.debug('"\u2023" missing block', linkType, id);
519
- return null;
520
- }
521
- return /* @__PURE__ */ React10.createElement(
522
- components.PageLink,
523
- __spreadProps(__spreadValues({
524
- className: "notion-link",
525
- href: mapPageUrl(id)
526
- }, linkProps), {
527
- target: "_blank",
528
- rel: "noopener noreferrer"
529
- }),
530
- /* @__PURE__ */ React10.createElement(PageTitle, { block: linkedBlock })
531
- );
532
- }
533
- }
534
- }
535
- case "h":
536
- return /* @__PURE__ */ React10.createElement("span", { className: `notion-${decorator[1]}` }, element);
537
- case "c":
538
- return /* @__PURE__ */ React10.createElement("code", { className: "notion-inline-code" }, element);
539
- case "b":
540
- return /* @__PURE__ */ React10.createElement("b", null, element);
541
- case "i":
542
- return /* @__PURE__ */ React10.createElement("em", null, element);
543
- case "s":
544
- return /* @__PURE__ */ React10.createElement("s", null, element);
545
- case "_":
546
- return /* @__PURE__ */ React10.createElement("span", { className: "notion-inline-underscore" }, element);
547
- case "e":
548
- return /* @__PURE__ */ React10.createElement(components.Equation, { math: decorator[1], inline: true });
549
- case "m":
550
- return element;
551
- //still need to return the base element
552
- case "a": {
553
- const v = decorator[1];
554
- const pathname = v.substring(1);
555
- const id = parsePageId(pathname, { uuid: true });
556
- if ((v[0] === "/" || v.includes(rootDomain)) && id) {
557
- const href = v.includes(rootDomain) ? v : `${mapPageUrl(id)}${getHashFragmentValue(v)}`;
558
- return /* @__PURE__ */ React10.createElement(components.PageLink, __spreadValues({ className: "notion-link", href }, linkProps), element);
559
- } else {
560
- return /* @__PURE__ */ React10.createElement(
561
- components.Link,
562
- __spreadValues({
563
- className: "notion-link",
564
- href: linkProtocol ? `${linkProtocol}:${decorator[1]}` : decorator[1]
565
- }, linkProps),
566
- element
567
- );
568
- }
569
- }
570
- // Date
571
- case "d": {
572
- const v = decorator[1];
573
- const type = v == null ? void 0 : v.type;
574
- if (type === "date") {
575
- const startDate = v.start_date;
576
- return formatDate(startDate);
577
- } else if (type === "daterange") {
578
- const startDate = v.start_date;
579
- const endDate = v.end_date;
580
- return `${formatDate(startDate)} \u2192 ${formatDate(endDate)}`;
581
- } else {
582
- return element;
583
- }
584
- }
585
- // User
586
- case "u": {
587
- const userId = decorator[1];
588
- const user = (_d = recordMap.notion_user[userId]) == null ? void 0 : _d.value;
589
- if (!user) {
590
- console.debug("missing user", userId);
591
- return null;
592
- }
593
- const name = user.name;
594
- const email = user.email;
595
- return /* @__PURE__ */ React10.createElement(components.Link, __spreadValues({ className: "notion-link", href: `mailto:${email}` }, linkProps), /* @__PURE__ */ React10.createElement(
596
- GracefulImage,
597
- {
598
- className: "notion-user",
599
- src: mapImageUrl(user.profile_photo, block),
600
- alt: name,
601
- style: { display: "inline", marginRight: "0.3em", marginBottom: "0.3em" }
602
- }
603
- ), name);
604
- }
605
- case "eoi": {
606
- const blockId = decorator[1];
607
- const externalObjectInstance = (_e = recordMap.block[blockId]) == null ? void 0 : _e.value;
608
- return /* @__PURE__ */ React10.createElement(EOI, { block: externalObjectInstance, inline: true });
609
- }
610
- default:
611
- if (true) console.debug("unsupported text format", decorator);
612
- return element;
613
- }
614
- },
615
- /* @__PURE__ */ React10.createElement(React10.Fragment, null, text)
616
- );
617
- return /* @__PURE__ */ React10.createElement(React10.Fragment, { key: index }, formatted);
618
- }));
619
- };
620
-
621
- // src/components/asset-wrapper.tsx
622
- var urlStyle = { width: "100%" };
623
- var AssetWrapper = ({ blockId, block }) => {
624
- var _a, _b, _c, _d, _e, _f;
625
- const value = block;
626
- const { components, mapPageUrl, rootDomain, zoom } = useNotionContext();
627
- let isURL = false;
628
- if (block.type === "image") {
629
- const caption = (_c = (_b = (_a = value == null ? void 0 : value.properties) == null ? void 0 : _a.caption) == null ? void 0 : _b[0]) == null ? void 0 : _c[0];
630
- if (caption) {
631
- const id = parsePageId2(caption, { uuid: true });
632
- const isPage = caption.charAt(0) === "/" && id;
633
- if (isPage || isValidURL(caption)) isURL = true;
634
- }
635
- }
636
- const figure = /* @__PURE__ */ React11.createElement(
637
- "figure",
638
- {
639
- className: `notion-asset-wrapper
640
- notion-asset-wrapper-${block.type}
641
- ${((_d = value.format) == null ? void 0 : _d.block_full_width) ? "notion-asset-wrapper-full" : ""}
642
- ${blockId}`
643
- },
644
- /* @__PURE__ */ React11.createElement(Asset, { block: value, zoomable: zoom && !isURL }, ((_e = value == null ? void 0 : value.properties) == null ? void 0 : _e.caption) && !isURL && /* @__PURE__ */ React11.createElement("figcaption", { className: "notion-asset-caption" }, /* @__PURE__ */ React11.createElement(Text, { value: value.properties.caption, block })))
645
- );
646
- if (isURL) {
647
- const caption = (_f = value == null ? void 0 : value.properties) == null ? void 0 : _f.caption[0][0];
648
- const id = parsePageId2(caption, { uuid: true });
649
- const isPage = caption.charAt(0) === "/" && id;
650
- const captionHostname = extractHostname(caption);
651
- return /* @__PURE__ */ React11.createElement(
652
- components.PageLink,
653
- {
654
- style: urlStyle,
655
- href: isPage ? mapPageUrl(id) : caption,
656
- target: captionHostname && captionHostname !== rootDomain && !caption.startsWith("/") ? "blank_" : null
657
- },
658
- figure
659
- );
660
- }
661
- return figure;
662
- };
663
- function isValidURL(str) {
664
- const pattern = new RegExp(
665
- "^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$",
666
- "i"
667
- );
668
- return !!pattern.test(str);
669
- }
670
- function extractHostname(url) {
671
- try {
672
- const hostname = new URL(url).hostname;
673
- return hostname;
674
- } catch (err) {
675
- return "";
676
- }
677
- }
678
-
679
- // src/components/header.tsx
680
- import React16 from "react";
681
- import { getPageBreadcrumbs } from "@texonom/nutils";
682
- import { useHotkeys } from "react-hotkeys-hook";
683
-
684
- // src/icons/search-icon.tsx
685
- import React12 from "react";
686
- var SearchIcon = (props) => {
687
- const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
688
- return /* @__PURE__ */ React12.createElement("svg", __spreadValues({ className: `notion-icon ${className || ""}`, viewBox: "0 0 17 17" }, rest), /* @__PURE__ */ React12.createElement("path", { d: "M6.78027 13.6729C8.24805 13.6729 9.60156 13.1982 10.709 12.4072L14.875 16.5732C15.0684 16.7666 15.3232 16.8633 15.5957 16.8633C16.167 16.8633 16.5713 16.4238 16.5713 15.8613C16.5713 15.5977 16.4834 15.3516 16.29 15.1582L12.1504 11.0098C13.0205 9.86719 13.5391 8.45215 13.5391 6.91406C13.5391 3.19629 10.498 0.155273 6.78027 0.155273C3.0625 0.155273 0.0214844 3.19629 0.0214844 6.91406C0.0214844 10.6318 3.0625 13.6729 6.78027 13.6729ZM6.78027 12.2139C3.87988 12.2139 1.48047 9.81445 1.48047 6.91406C1.48047 4.01367 3.87988 1.61426 6.78027 1.61426C9.68066 1.61426 12.0801 4.01367 12.0801 6.91406C12.0801 9.81445 9.68066 12.2139 6.78027 12.2139Z" }));
689
- };
690
-
691
- // src/components/search-dialog.tsx
692
- import React15 from "react";
693
- import { getBlockParentPage, getBlockTitle as getBlockTitle2 } from "@texonom/nutils";
694
-
695
- // src/icons/clear-icon.tsx
696
- import React13 from "react";
697
- var ClearIcon = (props) => {
698
- const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
699
- return /* @__PURE__ */ React13.createElement("svg", __spreadProps(__spreadValues({ className: `notion-icon ${className || ""}` }, rest), { viewBox: "0 0 30 30" }), /* @__PURE__ */ React13.createElement("path", { d: "M15,0C6.716,0,0,6.716,0,15s6.716,15,15,15s15-6.716,15-15S23.284,0,15,0z M22,20.6L20.6,22L15,16.4L9.4,22L8,20.6l5.6-5.6 L8,9.4L9.4,8l5.6,5.6L20.6,8L22,9.4L16.4,15L22,20.6z" }));
700
- };
701
-
702
- // src/icons/loading-icon.tsx
703
- import React14 from "react";
704
- var LoadingIcon = (props) => {
705
- const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
706
- return /* @__PURE__ */ React14.createElement("svg", __spreadProps(__spreadValues({ className: `notion-icon ${className || ""}` }, rest), { viewBox: "0 0 24 24" }), /* @__PURE__ */ React14.createElement("defs", null, /* @__PURE__ */ React14.createElement("linearGradient", { x1: "28.1542969%", y1: "63.7402344%", x2: "74.6289062%", y2: "17.7832031%", id: "linearGradient-1" }, /* @__PURE__ */ React14.createElement("stop", { stopColor: "rgba(164, 164, 164, 1)", offset: "0%" }), /* @__PURE__ */ React14.createElement("stop", { stopColor: "rgba(164, 164, 164, 0)", stopOpacity: "0", offset: "100%" }))), /* @__PURE__ */ React14.createElement("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none" }, /* @__PURE__ */ React14.createElement("g", { transform: "translate(-236.000000, -286.000000)" }, /* @__PURE__ */ React14.createElement("g", { transform: "translate(238.000000, 286.000000)" }, /* @__PURE__ */ React14.createElement("circle", { id: "Oval-2", stroke: "url(#linearGradient-1)", strokeWidth: "4", cx: "10", cy: "12", r: "10" }), /* @__PURE__ */ React14.createElement("path", { d: "M10,2 C4.4771525,2 0,6.4771525 0,12", id: "Oval-2", stroke: "rgba(164, 164, 164, 1)", strokeWidth: "4" }), /* @__PURE__ */ React14.createElement("rect", { id: "Rectangle-1", fill: "rgba(164, 164, 164, 1)", x: "8", y: "0", width: "4", height: "4", rx: "8" })))));
707
- };
708
-
709
- // src/components/search-dialog.tsx
710
- var debounce = (func, wait) => {
711
- let timeout;
712
- return (...args) => {
713
- if (timeout) clearTimeout(timeout);
714
- timeout = setTimeout(() => func(...args), wait);
715
- };
716
- };
717
- var SearchDialog = class extends React15.Component {
718
- constructor(props) {
719
- super(props);
720
- this.state = {
721
- isLoading: false,
722
- query: "",
723
- searchResult: null,
724
- searchError: null
725
- };
726
- this._onAfterOpen = () => {
727
- if (this._inputRef.current) this._inputRef.current.focus();
728
- };
729
- this._onChangeQuery = (e) => {
730
- const query = e.target.value;
731
- this.setState({ query });
732
- if (!query.trim()) {
733
- this.setState({ isLoading: false, searchResult: null, searchError: null });
734
- return;
735
- } else {
736
- this._search();
737
- }
738
- };
739
- this._onClearQuery = () => {
740
- this._onChangeQuery({ target: { value: "" } });
741
- };
742
- this._warmupSearch = () => __async(this, null, function* () {
743
- const { searchNotion, rootBlockId, rootSpaceId } = this.props;
744
- yield searchNotion({
745
- query: "",
746
- spaceId: rootSpaceId,
747
- filters: {
748
- ancestors: [rootBlockId],
749
- isDeletedOnly: false,
750
- excludeTemplates: true,
751
- navigableBlockContentOnly: true,
752
- requireEditPermissions: false
753
- }
754
- });
755
- });
756
- this._searchImpl = () => __async(this, null, function* () {
757
- const { searchNotion, rootBlockId, rootSpaceId } = this.props;
758
- const { query } = this.state;
759
- if (!query.trim()) {
760
- this.setState({ isLoading: false, searchResult: null, searchError: null });
761
- return;
762
- }
763
- this.setState({ isLoading: true });
764
- const result = yield searchNotion({
765
- query,
766
- spaceId: rootSpaceId,
767
- filters: {
768
- ancestors: [rootBlockId],
769
- isDeletedOnly: false,
770
- excludeTemplates: true,
771
- navigableBlockContentOnly: true,
772
- requireEditPermissions: false
773
- }
774
- });
775
- console.debug("search", query, result);
776
- let searchResult = null;
777
- let searchError = null;
778
- if (result.error || result.errorId) {
779
- searchError = result;
780
- } else {
781
- searchResult = __spreadValues({}, result);
782
- const results = searchResult.results.map((result2) => {
783
- var _a, _b;
784
- const block = (_a = searchResult.recordMap.block[result2.id]) == null ? void 0 : _a.value;
785
- if (!block) return;
786
- const title = getBlockTitle2(block, searchResult.recordMap);
787
- if (!title) return;
788
- result2.title = title;
789
- result2.block = block;
790
- result2.recordMap = searchResult.recordMap;
791
- result2.page = getBlockParentPage(block, searchResult.recordMap, {
792
- inclusive: true
793
- }) || block;
794
- if (!result2.page.id) return;
795
- if ((_b = result2.highlight) == null ? void 0 : _b.text)
796
- result2.highlight.html = result2.highlight.text.replace(/<gzkNfoUU>/gi, "<b>").replace(/<\/gzkNfoUU>/gi, "</b>");
797
- return result2;
798
- }).filter(Boolean);
799
- const searchResultsMap = results.reduce(
800
- (map, result2) => __spreadProps(__spreadValues({}, map), {
801
- [result2.page.id]: result2
802
- }),
803
- {}
804
- );
805
- searchResult.results = Object.values(searchResultsMap);
806
- }
807
- if (this.state.query === query) this.setState({ isLoading: false, searchResult, searchError });
808
- });
809
- this._inputRef = React15.createRef();
810
- }
811
- componentDidMount() {
812
- this._search = debounce(this._searchImpl.bind(this), 500);
813
- this._warmupSearch();
814
- }
815
- render() {
816
- const { isOpen, onClose } = this.props;
817
- const { isLoading, query, searchResult, searchError } = this.state;
818
- const hasQuery = !!query.trim();
819
- return /* @__PURE__ */ React15.createElement(NotionContextConsumer, null, (ctx2) => {
820
- const { components, defaultPageIcon, mapPageUrl } = ctx2;
821
- return /* @__PURE__ */ React15.createElement(
822
- components.Modal,
823
- {
824
- isOpen,
825
- contentLabel: "Search",
826
- className: "notion-search",
827
- overlayClassName: "notion-search-overlay",
828
- onRequestClose: onClose,
829
- onAfterOpen: this._onAfterOpen
830
- },
831
- /* @__PURE__ */ React15.createElement("div", { className: "quickFindMenu" }, /* @__PURE__ */ React15.createElement("div", { className: "searchBar" }, /* @__PURE__ */ React15.createElement("div", { className: "inlineIcon" }, isLoading ? /* @__PURE__ */ React15.createElement(LoadingIcon, { className: "loadingIcon" }) : /* @__PURE__ */ React15.createElement(SearchIcon, null)), /* @__PURE__ */ React15.createElement(
832
- "input",
833
- {
834
- className: "searchInput",
835
- placeholder: "Search",
836
- value: query,
837
- ref: this._inputRef,
838
- onInput: this._onChangeQuery
839
- }
840
- ), query && /* @__PURE__ */ React15.createElement("div", { role: "button", className: "clearButton", onClick: this._onClearQuery }, /* @__PURE__ */ React15.createElement(ClearIcon, { className: "clearIcon" }))), hasQuery && searchResult && /* @__PURE__ */ React15.createElement(React15.Fragment, null, searchResult.results.length ? /* @__PURE__ */ React15.createElement(NotionContextProvider, __spreadProps(__spreadValues({}, ctx2), { recordMap: searchResult.recordMap }), /* @__PURE__ */ React15.createElement("div", { className: "resultsPane" }, searchResult.results.map((result) => {
841
- var _a;
842
- return /* @__PURE__ */ React15.createElement(
843
- components.PageLink,
844
- {
845
- key: result.id,
846
- className: `result notion-page-link`,
847
- href: mapPageUrl(result.page.id, searchResult.recordMap)
848
- },
849
- /* @__PURE__ */ React15.createElement(PageTitle, { block: result.page, defaultIcon: defaultPageIcon }),
850
- ((_a = result.highlight) == null ? void 0 : _a.html) && /* @__PURE__ */ React15.createElement(
851
- "div",
852
- {
853
- className: "notion-search-result-highlight",
854
- dangerouslySetInnerHTML: {
855
- __html: result.highlight.html
856
- }
857
- }
858
- )
859
- );
860
- })), /* @__PURE__ */ React15.createElement("footer", { className: "resultsFooter" }, /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement("span", { className: "resultsCount" }, searchResult.total), searchResult.total === 1 ? " result" : " results"))) : /* @__PURE__ */ React15.createElement("div", { className: "noResultsPane" }, /* @__PURE__ */ React15.createElement("div", { className: "noResults" }, "No results"), /* @__PURE__ */ React15.createElement("div", { className: "noResultsDetail" }, "Try different search terms"))), hasQuery && !searchResult && searchError && /* @__PURE__ */ React15.createElement("div", { className: "noResultsPane" }, /* @__PURE__ */ React15.createElement("div", { className: "noResults" }, "Search error")))
861
- );
862
- });
863
- }
864
- };
865
-
866
- // src/components/header.tsx
867
- var Header = ({ block }) => {
868
- return /* @__PURE__ */ React16.createElement("header", { className: "notion-header" }, /* @__PURE__ */ React16.createElement("div", { className: "notion-nav-header" }, /* @__PURE__ */ React16.createElement(Breadcrumbs, { block }), /* @__PURE__ */ React16.createElement(Search, { block })));
869
- };
870
- var Breadcrumbs = ({ block, rootOnly = false }) => {
871
- const { recordMap, mapPageUrl, components } = useNotionContext();
872
- const breadcrumbs = React16.useMemo(() => {
873
- const breadcrumbs2 = getPageBreadcrumbs(recordMap, block.id);
874
- if (rootOnly) return [breadcrumbs2[0]].filter(Boolean);
875
- return breadcrumbs2;
876
- }, [recordMap, block.id, rootOnly]);
877
- return /* @__PURE__ */ React16.createElement("div", { className: "breadcrumbs", key: "breadcrumbs" }, breadcrumbs.map((breadcrumb, index) => {
878
- if (!breadcrumb) return null;
879
- const pageLinkProps = {};
880
- const componentMap = {
881
- pageLink: components.PageLink
882
- };
883
- if (breadcrumb.active) componentMap.pageLink = (props) => /* @__PURE__ */ React16.createElement("div", __spreadValues({}, props));
884
- else pageLinkProps.href = mapPageUrl(breadcrumb.pageId);
885
- return /* @__PURE__ */ React16.createElement(React16.Fragment, { key: breadcrumb.pageId }, /* @__PURE__ */ React16.createElement(componentMap.pageLink, __spreadValues({ className: `breadcrumb ${breadcrumb.active && "active"}` }, pageLinkProps), breadcrumb.icon && /* @__PURE__ */ React16.createElement(PageIcon, { className: "icon", block: breadcrumb.block }), breadcrumb.title && /* @__PURE__ */ React16.createElement("span", { className: "title" }, breadcrumb.title)), index < breadcrumbs.length - 1 && /* @__PURE__ */ React16.createElement("span", { className: "spacer" }, "/"));
886
- }));
887
- };
888
- var Search = ({ block, search, title = "Search" }) => {
889
- const { searchNotion, rootPageId, isShowingSearch, onHideSearch, rootSpaceId } = useNotionContext();
890
- const onSearchNotion = search || searchNotion;
891
- const [isSearchOpen, setIsSearchOpen] = React16.useState(isShowingSearch);
892
- React16.useEffect(() => {
893
- setIsSearchOpen(isShowingSearch);
894
- }, [isShowingSearch]);
895
- const onOpenSearch = React16.useCallback(() => {
896
- setIsSearchOpen(true);
897
- }, []);
898
- const onCloseSearch = React16.useCallback(() => {
899
- setIsSearchOpen(false);
900
- if (onHideSearch) onHideSearch();
901
- }, [onHideSearch]);
902
- useHotkeys("cmd+p", (event) => {
903
- onOpenSearch();
904
- event.preventDefault();
905
- event.stopPropagation();
906
- });
907
- useHotkeys("cmd+k", (event) => {
908
- onOpenSearch();
909
- event.preventDefault();
910
- event.stopPropagation();
911
- });
912
- const hasSearch = !!onSearchNotion;
913
- return /* @__PURE__ */ React16.createElement(React16.Fragment, null, hasSearch && /* @__PURE__ */ React16.createElement("div", { role: "button", className: `breadcrumb button notion-search-button`, onClick: onOpenSearch }, /* @__PURE__ */ React16.createElement(SearchIcon, { className: "searchIcon" }), title && /* @__PURE__ */ React16.createElement("span", { className: "title" }, title)), isSearchOpen && hasSearch && /* @__PURE__ */ React16.createElement(
914
- SearchDialog,
915
- {
916
- isOpen: isSearchOpen,
917
- rootBlockId: rootPageId || (block == null ? void 0 : block.id),
918
- rootSpaceId,
919
- onClose: onCloseSearch,
920
- searchNotion: onSearchNotion
921
- }
922
- ));
923
- };
924
-
925
- // src/next.tsx
926
- import React17 from "react";
927
- import isEqual from "react-fast-compare";
928
- var wrapNextImage = (NextImage) => {
929
- return React17.memo(function ReactNotionXNextImage(_a) {
930
- var _b = _a, {
931
- src,
932
- alt,
933
- width,
934
- height,
935
- className,
936
- style,
937
- layout
938
- } = _b, rest = __objRest(_b, [
939
- "src",
940
- "alt",
941
- "width",
942
- "height",
943
- "className",
944
- "style",
945
- "layout"
946
- ]);
947
- if (!layout) layout = width && height ? "intrinsic" : "fill";
948
- return /* @__PURE__ */ React17.createElement(
949
- NextImage,
950
- __spreadValues({
951
- className,
952
- src,
953
- alt,
954
- width: layout === "intrinsic" && width,
955
- height: layout === "intrinsic" && height,
956
- objectFit: style == null ? void 0 : style.objectFit,
957
- objectPosition: style == null ? void 0 : style.objectPosition,
958
- layout
959
- }, rest)
960
- );
961
- }, isEqual);
962
- };
963
- var wrapNextLink = (NextLink) => (function ReactNotionXNextLink(_a) {
964
- var _b = _a, { href, as, passHref, prefetch, replace, scroll, shallow, locale } = _b, linkProps = __objRest(_b, ["href", "as", "passHref", "prefetch", "replace", "scroll", "shallow", "locale"]);
965
- return /* @__PURE__ */ React17.createElement(
966
- NextLink,
967
- {
968
- href,
969
- as,
970
- passHref,
971
- prefetch,
972
- replace,
973
- scroll,
974
- shallow,
975
- locale
976
- },
977
- /* @__PURE__ */ React17.createElement("a", __spreadValues({}, linkProps))
978
- );
979
- });
980
-
981
- // src/context.tsx
982
- var DefaultLink = (props) => /* @__PURE__ */ React18.createElement("a", __spreadValues({ target: "_blank", rel: "noopener noreferrer" }, props));
983
- var DefaultLinkMemo = React18.memo(DefaultLink);
984
- var DefaultPageLink = (props) => /* @__PURE__ */ React18.createElement("a", __spreadValues({}, props));
985
- var DefaultPageLinkMemo = React18.memo(DefaultPageLink);
986
- var DefaultEmbed = (props) => /* @__PURE__ */ React18.createElement(AssetWrapper, __spreadValues({}, props));
987
- var DefaultHeader = Header;
988
- var dummyLink = (_a) => {
989
- var _b = _a, { href, rel, target, title } = _b, rest = __objRest(_b, ["href", "rel", "target", "title"]);
990
- return /* @__PURE__ */ React18.createElement("span", __spreadValues({}, rest));
991
- };
992
- var dummyComponent = (name) => () => {
993
- console.warn(`Warning: using empty component "${name}" (you should override this in NotionRenderer.components)`);
994
- return null;
995
- };
996
- var dummyOverrideFn = (_, defaultValueFn) => defaultValueFn();
997
- var defaultComponents = {
998
- Image: null,
999
- // disable custom images by default
1000
- Link: DefaultLinkMemo,
1001
- PageLink: DefaultPageLinkMemo,
1002
- Checkbox,
1003
- Callout: void 0,
1004
- // use the built-in callout rendering by default
1005
- Code: dummyComponent("Code"),
1006
- Equation: dummyComponent("Equation"),
1007
- Collection: dummyComponent("Collection"),
1008
- Property: void 0,
1009
- // use the built-in property rendering by default
1010
- propertyTextValue: dummyOverrideFn,
1011
- propertySelectValue: dummyOverrideFn,
1012
- propertyRelationValue: dummyOverrideFn,
1013
- propertyFormulaValue: dummyOverrideFn,
1014
- propertyTitleValue: dummyOverrideFn,
1015
- propertyPersonValue: dummyOverrideFn,
1016
- propertyFileValue: dummyOverrideFn,
1017
- propertyCheckboxValue: dummyOverrideFn,
1018
- propertyUrlValue: dummyOverrideFn,
1019
- propertyEmailValue: dummyOverrideFn,
1020
- propertyPhoneNumberValue: dummyOverrideFn,
1021
- propertyNumberValue: dummyOverrideFn,
1022
- propertyLastEditedTimeValue: dummyOverrideFn,
1023
- propertyCreatedTimeValue: dummyOverrideFn,
1024
- propertyDateValue: dummyOverrideFn,
1025
- Pdf: dummyComponent("Pdf"),
1026
- Tweet: dummyComponent("Tweet"),
1027
- Modal: dummyComponent("Modal"),
1028
- Header: DefaultHeader,
1029
- Embed: DefaultEmbed
1030
- };
1031
- var defaultNotionContext = {
1032
- recordMap: {
1033
- block: {},
1034
- collection: {},
1035
- collection_view: {},
1036
- collection_query: {},
1037
- notion_user: {},
1038
- signed_urls: {}
1039
- },
1040
- components: defaultComponents,
1041
- mapPageUrl: defaultMapPageUrl(),
1042
- mapImageUrl: defaultMapImageUrl,
1043
- searchNotion: null,
1044
- isShowingSearch: false,
1045
- onHideSearch: null,
1046
- fullPage: false,
1047
- darkMode: false,
1048
- previewImages: false,
1049
- forceCustomImages: false,
1050
- showCollectionViewDropdown: true,
1051
- linkTableTitleProperties: true,
1052
- isLinkCollectionToUrlProperty: false,
1053
- showTableOfContents: false,
1054
- minTableOfContentsItems: 3,
1055
- defaultPageIcon: null,
1056
- defaultPageCover: null,
1057
- defaultPageCoverPosition: 0.5,
1058
- zoom: null
1059
- };
1060
- var ctx = React18.createContext(defaultNotionContext);
1061
- var NotionContextProvider = (_a) => {
1062
- var _b = _a, {
1063
- components: themeComponents = {},
1064
- children,
1065
- mapPageUrl,
1066
- mapImageUrl,
1067
- rootPageId,
1068
- rootSpaceId
1069
- } = _b, rest = __objRest(_b, [
1070
- "components",
1071
- "children",
1072
- "mapPageUrl",
1073
- "mapImageUrl",
1074
- "rootPageId",
1075
- "rootSpaceId"
1076
- ]);
1077
- for (const key of Object.keys(rest)) if (rest[key] === void 0) delete rest[key];
1078
- const wrappedThemeComponents = React18.useMemo(() => {
1079
- const components = __spreadValues({}, themeComponents);
1080
- if (components.nextImage) components.Image = wrapNextImage(components.nextImage);
1081
- if (components.nextLink) {
1082
- const nextLink = wrapNextLink(components.nextLink);
1083
- components.nextLink = nextLink;
1084
- if (!components.PageLink) components.PageLink = nextLink;
1085
- if (!components.Link) components.Link = nextLink;
1086
- }
1087
- for (const key of Object.keys(components)) if (!components[key]) delete components[key];
1088
- return components;
1089
- }, [themeComponents]);
1090
- const value = React18.useMemo(
1091
- () => __spreadProps(__spreadValues(__spreadValues({}, defaultNotionContext), rest), {
1092
- rootPageId,
1093
- rootSpaceId,
1094
- mapPageUrl: mapPageUrl != null ? mapPageUrl : defaultMapPageUrl(rootPageId),
1095
- mapImageUrl: mapImageUrl != null ? mapImageUrl : defaultMapImageUrl,
1096
- components: __spreadValues(__spreadValues({}, defaultComponents), wrappedThemeComponents)
1097
- }),
1098
- [mapImageUrl, mapPageUrl, wrappedThemeComponents, rootPageId, rootSpaceId, rest]
1099
- );
1100
- return /* @__PURE__ */ React18.createElement(ctx.Provider, { value }, children);
1101
- };
1102
- var NotionContextConsumer = ctx.Consumer;
1103
- var useNotionContext = () => {
1104
- return React18.useContext(ctx);
1105
- };
1106
-
1107
- // src/icons/default-page-icon.tsx
1108
- import React19 from "react";
1109
- var DefaultPageIcon = (props) => {
1110
- const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
1111
- return /* @__PURE__ */ React19.createElement("svg", __spreadProps(__spreadValues({ className }, rest), { viewBox: "0 0 30 30", width: "16" }), /* @__PURE__ */ React19.createElement("path", { d: "M16,1H4v28h22V11L16,1z M16,3.828L23.172,11H16V3.828z M24,27H6V3h8v10h10V27z M8,17h14v-2H8V17z M8,21h14v-2H8V21z M8,25h14v-2H8V25z" }));
1112
- };
1113
-
1114
- // src/components/page-icon.tsx
1115
- var isIconBlock = (value) => {
1116
- return value.type === "page" || value.type === "callout" || value.type === "collection_view" || value.type === "collection_view_page";
1117
- };
1118
- var PageIconImpl = ({ block, className, inline = true, hideDefaultIcon = false, defaultIcon }) => {
1119
- var _a;
1120
- const { mapImageUrl, recordMap, darkMode } = useNotionContext();
1121
- let isImage = false;
1122
- let content = null;
1123
- if (isIconBlock(block)) {
1124
- const icon = ((_a = getBlockIcon(block, recordMap)) == null ? void 0 : _a.trim()) || defaultIcon;
1125
- const title = getBlockTitle3(block, recordMap);
1126
- if (icon && isUrl(icon)) {
1127
- const url = mapImageUrl(icon, block);
1128
- isImage = true;
1129
- content = /* @__PURE__ */ React20.createElement(LazyImage, { src: url, alt: title || "page icon", className: `${className || ""} notion-page-icon` });
1130
- } else if (icon && icon.startsWith("/icons/")) {
1131
- const url = "https://www.notion.so" + icon + "?mode=" + (darkMode ? "dark" : "light");
1132
- content = /* @__PURE__ */ React20.createElement(LazyImage, { src: url, alt: title || "page icon", className: `${className || ""} notion-page-icon` });
1133
- } else if (!icon) {
1134
- if (!hideDefaultIcon) {
1135
- isImage = true;
1136
- content = /* @__PURE__ */ React20.createElement(DefaultPageIcon, { className: `${className || ""} notion-page-icon`, alt: title ? title : "page icon" });
1137
- }
1138
- } else {
1139
- isImage = false;
1140
- content = /* @__PURE__ */ React20.createElement("span", { className: `${className || ""} notion-page-icon`, role: "img", "aria-label": icon }, icon);
1141
- }
1142
- }
1143
- if (!content) return null;
1144
- return /* @__PURE__ */ React20.createElement(
1145
- "div",
1146
- {
1147
- className: `
1148
- ${inline ? "notion-page-icon-inline" : "notion-page-icon-hero"}
1149
- ${isImage ? "notion-page-icon-image" : "notion-page-icon-span"}
1150
- `
1151
- },
1152
- content
1153
- );
1154
- };
1155
- var PageIcon = React20.memo(PageIconImpl);
1156
-
1157
- export {
1158
- Checkbox,
1159
- getListNumber,
1160
- getHashFragmentValue,
1161
- isBrowser,
1162
- getYoutubeId,
1163
- isUrl,
1164
- formatDate,
1165
- formatNotionDateTime,
1166
- LazyImage,
1167
- PageIconImpl,
1168
- PageIcon,
1169
- EOI,
1170
- GracefulImage,
1171
- Text,
1172
- PageTitleImpl,
1173
- PageTitle,
1174
- SearchDialog,
1175
- Header,
1176
- Breadcrumbs,
1177
- Search,
1178
- dummyLink,
1179
- NotionContextProvider,
1180
- NotionContextConsumer,
1181
- useNotionContext,
1182
- LiteYouTubeEmbed,
1183
- Asset,
1184
- AssetWrapper
1185
- };
1186
- //# sourceMappingURL=chunk-ZJAJPWJX.js.map