@texonom/nreact 1.3.1 → 1.4.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 (78) hide show
  1. package/build/.tsbuildinfo +1 -1
  2. package/build/{chunk-HJGIONX2.js → chunk-72RHNPWF.js} +56 -107
  3. package/build/{chunk-LB5ZQ7L5.js → chunk-P7HX4BAT.js} +2 -3
  4. package/build/dev/{chunk-NVAEYUJK.js → chunk-64UJZ76E.js} +57 -108
  5. package/build/dev/{chunk-NVAEYUJK.js.map → chunk-64UJZ76E.js.map} +1 -1
  6. package/build/dev/{chunk-CWNFRR32.js → chunk-ABDRHJEI.js} +3 -4
  7. package/build/dev/{chunk-CWNFRR32.js.map → chunk-ABDRHJEI.js.map} +1 -1
  8. package/build/dev/{chunk-JX5CEG3A.js → chunk-OAIRL2FN.js} +1 -1
  9. package/build/dev/{chunk-4XJBBVRZ.js → chunk-SEA7YL2O.js} +57 -108
  10. package/build/dev/chunk-SEA7YL2O.js.map +1 -0
  11. package/build/dev/index.js +42 -55
  12. package/build/dev/index.js.map +1 -1
  13. package/build/dev/third-party/code.js +3 -4
  14. package/build/dev/third-party/code.js.map +1 -1
  15. package/build/dev/third-party/collection.js +137 -113
  16. package/build/dev/third-party/collection.js.map +1 -1
  17. package/build/dev/third-party/equation.js +3 -4
  18. package/build/dev/third-party/equation.js.map +1 -1
  19. package/build/dev/third-party/modal.js +1 -1
  20. package/build/dev/third-party/pdf.js +1 -1
  21. package/build/index.js +42 -55
  22. package/build/next.d.ts.map +1 -1
  23. package/build/third-party/code.js +3 -4
  24. package/build/third-party/collection.js +137 -113
  25. package/build/third-party/equation.js +3 -4
  26. package/build/third-party/modal.js +1 -1
  27. package/build/third-party/pdf.js +1 -1
  28. package/build/utils.d.ts.map +1 -1
  29. package/package.json +12 -12
  30. package/build/chunk-26XPY26R.js +0 -1364
  31. package/build/chunk-3GUXT4PT.js +0 -1386
  32. package/build/chunk-3R4ITV3N.js +0 -1358
  33. package/build/chunk-626ANHMX.js +0 -4519
  34. package/build/chunk-BYOAK6PN.js +0 -1362
  35. package/build/chunk-E7SOYYOP.js +0 -1364
  36. package/build/chunk-GDUEQGYI.js +0 -1373
  37. package/build/chunk-INDII3MG.js +0 -1346
  38. package/build/chunk-LAZZ76RR.js +0 -142
  39. package/build/chunk-NH6F5YHO.js +0 -90
  40. package/build/chunk-THLNCQWF.js +0 -1364
  41. package/build/chunk-YEVPS76Z.js +0 -1355
  42. package/build/dev/chunk-2LHADYU7.js +0 -1365
  43. package/build/dev/chunk-2LHADYU7.js.map +0 -1
  44. package/build/dev/chunk-4XJBBVRZ.js.map +0 -1
  45. package/build/dev/chunk-5DDQTDIS.js +0 -1365
  46. package/build/dev/chunk-5DDQTDIS.js.map +0 -1
  47. package/build/dev/chunk-73CYHEZ6.js +0 -1374
  48. package/build/dev/chunk-73CYHEZ6.js.map +0 -1
  49. package/build/dev/chunk-7R2ZX3WF.js +0 -1359
  50. package/build/dev/chunk-7R2ZX3WF.js.map +0 -1
  51. package/build/dev/chunk-CRSVOVI5.js +0 -1387
  52. package/build/dev/chunk-CRSVOVI5.js.map +0 -1
  53. package/build/dev/chunk-EDEWD2W7.js +0 -1363
  54. package/build/dev/chunk-EDEWD2W7.js.map +0 -1
  55. package/build/dev/chunk-O5ZUWUSN.js +0 -158
  56. package/build/dev/chunk-O5ZUWUSN.js.map +0 -1
  57. package/build/dev/chunk-QAD7OWKG.js +0 -91
  58. package/build/dev/chunk-QAD7OWKG.js.map +0 -1
  59. package/build/dev/chunk-QHYYIFZL.js +0 -1365
  60. package/build/dev/chunk-QHYYIFZL.js.map +0 -1
  61. package/build/dev/chunk-QN4Z7A2J.js +0 -1359
  62. package/build/dev/chunk-QN4Z7A2J.js.map +0 -1
  63. package/build/dev/chunk-RO7JTBZN.js +0 -1356
  64. package/build/dev/chunk-RO7JTBZN.js.map +0 -1
  65. package/build/dev/chunk-UE6LH4B3.js +0 -1347
  66. package/build/dev/chunk-UE6LH4B3.js.map +0 -1
  67. package/build/dev/chunk-VHTSGS2P.js +0 -1365
  68. package/build/dev/chunk-VHTSGS2P.js.map +0 -1
  69. package/build/dev/chunk-VZCA75U7.js +0 -143
  70. package/build/dev/chunk-VZCA75U7.js.map +0 -1
  71. package/build/dev/chunk-XJQFUGEP.js +0 -4520
  72. package/build/dev/chunk-XJQFUGEP.js.map +0 -1
  73. package/build/map-image-url.d.ts +0 -3
  74. package/build/map-image-url.d.ts.map +0 -1
  75. package/build/map-page-url.d.ts +0 -2
  76. package/build/map-page-url.d.ts.map +0 -1
  77. /package/build/{chunk-723T62SD.js → chunk-C6BUIPAM.js} +0 -0
  78. /package/build/dev/{chunk-JX5CEG3A.js.map → chunk-OAIRL2FN.js.map} +0 -0
