Skip to content

Commit 868ba3b

Browse files
committed
Add toggle list support
1 parent 0f53569 commit 868ba3b

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
![npm version](https://badgen.net/npm/v/react-notion) ![npm version](https://badgen.net/david/dep/splitbee/react-notion) ![minzipped sized](https://badgen.net/bundlephobia/minzip/react-notion)
44

5-
65
A React renderer for Notion pages.
76
Use Notion as CMS for your blog, documentation or personal site.
87

@@ -111,14 +110,14 @@ Most common block types are supported. We happily accept pull requests to add su
111110
| Link | ✅ Yes | |
112111
| Code | ✅ Yes | |
113112
| Web Bookmark | ✅ Yes | |
113+
| Toggle List | ✅ Yes | |
114114
| Databases | ❌ Missing | |
115115
| Checkbox | ❌ Missing | |
116-
| Toggle List | ❌ Missing | |
117116
| Table Of Contents | ❌ Missing | |
118117

119118
## Credits
120119

121120
- [Tobias Lins](https://tobi.sh) – Idea, Code
122121
- [Timo Lins](https://timo.sh) – Code, Documentation
123122
- [samwightt](https://github.com/samwightt) – Inspiration & API Typings
124-
- [All people that contributed 💕](https://github.com/splitbee/react-notion/graphs/contributors)
123+
- [All people that contributed 💕](https://github.com/splitbee/react-notion/graphs/contributors)

src/block.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,13 @@ export const Block: React.FC<Block> = props => {
245245
</a>
246246
</div>
247247
);
248+
case "toggle":
249+
return (
250+
<details className="notion-toggle">
251+
<summary>{renderChildText(blockValue.properties.title)}</summary>
252+
<div>{children}</div>
253+
</details>
254+
);
248255
default:
249256
if (process.env.NODE_ENV !== "production") {
250257
console.log("Unsupported type " + block?.value?.type);

src/styles.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ h3 {
219219

220220
.notion-list li {
221221
padding: 6px 0px;
222+
white-space: pre-wrap;
222223
}
223224

224225
.notion-asset-wrapper {
@@ -232,7 +233,6 @@ h3 {
232233

233234
.notion-text {
234235
white-space: pre-wrap;
235-
word-break: break-word;
236236
caret-color: rgb(55, 53, 47);
237237
}
238238
.notion-block {
@@ -399,3 +399,7 @@ h3 {
399399
.notion-callout-text {
400400
margin-left: 8px;
401401
}
402+
403+
.notion-toggle > div {
404+
margin-left: 1.1em;
405+
}

src/types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ interface CalloutValueType extends BaseValueType {
182182
};
183183
}
184184

185+
interface ToggleValueType extends BaseValueType {
186+
type: "toggle";
187+
properties: {
188+
title: DecorationType[];
189+
};
190+
}
191+
185192
export interface ContentValueType extends BaseValueType {
186193
properties: {
187194
source: string[][];
@@ -238,7 +245,8 @@ export type BlockValueType =
238245
| VideoValueType
239246
| EmbedValueType
240247
| CalloutValueType
241-
| BookmarkValueType;
248+
| BookmarkValueType
249+
| ToggleValueType;
242250

243251
export interface BlockType {
244252
role: string;

0 commit comments

Comments
 (0)