@notionhq/custom-blocks 0.0.62 → 0.0.64
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/HOST.md +4 -4
- package/README.md +2 -2
- package/bin/cli/create.js +3 -3
- package/dist/bridge/SandboxBridge.js +17 -17
- package/dist/bridge/loadManifest.js +6 -6
- package/dist/bridge/messages/hostToSandbox.d.ts +32 -0
- package/dist/bridge/messages/hostToSandbox.d.ts.map +1 -1
- package/dist/bridge/messages/init.d.ts +16 -0
- package/dist/bridge/messages/init.d.ts.map +1 -1
- package/dist/bridge/messages/pageChanged.d.ts +16 -0
- package/dist/bridge/messages/pageChanged.d.ts.map +1 -1
- package/dist/bridge/pages/page.d.ts +24 -0
- package/dist/bridge/pages/page.d.ts.map +1 -1
- package/dist/bridge/pages/page.js +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/init.d.ts +2 -2
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +1 -1
- package/dist/react/NotionCustomBlock.css +47 -47
- package/dist/react/NotionCustomBlock.js +4 -4
- package/dist/react/standalonePreview.js +1 -1
- package/dist/react/useCustomBlockInit.d.ts +2 -2
- package/dist/react/useCustomBlockInit.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/docs/block-location.md +17 -3
- package/docs/lifecycle.md +3 -3
- package/docs/manifest.md +1 -1
- package/docs/pages.md +1 -1
- package/package.json +1 -1
- package/src/bridge/SandboxBridge.ts +17 -17
- package/src/bridge/loadManifest.ts +6 -6
- package/src/bridge/pages/page.ts +9 -0
- package/src/index.ts +1 -1
- package/src/init.ts +4 -4
- package/src/react/NotionCustomBlock.css +47 -47
- package/src/react/NotionCustomBlock.tsx +14 -10
- package/src/react/standalonePreview.ts +1 -1
- package/src/react/useCustomBlockInit.ts +2 -2
- package/src/utils.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
.
|
|
2
|
-
--
|
|
3
|
-
--
|
|
4
|
-
--
|
|
1
|
+
.custom-blocks-standalone-banner {
|
|
2
|
+
--custom-blocks-standalone-banner-background: #fff8e1;
|
|
3
|
+
--custom-blocks-standalone-banner-border: #f0d77b;
|
|
4
|
+
--custom-blocks-standalone-banner-text: #5d4200;
|
|
5
5
|
|
|
6
6
|
padding: 8px 12px;
|
|
7
|
-
background: var(--
|
|
8
|
-
color: var(--
|
|
9
|
-
border-bottom: 1px solid var(--
|
|
7
|
+
background: var(--custom-blocks-standalone-banner-background);
|
|
8
|
+
color: var(--custom-blocks-standalone-banner-text);
|
|
9
|
+
border-bottom: 1px solid var(--custom-blocks-standalone-banner-border);
|
|
10
10
|
font-size: 13px;
|
|
11
11
|
font-family: system-ui, sans-serif;
|
|
12
12
|
line-height: 1.4;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
.
|
|
16
|
-
--
|
|
17
|
-
--
|
|
18
|
-
--
|
|
19
|
-
--
|
|
20
|
-
--
|
|
21
|
-
--
|
|
22
|
-
--
|
|
23
|
-
--
|
|
24
|
-
--
|
|
15
|
+
.custom-blocks-default-init-error {
|
|
16
|
+
--custom-blocks-init-error-background: #f7f7f5;
|
|
17
|
+
--custom-blocks-init-error-card-background: #ffffff;
|
|
18
|
+
--custom-blocks-init-error-border: #e5e5e1;
|
|
19
|
+
--custom-blocks-init-error-text: #1f1f1d;
|
|
20
|
+
--custom-blocks-init-error-muted-text: #5f5e5b;
|
|
21
|
+
--custom-blocks-init-error-eyebrow-text: #787774;
|
|
22
|
+
--custom-blocks-init-error-pre-background: #f1f1ef;
|
|
23
|
+
--custom-blocks-init-error-pre-text: #37352f;
|
|
24
|
+
--custom-blocks-init-error-shadow: rgba(0, 0, 0, 0.08);
|
|
25
25
|
|
|
26
26
|
box-sizing: border-box;
|
|
27
27
|
min-height: 240px;
|
|
@@ -29,81 +29,81 @@
|
|
|
29
29
|
align-items: center;
|
|
30
30
|
justify-content: center;
|
|
31
31
|
padding: 24px;
|
|
32
|
-
background: var(--
|
|
33
|
-
color: var(--
|
|
32
|
+
background: var(--custom-blocks-init-error-background);
|
|
33
|
+
color: var(--custom-blocks-init-error-text);
|
|
34
34
|
font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
|
35
35
|
color-scheme: light;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
.
|
|
38
|
+
.custom-blocks-default-init-error__card {
|
|
39
39
|
box-sizing: border-box;
|
|
40
40
|
width: 100%;
|
|
41
41
|
max-width: 420px;
|
|
42
42
|
padding: 20px;
|
|
43
|
-
border: 1px solid var(--
|
|
43
|
+
border: 1px solid var(--custom-blocks-init-error-border);
|
|
44
44
|
border-radius: 12px;
|
|
45
|
-
background: var(--
|
|
46
|
-
box-shadow: 0 8px 24px var(--
|
|
45
|
+
background: var(--custom-blocks-init-error-card-background);
|
|
46
|
+
box-shadow: 0 8px 24px var(--custom-blocks-init-error-shadow);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.
|
|
49
|
+
.custom-blocks-default-init-error__eyebrow {
|
|
50
50
|
margin-bottom: 8px;
|
|
51
51
|
font-size: 11px;
|
|
52
52
|
font-weight: 600;
|
|
53
53
|
letter-spacing: 0.08em;
|
|
54
54
|
text-transform: uppercase;
|
|
55
|
-
color: var(--
|
|
55
|
+
color: var(--custom-blocks-init-error-eyebrow-text);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
.
|
|
58
|
+
.custom-blocks-default-init-error__title {
|
|
59
59
|
margin: 0;
|
|
60
60
|
font-size: 18px;
|
|
61
61
|
line-height: 1.3;
|
|
62
62
|
font-weight: 650;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
.
|
|
65
|
+
.custom-blocks-default-init-error__body {
|
|
66
66
|
margin: 8px 0 0;
|
|
67
67
|
font-size: 14px;
|
|
68
68
|
line-height: 1.5;
|
|
69
|
-
color: var(--
|
|
69
|
+
color: var(--custom-blocks-init-error-muted-text);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
.
|
|
72
|
+
.custom-blocks-default-init-error__details {
|
|
73
73
|
margin-top: 14px;
|
|
74
74
|
font-size: 12px;
|
|
75
|
-
color: var(--
|
|
75
|
+
color: var(--custom-blocks-init-error-muted-text);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
.
|
|
78
|
+
.custom-blocks-default-init-error__pre {
|
|
79
79
|
margin: 8px 0 0;
|
|
80
80
|
padding: 10px;
|
|
81
81
|
overflow: auto;
|
|
82
82
|
border-radius: 8px;
|
|
83
|
-
background: var(--
|
|
84
|
-
color: var(--
|
|
83
|
+
background: var(--custom-blocks-init-error-pre-background);
|
|
84
|
+
color: var(--custom-blocks-init-error-pre-text);
|
|
85
85
|
font-size: 12px;
|
|
86
86
|
line-height: 1.4;
|
|
87
87
|
white-space: pre-wrap;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
@media (prefers-color-scheme: dark) {
|
|
91
|
-
.
|
|
92
|
-
--
|
|
93
|
-
--
|
|
94
|
-
--
|
|
91
|
+
.custom-blocks-standalone-banner {
|
|
92
|
+
--custom-blocks-standalone-banner-background: #3b2f0b;
|
|
93
|
+
--custom-blocks-standalone-banner-border: #6f5713;
|
|
94
|
+
--custom-blocks-standalone-banner-text: #f5d36c;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
.
|
|
98
|
-
--
|
|
99
|
-
--
|
|
100
|
-
--
|
|
101
|
-
--
|
|
102
|
-
--
|
|
103
|
-
--
|
|
104
|
-
--
|
|
105
|
-
--
|
|
106
|
-
--
|
|
97
|
+
.custom-blocks-default-init-error {
|
|
98
|
+
--custom-blocks-init-error-background: #191918;
|
|
99
|
+
--custom-blocks-init-error-card-background: #20201f;
|
|
100
|
+
--custom-blocks-init-error-border: #373633;
|
|
101
|
+
--custom-blocks-init-error-text: #f1f1ef;
|
|
102
|
+
--custom-blocks-init-error-muted-text: #b9b8b3;
|
|
103
|
+
--custom-blocks-init-error-eyebrow-text: #9b9a97;
|
|
104
|
+
--custom-blocks-init-error-pre-background: #2a2a28;
|
|
105
|
+
--custom-blocks-init-error-pre-text: #e8e8e4;
|
|
106
|
+
--custom-blocks-init-error-shadow: rgba(0, 0, 0, 0.35);
|
|
107
107
|
|
|
108
108
|
color-scheme: dark;
|
|
109
109
|
}
|
|
@@ -80,7 +80,7 @@ export function NotionCustomBlock({
|
|
|
80
80
|
if (!isStandalone) {
|
|
81
81
|
return
|
|
82
82
|
}
|
|
83
|
-
console.warn(`[
|
|
83
|
+
console.warn(`[custom-blocks-sdk] ${init.error?.message}`)
|
|
84
84
|
seedStandalonePreviewState()
|
|
85
85
|
}, [isStandalone, init.error])
|
|
86
86
|
|
|
@@ -107,7 +107,7 @@ export function NotionCustomBlock({
|
|
|
107
107
|
}
|
|
108
108
|
return (
|
|
109
109
|
<>
|
|
110
|
-
<div role="status" className="
|
|
110
|
+
<div role="status" className="custom-blocks-standalone-banner">
|
|
111
111
|
Notion host not detected — running in standalone preview. SDK hooks
|
|
112
112
|
return placeholder values until embedded in Notion.
|
|
113
113
|
</div>
|
|
@@ -125,25 +125,29 @@ export function NotionCustomBlock({
|
|
|
125
125
|
function DefaultInitErrorFallback({ error }: { error: Error }) {
|
|
126
126
|
useEffect(() => {
|
|
127
127
|
console.warn(
|
|
128
|
-
`[
|
|
128
|
+
`[custom-blocks-sdk] Custom block init failed: ${error.message}`,
|
|
129
129
|
)
|
|
130
130
|
}, [error])
|
|
131
131
|
|
|
132
132
|
return (
|
|
133
|
-
<div role="alert" className="
|
|
134
|
-
<div className="
|
|
135
|
-
<div className="
|
|
136
|
-
|
|
133
|
+
<div role="alert" className="custom-blocks-default-init-error">
|
|
134
|
+
<div className="custom-blocks-default-init-error__card">
|
|
135
|
+
<div className="custom-blocks-default-init-error__eyebrow">
|
|
136
|
+
Custom block
|
|
137
|
+
</div>
|
|
138
|
+
<h2 className="custom-blocks-default-init-error__title">
|
|
137
139
|
Couldn't connect to Notion
|
|
138
140
|
</h2>
|
|
139
|
-
<p className="
|
|
141
|
+
<p className="custom-blocks-default-init-error__body">
|
|
140
142
|
This custom block loaded, but the setup handshake didn't finish.
|
|
141
143
|
Try again from Notion. If this keeps happening, check the browser
|
|
142
144
|
console for SDK details.
|
|
143
145
|
</p>
|
|
144
|
-
<details className="
|
|
146
|
+
<details className="custom-blocks-default-init-error__details">
|
|
145
147
|
<summary>Developer details</summary>
|
|
146
|
-
<pre className="
|
|
148
|
+
<pre className="custom-blocks-default-init-error__pre">
|
|
149
|
+
{error.message}
|
|
150
|
+
</pre>
|
|
147
151
|
</details>
|
|
148
152
|
</div>
|
|
149
153
|
</div>
|
|
@@ -12,7 +12,7 @@ export function seedStandalonePreviewState() {
|
|
|
12
12
|
theme: "light",
|
|
13
13
|
blockId: previewBlockId,
|
|
14
14
|
parent: { type: "page_id", page_id: previewPageId },
|
|
15
|
-
page: { id: previewPageId },
|
|
15
|
+
page: { id: previewPageId, parent: { type: "workspace", workspace: true } },
|
|
16
16
|
dataSources: { bindings: {} },
|
|
17
17
|
currentUser: {
|
|
18
18
|
object: "user",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useState } from "react"
|
|
2
2
|
import { CustomBlockInitError } from "../bridge/messages/init.js"
|
|
3
3
|
import {
|
|
4
|
-
type
|
|
4
|
+
type CustomBlockInitPayload,
|
|
5
5
|
type InitCustomBlockOptions,
|
|
6
6
|
initCustomBlock,
|
|
7
7
|
NotInIframeError,
|
|
@@ -22,7 +22,7 @@ export type CustomBlockInitFailure = CustomBlockInitError | NotInIframeError
|
|
|
22
22
|
export type UseCustomBlockInitResult =
|
|
23
23
|
| { isLoaded: false; error: undefined }
|
|
24
24
|
| { isLoaded: false; error: CustomBlockInitFailure }
|
|
25
|
-
| { isLoaded: true; error: undefined; initial:
|
|
25
|
+
| { isLoaded: true; error: undefined; initial: CustomBlockInitPayload }
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* React wrapper around {@link initCustomBlock}. Kicks off the SDK ↔ host
|
package/src/utils.ts
CHANGED
package/src/version.ts
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* This checked-in value intentionally stays generic for local development. The SDK publish build
|
|
6
6
|
* overwrites the compiled runtime module with package.json's semver before publishing.
|
|
7
7
|
*/
|
|
8
|
-
export const
|
|
8
|
+
export const CUSTOM_BLOCKS_SDK_VERSION: string = "0.0.0"
|