@notionhq/custom-blocks 0.2.10 → 0.2.12
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 +73 -69
- package/bin/notion-custom-blocks/cli.js +0 -0
- package/dist/version.js +1 -1
- package/docs/block-location.md +71 -45
- package/docs/data-sources.md +242 -141
- package/docs/deployment.md +30 -20
- package/docs/errors.md +33 -27
- package/docs/lifecycle.md +82 -72
- package/docs/pages.md +137 -81
- package/docs/users.md +65 -51
- package/package.json +65 -65
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
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
97
|
-
It reports the initial content height so the host can size the iframe before displaying
|
|
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
|
|
103
|
-
These variables cover colors, spacing, typography, and borders.
|
|
104
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
- [`docs/block-location.md`](./docs/block-location.md) — `useBlockId`, `useParent`, `usePage`,
|
|
122
|
-
|
|
123
|
-
|
|
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
|
|
126
|
-
|
|
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
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
143
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
package/dist/version.js
CHANGED
package/docs/block-location.md
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
12
|
-
|
|
|
13
|
-
| Current user
|
|
14
|
-
| Custom block ID | `getBlockId()`
|
|
15
|
-
| Parent
|
|
16
|
-
| Containing page | `getPage()`
|
|
17
|
-
| Theme
|
|
18
|
-
| Contrast mode
|
|
19
|
-
| Manifest
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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" }
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
161
|
+
See [data sources](./data-sources.md) for manifest details and `subscribeToDataSource()` for query
|
|
162
|
+
snapshots.
|