@caring-dev/react-notion-x 7.8.7 → 7.8.9
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/build/context-MVPVCXSf.d.ts +138 -0
- package/build/index.d.ts +9 -3
- package/build/index.js +30 -21
- package/build/index.js.map +1 -1
- package/build/third-party/collection.d.ts +1 -1
- package/build/third-party/collection.js +136 -39
- package/build/third-party/collection.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as types from 'notion-types';
|
|
3
|
+
import { ExtendedRecordMap } from 'notion-types';
|
|
4
|
+
import React__default from 'react';
|
|
5
|
+
|
|
6
|
+
type MapPageUrlFn = (pageId: string, recordMap?: types.ExtendedRecordMap | undefined) => string;
|
|
7
|
+
type MapImageUrlFn = (url: string | undefined, block: types.Block) => string | undefined;
|
|
8
|
+
type SearchNotionFn = (params: types.SearchParams) => Promise<types.SearchResults>;
|
|
9
|
+
type ComponentOverrideFn = (props: any, defaultValueFn: () => React__default.ReactNode) => any;
|
|
10
|
+
interface NotionComponents {
|
|
11
|
+
Image: any;
|
|
12
|
+
Link: any;
|
|
13
|
+
PageLink: any;
|
|
14
|
+
Checkbox: React__default.FC<{
|
|
15
|
+
isChecked: boolean;
|
|
16
|
+
blockId?: string;
|
|
17
|
+
}>;
|
|
18
|
+
Code: any;
|
|
19
|
+
Equation: any;
|
|
20
|
+
Callout?: any;
|
|
21
|
+
Button?: React__default.ComponentType<{
|
|
22
|
+
blockId: string;
|
|
23
|
+
block: types.ButtonBlock;
|
|
24
|
+
className?: string;
|
|
25
|
+
}>;
|
|
26
|
+
Collection: any;
|
|
27
|
+
Property?: any;
|
|
28
|
+
propertyTextValue: ComponentOverrideFn;
|
|
29
|
+
propertySelectValue: ComponentOverrideFn;
|
|
30
|
+
propertyRelationValue: ComponentOverrideFn;
|
|
31
|
+
propertyFormulaValue: ComponentOverrideFn;
|
|
32
|
+
propertyTitleValue: ComponentOverrideFn;
|
|
33
|
+
propertyPersonValue: ComponentOverrideFn;
|
|
34
|
+
propertyFileValue: ComponentOverrideFn;
|
|
35
|
+
propertyCheckboxValue: ComponentOverrideFn;
|
|
36
|
+
propertyUrlValue: ComponentOverrideFn;
|
|
37
|
+
propertyEmailValue: ComponentOverrideFn;
|
|
38
|
+
propertyPhoneNumberValue: ComponentOverrideFn;
|
|
39
|
+
propertyNumberValue: ComponentOverrideFn;
|
|
40
|
+
propertyLastEditedTimeValue: ComponentOverrideFn;
|
|
41
|
+
propertyCreatedTimeValue: ComponentOverrideFn;
|
|
42
|
+
propertyDateValue: ComponentOverrideFn;
|
|
43
|
+
propertyAutoIncrementIdValue: ComponentOverrideFn;
|
|
44
|
+
Pdf: any;
|
|
45
|
+
Tweet: any;
|
|
46
|
+
Modal: any;
|
|
47
|
+
Embed: any;
|
|
48
|
+
Header: any;
|
|
49
|
+
nextImage?: any;
|
|
50
|
+
nextLegacyImage?: any;
|
|
51
|
+
nextLink?: any;
|
|
52
|
+
}
|
|
53
|
+
interface CollectionViewProps {
|
|
54
|
+
collection: types.Collection;
|
|
55
|
+
collectionView: types.CollectionView;
|
|
56
|
+
collectionData: types.CollectionQueryResult;
|
|
57
|
+
padding?: number;
|
|
58
|
+
width?: number;
|
|
59
|
+
}
|
|
60
|
+
interface CollectionCardProps {
|
|
61
|
+
collection: types.Collection;
|
|
62
|
+
block: types.PageBlock;
|
|
63
|
+
cover: types.CollectionCardCover;
|
|
64
|
+
coverSize: types.CollectionCardCoverSize;
|
|
65
|
+
coverAspect: types.CollectionCardCoverAspect;
|
|
66
|
+
properties?: Array<{
|
|
67
|
+
property: types.PropertyID;
|
|
68
|
+
visible: boolean;
|
|
69
|
+
}>;
|
|
70
|
+
className?: string;
|
|
71
|
+
}
|
|
72
|
+
interface CollectionGroupProps {
|
|
73
|
+
collection: types.Collection;
|
|
74
|
+
collectionViewComponent: React__default.ElementType;
|
|
75
|
+
collectionGroup: any;
|
|
76
|
+
hidden: boolean;
|
|
77
|
+
schema: any;
|
|
78
|
+
value: any;
|
|
79
|
+
summaryProps: any;
|
|
80
|
+
detailsProps: any;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface NotionContext {
|
|
84
|
+
recordMap: ExtendedRecordMap;
|
|
85
|
+
components: NotionComponents;
|
|
86
|
+
mapPageUrl: MapPageUrlFn;
|
|
87
|
+
mapImageUrl: MapImageUrlFn;
|
|
88
|
+
searchNotion?: SearchNotionFn;
|
|
89
|
+
isShowingSearch?: boolean;
|
|
90
|
+
onHideSearch?: () => void;
|
|
91
|
+
rootPageId?: string;
|
|
92
|
+
rootDomain?: string;
|
|
93
|
+
fullPage: boolean;
|
|
94
|
+
darkMode: boolean;
|
|
95
|
+
previewImages: boolean;
|
|
96
|
+
forceCustomImages: boolean;
|
|
97
|
+
showCollectionViewDropdown: boolean;
|
|
98
|
+
showTableOfContents: boolean;
|
|
99
|
+
minTableOfContentsItems: number;
|
|
100
|
+
linkTableTitleProperties: boolean;
|
|
101
|
+
isLinkCollectionToUrlProperty: boolean;
|
|
102
|
+
defaultPageIcon?: string | null;
|
|
103
|
+
defaultPageCover?: string | null;
|
|
104
|
+
defaultPageCoverPosition?: number;
|
|
105
|
+
zoom: any;
|
|
106
|
+
}
|
|
107
|
+
interface PartialNotionContext {
|
|
108
|
+
recordMap?: ExtendedRecordMap;
|
|
109
|
+
components?: Partial<NotionComponents>;
|
|
110
|
+
mapPageUrl?: MapPageUrlFn;
|
|
111
|
+
mapImageUrl?: MapImageUrlFn;
|
|
112
|
+
searchNotion?: SearchNotionFn;
|
|
113
|
+
isShowingSearch?: boolean;
|
|
114
|
+
onHideSearch?: () => void;
|
|
115
|
+
rootPageId?: string;
|
|
116
|
+
rootDomain?: string;
|
|
117
|
+
fullPage?: boolean;
|
|
118
|
+
darkMode?: boolean;
|
|
119
|
+
previewImages?: boolean;
|
|
120
|
+
forceCustomImages?: boolean;
|
|
121
|
+
showCollectionViewDropdown?: boolean;
|
|
122
|
+
linkTableTitleProperties?: boolean;
|
|
123
|
+
isLinkCollectionToUrlProperty?: boolean;
|
|
124
|
+
showTableOfContents?: boolean;
|
|
125
|
+
minTableOfContentsItems?: number;
|
|
126
|
+
defaultPageIcon?: string | null;
|
|
127
|
+
defaultPageCover?: string | null;
|
|
128
|
+
defaultPageCoverPosition?: number;
|
|
129
|
+
zoom?: any;
|
|
130
|
+
}
|
|
131
|
+
declare function dummyLink({ href, rel, target, title, ...rest }: any): react_jsx_runtime.JSX.Element;
|
|
132
|
+
declare function NotionContextProvider({ components: themeComponents, children, mapPageUrl, mapImageUrl, rootPageId, ...rest }: PartialNotionContext & {
|
|
133
|
+
children?: React__default.ReactNode;
|
|
134
|
+
}): react_jsx_runtime.JSX.Element;
|
|
135
|
+
declare const NotionContextConsumer: React__default.Consumer<NotionContext>;
|
|
136
|
+
declare const useNotionContext: () => NotionContext;
|
|
137
|
+
|
|
138
|
+
export { type ComponentOverrideFn as C, type MapPageUrlFn as M, type NotionContext as N, type PartialNotionContext as P, type SearchNotionFn as S, type NotionComponents as a, type MapImageUrlFn as b, NotionContextProvider as c, dummyLink as d, NotionContextConsumer as e, type CollectionViewProps as f, type CollectionCardProps as g, type CollectionGroupProps as h, useNotionContext as u };
|
package/build/index.d.ts
CHANGED
|
@@ -3,10 +3,16 @@ import * as types from 'notion-types';
|
|
|
3
3
|
import { Block, Decoration, ExtendedRecordMap, BlockMap } from 'notion-types';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import React__default from 'react';
|
|
6
|
-
import { S as SearchNotionFn, a as NotionComponents, M as MapPageUrlFn, b as MapImageUrlFn } from './context
|
|
7
|
-
export { g as CollectionCardProps, h as CollectionGroupProps, f as CollectionViewProps, C as ComponentOverrideFn, N as NotionContext, e as NotionContextConsumer, c as NotionContextProvider, P as PartialNotionContext, d as dummyLink, u as useNotionContext } from './context
|
|
6
|
+
import { S as SearchNotionFn, a as NotionComponents, M as MapPageUrlFn, b as MapImageUrlFn } from './context-MVPVCXSf.js';
|
|
7
|
+
export { g as CollectionCardProps, h as CollectionGroupProps, f as CollectionViewProps, C as ComponentOverrideFn, N as NotionContext, e as NotionContextConsumer, c as NotionContextProvider, P as PartialNotionContext, d as dummyLink, u as useNotionContext } from './context-MVPVCXSf.js';
|
|
8
8
|
export { formatDate, formatNotionDateTime, isUrl } from 'notion-utils';
|
|
9
9
|
|
|
10
|
+
declare function Button({ block, blockId, className }: {
|
|
11
|
+
blockId: string;
|
|
12
|
+
block: types.ButtonBlock;
|
|
13
|
+
className?: string;
|
|
14
|
+
}): react_jsx_runtime.JSX.Element | null;
|
|
15
|
+
|
|
10
16
|
declare function Header({ block }: {
|
|
11
17
|
block: types.CollectionViewPageBlock | types.PageBlock;
|
|
12
18
|
}): react_jsx_runtime.JSX.Element;
|
|
@@ -91,4 +97,4 @@ declare const isBrowser = true;
|
|
|
91
97
|
declare const getYoutubeId: (url: string) => string | null;
|
|
92
98
|
declare const getUrlParams: (url: string) => Record<string, string> | undefined;
|
|
93
99
|
|
|
94
|
-
export { Breadcrumbs, Header, MapImageUrlFn, MapPageUrlFn, NotionComponents, NotionRenderer, PageIcon, PageIconImpl, Search, SearchNotionFn, Text, cs, getHashFragmentValue, getListNestingLevel, getListNumber, getListStyle, getUrlParams, getYoutubeId, isBrowser };
|
|
100
|
+
export { Breadcrumbs, Button, Header, MapImageUrlFn, MapPageUrlFn, NotionComponents, NotionRenderer, PageIcon, PageIconImpl, Search, SearchNotionFn, Text, cs, getHashFragmentValue, getListNestingLevel, getListNumber, getListStyle, getUrlParams, getYoutubeId, isBrowser };
|
package/build/index.js
CHANGED
|
@@ -176,6 +176,7 @@ var require_lodash = __commonJS({
|
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
// src/components/button.tsx
|
|
179
|
+
import { getBlockValue as getBlockValue3 } from "notion-utils";
|
|
179
180
|
import React16 from "react";
|
|
180
181
|
|
|
181
182
|
// src/context.tsx
|
|
@@ -2317,7 +2318,7 @@ function Button({
|
|
|
2317
2318
|
}
|
|
2318
2319
|
};
|
|
2319
2320
|
const executeAction = async () => {
|
|
2320
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j
|
|
2321
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j;
|
|
2321
2322
|
const firstActionId = (_a2 = automation.action_ids) == null ? void 0 : _a2[0];
|
|
2322
2323
|
if (!firstActionId) {
|
|
2323
2324
|
console.warn("No actions defined for automation:", automationId);
|
|
@@ -2349,12 +2350,11 @@ function Button({
|
|
|
2349
2350
|
if (typeof window !== "undefined" && "/api/webhook-proxy") {
|
|
2350
2351
|
const pageBlockId = Object.keys(recordMap.block || {}).find(
|
|
2351
2352
|
(id) => {
|
|
2352
|
-
|
|
2353
|
-
const b = (_a3 = recordMap.block[id]) == null ? void 0 : _a3.value;
|
|
2353
|
+
const b = getBlockValue3(recordMap.block[id]);
|
|
2354
2354
|
return b && "type" in b && b.type === "page";
|
|
2355
2355
|
}
|
|
2356
2356
|
);
|
|
2357
|
-
const pageBlock = pageBlockId ? (
|
|
2357
|
+
const pageBlock = pageBlockId ? getBlockValue3(recordMap.block[pageBlockId]) : null;
|
|
2358
2358
|
if (!pageBlock) {
|
|
2359
2359
|
console.warn("No page block found for webhook payload");
|
|
2360
2360
|
return;
|
|
@@ -2383,13 +2383,13 @@ function Button({
|
|
|
2383
2383
|
object: "user",
|
|
2384
2384
|
id: pageBlock.last_edited_by_id || "unknown"
|
|
2385
2385
|
},
|
|
2386
|
-
cover: ((
|
|
2386
|
+
cover: ((_g = pageBlock.format) == null ? void 0 : _g.page_cover) ? {
|
|
2387
2387
|
type: "external",
|
|
2388
2388
|
external: {
|
|
2389
2389
|
url: pageBlock.format.page_cover.startsWith("/") ? `https://www.notion.so${pageBlock.format.page_cover}` : pageBlock.format.page_cover
|
|
2390
2390
|
}
|
|
2391
2391
|
} : null,
|
|
2392
|
-
icon: ((
|
|
2392
|
+
icon: ((_h = pageBlock.format) == null ? void 0 : _h.page_icon) ? {
|
|
2393
2393
|
type: "external",
|
|
2394
2394
|
external: { url: pageBlock.format.page_icon }
|
|
2395
2395
|
} : null,
|
|
@@ -2404,7 +2404,7 @@ function Button({
|
|
|
2404
2404
|
title: {
|
|
2405
2405
|
id: "title",
|
|
2406
2406
|
type: "title",
|
|
2407
|
-
title: ((
|
|
2407
|
+
title: ((_i = pageBlock.properties) == null ? void 0 : _i.title) ? pageBlock.properties.title.map((t) => {
|
|
2408
2408
|
const text = typeof t === "string" ? t : t[0] || "";
|
|
2409
2409
|
return {
|
|
2410
2410
|
type: "text",
|
|
@@ -2431,7 +2431,7 @@ function Button({
|
|
|
2431
2431
|
const headers = {
|
|
2432
2432
|
"Content-Type": "application/json"
|
|
2433
2433
|
};
|
|
2434
|
-
if ((
|
|
2434
|
+
if ((_j = actionData.config) == null ? void 0 : _j.customHeaders) {
|
|
2435
2435
|
for (const header of actionData.config.customHeaders) {
|
|
2436
2436
|
headers[header.key] = header.value;
|
|
2437
2437
|
}
|
|
@@ -2495,7 +2495,7 @@ function getTextContent2(text) {
|
|
|
2495
2495
|
// src/renderer.tsx
|
|
2496
2496
|
import mediumZoom from "@fisch0920/medium-zoom";
|
|
2497
2497
|
import "notion-types";
|
|
2498
|
-
import { getBlockValue as
|
|
2498
|
+
import { getBlockValue as getBlockValue5, uuidToId as uuidToId3 } from "notion-utils";
|
|
2499
2499
|
import * as React21 from "react";
|
|
2500
2500
|
|
|
2501
2501
|
// src/block.tsx
|
|
@@ -2503,7 +2503,7 @@ import {
|
|
|
2503
2503
|
getBlockCollectionId,
|
|
2504
2504
|
getBlockIcon as getBlockIcon2,
|
|
2505
2505
|
getBlockParentPage as getBlockParentPage2,
|
|
2506
|
-
getBlockValue as
|
|
2506
|
+
getBlockValue as getBlockValue4,
|
|
2507
2507
|
getPageTableOfContents,
|
|
2508
2508
|
getTextContent as getTextContent3,
|
|
2509
2509
|
uuidToId as uuidToId2
|
|
@@ -2832,7 +2832,7 @@ function Block(props) {
|
|
|
2832
2832
|
} = block.format || {};
|
|
2833
2833
|
if (fullPage) {
|
|
2834
2834
|
const properties = block.type === "page" ? block.properties : {
|
|
2835
|
-
title: (_a =
|
|
2835
|
+
title: (_a = getBlockValue4(
|
|
2836
2836
|
recordMap.collection[getBlockCollectionId(block, recordMap)]
|
|
2837
2837
|
)) == null ? void 0 : _a.name
|
|
2838
2838
|
};
|
|
@@ -2903,7 +2903,10 @@ function Block(props) {
|
|
|
2903
2903
|
),
|
|
2904
2904
|
pageHeader,
|
|
2905
2905
|
/* @__PURE__ */ jsx32("h1", { className: "notion-title", children: pageTitle != null ? pageTitle : /* @__PURE__ */ jsx32(Text, { value: properties == null ? void 0 : properties.title, block }) }),
|
|
2906
|
-
(block.type === "collection_view_page" || block.type === "page" && block.parent_table === "collection") && /* @__PURE__ */
|
|
2906
|
+
(block.type === "collection_view_page" || block.type === "page" && block.parent_table === "collection") && /* @__PURE__ */ jsxs14(Fragment6, { children: [
|
|
2907
|
+
typeof window !== "undefined" && console.log("[react-notion-x] Rendering Collection (page)", block.type),
|
|
2908
|
+
/* @__PURE__ */ jsx32(components.Collection, { block, ctx: ctx2 })
|
|
2909
|
+
] }),
|
|
2907
2910
|
block.type !== "collection_view_page" && /* @__PURE__ */ jsxs14(
|
|
2908
2911
|
"div",
|
|
2909
2912
|
{
|
|
@@ -3074,7 +3077,7 @@ function Block(props) {
|
|
|
3074
3077
|
}
|
|
3075
3078
|
);
|
|
3076
3079
|
let output = null;
|
|
3077
|
-
const isTopLevel = block.type !== ((_j =
|
|
3080
|
+
const isTopLevel = block.type !== ((_j = getBlockValue4(recordMap.block[block.parent_id])) == null ? void 0 : _j.type);
|
|
3078
3081
|
const start = getListNumber(block.id, recordMap.block);
|
|
3079
3082
|
if (block.content) {
|
|
3080
3083
|
const listItem = block.properties ? /* @__PURE__ */ jsx32("li", { children: /* @__PURE__ */ jsx32(Text, { value: block.properties.title, block }) }) : null;
|
|
@@ -3163,7 +3166,7 @@ function Block(props) {
|
|
|
3163
3166
|
case "column": {
|
|
3164
3167
|
const spacerWidth = `min(32px, 4vw)`;
|
|
3165
3168
|
const ratio = ((_m = block.format) == null ? void 0 : _m.column_ratio) || 0.5;
|
|
3166
|
-
const parent =
|
|
3169
|
+
const parent = getBlockValue4(recordMap.block[block.parent_id]);
|
|
3167
3170
|
const columns = ((_n = parent == null ? void 0 : parent.content) == null ? void 0 : _n.length) || Math.max(2, Math.ceil(1 / ratio));
|
|
3168
3171
|
const width = `calc((100% - (${columns - 1} * ${spacerWidth})) * ${ratio})`;
|
|
3169
3172
|
const style = { width };
|
|
@@ -3191,6 +3194,9 @@ function Block(props) {
|
|
|
3191
3194
|
);
|
|
3192
3195
|
}
|
|
3193
3196
|
case "collection_view":
|
|
3197
|
+
if (typeof window !== "undefined") {
|
|
3198
|
+
console.log("[react-notion-x] Rendering Collection (inline)", block.id);
|
|
3199
|
+
}
|
|
3194
3200
|
return /* @__PURE__ */ jsx32(components.Collection, { block, className: blockId, ctx: ctx2 });
|
|
3195
3201
|
case "callout":
|
|
3196
3202
|
if (components.Callout) {
|
|
@@ -3347,7 +3353,7 @@ function Block(props) {
|
|
|
3347
3353
|
return /* @__PURE__ */ jsx32(SyncPointerBlock, { ...props, level: level + 1 });
|
|
3348
3354
|
case "alias": {
|
|
3349
3355
|
const blockPointerId = (_I = (_H = block == null ? void 0 : block.format) == null ? void 0 : _H.alias_pointer) == null ? void 0 : _I.id;
|
|
3350
|
-
const linkedBlock =
|
|
3356
|
+
const linkedBlock = getBlockValue4(recordMap.block[blockPointerId]);
|
|
3351
3357
|
if (!linkedBlock) {
|
|
3352
3358
|
console.log('"alias" missing block', blockPointerId);
|
|
3353
3359
|
return null;
|
|
@@ -3364,7 +3370,7 @@ function Block(props) {
|
|
|
3364
3370
|
case "table":
|
|
3365
3371
|
return /* @__PURE__ */ jsx32("table", { className: cs("notion-simple-table", blockId), children: /* @__PURE__ */ jsx32("tbody", { children }) });
|
|
3366
3372
|
case "table_row": {
|
|
3367
|
-
const tableBlock =
|
|
3373
|
+
const tableBlock = getBlockValue4(
|
|
3368
3374
|
recordMap.block[block.parent_id]
|
|
3369
3375
|
);
|
|
3370
3376
|
if (!tableBlock) {
|
|
@@ -3499,12 +3505,15 @@ function NotionBlockRenderer({
|
|
|
3499
3505
|
...props
|
|
3500
3506
|
}) {
|
|
3501
3507
|
var _a;
|
|
3502
|
-
const { recordMap } = useNotionContext();
|
|
3503
|
-
const id = blockId || Object.keys(recordMap.block)
|
|
3504
|
-
|
|
3505
|
-
|
|
3508
|
+
const { recordMap, rootPageId } = useNotionContext();
|
|
3509
|
+
const id = blockId || rootPageId && (recordMap.block[rootPageId] ? rootPageId : Object.keys(recordMap.block).find((k) => {
|
|
3510
|
+
const b = getBlockValue5(recordMap.block[k]);
|
|
3511
|
+
return b && uuidToId3(b.id) === uuidToId3(rootPageId);
|
|
3512
|
+
})) || Object.keys(recordMap.block)[0];
|
|
3513
|
+
const block = id ? getBlockValue5(recordMap.block[id]) : void 0;
|
|
3514
|
+
if (!id || !block) {
|
|
3506
3515
|
if (true) {
|
|
3507
|
-
console.warn("missing block", blockId);
|
|
3516
|
+
console.warn("missing block", blockId != null ? blockId : id);
|
|
3508
3517
|
}
|
|
3509
3518
|
return null;
|
|
3510
3519
|
}
|