@notionhq/custom-blocks 0.1.49 → 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/README.md +2 -3
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +2 -4
- package/dist/bridge/sandboxClient.d.ts +0 -5
- package/dist/bridge/sandboxClient.d.ts.map +1 -1
- package/dist/bridge/sandboxClient.js +0 -12
- package/dist/customBlock.d.ts +0 -22
- package/dist/customBlock.d.ts.map +1 -1
- package/dist/customBlock.js +0 -37
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/protocol/dataSources/dataSourcePage.d.ts +2 -2
- package/dist/protocol/dataSources/dataSourcePage.js +2 -3
- package/dist/protocol/messages/createPageResult.d.ts +2 -2
- package/dist/protocol/messages/getPage.d.ts +2 -2
- package/dist/protocol/messages/hostToSandbox.d.ts +9 -9
- package/dist/protocol/messages/init.d.ts +1 -1
- package/dist/protocol/messages/init.js +2 -3
- package/dist/protocol/messages/queryDataSourceResult.d.ts +2 -2
- package/dist/protocol/messages/updatePageResult.d.ts +2 -2
- package/dist/protocol/pages/page.d.ts +2 -2
- package/dist/protocol/pages/page.js +2 -3
- package/dist/protocol/protocolVersion.d.ts +1 -1
- package/dist/protocol/protocolVersion.js +1 -1
- package/dist/react/NotionCustomBlock.d.ts +1 -9
- package/dist/react/NotionCustomBlock.d.ts.map +1 -1
- package/dist/react/NotionCustomBlock.js +9 -3
- package/dist/react/index.d.ts +0 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +0 -1
- package/dist/types.d.ts +4 -38
- package/dist/types.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/docs/lifecycle.md +1 -14
- package/docs/users.md +97 -26
- package/package.json +1 -6
- package/src/bridge/SandboxBridge.ts +2 -4
- package/src/bridge/sandboxClient.ts +0 -15
- package/src/customBlock.ts +1 -65
- package/src/index.ts +1 -1
- package/src/react/NotionCustomBlock.tsx +9 -11
- package/src/react/index.ts +0 -1
- package/src/types.ts +4 -46
- package/dist/react/useCustomBlockAutoResize.d.ts +0 -26
- package/dist/react/useCustomBlockAutoResize.d.ts.map +0 -1
- package/dist/react/useCustomBlockAutoResize.js +0 -31
- package/src/react/useCustomBlockAutoResize.ts +0 -42
- package/vite-plugin/index.d.ts +0 -12
- package/vite-plugin/index.js +0 -11
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AACxG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iEAAiE,CAAA;AAC5G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gEAAgE,CAAA;AAC1G,OAAO,KAAK,EACX,kBAAkB,EAClB,YAAY,EACZ,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yDAAyD,CAAA;AACvG,OAAO,KAAK,EACX,uBAAuB,EACvB,8BAA8B,EAC9B,MAAM,+DAA+D,CAAA;AACtE,OAAO,KAAK,EACX,2BAA2B,EAC3B,oBAAoB,EACpB,MAAM,sDAAsD,CAAA;AAC7D,OAAO,KAAK,EACX,2BAA2B,EAC3B,oBAAoB,EACpB,MAAM,sDAAsD,CAAA;AAC7D,OAAO,KAAK,EACX,6BAA6B,EAC7B,gBAAgB,EAChB,sBAAsB,EACtB,MAAM,wDAAwD,CAAA;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAA;AACvG,OAAO,KAAK,EACX,iCAAiC,EACjC,iCAAiC,EACjC,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,6BAA6B,EAC7B,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAE,mCAAmC,EAAE,M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EG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,MAAM,EAAE,gBAAgB,CAAA;IACxB,UAAU,EAAE,0BAA0B,CAAA;IACtC,QAAQ,CAAC,EAAE,wBAAwB,CAAA;CACnC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAClD,uBAAuB,EACvB,8BAA8B,CAC9B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,CAChC,iBAAiB,EACjB,MAAM,GAAG,WAAW,GAAG,UAAU,CACjC,GAAG;IACH,oCAAoC;IACpC,WAAW,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,oBAAoB,CAC/C,oBAAoB,EACpB,2BAA2B,CAC3B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAClD,uBAAuB,EACvB,8BAA8B,CAC9B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,WAAW,CAAC,CAAA;AAExE,MAAM,MAAM,eAAe,GAAG,oBAAoB,CACjD,sBAAsB,EACtB,6BAA6B,CAC7B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,oBAAoB,CAC/C,oBAAoB,EACpB,2BAA2B,CAC3B,CAAA"}
|
package/dist/version.js
CHANGED
package/docs/lifecycle.md
CHANGED
|
@@ -75,8 +75,7 @@ The SDK measures the `#root` element and sends its initial height in
|
|
|
75
75
|
`initResult.success`. It sends later height changes in `resize` messages. The
|
|
76
76
|
host uses these messages to keep the iframe height in sync.
|
|
77
77
|
|
|
78
|
-
Using `<NotionCustomBlock>` enables this behavior automatically.
|
|
79
|
-
`customBlock.autoResize()` for a custom, framework-neutral initialization wrapper.
|
|
78
|
+
Using `<NotionCustomBlock>` enables this behavior automatically.
|
|
80
79
|
|
|
81
80
|
## API
|
|
82
81
|
|
|
@@ -196,18 +195,6 @@ function ThemeLabel() {
|
|
|
196
195
|
|
|
197
196
|
See [Block location and appearance](./block-location.md#reading-values-and-following-changes) for the available getters, subscriptions, and React hooks.
|
|
198
197
|
|
|
199
|
-
### `customBlock.autoResize()`
|
|
200
|
-
|
|
201
|
-
For non-React auto-resize, pass the element whose content height should drive the host iframe. The helper posts one initial measurement, observes later size changes when `ResizeObserver` is available, dedupes unchanged heights, and returns a cleanup function:
|
|
202
|
-
|
|
203
|
-
```ts
|
|
204
|
-
const stopAutoResize = customBlock.autoResize({
|
|
205
|
-
target: document.getElementById("root"),
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
// Call stopAutoResize() when your renderer is removed.
|
|
209
|
-
```
|
|
210
|
-
|
|
211
198
|
### `NotInIframeError`
|
|
212
199
|
|
|
213
200
|
Thrown when `initCustomBlock` is called in a top-level tab (no parent frame). It extends `CustomBlockInitializationError`, has `code: "not_in_iframe"` and `isRetryable: false`, and can be detected specifically with `instanceof NotInIframeError`. `<NotionCustomBlock>` catches it and falls back to a standalone preview with a warning banner.
|
package/docs/users.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `users` API
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Read the current user, fetch a user by ID, or list workspace users from inside a custom block.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import {
|
|
@@ -12,52 +12,113 @@ import {
|
|
|
12
12
|
import { useCurrentUser } from "@notionhq/custom-blocks/react";
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
`users.get()` and `users.list()` follow the SDK's [error-handling contract](./errors.md). Check `result.status` before reading `result.user` or `result.list`.
|
|
16
16
|
|
|
17
17
|
## Reading the current user
|
|
18
18
|
|
|
19
|
-
`useCurrentUser()`
|
|
19
|
+
`customBlock.getCurrentUser()` and `useCurrentUser()` return the user viewing the custom block. Both read the user from the block’s state without a separate request.
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
const me = useCurrentUser();
|
|
23
|
-
// me.id, me.name, me.person.email
|
|
24
|
-
```
|
|
21
|
+
Wait for `initCustomBlock()` to resolve before calling the getter or mounting components that use the hook. See [initialization](./lifecycle.md).
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
### TypeScript API
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
Use `customBlock.getCurrentUser()` to read the current user in any framework. Subscribe to context changes to keep your UI updated:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { customBlock, initCustomBlock } from "@notionhq/custom-blocks"
|
|
29
29
|
|
|
30
|
-
```ts
|
|
31
30
|
await initCustomBlock()
|
|
31
|
+
const user = customBlock.getCurrentUser()
|
|
32
|
+
console.log(user.name)
|
|
32
33
|
|
|
33
|
-
const unsubscribe = customBlock.subscribeToCurrentUser(
|
|
34
|
-
|
|
34
|
+
const unsubscribe = customBlock.subscribeToCurrentUser(nextUser => {
|
|
35
|
+
console.log(nextUser.name)
|
|
35
36
|
})
|
|
36
37
|
```
|
|
37
38
|
|
|
38
|
-
Call `unsubscribe()` when
|
|
39
|
+
Call `unsubscribe()` when you no longer need updates. The callback receives the initial profile and later changes.
|
|
39
40
|
See [context subscriptions](./block-location.md#reading-values-and-following-changes) for initialization and equality rules.
|
|
40
41
|
|
|
42
|
+
### React hook
|
|
43
|
+
|
|
44
|
+
In React, use `useCurrentUser()` to re-render when the current user changes:
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import { useCurrentUser } from "@notionhq/custom-blocks/react"
|
|
48
|
+
|
|
49
|
+
function Greeting() {
|
|
50
|
+
const user = useCurrentUser()
|
|
51
|
+
return <p>Hello, {user.name ?? "there"}</p>
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Both approaches return the same `NotionUser` shape.
|
|
56
|
+
|
|
57
|
+
## User object
|
|
58
|
+
|
|
59
|
+
`NotionUser` is based on the [public API User object](https://developers.notion.com/reference/user). `users.get()` and the current-user APIs return a `NotionUser`. `users.list()` returns a page of these objects. Custom blocks return only people, not bots or integrations.
|
|
60
|
+
|
|
61
|
+
All fields except `name` are always present. `name` may be omitted. `avatar_url` is present but can be `null`.
|
|
62
|
+
|
|
63
|
+
| Property | Type | Description |
|
|
64
|
+
| --- | --- | --- |
|
|
65
|
+
| `object` | `"user"` | Identifies a user object. |
|
|
66
|
+
| `id` | `string` (UUID) | The user's ID. Typed as `NotionUserId` in the SDK. |
|
|
67
|
+
| `name` | `string` (optional) | The user's name, if available. |
|
|
68
|
+
| `avatar_url` | `string` (nullable) | The user's avatar URL, or `null` if no avatar is available. |
|
|
69
|
+
| `type` | `"person"` | Custom blocks return people. |
|
|
70
|
+
| `person` | `object` | The user's person details. |
|
|
71
|
+
| `person.email` | `string` | The user's email address. |
|
|
72
|
+
|
|
41
73
|
## Listing users
|
|
42
74
|
|
|
43
|
-
`users.list(
|
|
75
|
+
Each `users.list()` call returns one page of workspace users visible to the viewing user. The SDK does not fetch the remaining pages automatically.
|
|
44
76
|
|
|
45
77
|
```ts
|
|
46
78
|
const result = await users.list({ pageSize: 50 });
|
|
47
|
-
if (result.status === "
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
79
|
+
if (result.status === "success") {
|
|
80
|
+
for (const user of result.list.results) {
|
|
81
|
+
console.log(user.id, user.name, user.person.email);
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
console.error(result.error);
|
|
51
85
|
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`ListUsersArgs` accepts the following options:
|
|
89
|
+
|
|
90
|
+
| Option | Description |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| `pageSize` | Maximum users per response. Optional integer from 1 to 100. Defaults to 100. |
|
|
93
|
+
| `startCursor` | Optional cursor from the previous response's `next_cursor`. Omit it for the first page. |
|
|
94
|
+
|
|
95
|
+
`users.list()` returns a promise that resolves to a `ListUsersResult`: either `{ status: "success", list }` or `{ status: "error", error }`.
|
|
96
|
+
|
|
97
|
+
On success, `list` is a `NotionUserList` with `results`, `next_cursor`, and `has_more`.
|
|
98
|
+
|
|
99
|
+
Pass `next_cursor` as `startCursor` to request the next page. Use the cursor exactly as returned. Do not parse it or create your own. Stop when `has_more` is false.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { users, type ListUsersArgs } from "@notionhq/custom-blocks";
|
|
103
|
+
|
|
104
|
+
const args: ListUsersArgs = { pageSize: 50 };
|
|
52
105
|
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
106
|
+
while (true) {
|
|
107
|
+
const result = await users.list(args);
|
|
108
|
+
if (result.status === "error") {
|
|
109
|
+
console.error(result.error);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for (const user of result.list.results) {
|
|
114
|
+
console.log(user.id, user.name);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!result.list.has_more || result.list.next_cursor === null) break;
|
|
118
|
+
args.startCursor = result.list.next_cursor;
|
|
56
119
|
}
|
|
57
120
|
```
|
|
58
121
|
|
|
59
|
-
`ListUsersArgs` accepts `pageSize` and `startCursor`; both are optional. `ListUsersResult` resolves to either `{ status: "success", list }` or `{ status: "error", error }`, where `list` is a `NotionUserList` (with `results`, `next_cursor`, `has_more`).
|
|
60
|
-
|
|
61
122
|
## Reading a single user
|
|
62
123
|
|
|
63
124
|
`users.get(userId)` fetches one `NotionUser` by `NotionUserId`:
|
|
@@ -69,14 +130,24 @@ if (result.status === "success") {
|
|
|
69
130
|
}
|
|
70
131
|
```
|
|
71
132
|
|
|
72
|
-
`
|
|
133
|
+
`users.get()` returns a promise that resolves to a `GetUserResult`: either `{ status: "success", user }` or `{ status: "error", error }`.
|
|
134
|
+
|
|
135
|
+
A `people` property can contain both users and groups (`object: "group"`). `users.get()` and `users.list()` only support people. You cannot use these APIs to resolve a group or list its members.
|
|
136
|
+
|
|
137
|
+
Skip group entries when you need a person’s name and avatar. Match the person’s ID against results from `users.list()`. Reuse those results if your UI already lists workspace users. IDs in a `people` property are plain strings. `users.get()` requires a `NotionUserId`, such as an ID from the user APIs.
|
|
138
|
+
|
|
139
|
+
## Permissions
|
|
140
|
+
|
|
141
|
+
A user returned by `users.list()` does not necessarily have access to the current page or data source. Do not use this list to check page or data source permissions.
|
|
142
|
+
|
|
143
|
+
If a request returns `status: "error"`, handle the error before reading `result.user` or `result.list`. See [error handling](./errors.md).
|
|
73
144
|
|
|
74
145
|
## Types
|
|
75
146
|
|
|
76
147
|
- `NotionUser` — the user record returned by `users.get` and inside `NotionUserList.results`.
|
|
77
148
|
- `NotionUserId` — branded string ID for a user.
|
|
78
149
|
- `NotionUserList` — paginated list shape returned by `users.list`.
|
|
79
|
-
- `useCurrentUser()` — hook that returns the
|
|
80
|
-
- `customBlock.getCurrentUser()` — framework-neutral getter for the
|
|
150
|
+
- `useCurrentUser()` — hook that returns the current user's `NotionUser`.
|
|
151
|
+
- `customBlock.getCurrentUser()` — framework-neutral getter for the current user's `NotionUser`.
|
|
81
152
|
- `ListUsersArgs` / `ListUsersResult`.
|
|
82
153
|
- `GetUserResult`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notionhq/custom-blocks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -22,10 +22,6 @@
|
|
|
22
22
|
"import": "./dist/testing.js",
|
|
23
23
|
"types": "./dist/testing.d.ts"
|
|
24
24
|
},
|
|
25
|
-
"./vite": {
|
|
26
|
-
"import": "./vite-plugin/index.js",
|
|
27
|
-
"types": "./vite-plugin/index.d.ts"
|
|
28
|
-
},
|
|
29
25
|
"./bundle": {
|
|
30
26
|
"types": "./bin/notion-custom-blocks/bundle.d.ts",
|
|
31
27
|
"import": "./bin/notion-custom-blocks/bundle.js"
|
|
@@ -43,7 +39,6 @@
|
|
|
43
39
|
"src",
|
|
44
40
|
"bin",
|
|
45
41
|
"docs",
|
|
46
|
-
"vite-plugin",
|
|
47
42
|
"dist"
|
|
48
43
|
],
|
|
49
44
|
"peerDependencies": {
|
|
@@ -931,9 +931,7 @@ export class SandboxBridge {
|
|
|
931
931
|
}
|
|
932
932
|
|
|
933
933
|
updatePage(args: UpdatePageArgs): Promise<UpdatePageResult> {
|
|
934
|
-
|
|
935
|
-
// TODO(custom-blocks): Remove the archived fallback when upgrading to bridge protocol v4.
|
|
936
|
-
const isArchived = args.is_archived ?? args.archived
|
|
934
|
+
const isArchived = args.is_archived
|
|
937
935
|
return new Promise(resolve => {
|
|
938
936
|
if (
|
|
939
937
|
(args.properties === undefined ||
|
|
@@ -1003,7 +1001,7 @@ export class SandboxBridge {
|
|
|
1003
1001
|
properties: resolvedProperties?.properties,
|
|
1004
1002
|
icon: pageUpdateArgs.icon,
|
|
1005
1003
|
cover: pageUpdateArgs.cover,
|
|
1006
|
-
is_archived: pageUpdateArgs.is_archived
|
|
1004
|
+
is_archived: pageUpdateArgs.is_archived,
|
|
1007
1005
|
})
|
|
1008
1006
|
}
|
|
1009
1007
|
|
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
} from "./SandboxBridge.js"
|
|
25
25
|
|
|
26
26
|
let bridge: SandboxBridge | undefined
|
|
27
|
-
let didWarnAboutPagesDelete = false
|
|
28
27
|
|
|
29
28
|
function getBridge(): SandboxBridge {
|
|
30
29
|
if (!bridge) {
|
|
@@ -146,20 +145,6 @@ export const pages = {
|
|
|
146
145
|
unarchive: (pageId: NotionPageId): Promise<UpdatePageResult> => {
|
|
147
146
|
return getBridge().updatePage({ pageId, is_archived: false })
|
|
148
147
|
},
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* @deprecated This method archives the page. It does not move the page to Trash.
|
|
152
|
-
* Use `pages.archive(pageId)` instead.
|
|
153
|
-
*/
|
|
154
|
-
delete: (pageId: NotionPageId): Promise<UpdatePageResult> => {
|
|
155
|
-
if (!didWarnAboutPagesDelete) {
|
|
156
|
-
didWarnAboutPagesDelete = true
|
|
157
|
-
console.warn(
|
|
158
|
-
"[Notion Custom Blocks] DEPRECATED: pages.delete() archives the page. It does not move the page to Trash. Use pages.archive() instead.",
|
|
159
|
-
)
|
|
160
|
-
}
|
|
161
|
-
return getBridge().updatePage({ pageId, is_archived: true })
|
|
162
|
-
},
|
|
163
148
|
}
|
|
164
149
|
|
|
165
150
|
/**
|
package/src/customBlock.ts
CHANGED
|
@@ -1,38 +1,15 @@
|
|
|
1
1
|
import type { NotionContrastMode } from "@notionhq/custom-blocks-protocol/contrast.js"
|
|
2
|
-
import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
|
|
3
2
|
import type { NotionBlockId } from "@notionhq/custom-blocks-protocol/ids.js"
|
|
4
3
|
import type { CustomBlockManifest } from "@notionhq/custom-blocks-protocol/manifest.js"
|
|
5
4
|
import type { CustomBlockPage } from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
6
5
|
import type { NotionParent } from "@notionhq/custom-blocks-protocol/parent.js"
|
|
7
6
|
import type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
|
|
8
7
|
import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
|
|
9
|
-
import { autoResize } from "./autoResize.js"
|
|
10
8
|
import { subscribeToDataSource } from "./bridge/dataSources/subscribe.js"
|
|
11
|
-
import type {
|
|
12
|
-
CustomBlockHostState,
|
|
13
|
-
InitializedHostState,
|
|
14
|
-
} from "./bridge/hostState.js"
|
|
9
|
+
import type { InitializedHostState } from "./bridge/hostState.js"
|
|
15
10
|
import { notifyListener } from "./bridge/notifyListener.js"
|
|
16
11
|
import { customBlockHost } from "./bridge/sandboxClient.js"
|
|
17
12
|
|
|
18
|
-
/** @deprecated Use individual context types and getters after `initCustomBlock` resolves. */
|
|
19
|
-
export type CustomBlockState =
|
|
20
|
-
| {
|
|
21
|
-
status: "uninitialized"
|
|
22
|
-
theme: NotionTheme
|
|
23
|
-
contrastMode: NotionContrastMode
|
|
24
|
-
}
|
|
25
|
-
| {
|
|
26
|
-
status: "initialized"
|
|
27
|
-
theme: NotionTheme
|
|
28
|
-
contrastMode: NotionContrastMode
|
|
29
|
-
blockId: NotionBlockId
|
|
30
|
-
parent: NotionParent
|
|
31
|
-
page: CustomBlockPage
|
|
32
|
-
currentUser: NotionUser
|
|
33
|
-
dataSources: NotionDataSource[]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
13
|
type Unsubscribe = () => void
|
|
37
14
|
|
|
38
15
|
/**
|
|
@@ -45,16 +22,6 @@ type Unsubscribe = () => void
|
|
|
45
22
|
* subscription is no longer needed.
|
|
46
23
|
*/
|
|
47
24
|
export const customBlock = {
|
|
48
|
-
/** @deprecated Use an individual subscription method, such as `subscribeToTheme()` or `subscribeToCurrentUser()`. */
|
|
49
|
-
subscribe(listener: () => void): Unsubscribe {
|
|
50
|
-
return customBlockHost.subscribe(listener)
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
/** @deprecated Use an individual getter method, such as `getTheme()` or `getCurrentUser()`, after `initCustomBlock()` resolves. */
|
|
54
|
-
getState(): CustomBlockState {
|
|
55
|
-
return toPublicState(customBlockHost.getState())
|
|
56
|
-
},
|
|
57
|
-
|
|
58
25
|
/**
|
|
59
26
|
* Get the current user viewing the block.
|
|
60
27
|
* Throws if called before SDK initialization completes.
|
|
@@ -171,8 +138,6 @@ export const customBlock = {
|
|
|
171
138
|
return subscribeToContext({ key: "manifest", listener })
|
|
172
139
|
},
|
|
173
140
|
|
|
174
|
-
autoResize,
|
|
175
|
-
|
|
176
141
|
/**
|
|
177
142
|
* Registers a listener that receives the current query snapshot and later updates.
|
|
178
143
|
* Returns a function that removes this listener. Other listeners remain subscribed.
|
|
@@ -180,35 +145,6 @@ export const customBlock = {
|
|
|
180
145
|
subscribeToDataSource,
|
|
181
146
|
}
|
|
182
147
|
|
|
183
|
-
let lastHostState: CustomBlockHostState | undefined
|
|
184
|
-
let lastPublicState: CustomBlockState | undefined
|
|
185
|
-
|
|
186
|
-
function toPublicState(hostState: CustomBlockHostState): CustomBlockState {
|
|
187
|
-
if (hostState === lastHostState && lastPublicState !== undefined) {
|
|
188
|
-
return lastPublicState
|
|
189
|
-
}
|
|
190
|
-
lastHostState = hostState
|
|
191
|
-
if (hostState.status === "uninitialized") {
|
|
192
|
-
lastPublicState = {
|
|
193
|
-
status: "uninitialized",
|
|
194
|
-
theme: hostState.theme,
|
|
195
|
-
contrastMode: hostState.contrastMode,
|
|
196
|
-
}
|
|
197
|
-
return lastPublicState
|
|
198
|
-
}
|
|
199
|
-
lastPublicState = {
|
|
200
|
-
status: "initialized",
|
|
201
|
-
theme: hostState.theme,
|
|
202
|
-
contrastMode: hostState.contrastMode,
|
|
203
|
-
blockId: hostState.blockId,
|
|
204
|
-
parent: hostState.parent,
|
|
205
|
-
page: hostState.page,
|
|
206
|
-
currentUser: hostState.currentUser,
|
|
207
|
-
dataSources: hostState.dataSources,
|
|
208
|
-
}
|
|
209
|
-
return lastPublicState
|
|
210
|
-
}
|
|
211
|
-
|
|
212
148
|
function getInitializedHostState(methodName: string): InitializedHostState {
|
|
213
149
|
const hostState = customBlockHost.getState()
|
|
214
150
|
if (hostState.status !== "initialized") {
|
package/src/index.ts
CHANGED
|
@@ -98,7 +98,7 @@ export type {
|
|
|
98
98
|
export type { NotionParent } from "@notionhq/custom-blocks-protocol/parent.js"
|
|
99
99
|
export type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
|
|
100
100
|
export { pages, users } from "./bridge/sandboxClient.js"
|
|
101
|
-
export {
|
|
101
|
+
export { customBlock } from "./customBlock.js"
|
|
102
102
|
export {
|
|
103
103
|
type CustomBlockInitPayload,
|
|
104
104
|
initCustomBlock,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { CustomBlockInitializationError } from "@notionhq/custom-blocks-protocol/messages/init.js"
|
|
2
2
|
import { type ReactNode, useEffect, useLayoutEffect, useState } from "react"
|
|
3
|
+
import { autoResize } from "../autoResize.js"
|
|
3
4
|
import { customBlockHost } from "../bridge/sandboxClient.js"
|
|
4
5
|
import { NotInIframeError } from "../init.js"
|
|
5
6
|
import { DebugMessageLog } from "./DebugMessageLog.js"
|
|
6
7
|
import { seedStandalonePreviewState } from "./standalonePreview.js"
|
|
7
|
-
import { useCustomBlockAutoResize } from "./useCustomBlockAutoResize.js"
|
|
8
8
|
import { useCustomBlockInit } from "./useCustomBlockInit.js"
|
|
9
9
|
import { useCustomBlockHost } from "./useHostState.js"
|
|
10
10
|
import "./NotionCustomBlock.css"
|
|
@@ -25,14 +25,6 @@ export type NotionCustomBlockProps = {
|
|
|
25
25
|
* rendered with developer details — replace it for production templates.
|
|
26
26
|
*/
|
|
27
27
|
errorFallback?: ReactNode | ((error: Error) => ReactNode)
|
|
28
|
-
/**
|
|
29
|
-
* Whether to post resize messages after initialization and dynamically resize the block.
|
|
30
|
-
*
|
|
31
|
-
* @deprecated TODO(custom-blocks): Remove this prop when bumping the SDK version to 0.2.0.
|
|
32
|
-
*
|
|
33
|
-
* @default true
|
|
34
|
-
*/
|
|
35
|
-
autoResize?: boolean
|
|
36
28
|
}
|
|
37
29
|
|
|
38
30
|
/**
|
|
@@ -57,15 +49,21 @@ export function NotionCustomBlock({
|
|
|
57
49
|
children,
|
|
58
50
|
fallback = null,
|
|
59
51
|
errorFallback,
|
|
60
|
-
autoResize = true,
|
|
61
52
|
}: NotionCustomBlockProps) {
|
|
62
53
|
const init = useCustomBlockInit()
|
|
63
|
-
useCustomBlockAutoResize({ enabled: init.isLoaded && autoResize })
|
|
64
54
|
// True if the block has no host (i.e. it's running in standalone preview).
|
|
65
55
|
const isStandalone = init.error instanceof NotInIframeError
|
|
66
56
|
const host = useCustomBlockHost()
|
|
67
57
|
const [debugOpen, setDebugOpen] = useState(false)
|
|
68
58
|
|
|
59
|
+
// Keep the host iframe height in sync with the block's content after initialization.
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!init.isLoaded || typeof window === "undefined") {
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
return autoResize({ target: document.getElementById("root") })
|
|
65
|
+
}, [init.isLoaded])
|
|
66
|
+
|
|
69
67
|
useEffect(() => {
|
|
70
68
|
const onKeyDown = (e: KeyboardEvent) => {
|
|
71
69
|
if (e.key === "\\") {
|
package/src/react/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -85,11 +85,10 @@ export type NotionPagePropertyInputMap = {
|
|
|
85
85
|
*/
|
|
86
86
|
export type NotionDataSourcePage = {
|
|
87
87
|
id: NotionPageId
|
|
88
|
-
// TODO(custom-blocks): Require is_archived and in_trash in bridge protocol v4.
|
|
89
88
|
/** Whether the page or an ancestor is archived. */
|
|
90
|
-
is_archived
|
|
89
|
+
is_archived: boolean
|
|
91
90
|
/** Whether the page or an ancestor is in Trash. */
|
|
92
|
-
in_trash
|
|
91
|
+
in_trash: boolean
|
|
93
92
|
/**
|
|
94
93
|
* Keyed mapping of raw property IDs to their value. Includes all properties on the data source,
|
|
95
94
|
* including the four built-ins (`created_time`, `last_edited_time`, `created_by`,
|
|
@@ -116,27 +115,10 @@ export type NotionDataSourcePageUpdateArgs = {
|
|
|
116
115
|
properties?: NotionPagePropertyInputMap
|
|
117
116
|
icon?: NotionPageIcon
|
|
118
117
|
cover?: NotionPageCover
|
|
119
|
-
/** Whether to archive this page.
|
|
118
|
+
/** Whether to archive this page. */
|
|
120
119
|
is_archived?: boolean
|
|
121
|
-
/** @deprecated Use is_archived instead. */
|
|
122
|
-
// TODO(custom-blocks): Remove archived when upgrading to bridge protocol v4.
|
|
123
|
-
archived?: boolean
|
|
124
120
|
}
|
|
125
121
|
|
|
126
|
-
/**
|
|
127
|
-
* @deprecated Use `NotionDataSourcePageUpdateArgs` instead.
|
|
128
|
-
*
|
|
129
|
-
* TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
|
|
130
|
-
*/
|
|
131
|
-
export type NotionDataSourcePageUpdateInput = NotionDataSourcePageUpdateArgs
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* @deprecated Use `UpdatePageResult` instead.
|
|
135
|
-
*
|
|
136
|
-
* TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
|
|
137
|
-
*/
|
|
138
|
-
export type NotionDataSourcePageUpdateResult = UpdatePageResult
|
|
139
|
-
|
|
140
122
|
export type NotionDataSourceTextFilterOperator = CustomBlockTextFilterOperator
|
|
141
123
|
export type NotionDataSourceNumberFilterOperator =
|
|
142
124
|
CustomBlockNumberFilterOperator
|
|
@@ -256,13 +238,6 @@ export type CreatePageArgs = {
|
|
|
256
238
|
position?: NotionCreatePagePosition
|
|
257
239
|
}
|
|
258
240
|
|
|
259
|
-
/**
|
|
260
|
-
* @deprecated Use `CreatePageArgs` instead.
|
|
261
|
-
*
|
|
262
|
-
* TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
|
|
263
|
-
*/
|
|
264
|
-
export type CreatePageInput = CreatePageArgs
|
|
265
|
-
|
|
266
241
|
/**
|
|
267
242
|
* The result of a `sdk.pages.create` API call.
|
|
268
243
|
*/
|
|
@@ -275,20 +250,10 @@ export type UpdatePageArgs = Omit<
|
|
|
275
250
|
UpdatePageMessage,
|
|
276
251
|
"type" | "requestId" | "archived"
|
|
277
252
|
> & {
|
|
278
|
-
/** Whether to archive this page.
|
|
253
|
+
/** Whether to archive this page. */
|
|
279
254
|
is_archived?: boolean
|
|
280
|
-
/** @deprecated Use is_archived instead. */
|
|
281
|
-
// TODO(custom-blocks): Remove archived when upgrading to bridge protocol v4.
|
|
282
|
-
archived?: boolean
|
|
283
255
|
}
|
|
284
256
|
|
|
285
|
-
/**
|
|
286
|
-
* @deprecated Use `UpdatePageArgs` instead.
|
|
287
|
-
*
|
|
288
|
-
* TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
|
|
289
|
-
*/
|
|
290
|
-
export type UpdatePageInput = UpdatePageArgs
|
|
291
|
-
|
|
292
257
|
/**
|
|
293
258
|
* Result of `sdk.pages.get`.
|
|
294
259
|
*/
|
|
@@ -307,13 +272,6 @@ export type UpdatePageResult = BridgeMessagePayload<
|
|
|
307
272
|
|
|
308
273
|
export type ListUsersArgs = Omit<ListUsersMessage, "type" | "requestId">
|
|
309
274
|
|
|
310
|
-
/**
|
|
311
|
-
* @deprecated Use `ListUsersArgs` instead.
|
|
312
|
-
*
|
|
313
|
-
* TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
|
|
314
|
-
*/
|
|
315
|
-
export type ListUsersInput = ListUsersArgs
|
|
316
|
-
|
|
317
275
|
export type ListUsersResult = BridgeMessagePayload<
|
|
318
276
|
ListUsersResultMessage,
|
|
319
277
|
CustomBlockListUsersErrorInfo
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Measures the sandbox's `#root` element and posts `resize` messages so the host iframe
|
|
3
|
-
* matches the block's border-box height. Unchanged values are deduped.
|
|
4
|
-
*
|
|
5
|
-
* `<NotionCustomBlock>` calls this hook for you. Only use it directly in a custom
|
|
6
|
-
* initialization wrapper that does not render `<NotionCustomBlock>`.
|
|
7
|
-
*
|
|
8
|
-
* @deprecated Use CSS `max-height` and `overflow` to constrain block content instead.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* function App() {
|
|
12
|
-
* const [enabled, setEnabled] = useState(true)
|
|
13
|
-
* useCustomBlockAutoResize({ enabled })
|
|
14
|
-
* return <div>…</div>
|
|
15
|
-
* }
|
|
16
|
-
*/
|
|
17
|
-
export declare function useCustomBlockAutoResize(args?: {
|
|
18
|
-
/**
|
|
19
|
-
* Whether or not the hook is enabled. To disable this behavior, pass `false`. This is
|
|
20
|
-
* provided as an argument to allow for conditional disabling of the hook.
|
|
21
|
-
*
|
|
22
|
-
* @default true
|
|
23
|
-
*/
|
|
24
|
-
enabled?: boolean;
|
|
25
|
-
}): void;
|
|
26
|
-
//# sourceMappingURL=useCustomBlockAutoResize.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCustomBlockAutoResize.d.ts","sourceRoot":"","sources":["../../src/react/useCustomBlockAutoResize.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,wBAAwB,CACvC,IAAI,GAAE;IACL;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CACZ,GACJ,IAAI,CAYN"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { customBlock } from "../customBlock.js";
|
|
3
|
-
/**
|
|
4
|
-
* Measures the sandbox's `#root` element and posts `resize` messages so the host iframe
|
|
5
|
-
* matches the block's border-box height. Unchanged values are deduped.
|
|
6
|
-
*
|
|
7
|
-
* `<NotionCustomBlock>` calls this hook for you. Only use it directly in a custom
|
|
8
|
-
* initialization wrapper that does not render `<NotionCustomBlock>`.
|
|
9
|
-
*
|
|
10
|
-
* @deprecated Use CSS `max-height` and `overflow` to constrain block content instead.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* function App() {
|
|
14
|
-
* const [enabled, setEnabled] = useState(true)
|
|
15
|
-
* useCustomBlockAutoResize({ enabled })
|
|
16
|
-
* return <div>…</div>
|
|
17
|
-
* }
|
|
18
|
-
*/
|
|
19
|
-
export function useCustomBlockAutoResize(args = {}) {
|
|
20
|
-
const { enabled = true } = args;
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (!enabled) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (typeof window === "undefined") {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const target = document.getElementById("root");
|
|
29
|
-
return customBlock.autoResize({ target });
|
|
30
|
-
}, [enabled]);
|
|
31
|
-
}
|