Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@
"y-partykit": "^0.0.25",
"yjs": "^13.6.27",
"zod": "^4.3.5",
"@blocknote/math-block": "workspace:*"
"@blocknote/math-block": "workspace:*",
"mermaid": "^11.0.0",
"@blocknote/diagram-block": "workspace:*",
"docx": "^9.6.1"
},
"devDependencies": {
"@blocknote/code-block": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
"playground": true,
"docs": true,
"author": "yousefed",
"tags": ["Interoperability"],
"tags": [
"Interoperability"
],
"dependencies": {
"@blocknote/xl-pdf-exporter": "latest",
"@blocknote/diagram-block": "latest",
"@blocknote/math-block": "latest",
"@blocknote/xl-multi-column": "latest",
"@blocknote/xl-pdf-exporter": "latest",
"@react-pdf/renderer": "^4.3.0"
},
"pro": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
"@mantine/hooks": "^9.0.2",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"@blocknote/xl-pdf-exporter": "latest",
"@blocknote/diagram-block": "latest",
"@blocknote/math-block": "latest",
"@blocknote/xl-multi-column": "latest",
"@blocknote/xl-pdf-exporter": "latest",
"@react-pdf/renderer": "^4.3.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import "@blocknote/core/fonts/inter.css";
import * as locales from "@blocknote/core/locales";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import {
createReactInlineMathSpec,
createReactMathBlockSpec,
} from "@blocknote/math-block";
import { createReactDiagramBlockSpec } from "@blocknote/diagram-block";
import {
SuggestionMenuController,
getDefaultReactSlashMenuItems,
Expand Down Expand Up @@ -38,7 +43,16 @@ export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
// Adds support for page breaks & multi-column blocks.
schema: withMultiColumn(withPageBreak(BlockNoteSchema.create())),
// Adds support for math & diagram blocks.
schema: withMultiColumn(withPageBreak(BlockNoteSchema.create())).extend({
blockSpecs: {
math: createReactMathBlockSpec(),
diagram: createReactDiagramBlockSpec(),
},
inlineContentSpecs: {
inlineMath: createReactInlineMathSpec(),
},
}),
dropCursor: multiColumnDropCursor,
dictionary: {
...locales.en,
Expand Down Expand Up @@ -330,6 +344,31 @@ export default function App() {
console.log("Hello World", message);
};`,
},
{
type: "math",
content: "a^2 = \\sqrt{b^2 + c^2}",
},
{
type: "diagram",
content: `graph TD
A[Start] --> B{Works?}
B -->|Yes| C[Ship it]
B -->|No| A`,
},
{
type: "paragraph",
content: [
{
type: "text",
text: "Inline math: ",
styles: {},
},
{
type: "inlineMath",
content: "e^{i\\pi} + 1 = 0",
},
],
},
{
type: "columnList",
children: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
"playground": true,
"docs": true,
"author": "yousefed",
"tags": [""],
"tags": [
""
],
"dependencies": {
"@blocknote/diagram-block": "latest",
"@blocknote/math-block": "latest",
"@blocknote/xl-docx-exporter": "latest",
"@blocknote/xl-multi-column": "latest"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"@mantine/hooks": "^9.0.2",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"@blocknote/diagram-block": "latest",
"@blocknote/math-block": "latest",
"@blocknote/xl-docx-exporter": "latest",
"@blocknote/xl-multi-column": "latest"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import "@blocknote/core/fonts/inter.css";
import * as locales from "@blocknote/core/locales";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import {
createReactInlineMathSpec,
createReactMathBlockSpec,
} from "@blocknote/math-block";
import { createReactDiagramBlockSpec } from "@blocknote/diagram-block";
import {
SuggestionMenuController,
getDefaultReactSlashMenuItems,
Expand All @@ -32,7 +37,16 @@ export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
// Adds support for page breaks & multi-column blocks.
schema: withMultiColumn(withPageBreak(BlockNoteSchema.create())),
// Adds support for math & diagram blocks.
schema: withMultiColumn(withPageBreak(BlockNoteSchema.create())).extend({
blockSpecs: {
math: createReactMathBlockSpec(),
diagram: createReactDiagramBlockSpec(),
},
inlineContentSpecs: {
inlineMath: createReactInlineMathSpec(),
},
}),
dropCursor: multiColumnDropCursor,
dictionary: {
...locales.en,
Expand Down Expand Up @@ -324,6 +338,31 @@ export default function App() {
console.log("Hello World", message);
};`,
},
{
type: "math",
content: "a^2 = \\sqrt{b^2 + c^2}",
},
{
type: "diagram",
content: `graph TD
A[Start] --> B{Works?}
B -->|Yes| C[Ship it]
B -->|No| A`,
},
{
type: "paragraph",
content: [
{
type: "text",
text: "Inline math: ",
styles: {},
},
{
type: "inlineMath",
content: "e^{i\\pi} + 1 = 0",
},
],
},

{
type: "columnList",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
"playground": true,
"docs": true,
"author": "areknawo",
"tags": [""],
"tags": [
""
],
"dependencies": {
"@blocknote/xl-odt-exporter": "latest",
"@blocknote/xl-multi-column": "latest"
"@blocknote/diagram-block": "latest",
"@blocknote/math-block": "latest",
"@blocknote/xl-multi-column": "latest",
"@blocknote/xl-odt-exporter": "latest"
},
"pro": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
"@mantine/hooks": "^9.0.2",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"@blocknote/xl-odt-exporter": "latest",
"@blocknote/xl-multi-column": "latest"
"@blocknote/diagram-block": "latest",
"@blocknote/math-block": "latest",
"@blocknote/xl-multi-column": "latest",
"@blocknote/xl-odt-exporter": "latest"
},
"devDependencies": {
"@types/react": "^19.2.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import * as locales from "@blocknote/core/locales";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import {
createReactInlineMathSpec,
createReactMathBlockSpec,
} from "@blocknote/math-block";
import { createReactDiagramBlockSpec } from "@blocknote/diagram-block";
import {
SuggestionMenuController,
getDefaultReactSlashMenuItems,
Expand All @@ -32,7 +37,16 @@ export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
// Adds support for page breaks & multi-column blocks.
schema: withMultiColumn(withPageBreak(BlockNoteSchema.create())),
// Adds support for math & diagram blocks.
schema: withMultiColumn(withPageBreak(BlockNoteSchema.create())).extend({
blockSpecs: {
math: createReactMathBlockSpec(),
diagram: createReactDiagramBlockSpec(),
},
inlineContentSpecs: {
inlineMath: createReactInlineMathSpec(),
},
}),
dropCursor: multiColumnDropCursor,
dictionary: {
...locales.en,
Expand Down Expand Up @@ -324,6 +338,31 @@ export default function App() {
console.log("Hello World", message);
};`,
},
{
type: "math",
content: "a^2 = \\sqrt{b^2 + c^2}",
},
{
type: "diagram",
content: `graph TD
A[Start] --> B{Works?}
B -->|Yes| C[Ship it]
B -->|No| A`,
},
{
type: "paragraph",
content: [
{
type: "text",
text: "Inline math: ",
styles: {},
},
{
type: "inlineMath",
content: "e^{i\\pi} + 1 = 0",
},
],
},
{
type: "columnList",
children: [
Expand Down
17 changes: 17 additions & 0 deletions examples/06-custom-schema/10-diagram-block/.bnexample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"playground": true,
"docs": true,
"author": "yousefed",
"tags": [
"Intermediate",
"Blocks",
"Custom Schemas",
"Suggestion Menus",
"Slash Menu"
],
"dependencies": {
"@blocknote/code-block": "latest",
"@blocknote/diagram-block": "latest",
"react-icons": "^5.5.0"
}
}
10 changes: 10 additions & 0 deletions examples/06-custom-schema/10-diagram-block/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Diagram Block

In this example, we register the `@blocknote/diagram-block` block in a custom schema. The block renders diagrams from [Mermaid](https://mermaid.js.org/) source code, showing the rendered diagram in place of the source and revealing an editable source popup when selected - built from the same `SourceBlockWithPreview` component the math block uses, so the block itself is only a few dozen lines.

**Try it out:** Click a diagram to edit its Mermaid source!

**Relevant Docs:**

- [Custom Blocks](/docs/features/custom-schemas/custom-blocks)
- [Editor Setup](/docs/getting-started/editor-setup)
14 changes: 14 additions & 0 deletions examples/06-custom-schema/10-diagram-block/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Diagram Block</title>
<script>
<!-- AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY -->
</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions examples/06-custom-schema/10-diagram-block/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY
import React from "react";
import { createRoot } from "react-dom/client";
import App from "./src/App.jsx";

const root = createRoot(document.getElementById("root")!);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>,
);
33 changes: 33 additions & 0 deletions examples/06-custom-schema/10-diagram-block/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@blocknote/example-custom-schema-diagram-block",
"description": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
"type": "module",
"private": true,
"version": "0.12.4",
"scripts": {
"start": "vp dev",
"dev": "vp dev",
"build:prod": "tsc && vp build",
"preview": "vp preview"
},
"dependencies": {
"@blocknote/ariakit": "latest",
"@blocknote/core": "latest",
"@blocknote/mantine": "latest",
"@blocknote/react": "latest",
"@blocknote/shadcn": "latest",
"@mantine/core": "^9.0.2",
"@mantine/hooks": "^9.0.2",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"@blocknote/code-block": "latest",
"@blocknote/diagram-block": "latest",
"react-icons": "^5.5.0"
},
"devDependencies": {
"@types/react": "^19.2.3",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.1",
"vite-plus": "catalog:"
}
}
Loading
Loading