Skip to content
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
fcdbf18
feat: wip
nperez0111 Jul 28, 2025
e1bb45e
feat: topological sorting, input rules and keyboard shortcuts
nperez0111 Jul 30, 2025
6b10846
feat: move code block over too
nperez0111 Jul 31, 2025
92952e7
feat: `getContent` parsing for custom blocks
nperez0111 Aug 1, 2025
6d85ef5
fix: render toggle lists
nperez0111 Aug 1, 2025
ec77940
fix: toggle headings
nperez0111 Aug 1, 2025
809ea0a
refactor: custom schema, which depends on no blocks
nperez0111 Aug 1, 2025
b46fcc6
refactor: trying to fit it in
nperez0111 Aug 4, 2025
5751974
fix: get tables working
nperez0111 Aug 4, 2025
c51767a
Made type guards more generic
matthewlipski Aug 5, 2025
97295ce
Updated type guard definitions
matthewlipski Aug 6, 2025
1ff7474
Small fix
matthewlipski Aug 6, 2025
9918510
feat: getting somewhere
nperez0111 Aug 6, 2025
1e0e059
Merge branch 'default-blocks-type-guards' into default-blocks
nperez0111 Aug 6, 2025
fc9e452
Removed `checkDefaultInlineContentTypeInSchema`
matthewlipski Aug 6, 2025
a0fc6e2
Small fixes
matthewlipski Aug 6, 2025
cda8eb6
fix: better parsing for headings
nperez0111 Aug 7, 2025
55957cd
chore: minor fix
nperez0111 Aug 8, 2025
dba7321
fix: widen type?
nperez0111 Aug 8, 2025
760be84
Merge branch 'default-blocks-type-guards' into default-blocks
nperez0111 Aug 8, 2025
f934d26
fix: remove tiptapblockimplementation
nperez0111 Aug 8, 2025
060108a
feat: Default blocks refactor fixes (#1953)
matthewlipski Aug 22, 2025
01478cd
Merge branch 'main' into default-blocks
nperez0111 Aug 25, 2025
cb8150c
refactor: settle the API a bit, migrate React to the new API, update …
nperez0111 Aug 26, 2025
ba57b93
feat: allow extending `blockSpecs` on a schema
nperez0111 Aug 28, 2025
71db2ba
build: trying to get the build to build again
nperez0111 Aug 28, 2025
36b9bd9
Merge branch 'main' into default-blocks
nperez0111 Aug 28, 2025
e41c137
chore: update prosemirror-model
nperez0111 Aug 28, 2025
1ddef1b
build: get things building again
nperez0111 Aug 28, 2025
62be3e2
test: get the tests further along
nperez0111 Aug 28, 2025
fda7be0
chore: rm unused
nperez0111 Aug 28, 2025
81c8d20
fix: better typing & support for hardBreakShortcut
nperez0111 Aug 28, 2025
ff2f039
Fixed export/copy test failures
matthewlipski Aug 28, 2025
fdbc419
Merge branch 'main' into default-blocks
nperez0111 Aug 29, 2025
41b2e43
fix: update the extend types
nperez0111 Aug 29, 2025
cf31ed6
chore: avoid withMultiColumn
nperez0111 Aug 29, 2025
a6ea62d
Fixed React export tests
matthewlipski Aug 29, 2025
703f86e
Merge branch 'default-blocks' of github.com:TypeCellOS/BlockNote into…
matthewlipski Aug 29, 2025
cd90895
Fixed most parse tests
matthewlipski Aug 29, 2025
258520f
Merge branch 'main' into default-blocks
matthewlipski Aug 31, 2025
dbc0c44
fix: minor typing bug
nperez0111 Sep 1, 2025
e3e4f5b
feat: inline content custom parse function
nperez0111 Sep 1, 2025
fc98fb8
Merge branch 'main' into default-blocks
nperez0111 Sep 1, 2025
ac0d392
Fixed remaining parse/paste issues
matthewlipski Sep 1, 2025
467b33d
Merge branch 'default-blocks' of github.com:TypeCellOS/BlockNote into…
matthewlipski Sep 1, 2025
f6cb1f9
Reverted example changes
matthewlipski Sep 1, 2025
a0e9443
Made select not render in code block if it has no options
matthewlipski Sep 1, 2025
5e3cad6
Updated unit test snaps
matthewlipski Sep 1, 2025
069f88f
chore: simpler `as const`
nperez0111 Sep 1, 2025
f4a0316
fix: rm heading & code-block opts
nperez0111 Sep 1, 2025
26b9b1c
Removed `codeBlock` and `heading` editor options & updated custom cod…
matthewlipski Sep 1, 2025
356aedc
Merge branch 'default-blocks-deprecate-options' into default-blocks
matthewlipski Sep 1, 2025
80963f4
Update examples
matthewlipski Sep 1, 2025
8ef6188
Updated code block docs & package export name
matthewlipski Sep 1, 2025
6b7bad8
chore: update comments
nperez0111 Sep 1, 2025
5dc2544
Fixed React custom block interactivity not working & added tests
matthewlipski Sep 1, 2025
87e57e3
Merge branch 'default-blocks' of github.com:TypeCellOS/BlockNote into…
matthewlipski Sep 1, 2025
17398cc
fix: update the types to have better inference based on options provided
nperez0111 Sep 2, 2025
95c493a
build: get build working again with better types
nperez0111 Sep 2, 2025
41d1449
build: finally get all the builds building
nperez0111 Sep 2, 2025
a92d1e7
fix: set default value
nperez0111 Sep 2, 2025
422cccb
fix: remove pageBreak from default schema
nperez0111 Sep 2, 2025
52a018c
refactor: move `meta` to block implementation instead of block config
nperez0111 Sep 2, 2025
84d50ce
test: update snap since order changed
nperez0111 Sep 2, 2025
05fbc87
chore: rm unused line
nperez0111 Sep 2, 2025
f242a2f
Minor fixes
matthewlipski Sep 2, 2025
59a7a63
Merge branch 'default-blocks' of github.com:TypeCellOS/BlockNote into…
matthewlipski Sep 2, 2025
b16a9ac
refactor: remove the strongly typed tiptap node abstraction
nperez0111 Sep 3, 2025
11f8633
feat: add `toExternalHTML` for custom inline content
nperez0111 Sep 3, 2025
b17a8d8
feat: support for react custom inline content
nperez0111 Sep 3, 2025
caf7ffd
Updated/fixed most e2e tests
matthewlipski Sep 3, 2025
b582be8
Merge branch 'default-blocks' of github.com:TypeCellOS/BlockNote into…
matthewlipski Sep 3, 2025
f9bca88
Updated remaining e2e snaps
matthewlipski Sep 3, 2025
ce882f1
fix: get the project to build again
nperez0111 Sep 3, 2025
eb049e2
refactor: remove `data-index` on numbered list item serialization
nperez0111 Sep 3, 2025
474897b
feat: support internal HTML as different from external HTML for inlin…
nperez0111 Sep 3, 2025
b4b56a9
chore: must please the linter
nperez0111 Sep 3, 2025
4b9d5d0
chore: minor changes
nperez0111 Sep 5, 2025
3f83c75
Merge branch 'main' into default-blocks
nperez0111 Sep 5, 2025
89ad4d5
Fixed old bug with HTML export not filling in unspecified props which…
matthewlipski Sep 5, 2025
6c0211a
Merge branch 'default-blocks' of github.com:TypeCellOS/BlockNote into…
matthewlipski Sep 5, 2025
52c7075
build: get build working again
nperez0111 Sep 9, 2025
4b40c57
refactor: use higher-level APIs
nperez0111 Sep 9, 2025
fdcfffb
refactor: export block types (and move blocks to separate sub-export)
nperez0111 Sep 9, 2025
3174b5b
chore: use helper function
nperez0111 Sep 9, 2025
cd788ad
refactor: move draggable to implementation
nperez0111 Sep 9, 2025
ddd3adf
fix: External HTML parse/export cases (#1991)
matthewlipski Sep 12, 2025
6e4beff
Merge branch 'main' into default-blocks
nperez0111 Sep 15, 2025
0246290
chore: rm console
nperez0111 Sep 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docs/app/(home)/hero/DemoEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
getMultiColumnSlashMenuItems,
locales as multiColumnLocales,
multiColumnDropCursor,
withMultiColumn,
ColumnListBlock,
ColumnBlock,
} from "@blocknote/xl-multi-column";
import "@blocknote/mantine/style.css";
import { useTheme } from "next-themes";
Expand Down Expand Up @@ -90,7 +91,12 @@ export default function DemoEditor() {
...locales.en,
multi_column: multiColumnLocales.en,
},
schema: withMultiColumn(BlockNoteSchema.create()),
schema: BlockNoteSchema.create().extend({
blockSpecs: {
column: ColumnBlock,
columnList: ColumnListBlock,
},
}),
dropCursor: multiColumnDropCursor,
collaboration: {
provider,
Expand Down
74 changes: 41 additions & 33 deletions docs/content/docs/features/blocks/code-blocks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,27 @@ Code blocks by default are a simple way to display code. But, BlockNote also sup
experience easy to use and reduce bundle size.
</Callout>

You can enable more advanced features by passing the `codeBlock` option when creating the editor.
You can enable more advanced features by extending the editor's default schema with a new `codeBlock`, which you can pass options into when creating. For more on extending the editor schema, see [Custom Schemas](/docs/features/custom-schemas).

```ts
const editor = new BlockNoteEditor({
codeBlock: {
indentLineWithTab: true,
defaultLanguage: "typescript",
supportedLanguages: {
typescript: {
name: "TypeScript",
aliases: ["ts"],
schema: BlockNoteSchema.create().extend({
codeBlock: createCodeBlockSpec({
indentLineWithTab: true,
defaultLanguage: "typescript",
supportedLanguages: {
typescript: {
name: "TypeScript",
aliases: ["ts"],
},
},
},
createHighlighter: () =>
createHighlighter({
themes: ["light-plus", "dark-plus"],
langs: [],
}),
},
createHighlighter: () =>
createHighlighter({
themes: ["light-plus", "dark-plus"],
langs: [],
}),
}),
}),
});
```

Expand All @@ -64,7 +66,7 @@ type CodeBlock = {

### Basic Setup

To enable code block syntax highlighting, you can use the `codeBlock` option in the `useCreateBlockNote` hook.
To enable code block syntax highlighting, you can extend the editor's default schema with a new `codeBlock`.

First, install the package:

Expand All @@ -75,20 +77,24 @@ npm install @blocknote/code-block
Then use it like this:

```tsx
import { codeBlock } from "@blocknote/code-block";
import { codeBlockOptions } from "@blocknote/code-block";

export default function App() {
const editor = useCreateBlockNote({
codeBlock,
schema: BlockNoteSchema.create().extend({
codeBlock: createCodeBlockSpec(codeBlockOptions),
}),
});

return <BlockNoteView editor={editor} />;
}
```

This will extend the default schema with a custom `codeBlock` that includes options from `@blocknote/code-block`, enabling syntax highlighting.

### Custom Themes & Languages

To configure a code block highlighting theme and language, you can use the `codeBlock` option in the `useCreateBlockNote` hook.
To configure a code block highlighting theme and language, you can again extend the editor's default schema with a new `codeBlock`.

This allows you to configure a [shiki](https://shiki.style) highlighter for the code blocks of your editor, allowing you to tailor the themes and languages you would like to use.

Expand All @@ -109,21 +115,23 @@ import { createHighlighter } from "./shiki.bundle.js";

export default function App() {
const editor = useCreateBlockNote({
codeBlock: {
indentLineWithTab: true,
defaultLanguage: "typescript",
supportedLanguages: {
typescript: {
name: "TypeScript",
aliases: ["ts"],
schema: BlockNoteSchema.create().extend({
codeBlock: createCodeBlockSpec({
indentLineWithTab: true,
defaultLanguage: "typescript",
supportedLanguages: {
typescript: {
name: "TypeScript",
aliases: ["ts"],
},
},
},
createHighlighter: () =>
createHighlighter({
themes: ["light-plus", "dark-plus"],
langs: [],
}),
},
createHighlighter: () =>
createHighlighter({
themes: ["light-plus", "dark-plus"],
langs: [],
}),
}),
}),
});

return <BlockNoteView editor={editor} />;
Expand Down
3 changes: 2 additions & 1 deletion examples/01-basic/01-minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@blocknote/ariakit": "latest",
"@blocknote/mantine": "latest",
"@blocknote/shadcn": "latest",
"@blocknote/code-block": "latest",
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
Expand All @@ -24,4 +25,4 @@
"@vitejs/plugin-react": "^4.3.1",
"vite": "^5.3.4"
}
}
}
10 changes: 8 additions & 2 deletions examples/01-basic/03-multi-column/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ import {
useCreateBlockNote,
} from "@blocknote/react";
import {
ColumnBlock,
ColumnListBlock,
getMultiColumnSlashMenuItems,
multiColumnDropCursor,
locales as multiColumnLocales,
withMultiColumn,
} from "@blocknote/xl-multi-column";
import { useMemo } from "react";
export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
// Adds column and column list blocks to the schema.
schema: withMultiColumn(BlockNoteSchema.create()),
schema: BlockNoteSchema.create().extend({
blockSpecs: {
column: ColumnBlock,
columnList: ColumnListBlock,
},
}),
// The default drop cursor only shows up above and below blocks - we replace
// it with the multi-column one that also shows up on the sides of blocks.
dropCursor: multiColumnDropCursor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const schema = BlockNoteSchema.create({
// Adds all default blocks.
...defaultBlockSpecs,
// Adds the Alert block.
alert: Alert,
alert: Alert(),
},
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
BlockSchema,
checkBlockIsFileBlock,
blockHasType,
InlineContentSchema,
StyleSchema,
} from "@blocknote/core";
Expand Down Expand Up @@ -41,7 +41,7 @@ export const FileReplaceButton = () => {

if (
block === undefined ||
!checkBlockIsFileBlock(block, editor) ||
!blockHasType(block, editor, "file", { url: "string" }) ||
!editor.isEditable
) {
return null;
Expand Down
3 changes: 2 additions & 1 deletion examples/04-theming/06-code-block/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Code Block Syntax Highlighting

To enable code block syntax highlighting, you can use the `codeBlock` option in the `useCreateBlockNote` hook. This is excluded by default to reduce bundle size.
To enable code block syntax highlighting, you can extend the editor's default schema with a new `codeBlock`, which you can pass options into when creating. By passing the default options from `@blocknote/code-block`, you can enable syntax highlighting. This is excluded by default to reduce bundle size.

**Relevant Docs:**

- [Code Block Syntax Highlighting](/docs/features/blocks/code-blocks)
- [Editor Setup](/docs/getting-started/editor-setup)
- [Custom Schema](/docs/features/custom-schemas)
9 changes: 7 additions & 2 deletions examples/04-theming/06-code-block/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { BlockNoteSchema, createCodeBlockSpec } from "@blocknote/core";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useCreateBlockNote } from "@blocknote/react";
// This packages some of the most used languages in on-demand bundle
import { codeBlock } from "@blocknote/code-block";
import { codeBlockOptions } from "@blocknote/code-block";

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
codeBlock,
schema: BlockNoteSchema.create().extend({
blockSpecs: {
codeBlock: createCodeBlockSpec(codeBlockOptions),
},
}),
initialContent: [
{
type: "codeBlock",
Expand Down
44 changes: 3 additions & 41 deletions examples/04-theming/07-custom-code-block/README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,11 @@
# Custom Code Block Theme & Language

To configure a code block highlighting theme and language, you can use the `codeBlock` option in the `useCreateBlockNote` hook.
To configure a code block highlighting theme and language, you can extend the editor's default schema with a new `codeBlock`, which you can pass options into when creating. You can then use a shiki highlighter to add custom syntax highlighting.

This allows you to configure a shiki highlighter for the code blocks of your editor, allowing you to tailor the themes and languages you would like to use.

To create a syntax highlighter, you can use the [shiki-codegen](https://shiki.style/packages/codegen) CLI for generating the code to create a syntax highlighter for your languages and themes.

For example to create a syntax highlighter using the optimized javascript engine, javascript, typescript, vue, with light and dark themes, you can run the following command:

```bash
npx shiki-codegen --langs javascript,typescript,vue --themes light,dark --engine javascript --precompiled ./shiki.bundle.ts
```

This will generate a `shiki.bundle.ts` file that you can use to create a syntax highlighter for your editor.

Like this:

```ts
import { createHighlighter } from "./shiki.bundle";

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
codeBlock: {
indentLineWithTab: true,
defaultLanguage: "typescript",
supportedLanguages: {
typescript: {
name: "TypeScript",
aliases: ["ts"],
},
},
createHighlighter: () =>
createHighlighter({
themes: ["light-plus", "dark-plus"],
langs: [],
}),
},
});

return <BlockNoteView editor={editor} />;
}
```
First use the [shiki-codegen](https://shiki.style/packages/codegen) CLI to create a `shiki.bundle.ts` file. You can then pass this file into the `codeBlock` options when creating it.

**Relevant Docs:**

- [Code Blocks](/docs/features/blocks/code-blocks)
- [shiki-codegen](https://shiki.style/packages/codegen)
- [Custom Schema](/docs/features/custom-schemas)
49 changes: 27 additions & 22 deletions examples/04-theming/07-custom-code-block/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BlockNoteSchema, createCodeBlockSpec } from "@blocknote/core";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
Expand All @@ -8,29 +9,33 @@ import { createHighlighter } from "./shiki.bundle";
export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
codeBlock: {
indentLineWithTab: true,
defaultLanguage: "typescript",
supportedLanguages: {
typescript: {
name: "TypeScript",
aliases: ["ts"],
},
javascript: {
name: "JavaScript",
aliases: ["js"],
},
vue: {
name: "Vue",
},
},
// This creates a highlighter, it can be asynchronous to load it afterwards
createHighlighter: () =>
createHighlighter({
themes: ["dark-plus", "light-plus"],
langs: [],
schema: BlockNoteSchema.create().extend({
blockSpecs: {
codeBlock: createCodeBlockSpec({
indentLineWithTab: true,
defaultLanguage: "typescript",
supportedLanguages: {
typescript: {
name: "TypeScript",
aliases: ["ts"],
},
javascript: {
name: "JavaScript",
aliases: ["js"],
},
vue: {
name: "Vue",
},
},
// This creates a highlighter, it can be asynchronous to load it afterwards
createHighlighter: () =>
createHighlighter({
themes: ["dark-plus", "light-plus"],
langs: [],
}),
}),
},
},
}),
initialContent: [
{
type: "codeBlock",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
BlockNoteSchema,
combineByGroup,
createPageBreakBlockSpec,
filterSuggestionItems,
withPageBreak,
} from "@blocknote/core";
import * as locales from "@blocknote/core/locales";
import "@blocknote/core/fonts/inter.css";
Expand All @@ -22,7 +22,8 @@ import {
getMultiColumnSlashMenuItems,
multiColumnDropCursor,
locales as multiColumnLocales,
withMultiColumn,
ColumnListBlock,
ColumnBlock,
} from "@blocknote/xl-multi-column";
import { PDFViewer } from "@react-pdf/renderer";
import { useEffect, useMemo, useState } from "react";
Expand All @@ -35,7 +36,13 @@ export default function App() {

// Creates a new editor instance with some initial content.
const editor = useCreateBlockNote({
schema: withMultiColumn(withPageBreak(BlockNoteSchema.create())),
schema: BlockNoteSchema.create().extend({
blockSpecs: {
pageBreak: createPageBreakBlockSpec(),
column: ColumnBlock,
columnList: ColumnListBlock,
},
}),
dropCursor: multiColumnDropCursor,
dictionary: {
...locales.en,
Expand Down
Loading
Loading