Skip to content
Open
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
6 changes: 6 additions & 0 deletions examples/01-basic/17-no-trailing-block/.bnexample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"playground": true,
"docs": false,
"author": "matthewlipski",
"tags": ["Basic"]
}
7 changes: 7 additions & 0 deletions examples/01-basic/17-no-trailing-block/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# No Trailing Block

This example shows how to disable the automatic creation of a trailing block at the end of the editor by setting the `trailingBlock` option to `false`.

**Relevant Docs:**

- [Editor Setup](/docs/getting-started/editor-setup)
14 changes: 14 additions & 0 deletions examples/01-basic/17-no-trailing-block/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html lang="en">
Comment thread
matthewlipski marked this conversation as resolved.
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>No Trailing 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/01-basic/17-no-trailing-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";
Comment thread
matthewlipski marked this conversation as resolved.

const root = createRoot(document.getElementById("root")!);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
31 changes: 31 additions & 0 deletions examples/01-basic/17-no-trailing-block/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@blocknote/example-basic-no-trailing-block",
"description": "AUTO-GENERATED FILE, DO NOT EDIT DIRECTLY",
"type": "module",
"private": true,
"version": "0.12.4",
"scripts": {
"start": "vite",
"dev": "vite",
"build:prod": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@blocknote/ariakit": "latest",
"@blocknote/core": "latest",
"@blocknote/mantine": "latest",
"@blocknote/react": "latest",
"@blocknote/shadcn": "latest",
"@mantine/core": "^8.3.11",
"@mantine/hooks": "^8.3.11",
"@mantine/utils": "^6.0.22",
"react": "^19.2.3",
"react-dom": "^19.2.3"
},
"devDependencies": {
"@types/react": "^19.2.3",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.1",
"vite": "^8.0.8"
}
}
14 changes: 14 additions & 0 deletions examples/01-basic/17-no-trailing-block/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useCreateBlockNote } from "@blocknote/react";

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
trailingBlock: false,
});

// Renders the editor instance using a React component.
return <BlockNoteView editor={editor} />;
}
36 changes: 36 additions & 0 deletions examples/01-basic/17-no-trailing-block/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/01-basic/17-no-trailing-block/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/"
),
Comment thread
matthewlipski marked this conversation as resolved.
} as any),
},
}));
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from "../../schema/index.js";
import { formatKeyboardShortcut } from "../../util/browser.js";
import { FilePanelExtension } from "../FilePanel/FilePanel.js";
import { FormattingToolbarExtension } from "../FormattingToolbar/FormattingToolbar.js";
import { DefaultSuggestionItem } from "./DefaultSuggestionItem.js";
import { SuggestionMenu } from "./SuggestionMenu.js";

Expand Down Expand Up @@ -242,6 +243,11 @@ export function getDefaultSlashMenuItems<

// Immediately open the file toolbar
editor.getExtension(FilePanelExtension)?.showMenu(insertedBlock.id);
// Immediately hide the formatting toolbar. This is only necessary for
// when the `trailingBlock` editor option is set to `false` and the
// inserted block is at the end of the document. Otherwise, the
// selection moves to the next block with inline content.
editor.getExtension(FormattingToolbarExtension)?.store.setState(false);
},
key: "image",
...editor.dictionary.slash_menu.image,
Expand All @@ -257,6 +263,11 @@ export function getDefaultSlashMenuItems<

// Immediately open the file toolbar
editor.getExtension(FilePanelExtension)?.showMenu(insertedBlock.id);
// Immediately hide the formatting toolbar. This is only necessary for
// when the `trailingBlock` editor option is set to `false` and the
// inserted block is at the end of the document. Otherwise, the
// selection moves to the next block with inline content.
editor.getExtension(FormattingToolbarExtension)?.store.setState(false);
},
key: "video",
...editor.dictionary.slash_menu.video,
Expand All @@ -272,6 +283,11 @@ export function getDefaultSlashMenuItems<

// Immediately open the file toolbar
editor.getExtension(FilePanelExtension)?.showMenu(insertedBlock.id);
// Immediately hide the formatting toolbar. This is only necessary for
// when the `trailingBlock` editor option is set to `false` and the
// inserted block is at the end of the document. Otherwise, the
// selection moves to the next block with inline content.
editor.getExtension(FormattingToolbarExtension)?.store.setState(false);
},
key: "audio",
...editor.dictionary.slash_menu.audio,
Expand All @@ -287,6 +303,11 @@ export function getDefaultSlashMenuItems<

// Immediately open the file toolbar
editor.getExtension(FilePanelExtension)?.showMenu(insertedBlock.id);
// Immediately hide the formatting toolbar. This is only necessary for
// when the `trailingBlock` editor option is set to `false` and the
// inserted block is at the end of the document. Otherwise, the
// selection moves to the next block with inline content.
editor.getExtension(FormattingToolbarExtension)?.store.setState(false);
},
key: "file",
...editor.dictionary.slash_menu.file,
Expand Down
19 changes: 19 additions & 0 deletions playground/src/examples.gen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,25 @@
},
"readme": "This example makes the editor read-only while showing the same content as the [Default Schema Showcase](/examples/basic/default-blocks) example.\n\n**Relevant Docs:**\n\n- [Editor Setup](/docs/getting-started/editor-setup)\n- [Document Structure](/docs/foundations/document-structure)\n- [Default Schema](/docs/foundations/schemas)"
},
{
"projectSlug": "no-trailing-block",
"fullSlug": "basic/no-trailing-block",
"pathFromRoot": "examples/01-basic/17-no-trailing-block",
"config": {
"playground": true,
"docs": false,
"author": "matthewlipski",
"tags": [
"Basic"
]
},
"title": "No Trailing Block",
"group": {
"pathFromRoot": "examples/01-basic",
"slug": "basic"
},
"readme": "This example shows how to disable the automatic creation of a trailing block at the end of the editor by setting the `trailingBlock` option to `false`.\n\n**Relevant Docs:**\n\n- [Editor Setup](/docs/getting-started/editor-setup)"
},
{
"projectSlug": "testing",
"fullSlug": "basic/testing",
Expand Down
62 changes: 54 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading