Fix for issue #386 Show '-' instead of '*' for unordered list

Added unorderedListStyle to the options
pull/389/head
Zignature 2 years ago
parent 59a676bc8a
commit 5df842b630

@ -136,6 +136,7 @@ easyMDE.value('New input for **EasyMDE**');
- **bold**: Can be set to `**` or `__`. Defaults to `**`. - **bold**: Can be set to `**` or `__`. Defaults to `**`.
- **code**: Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````. - **code**: Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````.
- **italic**: Can be set to `*` or `_`. Defaults to `*`. - **italic**: Can be set to `*` or `_`. Defaults to `*`.
- **unorderedListStyle**: can be `*`, `-` or `+`. Defaults to `*`.
- **scrollbarStyle**: Chooses a scrollbar implementation. The default is "native", showing native scrollbars. The core library also provides the "null" style, which completely hides the scrollbars. Addons can implement additional scrollbar models. - **scrollbarStyle**: Chooses a scrollbar implementation. The default is "native", showing native scrollbars. The core library also provides the "null" style, which completely hides the scrollbars. Addons can implement additional scrollbar models.
- **element**: The DOM element for the TextArea to use. Defaults to the first TextArea on the page. - **element**: The DOM element for the TextArea to use. Defaults to the first TextArea on the page.
- **forceSync**: If set to `true`, force text changes made in EasyMDE to be immediately stored in original text area. Defaults to `false`. - **forceSync**: If set to `true`, force text changes made in EasyMDE to be immediately stored in original text area. Defaults to `false`.
@ -242,6 +243,7 @@ const editor = new EasyMDE({
bold: "__", bold: "__",
italic: "_", italic: "_",
}, },
unorderedListStyle: "-",
element: document.getElementById("MyID"), element: document.getElementById("MyID"),
forceSync: true, forceSync: true,
hideIcons: ["guide", "heading"], hideIcons: ["guide", "heading"],

@ -793,7 +793,17 @@ function toggleHeading3(editor) {
*/ */
function toggleUnorderedList(editor) { function toggleUnorderedList(editor) {
var cm = editor.codemirror; var cm = editor.codemirror;
_toggleLine(cm, 'unordered-list'); var liststyle = editor.options.unorderedListStyle;
liststyle = (
liststyle != undefined
&& liststyle !== ''
&& liststyle.length == 1
)
? liststyle
: '*';
_toggleLine(cm, 'unordered-list', liststyle);
} }
@ -1171,7 +1181,7 @@ function _toggleHeading(cm, direction, size) {
} }
function _toggleLine(cm, name) { function _toggleLine(cm, name, liststyle) {
if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className)) if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
return; return;
@ -1190,7 +1200,7 @@ function _toggleLine(cm, name) {
var _getChar = function (name, i) { var _getChar = function (name, i) {
var map = { var map = {
'quote': '>', 'quote': '>',
'unordered-list': '*', 'unordered-list': liststyle,
'ordered-list': '%%i.', 'ordered-list': '%%i.',
}; };
@ -1200,7 +1210,7 @@ function _toggleLine(cm, name) {
var _checkChar = function (name, char) { var _checkChar = function (name, char) {
var map = { var map = {
'quote': '>', 'quote': '>',
'unordered-list': '\\*', 'unordered-list': '\\'.liststyle,
'ordered-list': '\\d+.', 'ordered-list': '\\d+.',
}; };
var rt = new RegExp(map[name]); var rt = new RegExp(map[name]);

Loading…
Cancel
Save