Skip to content

Commit 8e0fb6c

Browse files
committed
update docs
1 parent 0a433ca commit 8e0fb6c

File tree

9 files changed

+114
-67
lines changed

9 files changed

+114
-67
lines changed

docs/pages/docs/ai.mdx

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,52 @@ Users can work with an AI agent to edit, write and format their documents.
1515

1616
[VIDEO]
1717

18-
- Try the [basic AI demo](/examples/ai/minimal)
19-
- ..or try different models in the [AI playground](/examples/ai/playground)
20-
- [Setup documentation](/docs/ai/getting-started)
21-
- TODO
18+
19+
<Callout>
20+
BlockNote AI is now in early preview - we'd love to hear your feedback!
21+
We also collaborate with companies to help with the integration or implement
22+
more advanced AI related functionality. [Get in touch](/about).
23+
</Callout>
2224

2325
## Features
2426

2527
BlockNote AI has been designed to be fully customizable.
2628
BlockNote shows exactly what the AI agent is doing - making it easy for users to
2729
work hand in hand with AI agents.
2830

29-
- Customize commands to write new content or update existing content or formatting
30-
- Streaming support for quick feedback
31-
- Users can accept or reject AI suggestions
32-
- Connect any LLM model (from Llama to OpenAI, Mistral or Anthropic)
33-
- Customizable prompts
34-
- Built directly on the [Vercel AI SDK](https://sdk.vercel.ai)
35-
- No dependency on our backend - use your own infrastructure or connect directly to a hosted LLM API
36-
- Feature requests? [Get in touch](/about).
31+
### User Experience
32+
33+
- **Interactive AI Suggestions**: Users can accept or reject AI suggestions with a simple click, maintaining full control over their content
34+
- **Real-time Feedback**: Streaming support provides immediate responses, making the AI interaction feel natural and responsive
35+
- **Transparent Operations**: See exactly what the AI is doing at each step, with clear visual indicators of AI actions
36+
37+
### Technical Capabilities
38+
39+
- **Flexible Command System**: Customize commands to write or update existing content and formatting
40+
- **Multi-step Workflows**: Support for "Human in the Loop" workflows where users can guide the AI
41+
- **Model Agnostic**: Connect any LLM model (from Llama to OpenAI, Mistral or Anthropic)
42+
- **Customizable Prompts**: Fine-tune AI behavior with custom prompts and instructions
43+
- **No Backend Required**: Use your own infrastructure or connect directly to a hosted LLM API
44+
45+
### Integration
46+
47+
- **Built on Vercel AI SDK**: Leverages the power of the [Vercel AI SDK](https://sdk.vercel.ai) for reliable AI integration
48+
- **Easy Setup**: Get started quickly with minimal configuration
49+
- **Completely Customizable**: Fully customizable commands and UI elements
3750

3851
<Callout type={"info"}>
3952
This feature is provided by the `@blocknote/xl-ai`. `xl-` packages are fully
4053
open source, but released under a copyleft license. A commercial license for
4154
usage in closed source, proprietary products comes as part of the [Business
4255
subscription](/pricing).
4356
</Callout>
57+
58+
### Next Steps
59+
60+
- Try the [basic AI demo](/examples/ai/minimal) to see it in action
61+
- Explore different models in the [AI playground](/examples/ai/playground)
62+
- Check out the [setup documentation](/docs/ai/getting-started)
63+
- Learn about [customizing commands](/docs/ai/custom-commands)
64+
- Review the [API Reference](/docs/ai/reference)
65+
66+
Have a feature request or need help with integration? [Get in touch](/about) with our team.

docs/pages/docs/ai/_meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"setup": "Editor Setup",
3-
"custom-commands": "Customizing Commands",
2+
"getting-started": "Getting Started",
3+
"custom-commands": "Custom Commands",
44
"reference": "Reference"
55
}

docs/pages/docs/ai/custom-commands.mdx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
# Customizing AI Menu Items (commands)
1+
---
2+
title: Custom AI Commands
3+
description: Customize the AI menu items (commands) in your BlockNote rich text editor
4+
imageTitle: BlockNote AI
5+
path: /docs/ai/custom-commands
6+
---
7+
8+
import { Example } from "@/components/example";
9+
import { Callout } from "nextra/components";
10+
11+
# Custom AI Menu Items (commands)
212

313
A central part when users are interacting with the AI agent is the _AI Suggestion Menu_ where users can enter a custom prompt or select a pre-defined command.
414

@@ -8,7 +18,7 @@ This menu is easy to customize so you can expose commands fine-tuned to your app
818

919
## Defining your own commands
1020

11-
First, we define a new AI command, let's create one that makes selected text more casual
21+
First, we define a new AI command. Let's create one that makes selected text more informal.
1222

1323
```tsx
1424
import { AIMenuSuggestionItem, getAIExtension } from "@blocknote/xl-ai";
@@ -39,7 +49,7 @@ export const makeInformal = (
3949
});
4050
```
4151

42-
Now, we let's create a customized AI Menu to show this command when the user has selected some text and opened the AI menu:
52+
Now, we create a customized AI Menu to show this command when the user has selected some text and opened the AI menu:
4353

4454
```tsx
4555
import { AIMenu, getDefaultAIMenuItems } from "@blocknote/xl-ai";
@@ -80,7 +90,7 @@ function CustomAIMenu() {
8090

8191
Now, let's use this custom AI Menu in our app:
8292

83-
````tsx
93+
```tsx
8494
<BlockNoteView
8595
editor={editor}
8696
formattingToolbar={false}
@@ -106,6 +116,4 @@ Have a look at the full example below, where we also add an AI menu item when no
106116
# Reference
107117

108118
So far, we've added basic commands to the editor, but it's possible to completely customize low level prompts sent to the LLM.
109-
To learn in detail about the methods available such as `callLLM`, continue to the [AI reference docs](/docs/ai/reference).
110-
111-
````
119+
To learn in detail about the `callLLM` method used in this guide, continue to the [AI reference docs](/docs/ai/reference).

docs/pages/docs/ai/setup.mdx renamed to docs/pages/docs/ai/getting-started.mdx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
---
2-
title: AI Rich Text Editing
2+
title: Getting Started with BlockNote AI
33
description: Add AI functionality to your BlockNote rich text editor
44
imageTitle: BlockNote AI
5-
path: /docs/ai
5+
path: /docs/ai/getting-started
66
---
77

88
import { Example } from "@/components/example";
99
import { Callout } from "nextra/components";
1010

1111
# Getting Started with BlockNote AI
1212

13+
This guide walks you through the steps to add AI functionality to your BlockNote rich text editor.
14+
1315
First, install the `@blocknote/xl-ai` package:
1416

1517
```bash
@@ -53,12 +55,8 @@ Now, you can create the editor with the AI Extension enabled:
5355
import { createBlockNoteEditor } from "@blocknote/core";
5456
import { BlockNoteAIExtension } from "@blocknote/xl-ai";
5557
import {
56-
AIToolbarButton,
57-
AIMenuController,
5858
locales as aiLocales,
5959
createAIExtension,
60-
createBlockNoteAIClient,
61-
getAISlashMenuItems,
6260
} from "@blocknote/xl-ai";
6361

6462
const editor = createBlockNoteEditor({
@@ -75,13 +73,17 @@ const editor = createBlockNoteEditor({
7573
});
7674
```
7775

78-
### The `createAIExtension` method
79-
80-
TODO
76+
See the [API Reference](/docs/ai/reference) for more information on the `createAIExtension` method.
8177

8278
## Adding AI UI elements
8379

8480
Now, the only thing left to do is to customize the UI elements of your editor.
81+
We want to:
82+
83+
- add an AI button to the formatting toolbar (shown when selecting text)
84+
- add an AI option to the slash menu (shown when typing a `/`)
85+
86+
We do this by disabling the default FormattingToolbar and SuggestionMenu and adding our own. See [Changing UI Elements](/docs/ui-components) for more information.
8587

8688
```tsx
8789
<BlockNoteView
@@ -105,4 +107,6 @@ Now, the only thing left to do is to customize the UI elements of your editor.
105107

106108
# Full Example
107109

110+
See the full example code and live demo. Select some text and click the AI (stars) button, or type `/ai` anywhere in the editor to access AI functionality.
111+
108112
<Example name="ai/minimal" />

docs/pages/docs/ai/reference.mdx

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
---
2+
title: BlockNote AI Reference
3+
description: Reference documentation for the BlockNote AI extension
4+
imageTitle: BlockNote AI
5+
path: /docs/ai/reference
6+
---
7+
8+
import { Example } from "@/components/example";
9+
import { Callout } from "nextra/components";
10+
111
# BlockNote AI Reference
212

313
## `createAIExtension`
@@ -8,14 +18,16 @@ Use `createAIExtension` to create a new AI new AI Extension that can be register
818
// Usage:
919
const aiExtension = createAIExtension(opts: AIExtensionOptions);
1020

11-
// Definition:
21+
// Definitions:
22+
function createAIExtension(options: AIExtensionOptions): (editor: BlockNoteEditor) => AIExtension;
23+
1224
type AIExtensionOptions = {
13-
/**
25+
/**
1426
* The default language model to use for LLM calls
1527
*/
1628
model: LanguageModel;
1729
/**
18-
* Whether to stream the LLM response (not all models might support this)
30+
* Whether to stream the LLM response
1931
* @default true
2032
*/
2133
stream?: boolean;
@@ -24,10 +36,10 @@ type AIExtensionOptions = {
2436
* html format is recommended, the other formats are experimental
2537
* @default llmFormats.html
2638
*/
27-
dataFormat?: "html" | "json" | "markdown";
39+
dataFormat?: LLMFormat;
2840
/**
2941
* A function that can be used to customize the prompt sent to the LLM
30-
* @default undefined
42+
* @default the default prompt builder for the selected {@link dataFormat}
3143
*/
3244
promptBuilder?: PromptBuilder;
3345
/**
@@ -44,7 +56,7 @@ type AIExtensionOptions = {
4456
Use `getAIExtension` to retrieve the AI extension instance registered to the editor:
4557

4658
```typescript
47-
getAIExtension(editor: BlockNoteEditor): AIExtension;
59+
function getAIExtension(editor: BlockNoteEditor): AIExtension;
4860
```
4961

5062
## `AIExtension`
@@ -66,8 +78,8 @@ class AIExtension {
6678
aiMenuState:
6779
| ({
6880
/**
69-
* The ID of the block that the AI menu is open at
70-
* this changes as the AI is making changes to the document
81+
* The ID of the block that the AI menu is opened at.
82+
* This changes as the AI is making changes to the document
7183
*/
7284
blockId: string;
7385
} & (
@@ -145,7 +157,8 @@ class AIExtension {
145157

146158
### `LLMRequestOptions`
147159

148-
Requests an LLM are made by calling `callLLM` on the `AIExtension` object.
160+
Requests to a LLM are made by calling `callLLM` on the `AIExtension` object.
161+
This takes a `LLMRequestOptions` object as an argument.
149162

150163
```typescript
151164
type LLMRequestOptions = {
@@ -253,12 +266,12 @@ type LLMRequestOptions = {
253266
};
254267
```
255268

256-
## (advanced) `doLLMRequest`
269+
## `doLLMRequest` (advanced)
257270

258271
The `CallLLM` function automatically passes the default options set in the `AIExtension` to the LLM request.
259-
It also handles the LLM response and the AI menu state
272+
It also handles the LLM response and updates the state of the AI menu accordingly.
260273

261-
For advanced use cases, you can also directly use the `doLLMRequest` to issue an LLM request.
274+
For advanced use cases, you can also directly use the lower-level `doLLMRequest` function to issue an LLM request directly.
262275
In this case, you will need to manually handle the response.
263276

264277
```typescript
@@ -287,6 +300,15 @@ To implement a custom `PromptBuilder`, you can use the `promptHelpers` provided
287300
We recommend looking at the [default PromptBuilder](https://github.com/TypeCellOS/BlockNote/blob/main/packages/xl-ai/src/api/formats/html-blocks/defaultHTMLPromptBuilder.ts) implementations as a starting point to implement your own.
288301

289302
```typescript
303+
/**
304+
* A PromptBuilder is a function that takes a BlockNoteEditor and details about the user's promot
305+
* and turns it into an array of CoreMessage (AI SDK) to be passed to the LLM.
306+
*/
307+
type PromptBuilder = (
308+
editor: BlockNoteEditor<any, any, any>,
309+
opts: PromptBuilderInput,
310+
) => Promise<Array<CoreMessage>>;
311+
290312
/**
291313
* The input passed to a PromptBuilder
292314
*/
@@ -311,15 +333,6 @@ type PromptBuilderInput = {
311333
*/
312334
previousMessages?: Array<CoreMessage>;
313335
};
314-
315-
/**
316-
* A PromptBuilder is a function that takes a BlockNoteEditor and details about the user's promot
317-
* and turns it into an array of CoreMessage (AI SDK) to be passed to the LLM.
318-
*/
319-
type PromptBuilder = (
320-
editor: BlockNoteEditor<any, any, any>,
321-
opts: PromptBuilderInput,
322-
) => Promise<Array<CoreMessage>>;
323336
```
324337

325338
## Formats

examples/09-ai/01-minimal/README.md

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

33
This example shows the minimal setup to add AI integration to your BlockNote rich text editor.
44

5-
Select some text and click the AI (magic wand) button, or type `/ai` anywhere in the editor to access AI functionality.
5+
Select some text and click the AI (stars) button, or type `/ai` anywhere in the editor to access AI functionality.
66

77
**Relevant Docs:**
88

9-
- [Editor Setup](/docs/editor-basics/setup)
9+
- [Getting Stared with BlockNote AI](/docs/ai/getting-started)
1010
- [Changing the Formatting Toolbar](/docs/ui-components/formatting-toolbar#changing-the-formatting-toolbar)
1111
- [Changing Slash Menu Items](/docs/ui-components/suggestion-menus#changing-slash-menu-items)
12-
- [Getting Stared with BlockNote AI](/docs/ai/setup)

examples/09-ai/02-playground/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Change the configuration, the highlight some text to access the AI menu, or type
66

77
**Relevant Docs:**
88

9-
- [Editor Setup](/docs/editor-basics/setup)
9+
- [Getting Stared with BlockNote AI](/docs/ai/getting-started)
10+
- [BlockNote AI Reference](/docs/ai/reference)
1011
- [Changing the Formatting Toolbar](/docs/ui-components/formatting-toolbar#changing-the-formatting-toolbar)
1112
- [Changing Slash Menu Items](/docs/ui-components/suggestion-menus#changing-slash-menu-items)
12-
- [Getting Stared with BlockNote AI](/docs/ai/setup)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Adding AI Menu Items
22

3-
In this example, we add two items to the AI Menu. The first prompts the AI to make the selected text more casual, and can be found by selecting some text and click the AI (magic wand) button. The second prompts the AI to give ideas on related topics to extend the document with, and can be found by clicking the "Ask AI" Slash Menu item.
3+
In this example, we add two items to the AI Menu. The first prompts the AI to make the selected text more casual, and can be found by selecting some text and click the AI (stars) button. The second prompts the AI to give ideas on related topics to extend the document with, and can be found by clicking the "Ask AI" Slash Menu item.
44

5-
Select some text and click the AI (magic wand) button, or type `/ai` anywhere in the editor to access AI functionality.
5+
Select some text and click the AI (stars) button, or type `/ai` anywhere in the editor to access AI functionality.
66

77
**Relevant Docs:**
88

9-
- [Getting Stared with BlockNote AI](/docs/ai/setup)
9+
- [Getting Stared with BlockNote AI](/docs/ai/getting-started)
1010
- [Custom AI Menu Items](/docs/ai/custom-commands)

packages/xl-ai/src/AIExtension.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ type AIPluginState = {
3535
aiMenuState:
3636
| ({
3737
/**
38-
* The ID of the block that the AI menu is open at
39-
* this changes as the AI is making changes to the document
38+
* The ID of the block that the AI menu is opened at.
39+
* This changes as the AI is making changes to the document
4040
*/
4141
blockId: string;
4242
} & (
@@ -64,20 +64,20 @@ type GlobalLLMRequestOptions = {
6464
* The default language model to use for LLM calls
6565
*/
6666
model: LanguageModel;
67+
/**
68+
* Whether to stream the LLM response
69+
* @default true
70+
*/
71+
stream?: boolean;
6772
/**
6873
* The default data format to use for LLM calls
6974
* html format is recommended, the other formats are experimental
7075
* @default llmFormats.html
7176
*/
7277
dataFormat?: LLMFormat;
73-
/**
74-
* Whether to stream the LLM response
75-
* @default true
76-
*/
77-
stream?: boolean;
7878
/**
7979
* A function that can be used to customize the prompt sent to the LLM
80-
* @default undefined
80+
* @default the default prompt builder for the selected {@link dataFormat}
8181
*/
8282
promptBuilder?: PromptBuilder;
8383
};

0 commit comments

Comments
 (0)