@@ -1,1387 +0,0 @@
1
- import {
2
- __async,
3
- __commonJS,
4
- __objRest,
5
- __spreadProps,
6
- __spreadValues,
7
- __toESM
8
- } from "./chunk-JX5CEG3A.js";
9
-
10
- // ../../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
11
- var require_lodash = __commonJS({
12
- "../../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports, module) {
13
- var FUNC_ERROR_TEXT = "Expected a function";
14
- var NAN = 0 / 0;
15
- var symbolTag = "[object Symbol]";
16
- var reTrim = /^\s+|\s+$/g;
17
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
18
- var reIsBinary = /^0b[01]+$/i;
19
- var reIsOctal = /^0o[0-7]+$/i;
20
- var freeParseInt = parseInt;
21
- var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
22
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
23
- var root = freeGlobal || freeSelf || Function("return this")();
24
- var objectProto = Object.prototype;
25
- var objectToString = objectProto.toString;
26
- var nativeMax = Math.max;
27
- var nativeMin = Math.min;
28
- var now = function() {
29
- return root.Date.now();
30
- };
31
- function debounce(func, wait, options) {
32
- var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
33
- if (typeof func != "function") {
34
- throw new TypeError(FUNC_ERROR_TEXT);
35
- }
36
- wait = toNumber(wait) || 0;
37
- if (isObject(options)) {
38
- leading = !!options.leading;
39
- maxing = "maxWait" in options;
40
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
41
- trailing = "trailing" in options ? !!options.trailing : trailing;
42
- }
43
- function invokeFunc(time) {
44
- var args = lastArgs, thisArg = lastThis;
45
- lastArgs = lastThis = void 0;
46
- lastInvokeTime = time;
47
- result = func.apply(thisArg, args);
48
- return result;
49
- }
50
- function leadingEdge(time) {
51
- lastInvokeTime = time;
52
- timerId = setTimeout(timerExpired, wait);
53
- return leading ? invokeFunc(time) : result;
54
- }
55
- function remainingWait(time) {
56
- var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;
57
- return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;
58
- }
59
- function shouldInvoke(time) {
60
- var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
61
- return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
62
- }
63
- function timerExpired() {
64
- var time = now();
65
- if (shouldInvoke(time)) {
66
- return trailingEdge(time);
67
- }
68
- timerId = setTimeout(timerExpired, remainingWait(time));
69
- }
70
- function trailingEdge(time) {
71
- timerId = void 0;
72
- if (trailing && lastArgs) {
73
- return invokeFunc(time);
74
- }
75
- lastArgs = lastThis = void 0;
76
- return result;
77
- }
78
- function cancel() {
79
- if (timerId !== void 0) {
80
- clearTimeout(timerId);
81
- }
82
- lastInvokeTime = 0;
83
- lastArgs = lastCallTime = lastThis = timerId = void 0;
84
- }
85
- function flush() {
86
- return timerId === void 0 ? result : trailingEdge(now());
87
- }
88
- function debounced() {
89
- var time = now(), isInvoking = shouldInvoke(time);
90
- lastArgs = arguments;
91
- lastThis = this;
92
- lastCallTime = time;
93
- if (isInvoking) {
94
- if (timerId === void 0) {
95
- return leadingEdge(lastCallTime);
96
- }
97
- if (maxing) {
98
- timerId = setTimeout(timerExpired, wait);
99
- return invokeFunc(lastCallTime);
100
- }
101
- }
102
- if (timerId === void 0) {
103
- timerId = setTimeout(timerExpired, wait);
104
- }
105
- return result;
106
- }
107
- debounced.cancel = cancel;
108
- debounced.flush = flush;
109
- return debounced;
110
- }
111
- function throttle2(func, wait, options) {
112
- var leading = true, trailing = true;
113
- if (typeof func != "function") {
114
- throw new TypeError(FUNC_ERROR_TEXT);
115
- }
116
- if (isObject(options)) {
117
- leading = "leading" in options ? !!options.leading : leading;
118
- trailing = "trailing" in options ? !!options.trailing : trailing;
119
- }
120
- return debounce(func, wait, {
121
- "leading": leading,
122
- "maxWait": wait,
123
- "trailing": trailing
124
- });
125
- }
126
- function isObject(value) {
127
- var type = typeof value;
128
- return !!value && (type == "object" || type == "function");
129
- }
130
- function isObjectLike(value) {
131
- return !!value && typeof value == "object";
132
- }
133
- function isSymbol(value) {
134
- return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
135
- }
136
- function toNumber(value) {
137
- if (typeof value == "number") {
138
- return value;
139
- }
140
- if (isSymbol(value)) {
141
- return NAN;
142
- }
143
- if (isObject(value)) {
144
- var other = typeof value.valueOf == "function" ? value.valueOf() : value;
145
- value = isObject(other) ? other + "" : other;
146
- }
147
- if (typeof value != "string") {
148
- return value === 0 ? value : +value;
149
- }
150
- value = value.replace(reTrim, "");
151
- var isBinary = reIsBinary.test(value);
152
- return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
153
- }
154
- module.exports = throttle2;
155
- }
156
- });
157
-
158
- // src/components/checkbox.tsx
159
- import React2 from "react";
160
-
161
- // src/icons/check.tsx
162
- import React from "react";
163
- function SvgCheck(props) {
164
- 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" }));
165
- }
166
- var check_default = SvgCheck;
167
-
168
- // src/components/checkbox.tsx
169
- var Checkbox = ({ isChecked }) => {
170
- let content = null;
171
- if (isChecked)
172
- content = /* @__PURE__ */ React2.createElement("div", { className: "notion-property-checkbox-checked" }, /* @__PURE__ */ React2.createElement(check_default, null));
173
- else
174
- content = /* @__PURE__ */ React2.createElement("div", { className: "notion-property-checkbox-unchecked" });
175
- return /* @__PURE__ */ React2.createElement("span", { className: "notion-property notion-property-checkbox" }, content);
176
- };
177
-
178
- // src/map-image-url.ts
179
- var defaultMapImageUrl = (url, block) => {
180
- if (!url)
181
- return null;
182
- if (url.startsWith("data:"))
183
- return url;
184
- if (url.startsWith("https://images.unsplash.com"))
185
- return url;
186
- try {
187
- const u = new URL(url);
188
- if (u.pathname.startsWith("/secure.notion-static.com") && u.hostname.endsWith(".amazonaws.com")) {
189
- if (u.searchParams.has("X-Amz-Credential") && u.searchParams.has("X-Amz-Signature") && u.searchParams.has("X-Amz-Algorithm"))
190
- return url;
191
- }
192
- } catch (e) {
193
- }
194
- if (url.startsWith("/images"))
195
- url = `https://www.notion.so${url}`;
196
- url = `https://www.notion.so${url.startsWith("/image") ? url : `/image/${encodeURIComponent(url)}`}`;
197
- const notionImageUrlV2 = new URL(url);
198
- let table = block.parent_table === "space" ? "block" : block.parent_table;
199
- if (table === "collection" || table === "team")
200
- table = "block";
201
- notionImageUrlV2.searchParams.set("table", table);
202
- notionImageUrlV2.searchParams.set("id", block.id);
203
- notionImageUrlV2.searchParams.set("cache", "v2");
204
- url = notionImageUrlV2.toString();
205
- return url;
206
- };
207
-
208
- // src/map-page-url.ts
209
- var defaultMapPageUrl = (rootPageId) => (pageId) => {
210
- pageId = (pageId || "").replace(/-/g, "");
211
- if (rootPageId && pageId === rootPageId)
212
- return "/";
213
- else
214
- return `/${pageId}`;
215
- };
216
-
217
- // src/utils.ts
218
- import { isUrl, formatDate, formatNotionDateTime } from "@texonom/nutils";
219
- var cs = (...classes) => classes.filter((a) => !!a).join(" ");
220
- var groupBlockContent = (blockMap) => {
221
- const output = [];
222
- let lastType = void 0;
223
- let index = -1;
224
- Object.keys(blockMap).forEach((id) => {
225
- var _a, _b;
226
- const blockValue = (_a = blockMap[id]) == null ? void 0 : _a.value;
227
- if (blockValue)
228
- (_b = blockValue.content) == null ? void 0 : _b.forEach((blockId) => {
229
- var _a2, _b2;
230
- const blockType = (_b2 = (_a2 = blockMap[blockId]) == null ? void 0 : _a2.value) == null ? void 0 : _b2.type;
231
- if (blockType && blockType !== lastType) {
232
- index++;
233
- lastType = blockType;
234
- output[index] = [];
235
- }
236
- if (index > -1)
237
- output[index].push(blockId);
238
- });
239
- lastType = void 0;
240
- });
241
- return output;
242
- };
243
- var getListNumber = (blockId, blockMap) => {
244
- const groups = groupBlockContent(blockMap);
245
- const group = groups.find((g) => g.includes(blockId));
246
- if (!group)
247
- return;
248
- return group.indexOf(blockId) + 1;
249
- };
250
- var getHashFragmentValue = (url) => {
251
- return url.includes("#") ? url.replace(/^.+(#.+)$/, "$1") : "";
252
- };
253
- var isBrowser = typeof window !== "undefined";
254
- var youtubeDomains = /* @__PURE__ */ new Set([
255
- "youtu.be",
256
- "youtube.com",
257
- "www.youtube.com",
258
- "youtube-nocookie.com",
259
- "www.youtube-nocookie.com"
260
- ]);
261
- var getYoutubeId = (url) => {
262
- try {
263
- const { hostname } = new URL(url);
264
- if (!youtubeDomains.has(hostname))
265
- return null;
266
- const regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/i;
267
- const match = url.match(regExp);
268
- if (match && match[2].length == 11)
269
- return match[2];
270
- } catch (e) {
271
- }
272
- return null;
273
- };
274
-
275
- // src/components/page-icon.tsx
276
- import React20 from "react";
277
- import { getBlockIcon, getBlockTitle as getBlockTitle3 } from "@texonom/nutils";
278
-
279
- // src/context.tsx
280
- import React18 from "react";
281
-
282
- // src/components/asset-wrapper.tsx
283
- import React11 from "react";
284
- import { parsePageId as parsePageId2 } from "@texonom/nutils";
285
-
286
- // src/components/asset.tsx
287
- import React5 from "react";
288
- import { getTextContent } from "@texonom/nutils";
289
-
290
- // src/components/lazy-image.tsx
291
- import React3 from "react";
292
- import { normalizeUrl } from "@texonom/nutils";
293
- var LazyImage = (_a) => {
294
- var _b = _a, { src, alt, className, style, zoomable = false, priority = false, height } = _b, rest = __objRest(_b, ["src", "alt", "className", "style", "zoomable", "priority", "height"]);
295
- var _a2, _b2, _c;
296
- const { recordMap, zoom, previewImages, forceCustomImages, components } = useNotionContext();
297
- const zoomRef = React3.useRef(zoom ? zoom.clone() : null);
298
- 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;
299
- const onLoad = React3.useCallback(
300
- (e) => {
301
- if (zoomable && (e.target.src || e.target.srcset)) {
302
- if (zoomRef.current)
303
- zoomRef.current.attach(e.target);
304
- }
305
- },
306
- [zoomRef, zoomable]
307
- );
308
- const attachZoom = React3.useCallback(
309
- (image) => {
310
- if (zoomRef.current && image)
311
- zoomRef.current.attach(image);
312
- },
313
- [zoomRef]
314
- );
315
- const attachZoomRef = React3.useMemo(() => zoomable ? attachZoom : void 0, [zoomable, attachZoom]);
316
- if (previewImage && components.Image) {
317
- return /* @__PURE__ */ React3.createElement(
318
- components.Image,
319
- {
320
- src,
321
- alt,
322
- style,
323
- className,
324
- width: previewImage.originalWidth,
325
- height: previewImage.originalHeight,
326
- blurDataURL: previewImage.dataURIBase64,
327
- placeholder: "blur",
328
- priority,
329
- onLoad
330
- }
331
- );
332
- } else {
333
- if (components.Image && forceCustomImages)
334
- return /* @__PURE__ */ React3.createElement(
335
- components.Image,
336
- {
337
- src,
338
- alt,
339
- className,
340
- style,
341
- width: null,
342
- height: height || null,
343
- priority,
344
- onLoad
345
- }
346
- );
347
- return /* @__PURE__ */ React3.createElement(
348
- "img",
349
- __spreadValues({
350
- className,
351
- style,
352
- src,
353
- alt,
354
- ref: attachZoomRef,
355
- loading: "lazy",
356
- decoding: "async"
357
- }, rest)
358
- );
359
- }
360
- };
361
-
362
- // src/components/lite-youtube-embed.tsx
363
- import React4 from "react";
364
- var qs = (params) => {
365
- return Object.keys(params).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`).join("&");
366
- };
367
- var LiteYouTubeEmbed = ({
368
- id,
369
- defaultPlay = false,
370
- mute = false,
371
- lazyImage = false,
372
- iframeTitle = "YouTube video",
373
- alt = "Video preview",
374
- params = {},
375
- adLinksPreconnect = true,
376
- style,
377
- className
378
- }) => {
379
- const muteParam = mute || defaultPlay ? "1" : "0";
380
- const queryString = React4.useMemo(() => qs(__spreadValues({ autoplay: "1", mute: muteParam }, params)), [muteParam, params]);
381
- const resolution = "hqdefault";
382
- const posterUrl = `https://i.ytimg.com/vi/${id}/${resolution}.jpg`;
383
- const ytUrl = "https://www.youtube-nocookie.com";
384
- const iframeSrc = `${ytUrl}/embed/${id}?${queryString}`;
385
- const [isPreconnected, setIsPreconnected] = React4.useState(false);
386
- const [iframeInitialized, setIframeInitialized] = React4.useState(defaultPlay);
387
- const [isIframeLoaded, setIsIframeLoaded] = React4.useState(false);
388
- const warmConnections = React4.useCallback(() => {
389
- if (isPreconnected)
390
- return;
391
- setIsPreconnected(true);
392
- }, [isPreconnected]);
393
- const onLoadIframe = React4.useCallback(() => {
394
- if (iframeInitialized)
395
- return;
396
- setIframeInitialized(true);
397
- }, [iframeInitialized]);
398
- const onIframeLoaded = React4.useCallback(() => {
399
- setIsIframeLoaded(true);
400
- }, []);
401
- 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(
402
- "div",
403
- {
404
- onClick: onLoadIframe,
405
- onPointerOver: warmConnections,
406
- className: cs(
407
- "notion-yt-lite",
408
- isIframeLoaded && "notion-yt-loaded",
409
- iframeInitialized && "notion-yt-initialized",
410
- className
411
- ),
412
- style
413
- },
414
- /* @__PURE__ */ React4.createElement("img", { src: posterUrl, className: "notion-yt-thumbnail", loading: lazyImage ? "lazy" : void 0, alt }),
415
- /* @__PURE__ */ React4.createElement("div", { className: "notion-yt-playbtn" }),
416
- iframeInitialized && /* @__PURE__ */ React4.createElement(
417
- "iframe",
418
- {
419
- width: "560",
420
- height: "315",
421
- frameBorder: "0",
422
- allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
423
- allowFullScreen: true,
424
- title: iframeTitle,
425
- src: iframeSrc,
426
- onLoad: onIframeLoaded
427
- }
428
- )
429
- ));
430
- };
431
-
432
- // src/components/asset.tsx
433
- var isServer = typeof window === "undefined";
434
- var supportedAssetTypes = [
435
- "video",
436
- "image",
437
- "embed",
438
- "figma",
439
- "typeform",
440
- "excalidraw",
441
- "maps",
442
- "tweet",
443
- "pdf",
444
- "gist",
445
- "codepen",
446
- "drive"
447
- ];
448
- var Asset = ({ block, zoomable = true, children }) => {
449
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
450
- const { recordMap, mapImageUrl, components } = useNotionContext();
451
- if (!block || !supportedAssetTypes.includes(block.type))
452
- return null;
453
- const style = {
454
- position: "relative",
455
- display: "flex",
456
- justifyContent: "center",
457
- alignSelf: "center",
458
- width: "100%",
459
- maxWidth: "100%",
460
- flexDirection: "column"
461
- };
462
- const assetStyle = {};
463
- if (block.format) {
464
- const { block_aspect_ratio, block_height, block_width, block_full_width, block_page_width, block_preserve_scale } = block.format;
465
- if (block_full_width || block_page_width) {
466
- if (block_full_width)
467
- style.width = "100vw";
468
- else
469
- style.width = "100%";
470
- if (block.type === "video") {
471
- if (block_height)
472
- style.height = block_height;
473
- else if (block_aspect_ratio)
474
- style.paddingBottom = `${block_aspect_ratio * 100}%`;
475
- else if (block_preserve_scale)
476
- style.objectFit = "contain";
477
- } else if (block_aspect_ratio && block.type !== "image") {
478
- style.paddingBottom = `${block_aspect_ratio * 100}%`;
479
- } else if (block_height) {
480
- style.height = block_height;
481
- } else if (block_preserve_scale) {
482
- if (block.type === "image") {
483
- style.height = "100%";
484
- } else {
485
- style.paddingBottom = "75%";
486
- style.minHeight = 100;
487
- }
488
- }
489
- } else {
490
- switch ((_a = block.format) == null ? void 0 : _a.block_alignment) {
491
- case "center": {
492
- style.alignSelf = "center";
493
- break;
494
- }
495
- case "left": {
496
- style.alignSelf = "start";
497
- break;
498
- }
499
- case "right": {
500
- style.alignSelf = "end";
501
- break;
502
- }
503
- }
504
- if (block_width)
505
- style.width = block_width;
506
- if (block_preserve_scale && block.type !== "image") {
507
- style.paddingBottom = "50%";
508
- style.minHeight = 100;
509
- } else {
510
- if (block_height && block.type !== "image")
511
- style.height = block_height;
512
- }
513
- }
514
- if (block.type === "image")
515
- assetStyle.objectFit = "cover";
516
- else if (block_preserve_scale)
517
- assetStyle.objectFit = "contain";
518
- }
519
- 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]);
520
- let content = null;
521
- if (!source)
522
- return null;
523
- if (block.type === "tweet") {
524
- const src = source;
525
- if (!src)
526
- return null;
527
- const id = src.split("?")[0].split("/").pop();
528
- if (!id)
529
- return null;
530
- content = /* @__PURE__ */ React5.createElement(
531
- "div",
532
- {
533
- style: __spreadProps(__spreadValues({}, assetStyle), {
534
- maxWidth: 420,
535
- width: "100%",
536
- marginLeft: "auto",
537
- marginRight: "auto"
538
- })
539
- },
540
- /* @__PURE__ */ React5.createElement(components.Tweet, { id })
541
- );
542
- } else if (block.type === "pdf") {
543
- style.overflow = "auto";
544
- style.background = "rgb(226, 226, 226)";
545
- style.display = "block";
546
- if (!style.padding)
547
- style.padding = "8px 16px";
548
- if (!isServer)
549
- content = /* @__PURE__ */ React5.createElement(components.Pdf, { file: source });
550
- } 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") {
551
- 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) {
552
- style.paddingBottom = void 0;
553
- content = /* @__PURE__ */ React5.createElement("video", { playsInline: true, controls: true, preload: "metadata", style: assetStyle, src: source, title: block.type });
554
- } else {
555
- let src = ((_f = block.format) == null ? void 0 : _f.display_source) || source;
556
- if (src) {
557
- const youtubeVideoId = block.type === "video" ? getYoutubeId(src) : null;
558
- if (youtubeVideoId) {
559
- content = /* @__PURE__ */ React5.createElement(LiteYouTubeEmbed, { id: youtubeVideoId, style: assetStyle, className: "notion-asset-object-fit" });
560
- } else if (block.type === "gist") {
561
- if (!src.endsWith(".pibb"))
562
- src = `${src}.pibb`;
563
- assetStyle.width = "100%";
564
- style.paddingBottom = "50%";
565
- content = /* @__PURE__ */ React5.createElement(
566
- "iframe",
567
- {
568
- style: assetStyle,
569
- className: "notion-asset-object-fit",
570
- src,
571
- title: "GitHub Gist",
572
- frameBorder: "0",
573
- loading: "lazy",
574
- scrolling: "auto"
575
- }
576
- );
577
- } else {
578
- content = /* @__PURE__ */ React5.createElement(
579
- "iframe",
580
- {
581
- className: "notion-asset-object-fit",
582
- style: assetStyle,
583
- src,
584
- title: `iframe ${block.type}`,
585
- frameBorder: "0",
586
- allowFullScreen: true,
587
- loading: "lazy",
588
- scrolling: "auto"
589
- }
590
- );
591
- }
592
- }
593
- }
594
- } else if (block.type === "image") {
595
- if (source.includes("file.notion.so"))
596
- source = (_i = (_h = (_g = block.properties) == null ? void 0 : _g.source) == null ? void 0 : _h[0]) == null ? void 0 : _i[0];
597
- const src = mapImageUrl(source, block);
598
- const caption = getTextContent((_j = block.properties) == null ? void 0 : _j.caption);
599
- const alt = caption || "notion image";
600
- content = /* @__PURE__ */ React5.createElement(LazyImage, { src, alt, zoomable, height: style.height, style: assetStyle });
601
- }
602
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { style }, content, block.type === "image" && children), block.type !== "image" && children);
603
- };
604
-
605
- // src/components/text.tsx
606
- import React10 from "react";
607
- import { parsePageId } from "@texonom/nutils";
608
-
609
- // src/components/eoi.tsx
610
- import React7 from "react";
611
-
612
- // src/icons/type-github.tsx
613
- import React6 from "react";
614
- function SvgTypeGitHub(props) {
615
- return /* @__PURE__ */ React6.createElement("svg", __spreadValues({ viewBox: "0 0 260 260" }, props), /* @__PURE__ */ React6.createElement("g", null, /* @__PURE__ */ React6.createElement(
616
- "path",
617
- {
618
- 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",
619
- fill: "#161614"
620
- }
621
- )));
622
- }
623
- var type_github_default = SvgTypeGitHub;
624
-
625
- // src/components/eoi.tsx
626
- var EOI = ({ block, inline, className }) => {
627
- var _a, _b, _c;
628
- const { components } = useNotionContext();
629
- const { original_url, attributes, domain } = (block == null ? void 0 : block.format) || {};
630
- if (!original_url || !attributes)
631
- return null;
632
- const title = (_a = attributes.find((attr) => attr.id === "title")) == null ? void 0 : _a.values[0];
633
- let owner = (_b = attributes.find((attr) => attr.id === "owner")) == null ? void 0 : _b.values[0];
634
- const lastUpdatedAt = (_c = attributes.find((attr) => attr.id === "updated_at")) == null ? void 0 : _c.values[0];
635
- const lastUpdated = lastUpdatedAt ? formatNotionDateTime(lastUpdatedAt) : null;
636
- let externalImage;
637
- switch (domain) {
638
- case "github.com":
639
- externalImage = /* @__PURE__ */ React7.createElement(type_github_default, null);
640
- if (owner) {
641
- const parts = owner.split("/");
642
- owner = parts[parts.length - 1];
643
- }
644
- break;
645
- default:
646
- if (true)
647
- console.debug(`Unsupported external_object_instance domain "${domain}"`, JSON.stringify(block, null, 2));
648
- return null;
649
- }
650
- return /* @__PURE__ */ React7.createElement(
651
- components.Link,
652
- {
653
- target: "_blank",
654
- rel: "noopener noreferrer",
655
- href: original_url,
656
- className: cs("notion-external", inline ? "notion-external-mention" : "notion-external-block notion-row", className)
657
- },
658
- externalImage && /* @__PURE__ */ React7.createElement("div", { className: "notion-external-image" }, externalImage),
659
- /* @__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)))
660
- );
661
- };
662
-
663
- // src/components/graceful-image.tsx
664
- import React8 from "react";
665
- import { Img } from "react-image";
666
- var GracefulImage = (props) => {
667
- if (isBrowser)
668
- return /* @__PURE__ */ React8.createElement(Img, __spreadValues({}, props));
669
- else
670
- return /* @__PURE__ */ React8.createElement("img", __spreadValues({}, props));
671
- };
672
-
673
- // src/components/page-title.tsx
674
- import React9 from "react";
675
- import { getBlockTitle } from "@texonom/nutils";
676
- var PageTitleImpl = (_a) => {
677
- var _b = _a, { block, className, defaultIcon } = _b, rest = __objRest(_b, ["block", "className", "defaultIcon"]);
678
- var _a2, _b2;
679
- const { recordMap } = useNotionContext();
680
- if (!block)
681
- return null;
682
- if (block.type === "collection_view_page" || block.type === "collection_view") {
683
- const title = getBlockTitle(block, recordMap);
684
- if (!title)
685
- return null;
686
- const titleDecoration = [[title]];
687
- return /* @__PURE__ */ React9.createElement("span", __spreadValues({ className: cs("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 })));
688
- }
689
- if (!((_a2 = block.properties) == null ? void 0 : _a2.title))
690
- return null;
691
- return /* @__PURE__ */ React9.createElement("span", __spreadValues({ className: cs("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 })));
692
- };
693
- var PageTitle = React9.memo(PageTitleImpl);
694
-
695
- // src/components/text.tsx
696
- var Text = ({ value, block, linkProps, linkProtocol }) => {
697
- const { components, recordMap, mapPageUrl, mapImageUrl, rootDomain } = useNotionContext();
698
- return /* @__PURE__ */ React10.createElement(React10.Fragment, null, value == null ? void 0 : value.map((deco, index) => {
699
- const [text, decorations] = deco;
700
- if (!decorations)
701
- if (text === ",")
702
- return /* @__PURE__ */ React10.createElement("span", { key: index, style: { padding: "0.5em" } });
703
- else
704
- return /* @__PURE__ */ React10.createElement(React10.Fragment, { key: index }, text);
705
- const formatted = decorations.reduce(
706
- (element, decorator) => {
707
- var _a, _b, _c, _d, _e;
708
- switch (decorator[0]) {
709
- case "p": {
710
- const blockId = decorator[1];
711
- const linkedBlock = (_a = recordMap.block[blockId]) == null ? void 0 : _a.value;
712
- if (!linkedBlock) {
713
- console.debug('"p" missing block', blockId);
714
- return null;
715
- }
716
- return /* @__PURE__ */ React10.createElement(components.PageLink, { className: "notion-link", href: mapPageUrl(blockId) }, /* @__PURE__ */ React10.createElement(PageTitle, { block: linkedBlock }));
717
- }
718
- case "\u2023": {
719
- const linkType = decorator[1][0];
720
- const id = decorator[1][1];
721
- switch (linkType) {
722
- case "u": {
723
- const user = (_b = recordMap.notion_user[id]) == null ? void 0 : _b.value;
724
- if (!user) {
725
- console.debug('"\u2023" missing user', id);
726
- return null;
727
- }
728
- const name = [user.given_name, user.family_name].filter(Boolean).join(" ");
729
- return /* @__PURE__ */ React10.createElement(GracefulImage, { className: "notion-user", src: mapImageUrl(user.profile_photo, block), alt: name });
730
- }
731
- default: {
732
- const linkedBlock = (_c = recordMap.block[id]) == null ? void 0 : _c.value;
733
- if (!linkedBlock) {
734
- console.debug('"\u2023" missing block', linkType, id);
735
- return null;
736
- }
737
- return /* @__PURE__ */ React10.createElement(
738
- components.PageLink,
739
- __spreadProps(__spreadValues({
740
- className: "notion-link",
741
- href: mapPageUrl(id)
742
- }, linkProps), {
743
- target: "_blank",
744
- rel: "noopener noreferrer"
745
- }),
746
- /* @__PURE__ */ React10.createElement(PageTitle, { block: linkedBlock })
747
- );
748
- }
749
- }
750
- }
751
- case "h":
752
- return /* @__PURE__ */ React10.createElement("span", { className: `notion-${decorator[1]}` }, element);
753
- case "c":
754
- return /* @__PURE__ */ React10.createElement("code", { className: "notion-inline-code" }, element);
755
- case "b":
756
- return /* @__PURE__ */ React10.createElement("b", null, element);
757
- case "i":
758
- return /* @__PURE__ */ React10.createElement("em", null, element);
759
- case "s":
760
- return /* @__PURE__ */ React10.createElement("s", null, element);
761
- case "_":
762
- return /* @__PURE__ */ React10.createElement("span", { className: "notion-inline-underscore" }, element);
763
- case "e":
764
- return /* @__PURE__ */ React10.createElement(components.Equation, { math: decorator[1], inline: true });
765
- case "m":
766
- return element;
767
- case "a": {
768
- const v = decorator[1];
769
- const pathname = v.substring(1);
770
- const id = parsePageId(pathname, { uuid: true });
771
- if ((v[0] === "/" || v.includes(rootDomain)) && id) {
772
- const href = v.includes(rootDomain) ? v : `${mapPageUrl(id)}${getHashFragmentValue(v)}`;
773
- return /* @__PURE__ */ React10.createElement(components.PageLink, __spreadValues({ className: "notion-link", href }, linkProps), element);
774
- } else {
775
- return /* @__PURE__ */ React10.createElement(
776
- components.Link,
777
- __spreadValues({
778
- className: "notion-link",
779
- href: linkProtocol ? `${linkProtocol}:${decorator[1]}` : decorator[1]
780
- }, linkProps),
781
- element
782
- );
783
- }
784
- }
785
- case "d": {
786
- const v = decorator[1];
787
- const type = v == null ? void 0 : v.type;
788
- if (type === "date") {
789
- const startDate = v.start_date;
790
- return formatDate(startDate);
791
- } else if (type === "daterange") {
792
- const startDate = v.start_date;
793
- const endDate = v.end_date;
794
- return `${formatDate(startDate)} \u2192 ${formatDate(endDate)}`;
795
- } else {
796
- return element;
797
- }
798
- }
799
- case "u": {
800
- const userId = decorator[1];
801
- const user = (_d = recordMap.notion_user[userId]) == null ? void 0 : _d.value;
802
- if (!user) {
803
- console.debug("missing user", userId);
804
- return null;
805
- }
806
- const name = [user.given_name, user.family_name].filter(Boolean).join(" ");
807
- return /* @__PURE__ */ React10.createElement(GracefulImage, { className: "notion-user", src: mapImageUrl(user.profile_photo, block), alt: name });
808
- }
809
- case "eoi": {
810
- const blockId = decorator[1];
811
- const externalObjectInstance = (_e = recordMap.block[blockId]) == null ? void 0 : _e.value;
812
- return /* @__PURE__ */ React10.createElement(EOI, { block: externalObjectInstance, inline: true });
813
- }
814
- default:
815
- if (true)
816
- console.debug("unsupported text format", decorator);
817
- return element;
818
- }
819
- },
820
- /* @__PURE__ */ React10.createElement(React10.Fragment, null, text)
821
- );
822
- return /* @__PURE__ */ React10.createElement(React10.Fragment, { key: index }, formatted);
823
- }));
824
- };
825
-
826
- // src/components/asset-wrapper.tsx
827
- var urlStyle = { width: "100%" };
828
- var AssetWrapper = ({ blockId, block }) => {
829
- var _a, _b, _c, _d, _e, _f;
830
- const value = block;
831
- const { components, mapPageUrl, rootDomain, zoom } = useNotionContext();
832
- let isURL = false;
833
- if (block.type === "image") {
834
- 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];
835
- if (caption) {
836
- const id = parsePageId2(caption, { uuid: true });
837
- const isPage = caption.charAt(0) === "/" && id;
838
- if (isPage || isValidURL(caption))
839
- isURL = true;
840
- }
841
- }
842
- const figure = /* @__PURE__ */ React11.createElement(
843
- "figure",
844
- {
845
- className: cs(
846
- "notion-asset-wrapper",
847
- `notion-asset-wrapper-${block.type}`,
848
- ((_d = value.format) == null ? void 0 : _d.block_full_width) && "notion-asset-wrapper-full",
849
- blockId
850
- )
851
- },
852
- /* @__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 })))
853
- );
854
- if (isURL) {
855
- const caption = (_f = value == null ? void 0 : value.properties) == null ? void 0 : _f.caption[0][0];
856
- const id = parsePageId2(caption, { uuid: true });
857
- const isPage = caption.charAt(0) === "/" && id;
858
- const captionHostname = extractHostname(caption);
859
- return /* @__PURE__ */ React11.createElement(
860
- components.PageLink,
861
- {
862
- style: urlStyle,
863
- href: isPage ? mapPageUrl(id) : caption,
864
- target: captionHostname && captionHostname !== rootDomain && !caption.startsWith("/") ? "blank_" : null
865
- },
866
- figure
867
- );
868
- }
869
- return figure;
870
- };
871
- function isValidURL(str) {
872
- const pattern = new RegExp(
873
- "^(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_]*)?$",
874
- "i"
875
- );
876
- return !!pattern.test(str);
877
- }
878
- function extractHostname(url) {
879
- try {
880
- const hostname = new URL(url).hostname;
881
- return hostname;
882
- } catch (err) {
883
- return "";
884
- }
885
- }
886
-
887
- // src/components/header.tsx
888
- import React16 from "react";
889
- import { getPageBreadcrumbs } from "@texonom/nutils";
890
- import { useHotkeys } from "react-hotkeys-hook";
891
-
892
- // src/icons/search-icon.tsx
893
- import React12 from "react";
894
- var SearchIcon = (props) => {
895
- const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
896
- return /* @__PURE__ */ React12.createElement("svg", __spreadValues({ className: cs("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" }));
897
- };
898
-
899
- // src/components/search-dialog.tsx
900
- var import_lodash = __toESM(require_lodash(), 1);
901
- import React15 from "react";
902
- import { getBlockParentPage, getBlockTitle as getBlockTitle2 } from "@texonom/nutils";
903
-
904
- // src/icons/clear-icon.tsx
905
- import React13 from "react";
906
- var ClearIcon = (props) => {
907
- const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
908
- return /* @__PURE__ */ React13.createElement("svg", __spreadProps(__spreadValues({ className: cs("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" }));
909
- };
910
-
911
- // src/icons/loading-icon.tsx
912
- import React14 from "react";
913
- var LoadingIcon = (props) => {
914
- const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
915
- return /* @__PURE__ */ React14.createElement("svg", __spreadProps(__spreadValues({ className: cs("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" })))));
916
- };
917
-
918
- // src/components/search-dialog.tsx
919
- var SearchDialog = class extends React15.Component {
920
- constructor(props) {
921
- super(props);
922
- this.state = {
923
- isLoading: false,
924
- query: "",
925
- searchResult: null,
926
- searchError: null
927
- };
928
- this._onAfterOpen = () => {
929
- if (this._inputRef.current)
930
- this._inputRef.current.focus();
931
- };
932
- this._onChangeQuery = (e) => {
933
- const query = e.target.value;
934
- this.setState({ query });
935
- if (!query.trim()) {
936
- this.setState({ isLoading: false, searchResult: null, searchError: null });
937
- return;
938
- } else {
939
- this._search();
940
- }
941
- };
942
- this._onClearQuery = () => {
943
- this._onChangeQuery({ target: { value: "" } });
944
- };
945
- this._warmupSearch = () => __async(this, null, function* () {
946
- const { searchNotion, rootBlockId } = this.props;
947
- yield searchNotion({
948
- query: "",
949
- ancestorId: rootBlockId
950
- });
951
- });
952
- this._searchImpl = () => __async(this, null, function* () {
953
- const { searchNotion, rootBlockId } = this.props;
954
- const { query } = this.state;
955
- if (!query.trim()) {
956
- this.setState({ isLoading: false, searchResult: null, searchError: null });
957
- return;
958
- }
959
- this.setState({ isLoading: true });
960
- const result = yield searchNotion({
961
- query,
962
- ancestorId: rootBlockId
963
- });
964
- console.debug("search", query, result);
965
- let searchResult = null;
966
- let searchError = null;
967
- if (result.error || result.errorId) {
968
- searchError = result;
969
- } else {
970
- searchResult = __spreadValues({}, result);
971
- const results = searchResult.results.map((result2) => {
972
- var _a, _b;
973
- const block = (_a = searchResult.recordMap.block[result2.id]) == null ? void 0 : _a.value;
974
- if (!block)
975
- return;
976
- const title = getBlockTitle2(block, searchResult.recordMap);
977
- if (!title)
978
- return;
979
- result2.title = title;
980
- result2.block = block;
981
- result2.recordMap = searchResult.recordMap;
982
- result2.page = getBlockParentPage(block, searchResult.recordMap, {
983
- inclusive: true
984
- }) || block;
985
- if (!result2.page.id)
986
- return;
987
- if ((_b = result2.highlight) == null ? void 0 : _b.text)
988
- result2.highlight.html = result2.highlight.text.replace(/<gzkNfoUU>/gi, "<b>").replace(/<\/gzkNfoUU>/gi, "</b>");
989
- return result2;
990
- }).filter(Boolean);
991
- const searchResultsMap = results.reduce(
992
- (map, result2) => __spreadProps(__spreadValues({}, map), {
993
- [result2.page.id]: result2
994
- }),
995
- {}
996
- );
997
- searchResult.results = Object.values(searchResultsMap);
998
- }
999
- if (this.state.query === query)
1000
- this.setState({ isLoading: false, searchResult, searchError });
1001
- });
1002
- this._inputRef = React15.createRef();
1003
- }
1004
- componentDidMount() {
1005
- this._search = (0, import_lodash.default)(this._searchImpl.bind(this), 1e3);
1006
- this._warmupSearch();
1007
- }
1008
- render() {
1009
- const { isOpen, onClose } = this.props;
1010
- const { isLoading, query, searchResult, searchError } = this.state;
1011
- const hasQuery = !!query.trim();
1012
- return /* @__PURE__ */ React15.createElement(NotionContextConsumer, null, (ctx2) => {
1013
- const { components, defaultPageIcon, mapPageUrl } = ctx2;
1014
- return /* @__PURE__ */ React15.createElement(
1015
- components.Modal,
1016
- {
1017
- isOpen,
1018
- contentLabel: "Search",
1019
- className: "notion-search",
1020
- overlayClassName: "notion-search-overlay",
1021
- onRequestClose: onClose,
1022
- onAfterOpen: this._onAfterOpen
1023
- },
1024
- /* @__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(
1025
- "input",
1026
- {
1027
- className: "searchInput",
1028
- placeholder: "Search",
1029
- value: query,
1030
- ref: this._inputRef,
1031
- onChange: this._onChangeQuery
1032
- }
1033
- ), 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) => {
1034
- var _a;
1035
- return /* @__PURE__ */ React15.createElement(
1036
- components.PageLink,
1037
- {
1038
- key: result.id,
1039
- className: cs("result", "notion-page-link"),
1040
- href: mapPageUrl(result.page.id, searchResult.recordMap)
1041
- },
1042
- /* @__PURE__ */ React15.createElement(PageTitle, { block: result.page, defaultIcon: defaultPageIcon }),
1043
- ((_a = result.highlight) == null ? void 0 : _a.html) && /* @__PURE__ */ React15.createElement(
1044
- "div",
1045
- {
1046
- className: "notion-search-result-highlight",
1047
- dangerouslySetInnerHTML: {
1048
- __html: result.highlight.html
1049
- }
1050
- }
1051
- )
1052
- );
1053
- })), /* @__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")))
1054
- );
1055
- });
1056
- }
1057
- };
1058
-
1059
- // src/components/header.tsx
1060
- var Header = ({ block }) => {
1061
- 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 })));
1062
- };
1063
- var Breadcrumbs = ({ block, rootOnly = false }) => {
1064
- const { recordMap, mapPageUrl, components } = useNotionContext();
1065
- const breadcrumbs = React16.useMemo(() => {
1066
- const breadcrumbs2 = getPageBreadcrumbs(recordMap, block.id);
1067
- if (rootOnly)
1068
- return [breadcrumbs2[0]].filter(Boolean);
1069
- return breadcrumbs2;
1070
- }, [recordMap, block.id, rootOnly]);
1071
- return /* @__PURE__ */ React16.createElement("div", { className: "breadcrumbs", key: "breadcrumbs" }, breadcrumbs.map((breadcrumb, index) => {
1072
- if (!breadcrumb)
1073
- return null;
1074
- const pageLinkProps = {};
1075
- const componentMap = {
1076
- pageLink: components.PageLink
1077
- };
1078
- if (breadcrumb.active)
1079
- componentMap.pageLink = (props) => /* @__PURE__ */ React16.createElement("div", __spreadValues({}, props));
1080
- else
1081
- pageLinkProps.href = mapPageUrl(breadcrumb.pageId);
1082
- return /* @__PURE__ */ React16.createElement(React16.Fragment, { key: breadcrumb.pageId }, /* @__PURE__ */ React16.createElement(componentMap.pageLink, __spreadValues({ className: cs("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" }, "/"));
1083
- }));
1084
- };
1085
- var Search = ({ block, search, title = "Search" }) => {
1086
- const { searchNotion, rootPageId, isShowingSearch, onHideSearch } = useNotionContext();
1087
- const onSearchNotion = search || searchNotion;
1088
- const [isSearchOpen, setIsSearchOpen] = React16.useState(isShowingSearch);
1089
- React16.useEffect(() => {
1090
- setIsSearchOpen(isShowingSearch);
1091
- }, [isShowingSearch]);
1092
- const onOpenSearch = React16.useCallback(() => {
1093
- setIsSearchOpen(true);
1094
- }, []);
1095
- const onCloseSearch = React16.useCallback(() => {
1096
- setIsSearchOpen(false);
1097
- if (onHideSearch)
1098
- onHideSearch();
1099
- }, [onHideSearch]);
1100
- useHotkeys("cmd+p", (event) => {
1101
- onOpenSearch();
1102
- event.preventDefault();
1103
- event.stopPropagation();
1104
- });
1105
- useHotkeys("cmd+k", (event) => {
1106
- onOpenSearch();
1107
- event.preventDefault();
1108
- event.stopPropagation();
1109
- });
1110
- const hasSearch = !!onSearchNotion;
1111
- return /* @__PURE__ */ React16.createElement(React16.Fragment, null, hasSearch && /* @__PURE__ */ React16.createElement("div", { role: "button", className: cs("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(
1112
- SearchDialog,
1113
- {
1114
- isOpen: isSearchOpen,
1115
- rootBlockId: rootPageId || (block == null ? void 0 : block.id),
1116
- onClose: onCloseSearch,
1117
- searchNotion: onSearchNotion
1118
- }
1119
- ));
1120
- };
1121
-
1122
- // src/next.tsx
1123
- import React17 from "react";
1124
- import isEqual from "react-fast-compare";
1125
- var wrapNextImage = (NextImage) => {
1126
- return React17.memo(function ReactNotionXNextImage(_a) {
1127
- var _b = _a, {
1128
- src,
1129
- alt,
1130
- width,
1131
- height,
1132
- className,
1133
- style,
1134
- layout
1135
- } = _b, rest = __objRest(_b, [
1136
- "src",
1137
- "alt",
1138
- "width",
1139
- "height",
1140
- "className",
1141
- "style",
1142
- "layout"
1143
- ]);
1144
- if (!layout)
1145
- layout = width && height ? "intrinsic" : "fill";
1146
- return /* @__PURE__ */ React17.createElement(
1147
- NextImage,
1148
- __spreadValues({
1149
- className,
1150
- src,
1151
- alt,
1152
- width: layout === "intrinsic" && width,
1153
- height: layout === "intrinsic" && height,
1154
- objectFit: style == null ? void 0 : style.objectFit,
1155
- objectPosition: style == null ? void 0 : style.objectPosition,
1156
- layout
1157
- }, rest)
1158
- );
1159
- }, isEqual);
1160
- };
1161
- var wrapNextLink = (NextLink) => function ReactNotionXNextLink(_a) {
1162
- var _b = _a, { href, as, passHref, prefetch, replace, scroll, shallow, locale } = _b, linkProps = __objRest(_b, ["href", "as", "passHref", "prefetch", "replace", "scroll", "shallow", "locale"]);
1163
- return /* @__PURE__ */ React17.createElement(
1164
- NextLink,
1165
- {
1166
- href,
1167
- as,
1168
- passHref,
1169
- prefetch,
1170
- replace,
1171
- scroll,
1172
- shallow,
1173
- locale
1174
- },
1175
- /* @__PURE__ */ React17.createElement("a", __spreadValues({}, linkProps))
1176
- );
1177
- };
1178
-
1179
- // src/context.tsx
1180
- var DefaultLink = (props) => /* @__PURE__ */ React18.createElement("a", __spreadValues({ target: "_blank", rel: "noopener noreferrer" }, props));
1181
- var DefaultLinkMemo = React18.memo(DefaultLink);
1182
- var DefaultPageLink = (props) => /* @__PURE__ */ React18.createElement("a", __spreadValues({}, props));
1183
- var DefaultPageLinkMemo = React18.memo(DefaultPageLink);
1184
- var DefaultEmbed = (props) => /* @__PURE__ */ React18.createElement(AssetWrapper, __spreadValues({}, props));
1185
- var DefaultHeader = Header;
1186
- var dummyLink = (_a) => {
1187
- var _b = _a, { href, rel, target, title } = _b, rest = __objRest(_b, ["href", "rel", "target", "title"]);
1188
- return /* @__PURE__ */ React18.createElement("span", __spreadValues({}, rest));
1189
- };
1190
- var dummyComponent = (name) => () => {
1191
- console.warn(`Warning: using empty component "${name}" (you should override this in NotionRenderer.components)`);
1192
- return null;
1193
- };
1194
- var dummyOverrideFn = (_, defaultValueFn) => defaultValueFn();
1195
- var defaultComponents = {
1196
- Image: null,
1197
- // disable custom images by default
1198
- Link: DefaultLinkMemo,
1199
- PageLink: DefaultPageLinkMemo,
1200
- Checkbox,
1201
- Callout: void 0,
1202
- // use the built-in callout rendering by default
1203
- Code: dummyComponent("Code"),
1204
- Equation: dummyComponent("Equation"),
1205
- Collection: dummyComponent("Collection"),
1206
- Property: void 0,
1207
- // use the built-in property rendering by default
1208
- propertyTextValue: dummyOverrideFn,
1209
- propertySelectValue: dummyOverrideFn,
1210
- propertyRelationValue: dummyOverrideFn,
1211
- propertyFormulaValue: dummyOverrideFn,
1212
- propertyTitleValue: dummyOverrideFn,
1213
- propertyPersonValue: dummyOverrideFn,
1214
- propertyFileValue: dummyOverrideFn,
1215
- propertyCheckboxValue: dummyOverrideFn,
1216
- propertyUrlValue: dummyOverrideFn,
1217
- propertyEmailValue: dummyOverrideFn,
1218
- propertyPhoneNumberValue: dummyOverrideFn,
1219
- propertyNumberValue: dummyOverrideFn,
1220
- propertyLastEditedTimeValue: dummyOverrideFn,
1221
- propertyCreatedTimeValue: dummyOverrideFn,
1222
- propertyDateValue: dummyOverrideFn,
1223
- Pdf: dummyComponent("Pdf"),
1224
- Tweet: dummyComponent("Tweet"),
1225
- Modal: dummyComponent("Modal"),
1226
- Header: DefaultHeader,
1227
- Embed: DefaultEmbed
1228
- };
1229
- var defaultNotionContext = {
1230
- recordMap: {
1231
- block: {},
1232
- collection: {},
1233
- collection_view: {},
1234
- collection_query: {},
1235
- notion_user: {},
1236
- signed_urls: {}
1237
- },
1238
- components: defaultComponents,
1239
- mapPageUrl: defaultMapPageUrl(),
1240
- mapImageUrl: defaultMapImageUrl,
1241
- searchNotion: null,
1242
- isShowingSearch: false,
1243
- onHideSearch: null,
1244
- fullPage: false,
1245
- darkMode: false,
1246
- previewImages: false,
1247
- forceCustomImages: false,
1248
- showCollectionViewDropdown: true,
1249
- linkTableTitleProperties: true,
1250
- isLinkCollectionToUrlProperty: false,
1251
- showTableOfContents: false,
1252
- minTableOfContentsItems: 3,
1253
- defaultPageIcon: null,
1254
- defaultPageCover: null,
1255
- defaultPageCoverPosition: 0.5,
1256
- zoom: null
1257
- };
1258
- var ctx = React18.createContext(defaultNotionContext);
1259
- var NotionContextProvider = (_a) => {
1260
- var _b = _a, {
1261
- components: themeComponents = {},
1262
- children,
1263
- mapPageUrl,
1264
- mapImageUrl,
1265
- rootPageId
1266
- } = _b, rest = __objRest(_b, [
1267
- "components",
1268
- "children",
1269
- "mapPageUrl",
1270
- "mapImageUrl",
1271
- "rootPageId"
1272
- ]);
1273
- for (const key of Object.keys(rest))
1274
- if (rest[key] === void 0)
1275
- delete rest[key];
1276
- const wrappedThemeComponents = React18.useMemo(
1277
- () => __spreadValues({}, themeComponents),
1278
- [themeComponents]
1279
- );
1280
- if (wrappedThemeComponents.nextImage)
1281
- wrappedThemeComponents.Image = wrapNextImage(themeComponents.nextImage);
1282
- if (wrappedThemeComponents.nextLink)
1283
- wrappedThemeComponents.nextLink = wrapNextLink(themeComponents.nextLink);
1284
- for (const key of Object.keys(wrappedThemeComponents))
1285
- if (!wrappedThemeComponents[key])
1286
- delete wrappedThemeComponents[key];
1287
- const value = React18.useMemo(
1288
- () => __spreadProps(__spreadValues(__spreadValues({}, defaultNotionContext), rest), {
1289
- rootPageId,
1290
- mapPageUrl: mapPageUrl != null ? mapPageUrl : defaultMapPageUrl(rootPageId),
1291
- mapImageUrl: mapImageUrl != null ? mapImageUrl : defaultMapImageUrl,
1292
- components: __spreadValues(__spreadValues({}, defaultComponents), wrappedThemeComponents)
1293
- }),
1294
- [mapImageUrl, mapPageUrl, wrappedThemeComponents, rootPageId, rest]
1295
- );
1296
- return /* @__PURE__ */ React18.createElement(ctx.Provider, { value }, children);
1297
- };
1298
- var NotionContextConsumer = ctx.Consumer;
1299
- var useNotionContext = () => {
1300
- return React18.useContext(ctx);
1301
- };
1302
-
1303
- // src/icons/default-page-icon.tsx
1304
- import React19 from "react";
1305
- var DefaultPageIcon = (props) => {
1306
- const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
1307
- 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" }));
1308
- };
1309
-
1310
- // src/components/page-icon.tsx
1311
- var isIconBlock = (value) => {
1312
- return value.type === "page" || value.type === "callout" || value.type === "collection_view" || value.type === "collection_view_page";
1313
- };
1314
- var PageIconImpl = ({ block, className, inline = true, hideDefaultIcon = false, defaultIcon }) => {
1315
- var _a;
1316
- const { mapImageUrl, recordMap, darkMode } = useNotionContext();
1317
- let isImage = false;
1318
- let content = null;
1319
- if (isIconBlock(block)) {
1320
- const icon = ((_a = getBlockIcon(block, recordMap)) == null ? void 0 : _a.trim()) || defaultIcon;
1321
- const title = getBlockTitle3(block, recordMap);
1322
- if (icon && isUrl(icon)) {
1323
- const url = mapImageUrl(icon, block);
1324
- isImage = true;
1325
- content = /* @__PURE__ */ React20.createElement(LazyImage, { src: url, alt: title || "page icon", className: cs(className, "notion-page-icon") });
1326
- } else if (icon && icon.startsWith("/icons/")) {
1327
- const url = "https://www.notion.so" + icon + "?mode=" + (darkMode ? "dark" : "light");
1328
- content = /* @__PURE__ */ React20.createElement(LazyImage, { src: url, alt: title || "page icon", className: cs(className, "notion-page-icon") });
1329
- } else if (!icon) {
1330
- if (!hideDefaultIcon) {
1331
- isImage = true;
1332
- content = /* @__PURE__ */ React20.createElement(DefaultPageIcon, { className: cs(className, "notion-page-icon"), alt: title ? title : "page icon" });
1333
- }
1334
- } else {
1335
- isImage = false;
1336
- content = /* @__PURE__ */ React20.createElement("span", { className: cs(className, "notion-page-icon"), role: "img", "aria-label": icon }, icon);
1337
- }
1338
- }
1339
- if (!content)
1340
- return null;
1341
- return /* @__PURE__ */ React20.createElement(
1342
- "div",
1343
- {
1344
- className: cs(
1345
- inline ? "notion-page-icon-inline" : "notion-page-icon-hero",
1346
- isImage ? "notion-page-icon-image" : "notion-page-icon-span"
1347
- )
1348
- },
1349
- content
1350
- );
1351
- };
1352
- var PageIcon = React20.memo(PageIconImpl);
1353
-
1354
- export {
1355
- Checkbox,
1356
- defaultMapImageUrl,
1357
- defaultMapPageUrl,
1358
- cs,
1359
- getListNumber,
1360
- getHashFragmentValue,
1361
- isBrowser,
1362
- getYoutubeId,
1363
- isUrl,
1364
- formatDate,
1365
- formatNotionDateTime,
1366
- LazyImage,
1367
- PageIconImpl,
1368
- PageIcon,
1369
- require_lodash,
1370
- EOI,
1371
- GracefulImage,
1372
- Text,
1373
- PageTitleImpl,
1374
- PageTitle,
1375
- SearchDialog,
1376
- Header,
1377
- Breadcrumbs,
1378
- Search,
1379
- dummyLink,
1380
- NotionContextProvider,
1381
- NotionContextConsumer,
1382
- useNotionContext,
1383
- LiteYouTubeEmbed,
1384
- Asset,
1385
- AssetWrapper
1386
- };
1387
- //# sourceMappingURL=chunk-CRSVOVI5.js.map