From d835c947db231c65386fb17b7df83622051f1a22 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Sat, 19 Nov 2022 12:23:04 +0800 Subject: [PATCH] disable placeholder when doc is large --- packages/client/src/tiptap/core/extensions/placeholder.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/client/src/tiptap/core/extensions/placeholder.ts b/packages/client/src/tiptap/core/extensions/placeholder.ts index 794b5f31..2e788999 100644 --- a/packages/client/src/tiptap/core/extensions/placeholder.ts +++ b/packages/client/src/tiptap/core/extensions/placeholder.ts @@ -10,6 +10,7 @@ export interface PlaceholderOptions { showOnlyWhenEditable: boolean; showOnlyCurrent: boolean; includeChildren: boolean; + maxContentSize?: number; } export const Placeholder = Extension.create({ @@ -23,6 +24,7 @@ export const Placeholder = Extension.create({ showOnlyWhenEditable: true, showOnlyCurrent: true, includeChildren: false, + maxContentSize: 2000, }; }, @@ -35,6 +37,10 @@ export const Placeholder = Extension.create({ new Plugin({ props: { decorations: ({ doc, selection }) => { + if (doc.content.size > (this.options.maxContentSize || 2000)) { + return null; + } + const active = this.editor.isEditable || !this.options.showOnlyWhenEditable; const { anchor } = selection; const decorations: Decoration[] = [];