mirror of https://github.com/fantasticit/think.git
disable placeholder when doc is large
This commit is contained in:
parent
880acbd703
commit
d835c947db
|
@ -10,6 +10,7 @@ export interface PlaceholderOptions {
|
||||||
showOnlyWhenEditable: boolean;
|
showOnlyWhenEditable: boolean;
|
||||||
showOnlyCurrent: boolean;
|
showOnlyCurrent: boolean;
|
||||||
includeChildren: boolean;
|
includeChildren: boolean;
|
||||||
|
maxContentSize?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Placeholder = Extension.create<PlaceholderOptions>({
|
export const Placeholder = Extension.create<PlaceholderOptions>({
|
||||||
|
@ -23,6 +24,7 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
|
||||||
showOnlyWhenEditable: true,
|
showOnlyWhenEditable: true,
|
||||||
showOnlyCurrent: true,
|
showOnlyCurrent: true,
|
||||||
includeChildren: false,
|
includeChildren: false,
|
||||||
|
maxContentSize: 2000,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -35,6 +37,10 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
|
||||||
new Plugin({
|
new Plugin({
|
||||||
props: {
|
props: {
|
||||||
decorations: ({ doc, selection }) => {
|
decorations: ({ doc, selection }) => {
|
||||||
|
if (doc.content.size > (this.options.maxContentSize || 2000)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const active = this.editor.isEditable || !this.options.showOnlyWhenEditable;
|
const active = this.editor.isEditable || !this.options.showOnlyWhenEditable;
|
||||||
const { anchor } = selection;
|
const { anchor } = selection;
|
||||||
const decorations: Decoration[] = [];
|
const decorations: Decoration[] = [];
|
||||||
|
|
Loading…
Reference in New Issue