Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d893c6a
Added toggle heading
matthewlipski May 21, 2025
d77eca5
Changed collapsible heading to toggle and added react implementation
matthewlipski May 21, 2025
ec26e4d
Removed duplicate code
matthewlipski May 21, 2025
00fbdae
Small changes
matthewlipski May 21, 2025
9d148ae
Extracted toggle to separate component
matthewlipski Jun 10, 2025
7a7a2db
Added missing export
matthewlipski Jun 10, 2025
a484779
Added vanilla toggle heading block
matthewlipski Jun 10, 2025
7ce587d
Added translations
matthewlipski Jun 10, 2025
cb159d6
Typing fix
matthewlipski Jun 10, 2025
d7a6d7d
Made heading custom block to extend for toggle heading
matthewlipski Jun 11, 2025
a3a88f9
Small fix
matthewlipski Jun 11, 2025
2c12f1b
Removed toggle heading block and added `isTogglable` prop to regular …
matthewlipski Jun 11, 2025
238843a
Slightly changed how the toggle wrapper works
matthewlipski Jun 11, 2025
9378ef0
Changed heading block to again use `createStronglyTypedTiptapNode` in…
matthewlipski Jun 11, 2025
c603d4c
Added toggle list item default block
matthewlipski Jun 11, 2025
1f78656
Merge branch 'main' into toggle-blocks
matthewlipski Jun 11, 2025
1c2786e
Updated lock file
matthewlipski Jun 11, 2025
9b27b94
Updated unit tests
matthewlipski Jun 11, 2025
ff157b3
Updated PW tests
matthewlipski Jun 11, 2025
0b0f210
fix tests
YousefED Jun 12, 2025
90a029d
Merge branch 'main' into toggle-blocks
matthewlipski Jun 12, 2025
d322a9f
update snaps
YousefED Jun 12, 2025
b1848f3
Merge remote-tracking branch 'origin/main' into toggle-blocks
YousefED Jun 12, 2025
88bb5c3
Small cleanup
matthewlipski Jun 12, 2025
cbf23a2
Merge branch 'toggle-blocks' of github.com:TypeCellOS/BlockNote into …
matthewlipski Jun 12, 2025
860bcd5
Improved keyboard handling
matthewlipski Jun 12, 2025
c3b2f58
Updated `ToggleWrapper` keyboard handling
matthewlipski Jun 12, 2025
3533091
Skip AI tests
matthewlipski Jun 12, 2025
7ee4788
Updated PW snap
matthewlipski Jun 12, 2025
1b0cced
Implemented PR feedback
matthewlipski Jun 13, 2025
66c4e42
Implemented PR feedback
matthewlipski Jun 16, 2025
9767c52
Updated lockfile
matthewlipski Jun 16, 2025
09608a5
Updated PW snaps
matthewlipski Jun 16, 2025
33912b8
Implemented PR feedback
matthewlipski Jun 16, 2025
df3c678
Updated PW snaps
matthewlipski Jun 17, 2025
6f31924
Implemented PR feedback
matthewlipski Jun 18, 2025
c8df257
chore: update translations
nperez0111 Jun 20, 2025
5435942
chore: update translations
nperez0111 Jun 20, 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
6 changes: 6 additions & 0 deletions examples/06-custom-schema/06-togglable-blocks/.bnexample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"playground": true,
"docs": true,
"author": "matthewlipski",
"tags": ["Basic"]
}
55 changes: 55 additions & 0 deletions examples/06-custom-schema/06-togglable-blocks/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { BlockNoteSchema, defaultBlockSpecs } from "@blocknote/core";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useCreateBlockNote } from "@blocknote/react";

import { ToggleBlock } from "./Toggle.js";

// Our schema with block specs, which contain the configs and implementations for
// blocks that we want our editor to use.
const schema = BlockNoteSchema.create({
blockSpecs: {
// Adds all default blocks.
...defaultBlockSpecs,
// Adds the Alert block.
toggle: ToggleBlock,
},
});

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
schema,
initialContent: [
{
type: "paragraph",
content: "Welcome to this demo!",
},
{
type: "toggle",
content: "This is an example toggle",
children: [
{
type: "paragraph",
content: "This is the first child of the toggle block.",
},
{
type: "paragraph",
content: "This is the second child of the toggle block.",
},
],
},
{
type: "paragraph",
content: "Click the '>' icon to show/hide its children",
},
{
type: "paragraph",
},
],
});

// Renders the editor instance.
return <BlockNoteView editor={editor} />;
}
8 changes: 8 additions & 0 deletions examples/06-custom-schema/06-togglable-blocks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Togglable Blocks

This example shows how to create blocks with a toggle button to show/hide their children. This is done using the use the `ToggleWrapper` component from `@blocknote/react`.

**Relevant Docs:**

- [Custom Blocks](/docs/custom-schemas/custom-blocks)
- [Editor Setup](/docs/editor-basics/setup)
19 changes: 19 additions & 0 deletions examples/06-custom-schema/06-togglable-blocks/Toggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defaultProps } from "@blocknote/core";
import { createReactBlockSpec, ToggleWrapper } from "@blocknote/react";

export const ToggleBlock = createReactBlockSpec(
{
type: "toggle",
propSchema: {
...defaultProps,
},
content: "inline",
},
{
render: (props) => (
<ToggleWrapper block={props.block} editor={props.editor}>
<p ref={props.contentRef} />
</ToggleWrapper>
),
},
);
14 changes: 14 additions & 0 deletions examples/06-custom-schema/06-togglable-blocks/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html lang="en">
<head>
<script>
<!-- AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY -->
</script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Togglable Blocks</title>
</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/06-togglable-blocks/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 "./App.jsx";

const root = createRoot(document.getElementById("root")!);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
27 changes: 27 additions & 0 deletions examples/06-custom-schema/06-togglable-blocks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@blocknote/example-togglable-blocks",
"description": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
"private": true,
"version": "0.12.4",
"scripts": {
"start": "vite",
"dev": "vite",
"build:prod": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@blocknote/core": "latest",
"@blocknote/react": "latest",
"@blocknote/ariakit": "latest",
"@blocknote/mantine": "latest",
"@blocknote/shadcn": "latest",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "^4.3.1",
"vite": "^5.3.4"
}
}
36 changes: 36 additions & 0 deletions examples/06-custom-schema/06-togglable-blocks/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"__comment": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"composite": true
},
"include": [
"."
],
"__ADD_FOR_LOCAL_DEV_references": [
{
"path": "../../../packages/core/"
},
{
"path": "../../../packages/react/"
}
]
}
32 changes: 32 additions & 0 deletions examples/06-custom-schema/06-togglable-blocks/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY
import react from "@vitejs/plugin-react";
import * as fs from "fs";
import * as path from "path";
import { defineConfig } from "vite";
// import eslintPlugin from "vite-plugin-eslint";
// https://vitejs.dev/config/
export default defineConfig((conf) => ({
plugins: [react()],
optimizeDeps: {},
build: {
sourcemap: true,
},
resolve: {
alias:
conf.command === "build" ||
!fs.existsSync(path.resolve(__dirname, "../../packages/core/src"))
? {}
: ({
// Comment out the lines below to load a built version of blocknote
// or, keep as is to load live from sources with live reload working
"@blocknote/core": path.resolve(
__dirname,
"../../packages/core/src/"
),
"@blocknote/react": path.resolve(
__dirname,
"../../packages/react/src/"
),
} as any),
},
}));
Loading