diff --git a/components/lib/editor/Editor.js b/components/lib/editor/Editor.js index e7b436b6d4..e66a15c336 100644 --- a/components/lib/editor/Editor.js +++ b/components/lib/editor/Editor.js @@ -92,6 +92,14 @@ export const Editor = React.memo( } } + if (props.maxLength) { + const length = quill.current.getLength(); + + if (length > props.maxLength) { + quill.current.deleteText(props.maxLength, length); + } + } + if (props.onTextChange) { props.onTextChange({ htmlValue: html, @@ -213,5 +221,6 @@ Editor.defaultProps = { headerTemplate: null, onTextChange: null, onSelectionChange: null, - onLoad: null + onLoad: null, + maxLength: null }; diff --git a/components/lib/editor/editor.d.ts b/components/lib/editor/editor.d.ts index 47a2c456b7..8e5048df5c 100644 --- a/components/lib/editor/editor.d.ts +++ b/components/lib/editor/editor.d.ts @@ -14,10 +14,7 @@ interface EditorSelectionChangeParams { } export interface EditorProps extends Omit, HTMLDivElement>, 'ref'> { - id?: string; value?: string; - style?: React.CSSProperties; - className?: string; placeholder?: string; readOnly?: boolean; modules?: any;