Skip to content

Commit 78e4412

Browse files
add option to disable animations (#1062)
* add option to disable animations * Implemented PR feedback --------- Co-authored-by: matthewlipski <[email protected]>
1 parent 04613d3 commit 78e4412

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

docs/pages/docs/editor-basics/setup.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type BlockNoteEditorOptions = {
2727
dictionary?: Dictionary;
2828
schema?: BlockNoteSchema;
2929
trailingBlock?: boolean;
30+
animations?: boolean;
3031
};
3132
```
3233

@@ -50,6 +51,8 @@ The hook takes two optional parameters:
5051

5152
`trailingBlock`: An option which user can pass with `false` value to disable the automatic creation of a trailing new block on the next line when the user types or edits any block. Defaults to `true` if undefined.
5253

54+
`animations`: Whether changes to blocks (like indentation, creating lists, changing headings) should be animated or not. Defaults to `true`.
55+
5356
**deps:** Dependency array that's internally passed to `useMemo`. A new editor will only be created when this array changes.
5457

5558
<Callout type="info" emoji={"💡"}>
@@ -58,9 +61,9 @@ The hook takes two optional parameters:
5861
The `useCreateBlockNote` hook is actually a simple `useMemo` wrapper around
5962
the `BlockNoteEditor.create` method. You can use this method directly if you
6063
want to control the editor lifecycle manually. For example, we do this in
61-
the [Saving & Loading example](/examples/backend/saving-loading) to delay the
62-
editor creation until some content has been fetched from an external data
63-
source.
64+
the [Saving & Loading example](/examples/backend/saving-loading) to delay
65+
the editor creation until some content has been fetched from an external
66+
data source.
6467
</p>
6568
</Callout>
6669

packages/core/src/editor/BlockNoteEditor.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import { en } from "../i18n/locales";
6767

6868
import { Transaction } from "@tiptap/pm/state";
6969
import { createInternalHTMLSerializer } from "../api/exporters/html/internalHTMLSerializer";
70+
import { PreviousBlockTypePlugin } from "../extensions/PreviousBlockType/PreviousBlockTypePlugin";
7071
import "../style.css";
7172
import { initializeESMDependencies } from "../util/esmDependencies";
7273

@@ -75,6 +76,13 @@ export type BlockNoteEditorOptions<
7576
ISchema extends InlineContentSchema,
7677
SSchema extends StyleSchema
7778
> = {
79+
/**
80+
* Whether changes to blocks (like indentation, creating lists, changing headings) should be animated or not. Defaults to `true`.
81+
*
82+
* @default true
83+
*/
84+
animations?: boolean;
85+
7886
disableExtensions: string[];
7987
/**
8088
* A dictionary object containing translations for the editor.
@@ -364,6 +372,9 @@ export class BlockNoteEditor<
364372
...(this.filePanel ? [this.filePanel.plugin] : []),
365373
...(this.tableHandles ? [this.tableHandles.plugin] : []),
366374
PlaceholderPlugin(this, newOptions.placeholders),
375+
...(this.options.animations ?? true
376+
? [PreviousBlockTypePlugin()]
377+
: []),
367378
];
368379
},
369380
});

packages/core/src/pm-nodes/BlockContainer.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
import { PartialBlock } from "../blocks/defaultBlocks";
1212
import type { BlockNoteEditor } from "../editor/BlockNoteEditor";
1313
import { NonEditableBlockPlugin } from "../extensions/NonEditableBlocks/NonEditableBlockPlugin";
14-
import { PreviousBlockTypePlugin } from "../extensions/PreviousBlockType/PreviousBlockTypePlugin";
1514
import {
1615
BlockNoteDOMAttributes,
1716
BlockSchema,
@@ -492,7 +491,7 @@ export const BlockContainer = Node.create<{
492491
},
493492

494493
addProseMirrorPlugins() {
495-
return [PreviousBlockTypePlugin(), NonEditableBlockPlugin()];
494+
return [NonEditableBlockPlugin()];
496495
},
497496

498497
addKeyboardShortcuts() {

0 commit comments

Comments
 (0)