@notionhq/custom-blocks 0.2.11 → 0.2.13

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 CHANGED
@@ -1,31 +1,29 @@
1
1
  # @notionhq/custom-blocks
2
2
 
3
- > [!NOTE]
4
- > **Pre-release.** Custom blocks are in alpha. Breaking changes may land at any time.
3
+ > [!NOTE] **Pre-release.** Custom blocks are in alpha. Breaking changes may land at any time.
5
4
 
6
- Custom blocks let you build custom UI inside Notion that uses workspace data.
7
- This SDK provides APIs to read and update data the viewer can access. It
8
- includes framework-neutral TypeScript APIs and React hooks.
5
+ Custom blocks let you build custom UI inside Notion that uses workspace data. This SDK provides APIs
6
+ to read and update data the viewer can access. It includes framework-neutral TypeScript APIs and
7
+ React hooks.
9
8
 
10
9
  ## Bundle tooling
11
10
 
12
- Node build tools can import `build` and `upload` from
13
- `@notionhq/custom-blocks/bundle`. See [deployment tooling](./docs/deployment.md#apps-sdk-integration).
11
+ Node build tools can import `build` and `upload` from `@notionhq/custom-blocks/bundle`. See
12
+ [deployment tooling](./docs/deployment.md#apps-sdk-integration).
14
13
 
15
14
  ## Install
16
15
 
17
- Create a worker project with `ntn workers new --template custom`. Use the
18
- dependencies and entrypoint that the Notion CLI generates.
16
+ Create a worker project with `ntn workers new --template custom`. Use the dependencies and
17
+ entrypoint that the Notion CLI generates.
19
18
 
20
- React is optional. Blocks that import `@notionhq/custom-blocks/react` need
21
- `react` and `react-dom`. This repository's fixtures use the workspace SDK.
19
+ React is optional. Blocks that import `@notionhq/custom-blocks/react` need `react` and `react-dom`.
20
+ This repository's fixtures use the workspace SDK.
22
21
 
23
- For local preview, run `ntn workers customblocks dev` from the worker project.
24
- Then open `http://localhost:9873`. Install
22
+ For local preview, run `ntn workers customblocks dev` from the worker project. Then open
23
+ `http://localhost:9873`. Install
25
24
  [`@notionhq/custom-blocks-dev-shell`](https://www.npmjs.com/package/@notionhq/custom-blocks-dev-shell)
26
- as a devDependency to pin the shell and get its reference docs in
27
- `node_modules`. See [`docs/deployment.md`](./docs/deployment.md) for local
28
- serving details.
25
+ as a devDependency to pin the shell and get its reference docs in `node_modules`. See
26
+ [`docs/deployment.md`](./docs/deployment.md) for local serving details.
29
27
 
30
28
  ## Quick start
31
29
 
@@ -33,32 +31,29 @@ Declare your custom block along with the rest of your worker definition:
33
31
 
34
32
  ```ts
35
33
  // src/index.ts
36
- import { Worker } from "@notionhq/workers";
34
+ import { Worker } from "@notionhq/workers"
37
35
 
38
- const worker = new Worker();
39
- export default worker;
36
+ const worker = new Worker()
37
+ export default worker
40
38
 
41
39
  worker.customBlock("hello", {
42
40
  path: "./blocks/hello",
43
41
  command: "npx vite build",
44
- });
42
+ })
45
43
  ```
46
44
 
47
45
  Wrap your React app in `<NotionCustomBlock>` at the block's entry point:
48
46
 
49
47
  ```tsx
50
48
  // blocks/hello/src/index.tsx
51
- import "@notionhq/custom-blocks/nds.css";
52
- import {
53
- NotionCustomBlock,
54
- NotionTokenScope,
55
- } from "@notionhq/custom-blocks/react";
56
- import { createRoot } from "react-dom/client";
57
- import { App } from "./App";
58
- import "./style.css";
59
-
60
- const root = document.getElementById("root");
61
- if (!root) throw new Error("The root element is missing.");
49
+ import "@notionhq/custom-blocks/nds.css"
50
+ import { NotionCustomBlock, NotionTokenScope } from "@notionhq/custom-blocks/react"
51
+ import { createRoot } from "react-dom/client"
52
+ import { App } from "./App"
53
+ import "./style.css"
54
+
55
+ const root = document.getElementById("root")
56
+ if (!root) throw new Error("The root element is missing.")
62
57
 
63
58
  createRoot(root).render(
64
59
  <NotionCustomBlock>
@@ -66,18 +61,18 @@ createRoot(root).render(
66
61
  <App />
67
62
  </NotionTokenScope>
68
63
  </NotionCustomBlock>,
69
- );
64
+ )
70
65
  ```
71
66
 
72
67
  Hooks can then read live content directly from Notion:
73
68
 
74
69
  ```tsx
75
70
  // blocks/hello/src/App.tsx
76
- import { useBlockId } from "@notionhq/custom-blocks/react";
71
+ import { useBlockId } from "@notionhq/custom-blocks/react"
77
72
 
78
73
  export function App() {
79
- const blockId = useBlockId();
80
- return <div className="app">Hello from {blockId}.</div>;
74
+ const blockId = useBlockId()
75
+ return <div className="app">Hello from {blockId}.</div>
81
76
  }
82
77
  ```
83
78
 
@@ -93,59 +88,68 @@ Save these styles in `blocks/hello/src/style.css`:
93
88
  }
94
89
  ```
95
90
 
96
- `<NotionCustomBlock>` connects the SDK to the host and waits for host state before rendering its children.
97
- It reports the initial content height so the host can size the iframe before displaying it.
98
- It also reports later height changes automatically.
91
+ `<NotionCustomBlock>` connects the SDK to the host and waits for host state before rendering its
92
+ children. It reports the initial content height so the host can size the iframe before displaying
93
+ it. It also reports later height changes automatically.
99
94
 
100
95
  ## Notion design tokens
101
96
 
102
- The optional `@notionhq/custom-blocks/nds.css` stylesheet provides Notion CSS variables for matching Notion's UI.
103
- These variables cover colors, spacing, typography, and borders.
104
- Import the stylesheet once. Place components that use the variables inside `<NotionTokenScope>`, as shown above.
97
+ The optional `@notionhq/custom-blocks/nds.css` stylesheet provides Notion CSS variables for matching
98
+ Notion's UI. These variables cover colors, spacing, typography, and borders. Import the stylesheet
99
+ once. Place components that use the variables inside `<NotionTokenScope>`, as shown above.
105
100
 
106
101
  `<NotionTokenScope>` keeps Notion CSS variables in sync with the host’s theme and contrast settings.
107
102
 
108
103
  `NotionTokenScopeProps` has one required `children` prop.
109
104
 
110
- CSS variables apply only within `<NotionTokenScope>`. Place portal containers inside that scope, or wrap the portal content in another `<NotionTokenScope>`.
105
+ CSS variables apply only within `<NotionTokenScope>`. Place portal containers inside that scope, or
106
+ wrap the portal content in another `<NotionTokenScope>`.
111
107
 
112
- Outside React, use `customBlock.getTheme()` and `customBlock.getContrastMode()` to read the current appearance, or `customBlock.subscribeToTheme()` and `customBlock.subscribeToContrastMode()` to follow changes. See [Block location and appearance](./docs/block-location.md) for details.
108
+ Outside React, use `customBlock.getTheme()` and `customBlock.getContrastMode()` to read the current
109
+ appearance, or `customBlock.subscribeToTheme()` and `customBlock.subscribeToContrastMode()` to
110
+ follow changes. See [Block location and appearance](./docs/block-location.md) for details.
113
111
 
114
112
  ## Reference
115
113
 
116
- Each page covers one API category. Import framework-neutral APIs from
117
- `@notionhq/custom-blocks`. Import React hooks and components from
118
- `@notionhq/custom-blocks/react`.
119
-
120
- - [`docs/lifecycle.md`](./docs/lifecycle.md) — `<NotionCustomBlock>`, `useCustomBlockInit`, `initCustomBlock`, `NotInIframeError`. The handshake, the React wrapper, sizing.
121
- - [`docs/block-location.md`](./docs/block-location.md) — `useBlockId`, `useParent`, `usePage`, `useTheme`, `useContrastMode`, `NotionTokenScope`, and `NotionTokenScopeProps`. Where the block sits and how to read the host's appearance.
122
- - [`docs/data-sources.md`](./docs/data-sources.md) — `customBlock.subscribeToDataSource`, `useDataSource`, `useManifest`, `customBlock.getManifest`, the row, property, and date-value types, plus a worked example.
123
- - [`docs/pages.md`](./docs/pages.md) — `pages.create / get / open / update / archive / unarchive`, parent variants (including the recommended `data_source_key`), property input shapes.
114
+ Each page covers one API category. Import framework-neutral APIs from `@notionhq/custom-blocks`.
115
+ Import React hooks and components from `@notionhq/custom-blocks/react`.
116
+
117
+ - [`docs/lifecycle.md`](./docs/lifecycle.md) — `<NotionCustomBlock>`, `useCustomBlockInit`,
118
+ `initCustomBlock`, `NotInIframeError`. The handshake, the React wrapper, sizing.
119
+ - [`docs/block-location.md`](./docs/block-location.md) — `useBlockId`, `useParent`, `usePage`,
120
+ `useTheme`, `useContrastMode`, `NotionTokenScope`, and `NotionTokenScopeProps`. Where the block
121
+ sits and how to read the host's appearance.
122
+ - [`docs/data-sources.md`](./docs/data-sources.md) — `customBlock.subscribeToDataSource`,
123
+ `useDataSource`, `useManifest`, `customBlock.getManifest`, the row, property, and date-value
124
+ types, plus a worked example.
125
+ - [`docs/pages.md`](./docs/pages.md) — `pages.create / get / open / update / archive / unarchive`,
126
+ parent variants (including the recommended `data_source_key`), property input shapes.
124
127
  - [`docs/users.md`](./docs/users.md) — `users.list / get`, the `NotionUser` shape, paging.
125
- - [`docs/errors.md`](./docs/errors.md) — request results, error format, error codes, retries, and initialization failures.
126
- - [`docs/deployment.md`](./docs/deployment.md) — worker-backed deploys, localhost self-hosted fallback, where the manifest comes from.
128
+ - [`docs/errors.md`](./docs/errors.md) — request results, error format, error codes, retries, and
129
+ initialization failures.
130
+ - [`docs/deployment.md`](./docs/deployment.md) — worker-backed deploys, localhost self-hosted
131
+ fallback, where the manifest comes from.
127
132
 
128
133
  ## Limitations
129
134
 
130
- Custom blocks run in sandboxed iframes. A block cannot navigate the top-level
131
- page, call `window.open`, or start an authentication redirect.
135
+ Custom blocks run in sandboxed iframes. A block cannot navigate the top-level page, call
136
+ `window.open`, or start an authentication redirect.
132
137
 
133
- By default, a block cannot request external origins. A workspace owner can allow
134
- specific HTTPS origins under **Settings → Notion AI → Workers → Manage → Custom
135
- block external network access**. To allow subdomains, add a wildcard origin such
136
- as `https://*.example.com`. Add `https://example.com` separately if the block
137
- also needs the base domain. The allowlist applies to every custom block in the
138
- workspace. For `fetch` or `XMLHttpRequest`, an external API must allow the block's
139
- origin through CORS.
138
+ By default, a block cannot request external origins. A workspace owner can allow specific HTTPS
139
+ origins under **Settings → Notion AI → Workers → Manage → Custom block external network access**. To
140
+ allow subdomains, add a wildcard origin such as `https://*.example.com`. Add `https://example.com`
141
+ separately if the block also needs the base domain. The allowlist applies to every custom block in
142
+ the workspace. For `fetch` or `XMLHttpRequest`, an external API must allow the block's origin
143
+ through CORS.
140
144
 
141
- When a custom block makes repeated requests to an external API, consider its
142
- rate limits. Consider batching requests or caching results to reduce unnecessary
143
- calls. If the API returns 429, follow its retry guidance.
145
+ When a custom block makes repeated requests to an external API, consider its rate limits. Consider
146
+ batching requests or caching results to reduce unnecessary calls. If the API returns 429, follow its
147
+ retry guidance.
144
148
 
145
- Never put API secrets in a block bundle. Store them in the Worker. Read more in
146
- the [custom block security guide](https://developers.notion.com/custom-blocks/guides/security).
149
+ Never put API secrets in a block bundle. Store them in the Worker. Read more in the
150
+ [custom block security guide](https://developers.notion.com/custom-blocks/guides/security).
147
151
 
148
152
  ## Bridge protocol
149
153
 
150
- The SDK communicates with Notion through a versioned `postMessage` protocol.
151
- Use the SDK's public APIs and exported types. Do not send bridge messages directly.
154
+ The SDK communicates with Notion through a versioned `postMessage` protocol. Use the SDK's public
155
+ APIs and exported types. Do not send bridge messages directly.
File without changes
@@ -1,4 +1,8 @@
1
- type PackedTarGz = {
1
+ /**
2
+ * Deterministic gzipped-tarball packing for custom-block bundles, shared by the
3
+ * `build` and `upload` phases.
4
+ */
5
+ export type PackedTarGz = {
2
6
  tarGz: Buffer;
3
7
  checksumCrc32: string;
4
8
  };
@@ -8,4 +12,3 @@ type PackedTarGz = {
8
12
  * `CreateCustomBlockDeploy` signs into the presigned PUT URL).
9
13
  */
10
14
  export declare function packDirToTarGz(dir: string): PackedTarGz;
11
- export {};
@@ -1,10 +1,6 @@
1
1
  import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
3
  import * as zlib from "node:zlib";
4
- /**
5
- * Deterministic gzipped-tarball packing for custom-block bundles, shared by the
6
- * `build` and `upload` phases.
7
- */
8
4
  const BLOCK_SIZE = 512;
9
5
  /**
10
6
  * Pack a directory into a deterministic gzipped tarball and return both the
package/dist/version.js CHANGED
@@ -4,4 +4,4 @@
4
4
  *
5
5
  * WARNING: Generated during SDK publish. Do not edit in the published package.
6
6
  */
7
- export const CUSTOM_BLOCKS_SDK_VERSION = "0.2.11"
7
+ export const CUSTOM_BLOCKS_SDK_VERSION = "0.2.13"
@@ -1,30 +1,39 @@
1
1
  # Block location and appearance
2
2
 
3
- Block and app context describes where the block runs and the host's appearance. Use getters for current values, subscriptions for initial values and later changes, or React hooks in components.
3
+ Block and app context describes where the block runs and the host's appearance. Use getters for
4
+ current values, subscriptions for initial values and later changes, or React hooks in components.
4
5
 
5
6
  ## API overview
6
7
 
7
- Import `customBlock` from `@notionhq/custom-blocks` for getters and subscriptions. Import React hooks from `@notionhq/custom-blocks/react`.
8
+ Import `customBlock` from `@notionhq/custom-blocks` for getters and subscriptions. Import React
9
+ hooks from `@notionhq/custom-blocks/react`.
8
10
 
9
11
  The getter and subscription names below are methods on `customBlock`.
10
12
 
11
- | Context | Getter | Subscription | React hook |
12
- | --- | --- | --- | --- |
13
- | Current user | `getCurrentUser()` | `subscribeToCurrentUser(callback)` | `useCurrentUser()` |
14
- | Custom block ID | `getBlockId()` | `subscribeToBlockId(callback)` | `useBlockId()` |
15
- | Parent | `getParent()` | `subscribeToParent(callback)` | `useParent()` |
16
- | Containing page | `getPage()` | `subscribeToPage(callback)` | `usePage()` |
17
- | Theme | `getTheme()` | `subscribeToTheme(callback)` | `useTheme()` |
18
- | Contrast mode | `getContrastMode()` | `subscribeToContrastMode(callback)` | `useContrastMode()` |
19
- | Manifest | `getManifest()` | `subscribeToManifest(callback)` | `useManifest()` |
13
+ | Context | Getter | Subscription | React hook |
14
+ | --------------- | ------------------- | ----------------------------------- | ------------------- |
15
+ | Current user | `getCurrentUser()` | `subscribeToCurrentUser(callback)` | `useCurrentUser()` |
16
+ | Custom block ID | `getBlockId()` | `subscribeToBlockId(callback)` | `useBlockId()` |
17
+ | Parent | `getParent()` | `subscribeToParent(callback)` | `useParent()` |
18
+ | Containing page | `getPage()` | `subscribeToPage(callback)` | `usePage()` |
19
+ | Theme | `getTheme()` | `subscribeToTheme(callback)` | `useTheme()` |
20
+ | Contrast mode | `getContrastMode()` | `subscribeToContrastMode(callback)` | `useContrastMode()` |
21
+ | Manifest | `getManifest()` | `subscribeToManifest(callback)` | `useManifest()` |
20
22
 
21
23
  ## Reading values and following changes
22
24
 
23
- Getters return the current value and throw before initialization completes. In React, call context hooks inside `NotionCustomBlock`, which waits for initialization before rendering its children.
25
+ Getters return the current value and throw before initialization completes. In React, call context
26
+ hooks inside `NotionCustomBlock`, which waits for initialization before rendering its children.
24
27
 
25
- Subscriptions can register before initialization. They wait for initialization before delivering the initial value, or deliver immediately if initialization is complete. Start initialization with `initCustomBlock()` or `NotionCustomBlock`. Subscriptions do not start it themselves. These initialization APIs also report failures. Each subscription returns an unsubscribe function. Repeated cleanup calls have no effect.
28
+ Subscriptions can register before initialization. They wait for initialization before delivering the
29
+ initial value, or deliver immediately if initialization is complete. Start initialization with
30
+ `initCustomBlock()` or `NotionCustomBlock`. Subscriptions do not start it themselves. These
31
+ initialization APIs also report failures. Each subscription returns an unsubscribe function.
32
+ Repeated cleanup calls have no effect.
26
33
 
27
- After initial delivery, subscriptions compare values with `Object.is`. Objects use referential equality: a new reference triggers a callback even if its contents are unchanged. Updates to other context values do not trigger the callback. React hooks follow the same comparison rules.
34
+ After initial delivery, subscriptions compare values with `Object.is`. Objects use referential
35
+ equality: a new reference triggers a callback even if its contents are unchanged. Updates to other
36
+ context values do not trigger the callback. React hooks follow the same comparison rules.
28
37
 
29
38
  ```ts
30
39
  import { customBlock, initCustomBlock } from "@notionhq/custom-blocks"
@@ -41,17 +50,23 @@ console.log(customBlock.getTheme()) // Read the current theme once.
41
50
 
42
51
  ## Current user
43
52
 
44
- Use `getCurrentUser()`, `subscribeToCurrentUser()`, and `useCurrentUser()` to access the viewing user's `NotionUser`. See [users](./users.md#reading-the-current-user) for profile fields and user APIs.
53
+ Use `getCurrentUser()`, `subscribeToCurrentUser()`, and `useCurrentUser()` to access the viewing
54
+ user's `NotionUser`. See [users](./users.md#reading-the-current-user) for profile fields and user
55
+ APIs.
45
56
 
46
57
  ## Custom block ID
47
58
 
48
- Use `getBlockId()`, `subscribeToBlockId()`, and `useBlockId()` to access the custom block's own `NotionBlockId`.
59
+ Use `getBlockId()`, `subscribeToBlockId()`, and `useBlockId()` to access the custom block's own
60
+ `NotionBlockId`.
49
61
 
50
- The ID is stable for the lifetime of the block. Each subscription delivers once, unless cancelled before initialization. You can register before initialization without an error.
62
+ The ID is stable for the lifetime of the block. Each subscription delivers once, unless cancelled
63
+ before initialization. You can register before initialization without an error.
51
64
 
52
65
  ## Parent
53
66
 
54
- Use `getParent()`, `subscribeToParent()`, and `useParent()` to access the block's `NotionParent` in the document tree. For a custom collection view, the parent identifies the data source associated with the view.
67
+ Use `getParent()`, `subscribeToParent()`, and `useParent()` to access the block's `NotionParent` in
68
+ the document tree. For a custom collection view, the parent identifies the data source associated
69
+ with the view.
55
70
 
56
71
  ```ts
57
72
  type NotionParent =
@@ -60,7 +75,7 @@ type NotionParent =
60
75
  | { type: "data_source_id"; data_source_id: string } // custom block backing a custom collection view
61
76
  | { type: "workspace"; workspace: true } // top-level block parented by a team / workspace
62
77
  | { type: "agent_id"; agent_id: NotionAgentId } // agent-owned instruction content
63
- | { type: "unavailable" }; // access denied; no parent ID or kind
78
+ | { type: "unavailable" } // access denied; no parent ID or kind
64
79
  ```
65
80
 
66
81
  To identify custom blocks in agent-owned instruction content:
@@ -81,56 +96,67 @@ export function AgentInstructionBadge() {
81
96
 
82
97
  ## Containing page
83
98
 
84
- Use `getPage()`, `subscribeToPage()`, and `usePage()` to access the nearest enclosing page or collection view page. The page's parent can change even when its ID stays the same.
99
+ Use `getPage()`, `subscribeToPage()`, and `usePage()` to access the nearest enclosing page or
100
+ collection view page. The page's parent can change even when its ID stays the same.
85
101
 
86
102
  ```ts
87
103
  type CustomBlockPage = {
88
- id: NotionPageId;
89
- parent: NotionParent; // the containing page's own parent
90
- };
104
+ id: NotionPageId
105
+ parent: NotionParent // the containing page's own parent
106
+ }
91
107
  ```
92
108
 
93
- `page.parent` allows determining if the custom block is in a freestanding page or part of a database. Don't confuse it with `useParent()`, which is the custom block's own parent.
109
+ `page.parent` allows determining if the custom block is in a freestanding page or part of a
110
+ database. Don't confuse it with `useParent()`, which is the custom block's own parent.
94
111
 
95
112
  A containing page whose parent has `type: "data_source_id"` belongs to a data source.
96
113
 
97
- For anything beyond location — title, icon, properties — fetch the page through the pages API: `pages.get(page.id)`.
114
+ For anything beyond location — title, icon, properties — fetch the page through the pages API:
115
+ `pages.get(page.id)`.
98
116
 
99
- When the viewer cannot access the parent resource, the host returns
100
- `{ type: "unavailable" }`, including on `usePage().parent`. This applies to every
101
- parent kind, including data sources, even when the readable child identifies
102
- the parent. Neither the parent's ID nor its kind is exposed. An unavailable
103
- parent does not prevent initialization when the block and containing page are
104
- readable; other initialization requirements still apply.
117
+ When the viewer cannot access the parent resource, the host returns `{ type: "unavailable" }`,
118
+ including on `usePage().parent`. This applies to every parent kind, including data sources, even
119
+ when the readable child identifies the parent. Neither the parent's ID nor its kind is exposed. An
120
+ unavailable parent does not prevent initialization when the block and containing page are readable;
121
+ other initialization requirements still apply.
105
122
 
106
- Treat `unavailable` as unknown when branching on location: it does not establish
107
- whether the containing page is a database row. A parent that is still loading
108
- is not reported as access denied.
123
+ Treat `unavailable` as unknown when branching on location: it does not establish whether the
124
+ containing page is a database row. A parent that is still loading is not reported as access denied.
109
125
 
110
126
  ## Theme and contrast
111
127
 
112
- Use design tokens to style the block. When your code needs the current appearance, use a getter, subscription, or React hook from the [API overview](#api-overview).
128
+ Use design tokens to style the block. When your code needs the current appearance, use a getter,
129
+ subscription, or React hook from the [API overview](#api-overview).
113
130
 
114
- `NotionTheme` is `"light"` or `"dark"`. `NotionContrastMode` is `"standard"` or `"high"`. Hosts that omit a contrast mode use `"standard"`.
131
+ `NotionTheme` is `"light"` or `"dark"`. `NotionContrastMode` is `"standard"` or `"high"`. Hosts that
132
+ omit a contrast mode use `"standard"`.
115
133
 
116
- Getters read the current value after initialization. Subscriptions can register earlier. They deliver the initial value once initialized, then later changes. React hooks keep components current when called inside `NotionCustomBlock`.
134
+ Getters read the current value after initialization. Subscriptions can register earlier. They
135
+ deliver the initial value once initialized, then later changes. React hooks keep components current
136
+ when called inside `NotionCustomBlock`.
117
137
 
118
138
  ```tsx
119
- import { usePage, useTheme } from "@notionhq/custom-blocks/react";
139
+ import { usePage, useTheme } from "@notionhq/custom-blocks/react"
120
140
 
121
141
  export function Header() {
122
- const page = usePage();
123
- const theme = useTheme();
124
- return <header data-display-mode={theme}>Page: {page.id}</header>;
142
+ const page = usePage()
143
+ const theme = useTheme()
144
+ return <header data-display-mode={theme}>Page: {page.id}</header>
125
145
  }
126
146
  ```
127
147
 
128
- For styling, `NotionTokenScope` applies theme and contrast mode to the bundled Notion CSS variables automatically. The stylesheet uses `data-display-mode` for light and dark mode. The separate `data-theme` attribute selects content color palettes such as `blue`, `red`, and `gray`.
148
+ For styling, `NotionTokenScope` applies theme and contrast mode to the bundled Notion CSS variables
149
+ automatically. The stylesheet uses `data-display-mode` for light and dark mode. The separate
150
+ `data-theme` attribute selects content color palettes such as `blue`, `red`, and `gray`.
129
151
 
130
- See [Reading values and following changes](#reading-values-and-following-changes) for a getter and subscription example, including cleanup.
152
+ See [Reading values and following changes](#reading-values-and-following-changes) for a getter and
153
+ subscription example, including cleanup.
131
154
 
132
155
  ## Manifest
133
156
 
134
- Use `getManifest()`, `subscribeToManifest()`, and `useManifest()` to access the declared `CustomBlockManifest`. The manifest stays fixed for the lifetime of the running block, so each subscription delivers it once. You can register before initialization without an error.
157
+ Use `getManifest()`, `subscribeToManifest()`, and `useManifest()` to access the declared
158
+ `CustomBlockManifest`. The manifest stays fixed for the lifetime of the running block, so each
159
+ subscription delivers it once. You can register before initialization without an error.
135
160
 
136
- See [data sources](./data-sources.md) for manifest details and `subscribeToDataSource()` for query snapshots.
161
+ See [data sources](./data-sources.md) for manifest details and `subscribeToDataSource()` for query
162
+ snapshots.