patleeman / quill-markdown-shortcuts

Quill.js module that converts markdown to rich text formatting while typing.
https://patleeman.github.io/quill-markdown-shortcuts/
139 stars 49 forks source link

feat: Add ability to ignore elements #35

Open wooolfgang opened 4 years ago

wooolfgang commented 4 years ago

Hi @patleeman , first off - thank you for the great work! We're using this module for our web-app editor, and it works well.

One of the features we need for our comment section is to disallow certain elements such as headers + dividers (hr). In this pull request, I added a simple option (ignore = []) that will allow the ignoring of elements during auto-formatting.

Let me know your thoughts or feedback/issues with the submitted code. Thanks!

ivictbor commented 3 years ago

@wooolfgang I just wanted to create a same PR ;) Thanks a lot.

@patleeman will you merge and release? Are you active on a project or should we fork?

I love the plugin but now we face an annoying case when you type:

The variable_name is a snakecase, which means you type_underscore

Which makes

The variable name is a snakecase, which means you type underscore

Or lets just fix this regexp https://github.com/patleeman/quill-markdown-shortcuts/blob/master/src/index.js#L118

so it should include whitespace (or be at the beginning of the line) before first underscore. And same logic with last

Same issue with bold

We fixed the issue in our repo https://github.com/devforth/quill-markdown-shortcuts (npm i -S @devforth/quill-markdown-shortcuts)