Skip to content

Commit 8179f73

Browse files
committed
Merge remote-tracking branch 'origin/main' into releases
2 parents 54716a4 + 8cb5829 commit 8179f73

File tree

387 files changed

+11693
-3254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

387 files changed

+11693
-3254
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module.exports = {
2424
},
2525
},
2626
},
27+
ignorePatterns: ["**/ui/*"],
2728
rules: {
2829
curly: 1,
2930
"import/no-extraneous-dependencies": [

.github/ISSUE_TEMPLATE/bug_report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ assignees: ''
1111
<what's going wrong!?>
1212

1313
**To Reproduce**
14-
<links to a sandbox or clear steps to reproduce are super helpful!>
14+
<clear steps to reproduce are super helpful! Best is to provide an online sandbox, [click to create one](https://stackblitz.com/github/TypeCellOS/BlockNote/tree/main/examples/01-basic/01-minimal?file=App.tsx)>
1515

1616
**Misc**
1717
- Node version:

.github/ISSUE_TEMPLATE/feature_request.md

+3
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ A clear and concise description of any alternative solutions or features you've
1818

1919
**Additional context**
2020
Add any other context or screenshots about the feature request here.
21+
22+
**Bonus**
23+
[ ] I'm a [sponsor](https://github.com/sponsors/YousefED) and would appreciate if you could look into this sooner than later 💖

docs/components/pages/landing/hero/DemoEditor.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "@blocknote/core";
22
import "@blocknote/core/fonts/inter.css";
3-
import { BlockNoteView, useCreateBlockNote } from "@blocknote/react";
4-
import "@blocknote/react/style.css";
3+
import { useCreateBlockNote } from "@blocknote/react";
4+
import { BlockNoteView } from "@blocknote/mantine";
5+
import "@blocknote/mantine/style.css";
56
import { useCallback, useMemo, useState } from "react";
67
import YPartyKitProvider from "y-partykit/provider";
78
import * as Y from "yjs";

docs/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"dependencies": {
1212
"@blocknote/core": "^0.12.4",
1313
"@blocknote/react": "^0.12.4",
14+
"@blocknote/ariakit": "^0.12.4",
15+
"@blocknote/mantine": "^0.12.4",
16+
"@blocknote/shadcn": "^0.12.4",
1417
"@headlessui/react": "^1.7.18",
1518
"@mantine/core": "^7.7.1",
1619
"@next/bundle-analyzer": "^14.1.0",

docs/pages/docs/advanced/ariakit.mdx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: BlockNote with Ariakit
3+
description: Ariakit rich text editor with BlockNote
4+
imageTitle: BlockNote with Ariakit
5+
---
6+
7+
import { Example } from "@/components/example";
8+
import { Callout } from "nextra/components";
9+
10+
## Using Ariakit with BlockNote
11+
12+
[Ariakit](https://ariakit.org/) is an open-source library of unstyled (headless), primitive components with a focus on Accessibility. To use BlockNote with Ariakit, you can import `BlockNoteView` from `@blocknote/ariakit` (instead of from `@blocknote/mantine`).
13+
14+
You can fully style the components with your own CSS, or import the provided default styles using the CSS file from `@blocknote/ariakit/style.css`.
15+
16+
<Example name="basic/ariakit" />

docs/pages/docs/advanced/nextjs.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Next.js and BlockNote
33
description: Details on integrating BlockNote with Next.js
44
imageTitle: Next.js and BlockNote
5-
path: /docs/nextjs
65
---
76

87
# Next.js and BlockNote

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

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Real-time Collaborative rich text editor
33
description: Let's see how you can add Multiplayer capabilities to your BlockNote setup, and allow real-time collaboration between users (similar to Google Docs)
44
imageTitle: Real-time Collaboration
5-
path: /docs/real-time-collaboration
65
---
76

87
# Real-time Collaboration (multiplayer text editor)

docs/pages/docs/advanced/shadcn.mdx

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: BlockNote with ShadCN and Tailwind
3+
description: ShadCN + Tailwind rich text editor using BlockNote
4+
imageTitle: BlockNote with ShadCN and Tailwind
5+
---
6+
7+
import { Example } from "@/components/example";
8+
import { Callout } from "nextra/components";
9+
10+
## Using ShadCN, Radix and Tailwind with BlockNote
11+
12+
[shadcn/ui](https://ui.shadcn.com/) is an open-source collection of React components based on [Radix](https://radix-ui.com/) and Tailwind. To use BlockNote with shadcn, you can import `BlockNoteView` from `@blocknote/shadcn` (instead of from `@blocknote/mantine`) and the stylesheet from `@blocknote/shadcn/style.css`.
13+
14+
<Example name="basic/shadcn" />
15+
16+
## ShadCN Customization
17+
18+
BlockNote comes with default shadcn components. However, it's likely that you have copied and possibly customized your own shadcn components in your project.
19+
To make BlockNote use the ShadCN components from your project instead of the default ones, you can pass them using the `shadCNComponents` prop of `BlockNoteView`:
20+
21+
```tsx
22+
import * as Button from "@/components/ui/button"
23+
import * as Select from "@/components/ui/select"
24+
25+
return (
26+
<BlockNoteView editor={editor} shadCNComponents={{
27+
Select,
28+
Button,
29+
...
30+
}} />
31+
);
32+
```
33+
34+
You can pass components from the following ShadCN modules:
35+
36+
- Badge
37+
- Button
38+
- Card
39+
- DropdownMenu
40+
- Form
41+
- Input
42+
- Label
43+
- Popover
44+
- Select
45+
- Tabs
46+
- Toggle
47+
- Tooltip
48+
49+
<Callout type="warning" emoji="⚠️">
50+
To ensure compatibility, your ShadCN components should not use Portals
51+
(comment these out from your DropdownMenu, Popover and Select components).
52+
</Callout>

docs/pages/docs/advanced/vanilla-js.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Usage Without React (Vanilla JS)
33
description: BlockNote is mainly designed as a quick and easy drop-in block-based editor for React apps, but can also be used in vanilla JavaScript apps.
44
imageTitle: Usage Without React (Vanilla JS)
5-
path: /docs/vanilla-js
65
---
76

87
import { Callout } from "nextra/components";

docs/pages/docs/editor-basics/setup.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ type BlockNoteEditorOptions = {
2424
defaultStyles?: boolean;
2525
uploadFile?: (file: File) => Promise<string>;
2626
collaboration?: CollaborationOptions;
27+
dictionary?: Dictionary;
2728
schema?: BlockNoteSchema;
29+
trailingBlock?: boolean;
2830
};
2931
```
3032

@@ -42,8 +44,12 @@ The hook takes two optional parameters:
4244

4345
`collaboration`: Options for enabling real-time collaboration. See [Real-time Collaboration](/docs/advanced/real-time-collaboration) for more info.
4446

47+
`dictionary`: Provide strings for localization. See the [Localization / i18n example](/examples/basic/localization).
48+
4549
`schema` (_advanced_): The editor schema if you want to extend your editor with custom blocks, styles, or inline content [Custom Schemas](/docs/custom-schemas).
4650

51+
`trailingBlock`: An option which user can pass with `false` value to disable the automatic creation of a trailing new block on the next line when the user types or edits any block. Defaults to `true` if undefined.
52+
4753
**deps:** Dependency array that's internally passed to `useMemo`. A new editor will only be created when this array changes.
4854

4955
<Callout type="info" emoji={"💡"}>

docs/pages/docs/quickstart.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Getting started with BlockNote is quick and easy. Install the required packages
1717
To install BlockNote with [NPM](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm), run:
1818

1919
```console
20-
npm install @blocknote/core @blocknote/react
20+
npm install @blocknote/core @blocknote/react @blocknote/mantine
2121
```
2222

2323
## Creating an Editor
@@ -26,7 +26,7 @@ With the `useCreateBlockNote` hook, we can create a new editor instance, then us
2626

2727
<Example name="basic/minimal" />
2828

29-
We also import `@blocknote/react/style.css` to add default styling for the editor and the `Inter` font that BlockNote exports (optional).
29+
We also import `@blocknote/mantine/style.css` to add default styling for the editor and the `Inter` font that BlockNote exports (optional).
3030

3131
<Callout type="warning" emoji={""}>
3232
<strong>Next.js usage (or other server-side React frameworks)</strong>

docs/pages/docs/styling-theming/overriding-css.mdx

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Within the editor's DOM structure, you'll find many elements have classes with t
3737

3838
`.bn-drag-handle-menu`: Element for the drag handle menu.
3939

40-
`.bn-slash-menu`: Element for the slash menu.
40+
`.bn-suggestion-menu`: Element for suggestion menu.
4141

4242
## BlockNote CSS Attributes
4343

@@ -52,5 +52,3 @@ For example, `[data-content-type="heading"][data-level="2"]` will select all hea
5252
## Mantine Classes
5353

5454
Because BlockNote uses [Mantine](https://mantine.dev/) for its UI, you can also write CSS rules using any of the default Mantine component classes.
55-
56-

docs/pages/docs/styling-theming/themes.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { Example } from "@/components/example";
1111

1212
Themes let you quickly change the basic look of the editor UI, including colors, borders, shadows, and font. If you want to set more complex styles on the editor, see [Overriding CSS](/docs/styling-theming/overriding-css).
1313

14+
_Themes are only available when using the default Mantine components. ShadCN / Ariakit components can be styled differently._
15+
1416
## Theme CSS Variables
1517

1618
A theme is made up of a set of CSS variables, which can be overwritten to change the editor theme. BlockNote comes with two default themes, one for light and one for dark mode, which are selected based on system preference.

docs/pages/docs/ui-components/_meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"side-menu": "Block Side Menu",
33
"formatting-toolbar": "Formatting Toolbar",
4-
"link-toolbar": {
4+
"hyperlink-toolbar": {
55
"title": "Link Toolbar",
66
"display": "hidden"
77
},

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

+2-9
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,14 @@ You can change or replace the Formatting Toolbar with your own React component.
2323

2424
<Example name="ui-components/formatting-toolbar-buttons" />
2525

26+
We first define our custom `BlueButton`. The `useComponentsContext` hook gets all components used internally by BlockNote, so we want to use `Components.FormattingToolbar.Button` for this.
27+
2628
We use the `FormattingToolbar` component to create a custom Formatting Toolbar. By specifying its children, we can replace the default buttons in the toolbar with our own.
2729

2830
This custom Formatting Toolbar is passed to a `FormattingToolbarController`, which controls its position and visibility (above or below the highlighted text).
2931

3032
Setting `formattingToolbar={false}` on `BlockNoteView` tells BlockNote not to show the default Formatting Toolbar.
3133

32-
<div className="nx-mt-6 nx-leading-7 first:nx-mt-0">
33-
<small>
34-
<strong>Tip:</strong> The children you pass to the `FormattingToolbar` component
35-
should be default selects/buttons (e.g. `BlockTypeSelect` & `BasicTextStyleButton`) or custom selects/buttons
36-
(`ToolbarSelect` & `ToolbarButton`). To see all the components you can use, head to the
37-
[Formatting Toolbar's source code](https://github.com/TypeCellOS/BlockNote/blob/main/packages/react/src/components/FormattingToolbar/mantine/FormattingToolbar.tsx).
38-
</small>
39-
</div>
40-
4134
## Changing Block Type Select (Dropdown) Items
4235

4336
The first element in the default Formatting Toolbar is the Block Type Select, and you can change the items in it. The demo makes the Block Type Select work for image blocks by adding an item to it.

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

+3-10
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,12 @@ TODO Image
1919

2020
You can change or replace the Link Toolbar with your own React component. In the demo below, a button is added to the default Link Toolbar, which opens a browser alert.
2121

22-
[//]: # (<Example name="ui-components/link-toolbar-buttons" />)
22+
[//]: # '<Example name="ui-components/link-toolbar-buttons" />'
23+
24+
We first define our custom `AlertButton`. The `useComponentsContext` hook gets all components used internally by BlockNote, so we want to use `Components.LinkToolbar.Button` for this.
2325

2426
We use the `LinkToolbar` component to create a custom Link Toolbar. By specifying its children, we can replace the default buttons in the toolbar with our own.
2527

2628
This custom Link Toolbar is passed to a `LinkToolbarController`, which controls its position and visibility (above or below the hovered link).
2729

2830
Setting `linkToolbar={false}` on `BlockNoteView` tells BlockNote not to show the default Link Toolbar.
29-
30-
<div className="nx-mt-6 nx-leading-7 first:nx-mt-0">
31-
<small>
32-
<strong>Tip:</strong> The children you pass to the `LinkToolbar`
33-
component should be default buttons (e.g. TODO) or custom selects/buttons
34-
(`ToolbarSelect` & `ToolbarButton`). To see all the components you can
35-
use, head to the [Link Toolbar's source code](link).
36-
</small>
37-
</div>

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

+2-9
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,14 @@ You can change or replace the Block Side Menu with your own React component. In
3131

3232
<Example name="ui-components/side-menu-buttons" />
3333

34+
We first define our custom `RemoveBlockButton`. The `useComponentsContext` hook gets all components used internally by BlockNote, so we want to use `Components.SideMenu.Button` for this.
35+
3436
We use the `SideMenu` component to create a custom Block Side Menu. By specifying its children, we can replace the default buttons in the menu with our own.
3537

3638
This custom Side Menu is passed to a `SideMenuController`, which controls its position and visibility (on the left side when you hover a block).
3739

3840
Setting `sideMenu={false}` on `BlockNoteView` tells BlockNote not to show the default Block Side Menu.
3941

40-
<div className="nx-mt-6 nx-leading-7 first:nx-mt-0">
41-
<small>
42-
<strong>Tip:</strong> The children you pass to the `SideMenu` component
43-
should be default buttons (e.g. `DragHandleButton`) or custom buttons
44-
(`SideMenuButton`). To see all the components you can use, head to the
45-
[Side Menu's source code](link).
46-
</small>
47-
</div>
48-
4942
## Changing Drag Handle Menu Items
5043

5144
You can also change the items in the Drag Handle Menu. The demo below adds an item that resets the block type to a paragraph.

docs/styles.css

+8
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,11 @@
22
@tailwind components;
33
@tailwind utilities;
44
@tailwind variants;
5+
6+
/* Hack needed because the ShadCN Tailwind config overrides the Nextra Tailwind
7+
config. This is a problem because ShadCN relies on CSS variables which are only
8+
scoped to the editor, and are undefined when Nextra components try to use them.
9+
Seems like this only affects border radius in the demos though. */
10+
body {
11+
--radius: 0.5rem;
12+
}

examples/01-basic/01-minimal/App.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "@blocknote/core/fonts/inter.css";
2-
import { BlockNoteView, useCreateBlockNote } from "@blocknote/react";
3-
import "@blocknote/react/style.css";
2+
import { useCreateBlockNote } from "@blocknote/react";
3+
import { BlockNoteView } from "@blocknote/mantine";
4+
import "@blocknote/mantine/style.css";
45

56
export default function App() {
67
// Creates a new editor instance.

examples/01-basic/01-minimal/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@blocknote/example-minimal",
33
"description": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
44
"private": true,
5-
"version": "0.12.0",
5+
"version": "0.12.4",
66
"scripts": {
77
"start": "vite",
88
"dev": "vite",
@@ -11,8 +11,11 @@
1111
"lint": "eslint . --max-warnings 0"
1212
},
1313
"dependencies": {
14-
"@blocknote/core": "^0.12.0",
15-
"@blocknote/react": "^0.12.0",
14+
"@blocknote/core": "^0.12.4",
15+
"@blocknote/react": "^0.12.4",
16+
"@blocknote/ariakit": "^0.12.4",
17+
"@blocknote/mantine": "^0.12.4",
18+
"@blocknote/shadcn": "^0.12.4",
1619
"react": "^18.2.0",
1720
"react-dom": "^18.2.0"
1821
},

examples/01-basic/02-block-objects/App.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Block } from "@blocknote/core";
22
import "@blocknote/core/fonts/inter.css";
3-
import { BlockNoteView, useCreateBlockNote } from "@blocknote/react";
4-
import "@blocknote/react/style.css";
3+
import { useCreateBlockNote } from "@blocknote/react";
4+
import { BlockNoteView } from "@blocknote/mantine";
5+
import "@blocknote/mantine/style.css";
56
import { useState } from "react";
67

78
import "./styles.css";

examples/01-basic/02-block-objects/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@blocknote/example-block-objects",
33
"description": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
44
"private": true,
5-
"version": "0.12.0",
5+
"version": "0.12.4",
66
"scripts": {
77
"start": "vite",
88
"dev": "vite",
@@ -11,8 +11,11 @@
1111
"lint": "eslint . --max-warnings 0"
1212
},
1313
"dependencies": {
14-
"@blocknote/core": "^0.12.0",
15-
"@blocknote/react": "^0.12.0",
14+
"@blocknote/core": "^0.12.4",
15+
"@blocknote/react": "^0.12.4",
16+
"@blocknote/ariakit": "^0.12.4",
17+
"@blocknote/mantine": "^0.12.4",
18+
"@blocknote/shadcn": "^0.12.4",
1619
"react": "^18.2.0",
1720
"react-dom": "^18.2.0"
1821
},

examples/01-basic/03-all-blocks/App.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "@blocknote/core/fonts/inter.css";
2-
import { BlockNoteView, useCreateBlockNote } from "@blocknote/react";
3-
import "@blocknote/react/style.css";
2+
import { useCreateBlockNote } from "@blocknote/react";
3+
import { BlockNoteView } from "@blocknote/mantine";
4+
import "@blocknote/mantine/style.css";
45

56
export default function App() {
67
// Creates a new editor instance.

examples/01-basic/03-all-blocks/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@blocknote/example-all-blocks",
33
"description": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
44
"private": true,
5-
"version": "0.12.0",
5+
"version": "0.12.4",
66
"scripts": {
77
"start": "vite",
88
"dev": "vite",
@@ -11,8 +11,11 @@
1111
"lint": "eslint . --max-warnings 0"
1212
},
1313
"dependencies": {
14-
"@blocknote/core": "^0.12.0",
15-
"@blocknote/react": "^0.12.0",
14+
"@blocknote/core": "^0.12.4",
15+
"@blocknote/react": "^0.12.4",
16+
"@blocknote/ariakit": "^0.12.4",
17+
"@blocknote/mantine": "^0.12.4",
18+
"@blocknote/shadcn": "^0.12.4",
1619
"react": "^18.2.0",
1720
"react-dom": "^18.2.0"
1821
},

0 commit comments

Comments
 (0)