Files
outline/shared/editor/extensions/MaxLength.ts
T
Tom Moor 8c716b173a chore: Update editor generics (#12247)
* chore: Update editor generics

* fix: Address PR review on editor generics

- Restore null-guard on Link click handler so anchors aren't inert when no onClickLink is provided
- Mark onClickLink optional in LinkOptions and openLink command to match runtime
- Remove dead `collapsed` option from HeadingOptions
- Make ToggleBlock dictionary optional and restore optional-chained access for server-side schema instantiation

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-02 18:54:27 -04:00

33 lines
743 B
TypeScript

import type { Transaction } from "prosemirror-state";
import { Plugin } from "prosemirror-state";
import Extension from "../lib/Extension";
/**
* Options for the MaxLength extension.
*/
type MaxLengthOptions = {
/** Maximum allowed document size, in ProseMirror node size units. */
maxLength?: number;
};
export default class MaxLength extends Extension<MaxLengthOptions> {
get name() {
return "maxlength";
}
get plugins() {
return [
new Plugin({
filterTransaction: (tr: Transaction) => {
if (this.options.maxLength) {
const result = tr.doc && tr.doc.nodeSize > this.options.maxLength;
return !result;
}
return true;
},
}),
];
}
}