From 7fa3dbdead0c16a4bb0a4437e1591e469b9324dc Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Mon, 22 Sep 2025 12:00:24 +0200 Subject: [PATCH 1/4] Added ElectricSQL example --- .../04-electric-sql/.bnexample.json | 6 ++++ .../04-electric-sql/README.md | 11 ++++++ .../04-electric-sql/index.html | 14 ++++++++ .../{04-comments => 04-electric-sql}/main.tsx | 0 .../04-electric-sql/package.json | 27 ++++++++++++++ .../04-electric-sql/src/App.tsx | 9 +++++ .../tsconfig.json | 0 .../vite.config.ts | 0 .../.bnexample.json | 0 .../{04-comments => 05-comments}/README.md | 0 .../{04-comments => 05-comments}/index.html | 0 .../main.tsx | 0 .../{04-comments => 05-comments}/package.json | 0 .../{04-comments => 05-comments}/src/App.tsx | 0 .../src/SettingsSelect.tsx | 0 .../src/style.css | 0 .../src/userdata.ts | 0 .../tsconfig.json | 0 .../vite.config.ts | 0 .../.bnexample.json | 0 .../README.md | 0 .../index.html | 0 .../main.tsx | 0 .../package.json | 0 .../src/App.tsx | 0 .../src/SettingsSelect.tsx | 0 .../src/style.css | 0 .../src/userdata.ts | 0 .../tsconfig.json | 0 .../vite.config.ts | 0 .../.bnexample.json | 0 .../README.md | 0 .../index.html | 0 .../{07-forking => 07-ghost-writer}/main.tsx | 0 .../package.json | 0 .../src/App.tsx | 0 .../src/styles.css | 0 .../tsconfig.json | 0 .../vite.config.ts | 0 .../.bnexample.json | 0 .../{07-forking => 08-forking}/README.md | 0 .../{07-forking => 08-forking}/index.html | 0 examples/07-collaboration/08-forking/main.tsx | 11 ++++++ .../{07-forking => 08-forking}/package.json | 0 .../{07-forking => 08-forking}/src/App.tsx | 0 .../07-collaboration/08-forking/tsconfig.json | 36 +++++++++++++++++++ .../08-forking/vite.config.ts | 32 +++++++++++++++++ playground/src/examples.gen.tsx | 29 ++++++++++++--- 48 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 examples/07-collaboration/04-electric-sql/.bnexample.json create mode 100644 examples/07-collaboration/04-electric-sql/README.md create mode 100644 examples/07-collaboration/04-electric-sql/index.html rename examples/07-collaboration/{04-comments => 04-electric-sql}/main.tsx (100%) create mode 100644 examples/07-collaboration/04-electric-sql/package.json create mode 100644 examples/07-collaboration/04-electric-sql/src/App.tsx rename examples/07-collaboration/{04-comments => 04-electric-sql}/tsconfig.json (100%) rename examples/07-collaboration/{04-comments => 04-electric-sql}/vite.config.ts (100%) rename examples/07-collaboration/{04-comments => 05-comments}/.bnexample.json (100%) rename examples/07-collaboration/{04-comments => 05-comments}/README.md (100%) rename examples/07-collaboration/{04-comments => 05-comments}/index.html (100%) rename examples/07-collaboration/{05-comments-with-sidebar => 05-comments}/main.tsx (100%) rename examples/07-collaboration/{04-comments => 05-comments}/package.json (100%) rename examples/07-collaboration/{04-comments => 05-comments}/src/App.tsx (100%) rename examples/07-collaboration/{04-comments => 05-comments}/src/SettingsSelect.tsx (100%) rename examples/07-collaboration/{04-comments => 05-comments}/src/style.css (100%) rename examples/07-collaboration/{04-comments => 05-comments}/src/userdata.ts (100%) rename examples/07-collaboration/{05-comments-with-sidebar => 05-comments}/tsconfig.json (100%) rename examples/07-collaboration/{05-comments-with-sidebar => 05-comments}/vite.config.ts (100%) rename examples/07-collaboration/{05-comments-with-sidebar => 06-comments-with-sidebar}/.bnexample.json (100%) rename examples/07-collaboration/{05-comments-with-sidebar => 06-comments-with-sidebar}/README.md (100%) rename examples/07-collaboration/{05-comments-with-sidebar => 06-comments-with-sidebar}/index.html (100%) rename examples/07-collaboration/{06-ghost-writer => 06-comments-with-sidebar}/main.tsx (100%) rename examples/07-collaboration/{05-comments-with-sidebar => 06-comments-with-sidebar}/package.json (100%) rename examples/07-collaboration/{05-comments-with-sidebar => 06-comments-with-sidebar}/src/App.tsx (100%) rename examples/07-collaboration/{05-comments-with-sidebar => 06-comments-with-sidebar}/src/SettingsSelect.tsx (100%) rename examples/07-collaboration/{05-comments-with-sidebar => 06-comments-with-sidebar}/src/style.css (100%) rename examples/07-collaboration/{05-comments-with-sidebar => 06-comments-with-sidebar}/src/userdata.ts (100%) rename examples/07-collaboration/{06-ghost-writer => 06-comments-with-sidebar}/tsconfig.json (100%) rename examples/07-collaboration/{06-ghost-writer => 06-comments-with-sidebar}/vite.config.ts (100%) rename examples/07-collaboration/{06-ghost-writer => 07-ghost-writer}/.bnexample.json (100%) rename examples/07-collaboration/{06-ghost-writer => 07-ghost-writer}/README.md (100%) rename examples/07-collaboration/{06-ghost-writer => 07-ghost-writer}/index.html (100%) rename examples/07-collaboration/{07-forking => 07-ghost-writer}/main.tsx (100%) rename examples/07-collaboration/{06-ghost-writer => 07-ghost-writer}/package.json (100%) rename examples/07-collaboration/{06-ghost-writer => 07-ghost-writer}/src/App.tsx (100%) rename examples/07-collaboration/{06-ghost-writer => 07-ghost-writer}/src/styles.css (100%) rename examples/07-collaboration/{07-forking => 07-ghost-writer}/tsconfig.json (100%) rename examples/07-collaboration/{07-forking => 07-ghost-writer}/vite.config.ts (100%) rename examples/07-collaboration/{07-forking => 08-forking}/.bnexample.json (100%) rename examples/07-collaboration/{07-forking => 08-forking}/README.md (100%) rename examples/07-collaboration/{07-forking => 08-forking}/index.html (100%) create mode 100644 examples/07-collaboration/08-forking/main.tsx rename examples/07-collaboration/{07-forking => 08-forking}/package.json (100%) rename examples/07-collaboration/{07-forking => 08-forking}/src/App.tsx (100%) create mode 100644 examples/07-collaboration/08-forking/tsconfig.json create mode 100644 examples/07-collaboration/08-forking/vite.config.ts diff --git a/examples/07-collaboration/04-electric-sql/.bnexample.json b/examples/07-collaboration/04-electric-sql/.bnexample.json new file mode 100644 index 0000000000..29a56bc991 --- /dev/null +++ b/examples/07-collaboration/04-electric-sql/.bnexample.json @@ -0,0 +1,6 @@ +{ + "playground": true, + "docs": true, + "author": "matthewlipski", + "tags": ["Advanced", "Saving/Loading", "Collaboration"] +} diff --git a/examples/07-collaboration/04-electric-sql/README.md b/examples/07-collaboration/04-electric-sql/README.md new file mode 100644 index 0000000000..58296a8e95 --- /dev/null +++ b/examples/07-collaboration/04-electric-sql/README.md @@ -0,0 +1,11 @@ +# Collaborative Editing with ElectricSQL + +In this example, we use ElectricSQL to let multiple users collaborate on a single BlockNote document in real-time. The setup for this demo is more involved than the other collaboration examples, as it requires a running server and has a more fully-fledged UI. Therefore, the demo just uses an iframe element to show a hosted instance of the full ElectricSQL + BlockNote setup, which you can find the code for [here](https://github.com/TypeCellOS/blocknote-electric-example). + +**Try it out:** Open this page (or the [iframe url](https://blocknote-electric-example.vercel.app/)) in a new browser tab or window to see it in action! + +**Relevant Docs:** + +- [Editor Setup](/docs/getting-started/editor-setup) +- [Real-time collaboration](/docs/features/collaboration) +- [ElectricSQL](https://electric-sql.com/) diff --git a/examples/07-collaboration/04-electric-sql/index.html b/examples/07-collaboration/04-electric-sql/index.html new file mode 100644 index 0000000000..6f1336e280 --- /dev/null +++ b/examples/07-collaboration/04-electric-sql/index.html @@ -0,0 +1,14 @@ + + + + + Collaborative Editing with Electric SQL + + + +
+ + + diff --git a/examples/07-collaboration/04-comments/main.tsx b/examples/07-collaboration/04-electric-sql/main.tsx similarity index 100% rename from examples/07-collaboration/04-comments/main.tsx rename to examples/07-collaboration/04-electric-sql/main.tsx diff --git a/examples/07-collaboration/04-electric-sql/package.json b/examples/07-collaboration/04-electric-sql/package.json new file mode 100644 index 0000000000..cbd8e42e4b --- /dev/null +++ b/examples/07-collaboration/04-electric-sql/package.json @@ -0,0 +1,27 @@ +{ + "name": "@blocknote/example-collaboration-electric-sql", + "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": "^19.1.0", + "react-dom": "^19.1.0" + }, + "devDependencies": { + "@types/react": "^19.1.0", + "@types/react-dom": "^19.1.0", + "@vitejs/plugin-react": "^4.3.1", + "vite": "^5.3.4" + } +} \ No newline at end of file diff --git a/examples/07-collaboration/04-electric-sql/src/App.tsx b/examples/07-collaboration/04-electric-sql/src/App.tsx new file mode 100644 index 0000000000..20c21849e1 --- /dev/null +++ b/examples/07-collaboration/04-electric-sql/src/App.tsx @@ -0,0 +1,9 @@ +export default function App() { + return ( +