notion-to-jsx 0.0.0 → 0.2.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.
package/dist/index.js ADDED
@@ -0,0 +1,777 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Renderer: () => Renderer
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/components/Renderer/index.tsx
38
+ var import_react6 = __toESM(require("react"));
39
+
40
+ // src/components/Renderer/styles.css.ts
41
+ var container = "styles_container__epva5u0";
42
+
43
+ // src/components/Renderer/components/List/styles.css.ts
44
+ var import_createRuntimeFn = require("@vanilla-extract/recipes/createRuntimeFn");
45
+ var list = (0, import_createRuntimeFn.createRuntimeFn)({ defaultClassName: "styles_list__es8vim0", variantClassNames: { type: { bulleted: "styles_list_type_bulleted__es8vim1", numbered: "styles_list_type_numbered__es8vim2" } }, defaultVariants: {}, compoundVariants: [] });
46
+ var listItem = "styles_listItem__es8vim3";
47
+
48
+ // src/components/Renderer/components/List/List.tsx
49
+ var import_jsx_runtime = require("react/jsx-runtime");
50
+ var List = ({
51
+ as: Component = "ul",
52
+ type,
53
+ className,
54
+ children,
55
+ ...props
56
+ }) => {
57
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { className: list({ type }), ...props, children });
58
+ };
59
+ var ListItem = ({
60
+ className,
61
+ children,
62
+ ...props
63
+ }) => {
64
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: listItem, ...props, children });
65
+ };
66
+
67
+ // src/components/Renderer/components/MemoizedComponents.tsx
68
+ var import_react4 = __toESM(require("react"));
69
+
70
+ // src/components/Renderer/components/RichText/styles.css.ts
71
+ var import_createRuntimeFn2 = require("@vanilla-extract/recipes/createRuntimeFn");
72
+ var link = "styles_link__fdf3tw7";
73
+ var richText = (0, import_createRuntimeFn2.createRuntimeFn)({ defaultClassName: "styles_richText__fdf3tw0", variantClassNames: { bold: { true: "styles_richText_bold_true__fdf3tw1" }, italic: { true: "styles_richText_italic_true__fdf3tw2" }, strikethrough: { true: "styles_richText_strikethrough_true__fdf3tw3" }, underline: { true: "styles_richText_underline_true__fdf3tw4" }, code: { true: "styles_richText_code_true__fdf3tw5" } }, defaultVariants: {}, compoundVariants: [[{ strikethrough: true, underline: true }, "styles_richText_compound_0__fdf3tw6"]] });
74
+
75
+ // src/components/Renderer/components/RichText/RichTexts.tsx
76
+ var import_jsx_runtime2 = require("react/jsx-runtime");
77
+ var RichTexts = ({ richTexts }) => {
78
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: richTexts.map((text, index) => {
79
+ const { bold, italic, strikethrough, underline, code, color } = text.annotations;
80
+ const content3 = text.text.link ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
81
+ "a",
82
+ {
83
+ href: text.text.link,
84
+ target: "_blank",
85
+ rel: "noopener noreferrer",
86
+ className: link,
87
+ children: text.text.content
88
+ }
89
+ ) : text.text.content;
90
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
91
+ "span",
92
+ {
93
+ className: richText({
94
+ bold,
95
+ italic,
96
+ strikethrough,
97
+ underline,
98
+ code
99
+ }),
100
+ children: content3
101
+ },
102
+ index
103
+ );
104
+ }) });
105
+ };
106
+ var RichTexts_default = RichTexts;
107
+
108
+ // src/components/Renderer/components/Image/Image.tsx
109
+ var import_react = require("react");
110
+
111
+ // src/components/Renderer/components/Image/styles.css.ts
112
+ var import_createRuntimeFn3 = require("@vanilla-extract/recipes/createRuntimeFn");
113
+ var caption = "styles_caption__2f3ncfc";
114
+ var imageContainer = "styles_imageContainer__2f3ncf0";
115
+ var imageWrapper = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "styles_imageWrapper__2f3ncf3", variantClassNames: { hasWidth: { true: "styles_imageWrapper_hasWidth_true__2f3ncf4", false: "styles_imageWrapper_hasWidth_false__2f3ncf5" } }, defaultVariants: { hasWidth: false }, compoundVariants: [] });
116
+ var placeholder = "styles_placeholder__2f3ncfb";
117
+ var styledImage = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "styles_styledImage__2f3ncf6", variantClassNames: { loaded: { true: "styles_styledImage_loaded_true__2f3ncf7", false: "styles_styledImage_loaded_false__2f3ncf8" }, hasAspectRatio: { true: "styles_styledImage_hasAspectRatio_true__2f3ncf9", false: "styles_styledImage_hasAspectRatio_false__2f3ncfa" } }, defaultVariants: { loaded: false, hasAspectRatio: false }, compoundVariants: [] });
118
+
119
+ // src/components/Renderer/components/Image/Image.tsx
120
+ var import_jsx_runtime3 = require("react/jsx-runtime");
121
+ var MAX_WIDTH = 720;
122
+ var Image = ({
123
+ src,
124
+ alt,
125
+ caption: imageCaption,
126
+ priority = false,
127
+ format
128
+ }) => {
129
+ const [isLoaded, setIsLoaded] = (0, import_react.useState)(false);
130
+ const [error, setError] = (0, import_react.useState)(false);
131
+ (0, import_react.useEffect)(() => {
132
+ setIsLoaded(false);
133
+ setError(false);
134
+ }, [src]);
135
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("figure", { className: imageContainer, children: [
136
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
137
+ "div",
138
+ {
139
+ className: imageWrapper({
140
+ hasWidth: !!format?.block_width
141
+ }),
142
+ style: format?.block_width ? {
143
+ width: format.block_width > MAX_WIDTH ? "100%" : `${format.block_width}px`
144
+ } : void 0,
145
+ children: [
146
+ !isLoaded && !error && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
147
+ "div",
148
+ {
149
+ className: placeholder,
150
+ style: {
151
+ width: format?.block_width ? format.block_width > MAX_WIDTH ? "100%" : `${format.block_width}px` : "100%",
152
+ aspectRatio: format?.block_aspect_ratio ? `${format.block_aspect_ratio}` : "auto"
153
+ },
154
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
155
+ "svg",
156
+ {
157
+ width: "38",
158
+ height: "38",
159
+ viewBox: "0 0 38 38",
160
+ xmlns: "http://www.w3.org/2000/svg",
161
+ stroke: "#888",
162
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("g", { fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("g", { transform: "translate(1 1)", strokeWidth: "2", children: [
163
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { strokeOpacity: ".5", cx: "18", cy: "18", r: "18" }),
164
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M36 18c0-9.94-8.06-18-18-18", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
165
+ "animateTransform",
166
+ {
167
+ attributeName: "transform",
168
+ type: "rotate",
169
+ from: "0 18 18",
170
+ to: "360 18 18",
171
+ dur: "1s",
172
+ repeatCount: "indefinite"
173
+ }
174
+ ) })
175
+ ] }) })
176
+ }
177
+ )
178
+ }
179
+ ),
180
+ error && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
181
+ "div",
182
+ {
183
+ className: placeholder,
184
+ style: {
185
+ width: format?.block_width ? format.block_width > MAX_WIDTH ? "100%" : `${format.block_width}px` : "100%",
186
+ aspectRatio: format?.block_aspect_ratio ? `${format.block_aspect_ratio}` : "auto"
187
+ },
188
+ children: [
189
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
190
+ "svg",
191
+ {
192
+ width: "48",
193
+ height: "48",
194
+ viewBox: "0 0 24 24",
195
+ fill: "none",
196
+ xmlns: "http://www.w3.org/2000/svg",
197
+ children: [
198
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
199
+ "path",
200
+ {
201
+ d: "M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",
202
+ stroke: "#FF6B6B",
203
+ strokeWidth: "2",
204
+ strokeLinecap: "round",
205
+ strokeLinejoin: "round"
206
+ }
207
+ ),
208
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
209
+ "path",
210
+ {
211
+ d: "M15 9L9 15",
212
+ stroke: "#FF6B6B",
213
+ strokeWidth: "2",
214
+ strokeLinecap: "round",
215
+ strokeLinejoin: "round"
216
+ }
217
+ ),
218
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
219
+ "path",
220
+ {
221
+ d: "M9 9L15 15",
222
+ stroke: "#FF6B6B",
223
+ strokeWidth: "2",
224
+ strokeLinecap: "round",
225
+ strokeLinejoin: "round"
226
+ }
227
+ )
228
+ ]
229
+ }
230
+ ),
231
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { width: "10px" } }),
232
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { style: { color: "#FF6B6B", fontSize: "14px" }, children: "Image Load failed" })
233
+ ]
234
+ }
235
+ ),
236
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
237
+ "img",
238
+ {
239
+ className: styledImage({
240
+ loaded: isLoaded,
241
+ hasAspectRatio: !!format?.block_aspect_ratio
242
+ }),
243
+ src,
244
+ alt,
245
+ loading: priority ? "eager" : "lazy",
246
+ onLoad: () => setIsLoaded(true),
247
+ onError: () => setError(true),
248
+ width: format?.block_width,
249
+ height: format?.block_height,
250
+ style: format?.block_aspect_ratio ? { aspectRatio: `${format.block_aspect_ratio}` } : void 0
251
+ }
252
+ )
253
+ ]
254
+ }
255
+ ),
256
+ imageCaption && imageCaption.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("figcaption", { className: caption, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MemoizedRichText, { richTexts: imageCaption }) })
257
+ ] });
258
+ };
259
+ var Image_default = Image;
260
+
261
+ // src/components/Renderer/components/Bookmark/Bookmark.tsx
262
+ var import_react2 = require("react");
263
+
264
+ // src/components/Renderer/components/Bookmark/styles.css.ts
265
+ var card = "styles_card__qrq8yf1";
266
+ var content = "styles_content__qrq8yf2";
267
+ var description = "styles_description__qrq8yf6";
268
+ var favicon = "styles_favicon__qrq8yf8";
269
+ var link2 = "styles_link__qrq8yf0";
270
+ var previewContainer = "styles_previewContainer__qrq8yf3";
271
+ var previewImage = "styles_previewImage__qrq8yf4";
272
+ var siteName = "styles_siteName__qrq8yf7";
273
+ var title = "styles_title__qrq8yf5";
274
+ var urlText = "styles_urlText__qrq8yf9";
275
+
276
+ // src/components/Renderer/components/Bookmark/Bookmark.tsx
277
+ var import_jsx_runtime4 = require("react/jsx-runtime");
278
+ var fetchOpenGraphData = async (url) => {
279
+ try {
280
+ const apiUrl = `https://api.microlink.io/?url=${encodeURIComponent(url)}`;
281
+ const response = await fetch(apiUrl);
282
+ const data = await response.json();
283
+ if (!response.ok) {
284
+ throw new Error("Failed to fetch metadata");
285
+ }
286
+ const { status, data: metaData } = data;
287
+ if (status !== "success") {
288
+ throw new Error("API returned error status");
289
+ }
290
+ const parsedUrl = new URL(url);
291
+ const domain = parsedUrl.hostname;
292
+ return {
293
+ title: metaData.title || domain,
294
+ description: metaData.description || "No description available",
295
+ image: metaData.image?.url || "",
296
+ siteName: metaData.publisher || domain,
297
+ url: metaData.url || "",
298
+ favicon: metaData.logo?.url || `https://www.google.com/s2/favicons?domain=${domain}&sz=64`
299
+ };
300
+ } catch (error) {
301
+ console.error("Error fetching OpenGraph data:", error);
302
+ const parsedUrl = new URL(url);
303
+ const domain = parsedUrl.hostname;
304
+ return {
305
+ title: domain,
306
+ description: "No description available",
307
+ image: "",
308
+ url: "",
309
+ siteName: domain,
310
+ favicon: `https://www.google.com/s2/favicons?domain=${domain}&sz=64`
311
+ };
312
+ }
313
+ };
314
+ var Bookmark = ({ url }) => {
315
+ const [ogData, setOgData] = (0, import_react2.useState)(null);
316
+ const [error, setError] = (0, import_react2.useState)(false);
317
+ (0, import_react2.useEffect)(() => {
318
+ const loadOgData = async () => {
319
+ try {
320
+ const data = await fetchOpenGraphData(url);
321
+ setOgData(data);
322
+ } catch (err) {
323
+ setError(true);
324
+ }
325
+ };
326
+ loadOgData();
327
+ }, [url]);
328
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: link2, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: card, children: [
329
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: content, children: [
330
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
331
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h4", { className: title, children: ogData?.title || url }),
332
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: description, children: ogData?.description || "" })
333
+ ] }),
334
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: siteName, children: [
335
+ ogData?.favicon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: ogData.favicon, alt: "", className: favicon }),
336
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: urlText, children: ogData?.url || "" })
337
+ ] })
338
+ ] }),
339
+ ogData?.image && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: previewContainer, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
340
+ "img",
341
+ {
342
+ className: previewImage,
343
+ src: ogData.image,
344
+ alt: ogData.title,
345
+ loading: "lazy",
346
+ onError: (e) => {
347
+ const target = e.target;
348
+ target.style.display = "none";
349
+ }
350
+ }
351
+ ) })
352
+ ] }) });
353
+ };
354
+ var Bookmark_default = Bookmark;
355
+
356
+ // src/components/Renderer/components/LinkPreview/LinkPreview.tsx
357
+ var import_react3 = require("react");
358
+
359
+ // src/components/Renderer/components/LinkPreview/styles.css.ts
360
+ var card2 = "styles_card__o1p3m11";
361
+ var content2 = "styles_content__o1p3m12";
362
+ var icon = "styles_icon__o1p3m14";
363
+ var iconContainer = "styles_iconContainer__o1p3m13";
364
+ var link3 = "styles_link__o1p3m10";
365
+ var title2 = "styles_title__o1p3m15";
366
+ var updatedText = "styles_updatedText__o1p3m16";
367
+
368
+ // src/components/Renderer/components/LinkPreview/LinkPreview.tsx
369
+ var import_jsx_runtime5 = require("react/jsx-runtime");
370
+ var fetchGitHubRepoData = async (repoPath) => {
371
+ try {
372
+ const apiUrl = `https://api.github.com/repos/${repoPath}`;
373
+ const response = await fetch(apiUrl);
374
+ if (!response.ok) {
375
+ throw new Error("Failed to fetch GitHub repo data");
376
+ }
377
+ const data = await response.json();
378
+ return data;
379
+ } catch (error) {
380
+ console.error("Error fetching GitHub repo data:", error);
381
+ return null;
382
+ }
383
+ };
384
+ var extractRepoPathFromUrl = (url) => {
385
+ try {
386
+ const parsedUrl = new URL(url);
387
+ if (parsedUrl.hostname === "github.com") {
388
+ const path = parsedUrl.pathname.substring(1);
389
+ const pathParts = path.split("/");
390
+ if (pathParts.length >= 2) {
391
+ return `${pathParts[0]}/${pathParts[1]}`;
392
+ }
393
+ }
394
+ return null;
395
+ } catch (error) {
396
+ console.error("Error parsing URL:", error);
397
+ return null;
398
+ }
399
+ };
400
+ var formatUpdatedTime = (dateString) => {
401
+ const date = new Date(dateString);
402
+ const now = /* @__PURE__ */ new Date();
403
+ const diffInHours = Math.floor(
404
+ (now.getTime() - date.getTime()) / (1e3 * 60 * 60)
405
+ );
406
+ if (diffInHours < 24) {
407
+ return `Updated ${diffInHours} hours ago`;
408
+ } else {
409
+ const diffInDays = Math.floor(diffInHours / 24);
410
+ if (diffInDays === 1) {
411
+ return "Updated yesterday";
412
+ } else if (diffInDays < 30) {
413
+ return `Updated ${diffInDays} days ago`;
414
+ } else {
415
+ const months = [
416
+ "Jan",
417
+ "Feb",
418
+ "Mar",
419
+ "Apr",
420
+ "May",
421
+ "Jun",
422
+ "Jul",
423
+ "Aug",
424
+ "Sep",
425
+ "Oct",
426
+ "Nov",
427
+ "Dec"
428
+ ];
429
+ return `Updated on ${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
430
+ }
431
+ }
432
+ };
433
+ var LinkPreview = ({ url }) => {
434
+ const [repoData, setRepoData] = (0, import_react3.useState)(null);
435
+ const [loading, setLoading] = (0, import_react3.useState)(true);
436
+ (0, import_react3.useEffect)(() => {
437
+ const loadRepoData = async () => {
438
+ setLoading(true);
439
+ const repoPath = extractRepoPathFromUrl(url);
440
+ if (repoPath) {
441
+ const data = await fetchGitHubRepoData(repoPath);
442
+ setRepoData(data);
443
+ }
444
+ setLoading(false);
445
+ };
446
+ loadRepoData();
447
+ }, [url]);
448
+ const repoName = repoData?.name || extractRepoPathFromUrl(url)?.split("/")[1] || "Repository";
449
+ const updatedTimeText = repoData?.updated_at ? formatUpdatedTime(repoData.updated_at) : "";
450
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: link3, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: card2, children: [
451
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: iconContainer, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
452
+ "img",
453
+ {
454
+ src: repoData?.owner?.avatar_url || "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
455
+ alt: "Repository icon",
456
+ className: icon
457
+ }
458
+ ) }),
459
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: content2, children: [
460
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: title2, children: repoName }),
461
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: updatedText, children: loading ? "Loading..." : `NotionX \u2022 ${updatedTimeText}` })
462
+ ] })
463
+ ] }) });
464
+ };
465
+ var LinkPreview_default = LinkPreview;
466
+
467
+ // src/components/Renderer/components/MemoizedComponents.tsx
468
+ var MemoizedRichText = import_react4.default.memo(
469
+ RichTexts_default,
470
+ (prev, next) => {
471
+ return JSON.stringify(prev.richTexts) === JSON.stringify(next.richTexts);
472
+ }
473
+ );
474
+ var MemoizedImage = import_react4.default.memo(Image_default, (prev, next) => {
475
+ return prev.src === next.src && prev.alt === next.alt && JSON.stringify(prev.caption) === JSON.stringify(next.caption);
476
+ });
477
+ var MemoizedBookmark = import_react4.default.memo(
478
+ Bookmark_default,
479
+ (prev, next) => {
480
+ return prev.url === next.url;
481
+ }
482
+ );
483
+ var MemoizedLinkPreview = import_react4.default.memo(
484
+ LinkPreview_default,
485
+ (prev, next) => {
486
+ return prev.url === next.url;
487
+ }
488
+ );
489
+
490
+ // src/components/Renderer/components/List/ListBlocksRenderer.tsx
491
+ var import_jsx_runtime6 = require("react/jsx-runtime");
492
+ var RecursiveListItem = ({ block, index }) => {
493
+ const blockProps = {
494
+ tabIndex: 0,
495
+ "data-block-id": block.id
496
+ };
497
+ const blockType = block.type;
498
+ const richTexts = block[blockType]?.rich_text;
499
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(ListItem, { ...blockProps, children: [
500
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MemoizedRichText, { richTexts }),
501
+ block.children && block.children.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
502
+ RecursiveListGroup,
503
+ {
504
+ blocks: block.children,
505
+ type: blockType.split("_")[0]
506
+ }
507
+ )
508
+ ] });
509
+ };
510
+ var RecursiveListGroup = ({ blocks, type }) => {
511
+ if (!blocks || blocks.length === 0) return null;
512
+ const listItems = blocks.filter(
513
+ (block) => block.type === `${type}_list_item`
514
+ );
515
+ if (listItems.length === 0) return null;
516
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
517
+ List,
518
+ {
519
+ as: type === "numbered" ? "ol" : "ul",
520
+ type,
521
+ role: "list",
522
+ "aria-label": type === "bulleted" ? "Bulleted list" : "Numbered list",
523
+ children: listItems.map((block, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RecursiveListItem, { block, index }, block.id))
524
+ }
525
+ );
526
+ };
527
+ var ListBlocksRenderer = ({ blocks, startIndex, type }) => {
528
+ let consecutiveItems = 0;
529
+ for (let i = startIndex; i < blocks.length; i++) {
530
+ const block = blocks[i];
531
+ if (!block) break;
532
+ if (block.type === `${type}_list_item`) {
533
+ consecutiveItems++;
534
+ } else {
535
+ break;
536
+ }
537
+ }
538
+ const listItems = blocks.slice(startIndex, startIndex + consecutiveItems);
539
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
540
+ List,
541
+ {
542
+ as: type === "numbered" ? "ol" : "ul",
543
+ type,
544
+ role: "list",
545
+ "aria-label": type === "bulleted" ? "Bulleted list" : "Numbered list",
546
+ children: listItems.map((block, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
547
+ RecursiveListItem,
548
+ {
549
+ block,
550
+ index: startIndex + index
551
+ },
552
+ block.id
553
+ ))
554
+ }
555
+ );
556
+ };
557
+ var ListBlocksRenderer_default = ListBlocksRenderer;
558
+
559
+ // src/components/Renderer/components/Code/CodeBlock.tsx
560
+ var import_react5 = require("react");
561
+
562
+ // src/components/Renderer/components/Code/styles.css.ts
563
+ var codeBlock = "styles_codeBlock__1qn42yc0";
564
+
565
+ // src/components/Renderer/components/Code/CodeBlock.tsx
566
+ var import_prismjs = __toESM(require("prismjs"));
567
+ var import_prism = require("prismjs/themes/prism.css");
568
+ var import_prism_typescript = require("prismjs/components/prism-typescript");
569
+ var import_prism_javascript = require("prismjs/components/prism-javascript");
570
+ var import_prism_jsx = require("prismjs/components/prism-jsx");
571
+ var import_prism_tsx = require("prismjs/components/prism-tsx");
572
+ var import_jsx_runtime7 = require("react/jsx-runtime");
573
+ if (typeof window !== "undefined") {
574
+ window.Prism = import_prismjs.default;
575
+ }
576
+ var CodeBlock = ({ code, language, caption: caption2 }) => {
577
+ const highlightedCode = (0, import_react5.useMemo)(() => {
578
+ const prismLanguage = import_prismjs.default.languages[language] || import_prismjs.default.languages.plaintext;
579
+ return import_prismjs.default.highlight(code, prismLanguage, language);
580
+ }, [code, language]);
581
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
582
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("pre", { className: codeBlock, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { dangerouslySetInnerHTML: { __html: highlightedCode } }) }),
583
+ caption2 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("figcaption", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MemoizedRichText, { richTexts: caption2 }) })
584
+ ] });
585
+ };
586
+ var CodeBlock_default = CodeBlock;
587
+
588
+ // src/components/Renderer/components/Typography/styles.css.ts
589
+ var heading1 = "styles_heading1__90a95g1";
590
+ var heading2 = "styles_heading2__90a95g2";
591
+ var heading3 = "styles_heading3__90a95g3";
592
+ var paragraph = "styles_paragraph__90a95g0";
593
+
594
+ // src/components/Renderer/components/Typography/Typography.tsx
595
+ var import_jsx_runtime8 = require("react/jsx-runtime");
596
+ var Paragraph = ({
597
+ className,
598
+ children,
599
+ ...props
600
+ }) => {
601
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: paragraph, ...props, children });
602
+ };
603
+ var Heading1 = ({
604
+ className,
605
+ children,
606
+ ...props
607
+ }) => {
608
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { className: heading1, ...props, children });
609
+ };
610
+ var Heading2 = ({
611
+ className,
612
+ children,
613
+ ...props
614
+ }) => {
615
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { className: heading2, ...props, children });
616
+ };
617
+ var Heading3 = ({
618
+ className,
619
+ children,
620
+ ...props
621
+ }) => {
622
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h3", { className: heading3, ...props, children });
623
+ };
624
+
625
+ // src/components/Renderer/components/Block/BlockRenderer.tsx
626
+ var import_jsx_runtime9 = require("react/jsx-runtime");
627
+ var BlockRenderer = ({ block, onFocus, index }) => {
628
+ if (!block) return null;
629
+ const blockProps = {
630
+ tabIndex: 0,
631
+ onFocus,
632
+ "data-block-id": block.id
633
+ };
634
+ switch (block.type) {
635
+ case "link_preview":
636
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
637
+ MemoizedLinkPreview,
638
+ {
639
+ url: block.link_preview.url,
640
+ ...blockProps
641
+ }
642
+ );
643
+ case "paragraph":
644
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Paragraph, { ...blockProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MemoizedRichText, { richTexts: block.paragraph.rich_text }) });
645
+ case "heading_1":
646
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Heading1, { ...blockProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MemoizedRichText, { richTexts: block.heading_1.rich_text }) });
647
+ case "heading_2":
648
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Heading2, { ...blockProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MemoizedRichText, { richTexts: block.heading_2.rich_text }) });
649
+ case "heading_3":
650
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Heading3, { ...blockProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MemoizedRichText, { richTexts: block.heading_3.rich_text }) });
651
+ case "code":
652
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ...blockProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
653
+ CodeBlock_default,
654
+ {
655
+ code: block.code.rich_text[0].text.content,
656
+ language: block.code.language,
657
+ caption: block.code.caption?.[0]?.plain_text
658
+ }
659
+ ) });
660
+ case "image":
661
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("figure", { ...blockProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
662
+ MemoizedImage,
663
+ {
664
+ src: block.image.file?.url || block.image.external?.url,
665
+ alt: block.image.caption?.[0]?.plain_text || "",
666
+ caption: block.image.caption,
667
+ format: block.image.format
668
+ }
669
+ ) });
670
+ case "bookmark":
671
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MemoizedBookmark, { url: block.bookmark.url });
672
+ default:
673
+ return null;
674
+ }
675
+ };
676
+ var BlockRenderer_default = BlockRenderer;
677
+
678
+ // src/styles/theme.css.ts
679
+ var darkTheme = "theme_darkTheme__sq3jkb15";
680
+ var lightTheme = "theme_lightTheme__sq3jkb14";
681
+
682
+ // src/components/Title/index.tsx
683
+ var import_jsx_runtime10 = require("react/jsx-runtime");
684
+ var Title = ({ title: title3 }) => {
685
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Heading1, { children: title3 });
686
+ };
687
+ var Title_default = Title;
688
+
689
+ // src/components/Cover/styles.css.ts
690
+ var cover = "styles_cover__p0cp8d0";
691
+
692
+ // src/components/Cover/index.tsx
693
+ var import_jsx_runtime11 = require("react/jsx-runtime");
694
+ var Cover = ({ src, alt }) => {
695
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("img", { src, alt, className: cover });
696
+ };
697
+ var Cover_default = Cover;
698
+
699
+ // src/components/Renderer/index.tsx
700
+ var import_jsx_runtime12 = require("react/jsx-runtime");
701
+ var Renderer = import_react6.default.memo(
702
+ ({ blocks, isDarkMode = false, title: title3, cover: cover2, onBlockFocus }) => {
703
+ const theme = isDarkMode ? darkTheme : lightTheme;
704
+ const [focusedIndex, setFocusedIndex] = (0, import_react6.useState)(-1);
705
+ const handleBlockFocus = (0, import_react6.useCallback)(
706
+ (index) => {
707
+ setFocusedIndex(index);
708
+ onBlockFocus?.(index);
709
+ },
710
+ [onBlockFocus]
711
+ );
712
+ const renderedBlocks = (0, import_react6.useMemo)(() => {
713
+ const result = [];
714
+ for (let i = 0; i < blocks.length; i++) {
715
+ const block = blocks[i];
716
+ if (!block) break;
717
+ const handleListItem = (listType) => {
718
+ const listItemType = `${listType}_list_item`;
719
+ if (block.type === listItemType && (i === 0 || blocks[i - 1]?.type !== listItemType)) {
720
+ result.push(
721
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
722
+ ListBlocksRenderer_default,
723
+ {
724
+ blocks,
725
+ startIndex: i,
726
+ type: listType
727
+ },
728
+ block.id
729
+ )
730
+ );
731
+ while (i + 1 < blocks.length && blocks[i + 1] && blocks[i + 1]?.type === listItemType) {
732
+ i++;
733
+ }
734
+ return true;
735
+ }
736
+ return false;
737
+ };
738
+ if (handleListItem("bulleted") || handleListItem("numbered")) {
739
+ continue;
740
+ } else {
741
+ result.push(
742
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
743
+ BlockRenderer_default,
744
+ {
745
+ block,
746
+ index: i,
747
+ onFocus: () => handleBlockFocus(i)
748
+ },
749
+ block.id
750
+ )
751
+ );
752
+ }
753
+ }
754
+ return result;
755
+ }, [blocks, handleBlockFocus]);
756
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
757
+ cover2 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Cover_default, { src: cover2, alt: title3 || "Notion page content" }),
758
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
759
+ "article",
760
+ {
761
+ className: `${theme} ${container}`,
762
+ "aria-label": title3 || "Notion page content",
763
+ children: [
764
+ title3 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Title_default, { title: title3 }),
765
+ renderedBlocks
766
+ ]
767
+ }
768
+ )
769
+ ] });
770
+ }
771
+ );
772
+ Renderer.displayName = "Renderer";
773
+ // Annotate the CommonJS export names for ESM import in node:
774
+ 0 && (module.exports = {
775
+ Renderer
776
+ });
777
+ //# sourceMappingURL=index.js.map