Skip to content

Commit 18aedff

Browse files
docs: Quote block investigation fixes (#1576)
* Fixed a bunch of docs annoyances * Fixed theming * Reverted frontmatter deletions & `ImageBlockContent` changes * Fixed `async` types in docs
1 parent e4d045f commit 18aedff

File tree

28 files changed

+641
-105
lines changed

28 files changed

+641
-105
lines changed

docs/components/ThemedImage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export function ThemedImage(
66
darkImage: React.ComponentProps<typeof Image>["src"];
77
} & React.ComponentProps<typeof Image>,
88
) {
9-
const { theme } = useTheme();
9+
const { resolvedTheme } = useTheme();
1010
const { darkImage, ...rest } = props;
11-
if (theme === "dark") {
11+
if (resolvedTheme === "dark") {
1212
// eslint-disable-next-line jsx-a11y/alt-text
1313
return <Image {...rest} src={darkImage} />;
1414
} else {

docs/components/example/ThemedExample.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { examples } from "./generated/exampleComponents.gen";
66
export default function ThemedExample(props: { name: keyof typeof examples }) {
77
const example = examples[props.name];
88
const App = example.App;
9-
const { theme } = useTheme();
9+
const { resolvedTheme } = useTheme();
1010

1111
return (
1212
<BlockNoteContext.Provider
13-
value={{ colorSchemePreference: theme === "dark" ? "dark" : "light" }}>
13+
value={{ colorSchemePreference: resolvedTheme === "dark" ? "dark" : "light" }}>
1414
<App />
1515
</BlockNoteContext.Provider>
1616
);

docs/pages/docs/advanced/grid-suggestion-menus.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ imageTitle: Grid Suggestion Menus
55
---
66

77
import { Example } from "@/components/example";
8+
import { ThemedImage } from "@/components/ThemedImage";
89

910
# Grid Suggestion Menus
1011

@@ -18,10 +19,12 @@ The Emoji Picker is a Grid Suggestion Menu that opens with the `:` character (or
1819

1920
It only displays once the user types 2 non-whitespace characters a query, to minimize cases where the user only wants to enter the `:` character.
2021

21-
<img
22-
style={{ maxWidth: "400px" }}
22+
<ThemedImage
2323
src="/img/screenshots/emoji_picker.png"
24+
darkImage="/img/screenshots/emoji_picker_dark.png"
2425
alt="image"
26+
width={400}
27+
height={400}
2528
/>
2629

2730
### Changing Emoji Picker Columns

docs/pages/docs/collaboration/real-time-collaboration.mdx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ description: Let's see how you can add Multiplayer capabilities to your BlockNot
44
imageTitle: Real-time Collaboration
55
---
66

7+
import { ThemedImage } from "@/components/ThemedImage";
8+
79
# Real-time Collaboration (multiplayer text editor)
810

911
Let's see how you can add Multiplayer capabilities to your BlockNote setup, and allow real-time collaboration between users (similar to Google Docs):
1012

11-
<img
12-
style={{ maxWidth: "300px", border: "1px solid gray" }}
13+
<ThemedImage
14+
style={{ border: "1px solid gray" }}
1315
src="/img/features/collaboration_light.gif"
16+
darkImage="/img/features/collaboration_dark.gif"
1417
alt="text editing collaboration"
18+
width={300}
19+
height={300}
1520
/>
1621

1722
_Try the live demo on the [homepage](https://www.blocknotejs.org)_

docs/pages/docs/custom-schemas/custom-blocks.mdx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ const Alert = createReactBlockSpec(
4646
The Block Config describes the shape of your custom blocks. Use it to specify the type, properties (props) and content your custom blocks should support:
4747

4848
```typescript
49-
type CustomBlockConfig = {
49+
type BlockConfig = {
5050
type: string;
5151
content: "inline" | "none";
5252
readonly propSchema: PropSchema;
53+
isSelectable?: boolean;
54+
hardBreakShortcut?: "shift+enter" | "enter" | "none";
5355
};
5456
```
5557

@@ -87,6 +89,16 @@ type PropSchema<
8789
8890
_In the alert demo, we add a `type` prop for the type of alert that we want (warning / error / info / success). We also want basic styling options, so we add text alignment and text color from the [Default Block Properties](/docs/block-types#default-block-properties)._
8991
92+
**`isSelectable`**
93+
94+
Can be set to false in order to make the block non-selectable, both using the mouse and keyboard. This also helps with being able to select non-editable content within the block. Should only be set to false when `content` is `none` and defaults to true.
95+
96+
**`hardBreakShortcut`**
97+
98+
Defines which keyboard shortcut should be used to insert a hard break into the block's inline content. Defaults to `"shift+enter"`.
99+
100+
##### File Block Config
101+
90102
#### Block Implementation (`ReactCustomBlockImplementation`)
91103
92104
The Block Implementation defines how the block should be rendered in the editor, and how it should be parsed from and converted to HTML.
@@ -146,3 +158,11 @@ const schema = BlockNoteSchema.create({
146158
```
147159

148160
You can then instantiate your editor with this custom schema, as explained on the [Custom Schemas](/docs/custom-schemas) page.
161+
162+
### Improving the User Experience
163+
164+
Now you know how to create a custom block and add it to your editor. However, users don't have a way of creating instances of it to their documents.
165+
166+
To fix this, it's recommended to implement a [command to insert your custom in the Slash Menu](/docs/ui-components/suggestion-menus#changing-slash-menu-items), and [an item for it in the Block Type Select](/docs/ui-components/formatting-toolbar#changing-block-type-select-items). The demo below builds upon the earlier alert block example, adding both of these.
167+
168+
<Example name="custom-schema/alert-block-full-ux" />

docs/pages/docs/editor-api/converting-blocks.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ BlockNote can import / export Blocks to and from Markdown. Note that this is als
2828
`blocksToMarkdownLossy` converts `Block` objects to a Markdown string:
2929

3030
```typescript
31-
blocksToMarkdownLossy(blocks?: Block[]): string;
31+
async blocksToMarkdownLossy(blocks?: Block[]): Promise<string>;
3232

3333
// Usage
34-
const markdownFromBlocks = editor.blocksToMarkdownLossy(blocks);
34+
const markdownFromBlocks = await editor.blocksToMarkdownLossy(blocks);
3535
```
3636

3737
`blocks:` The blocks to convert. If not provided, the entire document (all top-level blocks) is used.
@@ -49,10 +49,10 @@ The output is simplified as Markdown does not support all features of BlockNote
4949
Use `tryParseMarkdownToBlocks` to try parsing a Markdown string into `Block` objects:
5050

5151
```typescript
52-
tryParseMarkdownToBlocks(markdown: string): Blocks[];
52+
async tryParseMarkdownToBlocks(markdown: string): Promise<Blocks[]>;
5353

5454
// Usage
55-
const blocksFromMarkdown = editor.tryParseMarkdownToBlocks(markdown);
55+
const blocksFromMarkdown = await editor.tryParseMarkdownToBlocks(markdown);
5656
```
5757

5858
`returns:` The blocks parsed from the Markdown string.
@@ -72,10 +72,10 @@ For example, you an use this for static rendering documents that have been creat
7272
Make sure to include the same stylesheets when you want to render the output HTML ([see example](/examples/backend/rendering-static-documents)).
7373

7474
```typescript
75-
blocksToFullHTML(blocks?: Block[]): string;
75+
async blocksToFullHTML(blocks?: Block[]): Promise<string>;
7676

7777
// Usage
78-
const HTMLFromBlocks = editor.blocksToFullHTML(blocks);
78+
const HTMLFromBlocks = await editor.blocksToFullHTML(blocks);
7979
```
8080

8181
`blocks:` The blocks to convert. If not provided, the entire document (all top-level blocks) is used.
@@ -93,10 +93,10 @@ Converting Blocks to HTML this way will lose some information such as the nestin
9393
Use `blocksToHTMLLossy` to export `Block` objects to an HTML string:
9494

9595
```typescript
96-
blocksToHTMLLossy(blocks?: Block[]): string;
96+
async blocksToHTMLLossy(blocks?: Block[]): Promise<string>;
9797

9898
// Usage
99-
const HTMLFromBlocks = editor.blocksToHTMLLossy(blocks);
99+
const HTMLFromBlocks = await editor.blocksToHTMLLossy(blocks);
100100
```
101101

102102
`blocks:` The blocks to convert. If not provided, the entire document (all top-level blocks) is used.
@@ -114,10 +114,10 @@ To better conform to HTML standards, children of blocks which aren't list items
114114
Use `tryParseHTMLToBlocks` to parse an HTML string to `Block` objects:
115115

116116
```typescript
117-
tryParseHTMLToBlocks(html: string): Blocks[];
117+
async tryParseHTMLToBlocks(html: string): Promise<Blocks[]>;
118118

119119
// Usage
120-
const blocksFromHTML = editor.tryParseHTMLToBlocks(html);
120+
const blocksFromHTML = await editor.tryParseHTMLToBlocks(html);
121121
```
122122

123123
`returns:` The blocks parsed from the HTML string.

docs/pages/docs/editor-basics/document-structure.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ description: Learn how documents (the content of the rich text editor) are struc
33
---
44

55
import { Example } from "@/components/example";
6+
import { ThemedImage } from "@/components/ThemedImage";
67

78
# Document Structure
89

@@ -13,10 +14,13 @@ Learn how documents (the content of the rich text editor) are structured to make
1314
Each BlockNote document is made up of a list of blocks.
1415
A block is a piece of content like a paragraph, heading, list item or image. Blocks can be dragged around by users in the editor. A block contains a piece of content and optionally nested (child) blocks:
1516

16-
<img
17+
<ThemedImage
18+
style={{ marginTop: "1em" }}
1719
src="/img/screenshots/block_structure.png"
20+
darkImage="/img/screenshots/block_structure_dark.png"
1821
alt="image"
19-
style={{ width: "100%", marginTop: "1em" }}
22+
width={2000}
23+
height={2000}
2024
/>
2125

2226
### Block Objects

docs/pages/docs/ui-components/formatting-toolbar.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ path: /docs/formatting-toolbar
66
---
77

88
import { Example } from "@/components/example";
9+
import { ThemedImage } from "@/components/ThemedImage";
910

1011
# Formatting Toolbar
1112

1213
The Formatting Toolbar appears whenever you highlight text in the editor.
1314

14-
<img
15-
style={{ maxWidth: "600px" }}
15+
<ThemedImage
1616
src="/img/screenshots/formatting_toolbar.png"
17+
darkImage="/img/screenshots/formatting_toolbar_dark.png"
1718
alt="image"
19+
width={600}
20+
height={600}
1821
/>
1922

2023
## Changing the Formatting Toolbar

docs/pages/docs/ui-components/image-toolbar.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ path: /docs/image-toolbar
66
---
77

88
import { Example } from "@/components/example";
9+
import { ThemedImage } from "@/components/ThemedImage";
910

1011
# Image Toolbar
1112

1213
The Image Toolbar appears whenever you select an image that doesn't have a URL, or when you click the "Replace Image" button in the [Formatting Toolbar](/docs/formatting-toolbar) when an image is selected.
1314

14-
<img style={{maxWidth: "600px"}} src="/img/screenshots/image_toolbar.png" alt="image" />
15+
<ThemedImage
16+
src="/img/screenshots/image_toolbar.png"
17+
darkImage="/img/screenshots/image_toolbar_dark.png"
18+
alt="image"
19+
width={600}
20+
height={600}
21+
/>
1522

1623
## Image Upload
1724

docs/pages/docs/ui-components/side-menu.mdx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,28 @@ path: /docs/side-menu
66
---
77

88
import { Example } from "@/components/example";
9+
import { ThemedImage } from "@/components/ThemedImage";
910

1011
# Block Side Menu
1112

1213
The Block Side Menu appears on the left side whenever you hover a block. By default, it consists of a `+` button and a drag handle (``):
1314

14-
<img
15-
style={{ maxWidth: "500px" }}
15+
<ThemedImage
1616
src="/img/screenshots/side_menu.png"
17-
alt="Side menu"
17+
darkImage="/img/screenshots/side_menu_dark.png"
18+
alt="image"
19+
width={500}
20+
height={500}
1821
/>
1922

2023
Clicking the drag handle (``) in the Block Side Menu opens the Drag Handle Menu:
2124

22-
<img
23-
style={{ maxWidth: "250px" }}
25+
<ThemedImage
2426
src="/img/screenshots/drag_handle_menu.png"
27+
darkImage="/img/screenshots/drag_handle_menu_dark.png"
2528
alt="image"
29+
width={250}
30+
height={250}
2631
/>
2732

2833
## Changing the Block Side Menu

0 commit comments

Comments
 (0)