uiwjs / react-md-editor

A simple markdown editor with preview, implemented with React.js and TypeScript.
https://uiwjs.github.io/react-md-editor
MIT License
2.03k stars 149 forks source link

IMPORTANT MISSING FEATURE: Prop to limit the character length - maxLength and minLength attributes #626

Closed invincibleinventor closed 3 months ago

invincibleinventor commented 3 months ago

How do I limit the amount of characters (I do not mind if it includes the characters involved in the markdown syntax such as asteriks). Something similar to the maxLength attribute in a textarea maybe? Such a feature would be very relavant in places where one cannot afford to have an infinite amount of text written. Please let me know how could I add such a limit to my MDEditor component or if possible, a prop for controlling minLength and maxLength in the MD textarea. Thanks!

jaywcjlove commented 3 months ago

@invincibleinventor The textareaProps props can be set

import React from "react";
import MDEditor from '@uiw/react-md-editor';

<MDEditor
  value={....}
  textareaProps={{
    placeholder: 'Please enter Markdown text',
    maxLength: 10
  }}
/>
invincibleinventor commented 3 months ago

Works perfectly! Thanks a lot. Closing this issue...