I am making a plug in to make his medium editor more like medium. I am not sure how to turn off the user's ability to press enter if they have not typed anything or how to add a line dividing paragraphs if the user presses enter twice.
adding functionality to daviferreira's WYSIWYG medium editor
904 views Asked by user3200085 AtThere are 3 answers
On
medium-editor supports a disableDoubleReturn option which you can pass into the editor during instantiation. This prevents the user from being able to have 2 or more consecutive new lines. I believe this would accomplish the first requirement you listed.
var mediumEditor = new MediumEditor('.editor', { disableDoubleReturn: true });
To accomplish the 2nd requirement you listed, you could add some functionality into medium-editor itself to call a callback when the user hits return or even add a hrBetweenParagraphs option which could add a line in between consecutive paragraphs.
You could implement either of these in the bindReturn method of core.js in the most recent version of the repo, as this is where hitting enter is handled. We accept many pull requests very frequently, so we'd be happy to take in something like this :)
For code ideas, take a look at grande.js which implements both of these subtle features:
https://github.com/mduvall/grande.js/
Particularly:
function preprocessKeyDown()andfunction insertHorizontalRule()