@texonom/nreact 1.4.7 → 1.5.0

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