Merge branch 'master' into options-toolbarbutton-attributes

pull/388/head
Jeroen Akkerman 2 years ago
commit 1c656d5712

@ -4,7 +4,10 @@ All notable changes to easymde will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
<!-- ## [Unreleased] --> ## [Unreleased]
### Added
- `unorderedListStyle` option to change the character used for unordered lists (Thanks to [@Zignature], [#389]).
## [2.16.0] - 2021-10-28 ## [2.16.0] - 2021-10-28
### Added ### Added
- `direction` option to enable RTL mode (Thanks to [@souljuse], [#358]). - `direction` option to enable RTL mode (Thanks to [@souljuse], [#358]).
@ -232,6 +235,7 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown
[#9]: https://github.com/Ionaru/easy-markdown-editor/issues/9 [#9]: https://github.com/Ionaru/easy-markdown-editor/issues/9
<!-- Linked PRs --> <!-- Linked PRs -->
[#389]: https://github.com/Ionaru/easy-markdown-editor/pull/389
[#364]: https://github.com/Ionaru/easy-markdown-editor/pull/364 [#364]: https://github.com/Ionaru/easy-markdown-editor/pull/364
[#358]: https://github.com/Ionaru/easy-markdown-editor/pull/358 [#358]: https://github.com/Ionaru/easy-markdown-editor/pull/358
[#357]: https://github.com/Ionaru/easy-markdown-editor/pull/357 [#357]: https://github.com/Ionaru/easy-markdown-editor/pull/357
@ -329,6 +333,7 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown
[@ukjinjang]: https://github.com/ukjinjang [@ukjinjang]: https://github.com/ukjinjang
[@robjean9]: https://github.com/robjean9 [@robjean9]: https://github.com/robjean9
[@Offerel]: https://github.com/Offerel [@Offerel]: https://github.com/Offerel
[@Zignature]: https://github.com/Zignature
<!-- Linked versions --> <!-- Linked versions -->
[Unreleased]: https://github.com/Ionaru/easy-markdown-editor/compare/2.16.0...HEAD [Unreleased]: https://github.com/Ionaru/easy-markdown-editor/compare/2.16.0...HEAD

@ -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"],

@ -188,6 +188,11 @@ function removeClass(el, className) {
function createToolbarDropdown(options, enableTooltips, shortcuts, parent) { function createToolbarDropdown(options, enableTooltips, shortcuts, parent) {
var el = createToolbarButton(options, false, enableTooltips, shortcuts, 'button', parent); var el = createToolbarButton(options, false, enableTooltips, shortcuts, 'button', parent);
el.className += ' easymde-dropdown'; el.className += ' easymde-dropdown';
el.onclick = function () {
el.focus();
};
var content = document.createElement('div'); var content = document.createElement('div');
content.className = 'easymde-dropdown-content'; content.className = 'easymde-dropdown-content';
for (var childrenIndex = 0; childrenIndex < options.children.length; childrenIndex++) { for (var childrenIndex = 0; childrenIndex < options.children.length; childrenIndex++) {
@ -201,6 +206,7 @@ function createToolbarDropdown(options, enableTooltips, shortcuts, parent) {
childElement = createToolbarButton(child, true, enableTooltips, shortcuts, 'button', parent); childElement = createToolbarButton(child, true, enableTooltips, shortcuts, 'button', parent);
} }
childElement.addEventListener('click', function (e) { e.stopPropagation(); }, false);
content.appendChild(childElement); content.appendChild(childElement);
} }
el.appendChild(content); el.appendChild(content);
@ -799,7 +805,13 @@ function toggleHeading3(editor) {
*/ */
function toggleUnorderedList(editor) { function toggleUnorderedList(editor) {
var cm = editor.codemirror; var cm = editor.codemirror;
_toggleLine(cm, 'unordered-list');
var listStyle = '*'; // Default
if (['-', '+', '*'].includes(editor.options.unorderedListStyle)) {
listStyle = editor.options.unorderedListStyle;
}
_toggleLine(cm, 'unordered-list', listStyle);
} }
@ -1177,7 +1189,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;
@ -1196,7 +1208,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.',
}; };
@ -1206,7 +1218,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]);

@ -38,6 +38,7 @@ const editor2 = new EasyMDE({
autoDownloadFontAwesome: undefined, autoDownloadFontAwesome: undefined,
previewClass: ['my-custom-class', 'some-other-class'], previewClass: ['my-custom-class', 'some-other-class'],
nativeSpellcheck: true, nativeSpellcheck: true,
unorderedListStyle: '-',
inputStyle: 'contenteditable', inputStyle: 'contenteditable',
toolbar: [ toolbar: [
{ {
@ -104,6 +105,7 @@ const editorImages = new EasyMDE({
previewImagesInEditor: false, previewImagesInEditor: false,
imageAccept: 'image/png, image/bmp', imageAccept: 'image/png, image/bmp',
imageCSRFToken: undefined, imageCSRFToken: undefined,
unorderedListStyle: '+',
imageMaxSize: 10485760, imageMaxSize: 10485760,
imageUploadEndpoint: 'https://my.domain/image-upload/', imageUploadEndpoint: 'https://my.domain/image-upload/',
imageTexts: { imageTexts: {
@ -170,6 +172,7 @@ const editorImagesCustom = new EasyMDE({
new EasyMDE({ new EasyMDE({
sideBySideFullscreen: true, sideBySideFullscreen: true,
lineNumbers: false, lineNumbers: false,
unorderedListStyle: '*',
autosave: { autosave: {
enabled: true, enabled: true,
delay: 2000, delay: 2000,

@ -206,6 +206,7 @@ declare namespace EasyMDE {
onToggleFullScreen?: (goingIntoFullScreen: boolean) => void; onToggleFullScreen?: (goingIntoFullScreen: boolean) => void;
theme?: string; theme?: string;
scrollbarStyle?: string; scrollbarStyle?: string;
unorderedListStyle?: '*' | '-' | '+';
uploadImage?: boolean; uploadImage?: boolean;
imageMaxSize?: number; imageMaxSize?: number;

Loading…
Cancel
Save