Browse Source

Merge branch 'master' into bugfix/simplemde-compatibility

tags/v2.6.0
Jeroen Akkerman 2 months ago
parent
commit
b14d7dda1c
11 changed files with 463 additions and 521 deletions
  1. 2
    1
      .eslintrc
  2. 3
    0
      .gitignore
  3. 8
    8
      CONTRIBUTING.md
  4. 2
    2
      README.md
  5. 0
    7
      dist/easymde.min.css
  6. 0
    7
      dist/easymde.min.js
  7. 346
    411
      package-lock.json
  8. 5
    0
      package.json
  9. 77
    77
      src/js/easymde.js
  10. 9
    5
      types/easymde-test.ts
  11. 11
    3
      types/easymde.d.ts

+ 2
- 1
.eslintrc View File

@@ -9,7 +9,8 @@
9 9
         "semi": [
10 10
             "error",
11 11
             "always"
12
-        ]
12
+        ],
13
+        "comma-dangle": ["error", "always-multiline"]
13 14
     },
14 15
     "env": {
15 16
         "browser": true,

+ 3
- 0
.gitignore View File

@@ -1,3 +1,6 @@
1
+# generated files
2
+dist/
3
+
1 4
 # NPM files
2 5
 node_modules/
3 6
 

+ 8
- 8
CONTRIBUTING.md View File

@@ -14,7 +14,7 @@ You can [submit an issue️](https://github.com/Ionaru/easy-markdown-editor/issu
14 14
 
15 15
 ### 📦 Prerequisites
16 16
 
17
-You need node.js and npm.
17
+You need Node.js and npm.
18 18
 
19 19
 To install them on Debian-based systems:
20 20
 
@@ -37,7 +37,7 @@ git clone https://github.com/Ionaru/easy-markdown-editor.git
37 37
 cd easy-markdown-editor
38 38
 ```
39 39
 
40
-Then install the EasyMDE with npm:
40
+Then install the required dependencies:
41 41
 
42 42
 ```bash
43 43
 npm install
@@ -50,12 +50,12 @@ Yay! You are ready! 🍾
50 50
 
51 51
 1. First, [create a fork of this project](https://github.com/Ionaru/easy-markdown-editor/fork), and copy the https URL (*clone or download* button) of your project (something like https://github.com/YOUR_USERNAME/easy-markdown-editor.git );
52 52
 2. a) If you already cloned and worked on the project: `git remote add source https://github.com/Ionaru/easy-markdown-editor.git`;
53
-b) otherwise, clone your fork: `git clone https://github.com/YOUR_USERNAME/easy-markdown-editor.git`;
54
-3. create a new dedicated branch `git checkout -b myMergeRequest`;
55
-4. write some nice code and commit your work;
56
-5. check files against the ESLint syntax and build minified versions: `gulp`;
57
-6. push it to a dedicated branch `git push origin myMergeRequest`;
58
-7. got to the [main project page](https://github.com/Ionaru/easy-markdown-editor) and click on the button *Compare and pull request*, then fill the description.
53
+b) Otherwise, clone your fork: `git clone https://github.com/YOUR_USERNAME/easy-markdown-editor.git`;
54
+3. Create a new dedicated branch `git checkout -b myMergeRequest`;
55
+4. Write some nice code and commit your work;
56
+5. Check files against the ESLint syntax and build minified versions: `gulp`;
57
+6. Push it to a dedicated branch `git push origin myMergeRequest`;
58
+7. Go to the [main project page](https://github.com/Ionaru/easy-markdown-editor) and click on the button *Compare and pull request*, then fill the description.
59 59
 
60 60
 If you want to make other pull requests, go back to the master branch (`git checkout master`), update it (`git pull --rebase source master`), then follow the instructions above from step 3.
61 61
 

+ 2
- 2
README.md View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 [![npm version](https://img.shields.io/npm/v/easymde.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde)
4 4
 [![npm version](https://img.shields.io/npm/v/easymde/next.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde/v/next)
5
-[![Build Status](https://img.shields.io/travis/Ionaru/easy-markdown-editor.svg?style=for-the-badge)](https://travis-ci.org/Ionaru/easy-markdown-editor)
5
+[![Build Status](https://img.shields.io/travis/Ionaru/easy-markdown-editor/master.svg?style=for-the-badge)](https://travis-ci.org/Ionaru/easy-markdown-editor)
6 6
 
7 7
 > This repository is a fork of
8 8
 [SimpleMDE, made by Sparksuite](https://github.com/sparksuite/simplemde-markdown-editor/).
@@ -151,7 +151,7 @@ easyMDE.value('New input for **EasyMDE**');
151 151
 - **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
152 152
   - **codeSyntaxHighlighting**: If set to `true`, will highlight using [highlight.js](https://github.com/isagalaev/highlight.js). Defaults to `false`. To use this feature you must include highlight.js on your page or pass in using the `hljs` option. For example, include the script and the CSS files like:<br>`<script src="https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script>`<br>`<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">`
153 153
   - **hljs**: An injectible instance of [highlight.js](https://github.com/isagalaev/highlight.js). If you don't want to rely on the global namespace (`window.hljs`), you can provide an instance here. Defaults to `undefined`.
154
-  - **markedOptions**: Set the internal Markdown renderer's [options](https://github.com/chjj/marked#options-1). Other `renderingConfig` options will take precedence.
154
+  - **markedOptions**: Set the internal Markdown renderer's [options](https://marked.js.org/#/USING_ADVANCED.md#options). Other `renderingConfig` options will take precedence.
155 155
   - **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`.
156 156
 - **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts).
157 157
 - **showIcons**: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar.

+ 0
- 7
dist/easymde.min.css
File diff suppressed because it is too large
View File


+ 0
- 7
dist/easymde.min.js
File diff suppressed because it is too large
View File


+ 346
- 411
package-lock.json
File diff suppressed because it is too large
View File


+ 5
- 0
package.json View File

@@ -2,6 +2,11 @@
2 2
     "name": "easymde",
3 3
     "version": "2.5.1",
4 4
     "description": "A simple, beautiful, and embeddable JavaScript Markdown editor that easy to use. Features include autosaving and spell checking.",
5
+    "files": [
6
+        "dist/**/*",
7
+        "src/**/*",
8
+        "types/easymde.d.ts"
9
+    ],
5 10
     "keywords": [
6 11
         "embeddable",
7 12
         "markdown",

+ 77
- 77
src/js/easymde.js View File

@@ -42,7 +42,7 @@ var bindings = {
42 42
     'undo': undo,
43 43
     'redo': redo,
44 44
     'toggleSideBySide': toggleSideBySide,
45
-    'toggleFullScreen': toggleFullScreen
45
+    'toggleFullScreen': toggleFullScreen,
46 46
 };
47 47
 
48 48
 var shortcuts = {
@@ -59,7 +59,7 @@ var shortcuts = {
59 59
     'toggleCodeBlock': 'Cmd-Alt-C',
60 60
     'togglePreview': 'Cmd-P',
61 61
     'toggleSideBySide': 'F9',
62
-    'toggleFullScreen': 'F11'
62
+    'toggleFullScreen': 'F11',
63 63
 };
64 64
 
65 65
 var getBindingName = function (f) {
@@ -338,11 +338,11 @@ function toggleCodeBlock(editor) {
338 338
         line = line || cm.getLineHandle(line_num);
339 339
         firstTok = firstTok || cm.getTokenAt({
340 340
             line: line_num,
341
-            ch: 1
341
+            ch: 1,
342 342
         });
343 343
         lastTok = lastTok || (!!line.text && cm.getTokenAt({
344 344
             line: line_num,
345
-            ch: line.text.length - 1
345
+            ch: line.text.length - 1,
346 346
         }));
347 347
         var types = firstTok.type ? firstTok.type.split(' ') : [];
348 348
         if (lastTok && token_state(lastTok).indentedCode) {
@@ -375,10 +375,10 @@ function toggleCodeBlock(editor) {
375 375
         _replaceSelection(cm, false, [repl_start, repl_end]);
376 376
         cm.setSelection({
377 377
             line: start_line_sel,
378
-            ch: 0
378
+            ch: 0,
379 379
         }, {
380 380
             line: end_line_sel,
381
-            ch: 0
381
+            ch: 0,
382 382
         });
383 383
     }
384 384
 
@@ -387,7 +387,7 @@ function toggleCodeBlock(editor) {
387 387
         cur_end = cm.getCursor('end'),
388 388
         tok = cm.getTokenAt({
389 389
             line: cur_start.line,
390
-            ch: cur_start.ch || 1
390
+            ch: cur_start.ch || 1,
391 391
         }), // avoid ch 0 which is a cursor pos but not token
392 392
         line = cm.getLineHandle(cur_start.line),
393 393
         is_code = code_type(cm, cur_start.line, line, tok);
@@ -399,10 +399,10 @@ function toggleCodeBlock(editor) {
399 399
             end = line.text.slice(cur_start.ch).replace('`', '');
400 400
         cm.replaceRange(start + end, {
401 401
             line: cur_start.line,
402
-            ch: 0
402
+            ch: 0,
403 403
         }, {
404 404
             line: cur_start.line,
405
-            ch: 99999999999999
405
+            ch: 99999999999999,
406 406
         });
407 407
         cur_start.ch--;
408 408
         if (cur_start !== cur_end) {
@@ -423,7 +423,7 @@ function toggleCodeBlock(editor) {
423 423
             }
424 424
             var fencedTok = cm.getTokenAt({
425 425
                 line: block_start,
426
-                ch: 1
426
+                ch: 1,
427 427
             });
428 428
             var fence_chars = token_state(fencedTok).fencedChars;
429 429
             var start_text, start_line;
@@ -460,25 +460,25 @@ function toggleCodeBlock(editor) {
460 460
                 // end line first, so that line numbers don't change
461 461
                 cm.replaceRange(end_text, {
462 462
                     line: end_line,
463
-                    ch: 0
463
+                    ch: 0,
464 464
                 }, {
465 465
                     line: end_line + (end_text ? 0 : 1),
466
-                    ch: 0
466
+                    ch: 0,
467 467
                 });
468 468
                 cm.replaceRange(start_text, {
469 469
                     line: start_line,
470
-                    ch: 0
470
+                    ch: 0,
471 471
                 }, {
472 472
                     line: start_line + (start_text ? 0 : 1),
473
-                    ch: 0
473
+                    ch: 0,
474 474
                 });
475 475
             });
476 476
             cm.setSelection({
477 477
                 line: start_line + (start_text ? 1 : 0),
478
-                ch: 0
478
+                ch: 0,
479 479
             }, {
480 480
                 line: end_line + (start_text ? 1 : -1),
481
-                ch: 0
481
+                ch: 0,
482 482
             });
483 483
             cm.focus();
484 484
         } else {
@@ -513,17 +513,17 @@ function toggleCodeBlock(editor) {
513 513
             cm.operation(function () {
514 514
                 cm.replaceRange('', {
515 515
                     line: block_start,
516
-                    ch: 0
516
+                    ch: 0,
517 517
                 }, {
518 518
                     line: block_start + 1,
519
-                    ch: 0
519
+                    ch: 0,
520 520
                 });
521 521
                 cm.replaceRange('', {
522 522
                     line: block_end - 1,
523
-                    ch: 0
523
+                    ch: 0,
524 524
                 }, {
525 525
                     line: block_end,
526
-                    ch: 0
526
+                    ch: 0,
527 527
                 });
528 528
             });
529 529
             cm.focus();
@@ -569,13 +569,13 @@ function toggleCodeBlock(editor) {
569 569
         var next_line = cm.getLineHandle(block_end + 1),
570 570
             next_line_last_tok = next_line && cm.getTokenAt({
571 571
                 line: block_end + 1,
572
-                ch: next_line.text.length - 1
572
+                ch: next_line.text.length - 1,
573 573
             }),
574 574
             next_line_indented = next_line_last_tok && token_state(next_line_last_tok).indentedCode;
575 575
         if (next_line_indented) {
576 576
             cm.replaceRange('\n', {
577 577
                 line: block_end + 1,
578
-                ch: 0
578
+                ch: 0,
579 579
             });
580 580
         }
581 581
 
@@ -678,7 +678,7 @@ function drawLink(editor) {
678 678
     var options = editor.options;
679 679
     var url = 'https://';
680 680
     if (options.promptURLs) {
681
-        url = prompt(options.promptTexts.link);
681
+        url = prompt(options.promptTexts.link, 'https://');
682 682
         if (!url) {
683 683
             return false;
684 684
         }
@@ -695,7 +695,7 @@ function drawImage(editor) {
695 695
     var options = editor.options;
696 696
     var url = 'https://';
697 697
     if (options.promptURLs) {
698
-        url = prompt(options.promptTexts.image);
698
+        url = prompt(options.promptTexts.image, 'https://');
699 699
         if (!url) {
700 700
             return false;
701 701
         }
@@ -867,7 +867,7 @@ function _replaceSelection(cm, active, startEnd, url) {
867 867
         end = text.slice(startPoint.ch);
868 868
         cm.replaceRange(start + end, {
869 869
             line: startPoint.line,
870
-            ch: 0
870
+            ch: 0,
871 871
         });
872 872
     } else {
873 873
         text = cm.getSelection();
@@ -942,10 +942,10 @@ function _toggleHeading(cm, direction, size) {
942 942
 
943 943
             cm.replaceRange(text, {
944 944
                 line: i,
945
-                ch: 0
945
+                ch: 0,
946 946
             }, {
947 947
                 line: i,
948
-                ch: 99999999999999
948
+                ch: 99999999999999,
949 949
             });
950 950
         })(i);
951 951
     }
@@ -966,14 +966,14 @@ function _toggleLine(cm, name) {
966 966
     var repl = {
967 967
         'quote': /^(\s*)>\s+/,
968 968
         'unordered-list': listRegexp,
969
-        'ordered-list': listRegexp
969
+        'ordered-list': listRegexp,
970 970
     };
971 971
 
972 972
     var _getChar = function (name, i) {
973 973
         var map = {
974 974
             'quote': '>',
975 975
             'unordered-list': '*',
976
-            'ordered-list': '%%i.'
976
+            'ordered-list': '%%i.',
977 977
         };
978 978
 
979 979
         return map[name].replace('%%i', i);
@@ -983,7 +983,7 @@ function _toggleLine(cm, name) {
983 983
         var map = {
984 984
             'quote': '>',
985 985
             'unordered-list': '*',
986
-            'ordered-list': 'd+.'
986
+            'ordered-list': 'd+.',
987 987
         };
988 988
         var rt = new RegExp(map[name]);
989 989
 
@@ -1011,10 +1011,10 @@ function _toggleLine(cm, name) {
1011 1011
             }
1012 1012
             cm.replaceRange(text, {
1013 1013
                 line: i,
1014
-                ch: 0
1014
+                ch: 0,
1015 1015
             }, {
1016 1016
                 line: i,
1017
-                ch: 99999999999999
1017
+                ch: 99999999999999,
1018 1018
             });
1019 1019
         })(i);
1020 1020
     }
@@ -1052,10 +1052,10 @@ function _toggleBlock(editor, type, start_chars, end_chars) {
1052 1052
         }
1053 1053
         cm.replaceRange(start + end, {
1054 1054
             line: startPoint.line,
1055
-            ch: 0
1055
+            ch: 0,
1056 1056
         }, {
1057 1057
             line: startPoint.line,
1058
-            ch: 99999999999999
1058
+            ch: 99999999999999,
1059 1059
         });
1060 1060
 
1061 1061
         if (type == 'bold' || type == 'strikethrough') {
@@ -1104,10 +1104,10 @@ function _cleanBlock(cm) {
1104 1104
 
1105 1105
         cm.replaceRange(text, {
1106 1106
             line: line,
1107
-            ch: 0
1107
+            ch: 0,
1108 1108
         }, {
1109 1109
             line: line,
1110
-            ch: 99999999999999
1110
+            ch: 99999999999999,
1111 1111
         });
1112 1112
     }
1113 1113
 }
@@ -1144,7 +1144,7 @@ function extend(target) {
1144 1144
 
1145 1145
 /* The right word count in respect for CJK. */
1146 1146
 function wordCount(data) {
1147
-    var pattern = /[a-zA-Z0-9_\u0392-\u03c9\u0410-\u04F9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
1147
+    var pattern = /[a-zA-Z0-9_\u00A0-\u02AF\u0392-\u03c9\u0410-\u04F9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
1148 1148
     var m = data.match(pattern);
1149 1149
     var count = 0;
1150 1150
     if (m === null) return count;
@@ -1164,125 +1164,125 @@ var toolbarBuiltInButtons = {
1164 1164
         action: toggleBold,
1165 1165
         className: 'fa fa-bold',
1166 1166
         title: 'Bold',
1167
-        default: true
1167
+        default: true,
1168 1168
     },
1169 1169
     'italic': {
1170 1170
         name: 'italic',
1171 1171
         action: toggleItalic,
1172 1172
         className: 'fa fa-italic',
1173 1173
         title: 'Italic',
1174
-        default: true
1174
+        default: true,
1175 1175
     },
1176 1176
     'strikethrough': {
1177 1177
         name: 'strikethrough',
1178 1178
         action: toggleStrikethrough,
1179 1179
         className: 'fa fa-strikethrough',
1180
-        title: 'Strikethrough'
1180
+        title: 'Strikethrough',
1181 1181
     },
1182 1182
     'heading': {
1183 1183
         name: 'heading',
1184 1184
         action: toggleHeadingSmaller,
1185 1185
         className: 'fa fa-header fa-heading',
1186 1186
         title: 'Heading',
1187
-        default: true
1187
+        default: true,
1188 1188
     },
1189 1189
     'heading-smaller': {
1190 1190
         name: 'heading-smaller',
1191 1191
         action: toggleHeadingSmaller,
1192 1192
         className: 'fa fa-header fa-heading header-smaller',
1193
-        title: 'Smaller Heading'
1193
+        title: 'Smaller Heading',
1194 1194
     },
1195 1195
     'heading-bigger': {
1196 1196
         name: 'heading-bigger',
1197 1197
         action: toggleHeadingBigger,
1198 1198
         className: 'fa fa-header fa-heading header-bigger',
1199
-        title: 'Bigger Heading'
1199
+        title: 'Bigger Heading',
1200 1200
     },
1201 1201
     'heading-1': {
1202 1202
         name: 'heading-1',
1203 1203
         action: toggleHeading1,
1204 1204
         className: 'fa fa-header fa-heading header-1',
1205
-        title: 'Big Heading'
1205
+        title: 'Big Heading',
1206 1206
     },
1207 1207
     'heading-2': {
1208 1208
         name: 'heading-2',
1209 1209
         action: toggleHeading2,
1210 1210
         className: 'fa fa-header fa-heading header-2',
1211
-        title: 'Medium Heading'
1211
+        title: 'Medium Heading',
1212 1212
     },
1213 1213
     'heading-3': {
1214 1214
         name: 'heading-3',
1215 1215
         action: toggleHeading3,
1216 1216
         className: 'fa fa-header fa-heading header-3',
1217
-        title: 'Small Heading'
1217
+        title: 'Small Heading',
1218 1218
     },
1219 1219
     'separator-1': {
1220
-        name: 'separator-1'
1220
+        name: 'separator-1',
1221 1221
     },
1222 1222
     'code': {
1223 1223
         name: 'code',
1224 1224
         action: toggleCodeBlock,
1225 1225
         className: 'fa fa-code',
1226
-        title: 'Code'
1226
+        title: 'Code',
1227 1227
     },
1228 1228
     'quote': {
1229 1229
         name: 'quote',
1230 1230
         action: toggleBlockquote,
1231 1231
         className: 'fa fa-quote-left',
1232 1232
         title: 'Quote',
1233
-        default: true
1233
+        default: true,
1234 1234
     },
1235 1235
     'unordered-list': {
1236 1236
         name: 'unordered-list',
1237 1237
         action: toggleUnorderedList,
1238 1238
         className: 'fa fa-list-ul',
1239 1239
         title: 'Generic List',
1240
-        default: true
1240
+        default: true,
1241 1241
     },
1242 1242
     'ordered-list': {
1243 1243
         name: 'ordered-list',
1244 1244
         action: toggleOrderedList,
1245 1245
         className: 'fa fa-list-ol',
1246 1246
         title: 'Numbered List',
1247
-        default: true
1247
+        default: true,
1248 1248
     },
1249 1249
     'clean-block': {
1250 1250
         name: 'clean-block',
1251 1251
         action: cleanBlock,
1252 1252
         className: 'fa fa-eraser',
1253
-        title: 'Clean block'
1253
+        title: 'Clean block',
1254 1254
     },
1255 1255
     'separator-2': {
1256
-        name: 'separator-2'
1256
+        name: 'separator-2',
1257 1257
     },
1258 1258
     'link': {
1259 1259
         name: 'link',
1260 1260
         action: drawLink,
1261 1261
         className: 'fa fa-link',
1262 1262
         title: 'Create Link',
1263
-        default: true
1263
+        default: true,
1264 1264
     },
1265 1265
     'image': {
1266 1266
         name: 'image',
1267 1267
         action: drawImage,
1268 1268
         className: 'fa fa-image',
1269 1269
         title: 'Insert Image',
1270
-        default: true
1270
+        default: true,
1271 1271
     },
1272 1272
     'table': {
1273 1273
         name: 'table',
1274 1274
         action: drawTable,
1275 1275
         className: 'fa fa-table',
1276
-        title: 'Insert Table'
1276
+        title: 'Insert Table',
1277 1277
     },
1278 1278
     'horizontal-rule': {
1279 1279
         name: 'horizontal-rule',
1280 1280
         action: drawHorizontalRule,
1281 1281
         className: 'fa fa-minus',
1282
-        title: 'Insert Horizontal Line'
1282
+        title: 'Insert Horizontal Line',
1283 1283
     },
1284 1284
     'separator-3': {
1285
-        name: 'separator-3'
1285
+        name: 'separator-3',
1286 1286
     },
1287 1287
     'preview': {
1288 1288
         name: 'preview',
@@ -1290,7 +1290,7 @@ var toolbarBuiltInButtons = {
1290 1290
         className: 'fa fa-eye',
1291 1291
         noDisable: true,
1292 1292
         title: 'Toggle Preview',
1293
-        default: true
1293
+        default: true,
1294 1294
     },
1295 1295
     'side-by-side': {
1296 1296
         name: 'side-by-side',
@@ -1299,7 +1299,7 @@ var toolbarBuiltInButtons = {
1299 1299
         noDisable: true,
1300 1300
         noMobile: true,
1301 1301
         title: 'Toggle Side by Side',
1302
-        default: true
1302
+        default: true,
1303 1303
     },
1304 1304
     'fullscreen': {
1305 1305
         name: 'fullscreen',
@@ -1308,54 +1308,54 @@ var toolbarBuiltInButtons = {
1308 1308
         noDisable: true,
1309 1309
         noMobile: true,
1310 1310
         title: 'Toggle Fullscreen',
1311
-        default: true
1311
+        default: true,
1312 1312
     },
1313 1313
     'separator-4': {
1314
-        name: 'separator-4'
1314
+        name: 'separator-4',
1315 1315
     },
1316 1316
     'guide': {
1317 1317
         name: 'guide',
1318
-        action: 'https://simplemde.com/markdown-guide',
1318
+        action: 'https://www.markdownguide.org/basic-syntax/',
1319 1319
         className: 'fa fa-question-circle',
1320 1320
         noDisable: true,
1321 1321
         title: 'Markdown Guide',
1322
-        default: true
1322
+        default: true,
1323 1323
     },
1324 1324
     'separator-5': {
1325
-        name: 'separator-5'
1325
+        name: 'separator-5',
1326 1326
     },
1327 1327
     'undo': {
1328 1328
         name: 'undo',
1329 1329
         action: undo,
1330 1330
         className: 'fa fa-undo',
1331 1331
         noDisable: true,
1332
-        title: 'Undo'
1332
+        title: 'Undo',
1333 1333
     },
1334 1334
     'redo': {
1335 1335
         name: 'redo',
1336 1336
         action: redo,
1337 1337
         className: 'fa fa-repeat fa-redo',
1338 1338
         noDisable: true,
1339
-        title: 'Redo'
1340
-    }
1339
+        title: 'Redo',
1340
+    },
1341 1341
 };
1342 1342
 
1343 1343
 var insertTexts = {
1344 1344
     link: ['[', '](#url#)'],
1345 1345
     image: ['![](', '#url#)'],
1346 1346
     table: ['', '\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text     | Text     | Text     |\n\n'],
1347
-    horizontalRule: ['', '\n\n-----\n\n']
1347
+    horizontalRule: ['', '\n\n-----\n\n'],
1348 1348
 };
1349 1349
 
1350 1350
 var promptTexts = {
1351 1351
     link: 'URL for the link:',
1352
-    image: 'URL of the image:'
1352
+    image: 'URL of the image:',
1353 1353
 };
1354 1354
 
1355 1355
 var blockStyles = {
1356 1356
     'bold': '**',
1357 1357
     'code': '```',
1358
-    'italic': '*'
1358
+    'italic': '*',
1359 1359
 };
1360 1360
 
1361 1361
 /**
@@ -1443,7 +1443,7 @@ function EasyMDE(options) {
1443 1443
 
1444 1444
     // Set default options for parsing config
1445 1445
     options.parsingConfig = extend({
1446
-        highlightFormatting: true // needed for toggleCodeBlock to detect types of code
1446
+        highlightFormatting: true, // needed for toggleCodeBlock to detect types of code
1447 1447
     }, options.parsingConfig || {});
1448 1448
 
1449 1449
 
@@ -1585,7 +1585,7 @@ EasyMDE.prototype.render = function (el) {
1585 1585
         backdrop.gitHubSpice = false;
1586 1586
 
1587 1587
         CodeMirrorSpellChecker({
1588
-            codeMirrorInstance: CodeMirror
1588
+            codeMirrorInstance: CodeMirror,
1589 1589
         });
1590 1590
     } else {
1591 1591
         mode = options.parsingConfig;
@@ -1596,7 +1596,7 @@ EasyMDE.prototype.render = function (el) {
1596 1596
     // eslint-disable-next-line no-unused-vars
1597 1597
     function configureMouse(cm, repeat, event) {
1598 1598
         return {
1599
-            addNew: false
1599
+            addNew: false,
1600 1600
         };
1601 1601
     }
1602 1602
 
@@ -1614,7 +1614,7 @@ EasyMDE.prototype.render = function (el) {
1614 1614
         allowDropFileTypes: ['text/plain'],
1615 1615
         placeholder: options.placeholder || el.getAttribute('placeholder') || '',
1616 1616
         styleSelectedText: (options.styleSelectedText != undefined) ? options.styleSelectedText : !isMobile(),
1617
-        configureMouse: configureMouse
1617
+        configureMouse: configureMouse,
1618 1618
     });
1619 1619
 
1620 1620
     this.codemirror.getScrollerElement().style.minHeight = options.minHeight;
@@ -1914,7 +1914,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
1914 1914
             items.push({
1915 1915
                 className: status[i].className,
1916 1916
                 defaultValue: status[i].defaultValue,
1917
-                onUpdate: status[i].onUpdate
1917
+                onUpdate: status[i].onUpdate,
1918 1918
             });
1919 1919
         } else {
1920 1920
             var name = status[i];
@@ -1952,7 +1952,7 @@ EasyMDE.prototype.createStatusbar = function (status) {
1952 1952
             items.push({
1953 1953
                 className: name,
1954 1954
                 defaultValue: defaultValue,
1955
-                onUpdate: onUpdate
1955
+                onUpdate: onUpdate,
1956 1956
             });
1957 1957
         }
1958 1958
     }

+ 9
- 5
types/easymde-test.ts View File

@@ -1,14 +1,16 @@
1 1
 // Create new instance
2 2
 const editor = new EasyMDE({
3 3
     autoDownloadFontAwesome: false,
4
-    element: document.getElementById("mdEditor")!,
5
-    hideIcons: ["side-by-side", "fullscreen"],
4
+    element: document.getElementById('mdEditor')!,
5
+    hideIcons: ['side-by-side', 'fullscreen'],
6 6
     shortcuts: {
7
-        drawTable: "Cmd-Alt-T",
7
+        drawTable: 'Cmd-Alt-T',
8 8
         toggleFullScreen: null
9 9
     },
10 10
     spellChecker: false,
11
-    onToggleFullScreen: (full: boolean) => { console.log('FullscreenToggled', full); },
11
+    onToggleFullScreen: (full: boolean) => {
12
+        console.log('FullscreenToggled', full);
13
+    },
12 14
     theme: 'someOtherTheme',
13 15
 });
14 16
 
@@ -23,4 +25,6 @@ const fullscreen = editor.isFullscreenActive() as boolean;
23 25
 editor.codemirror.setOption('readOnly', true);
24 26
 
25 27
 // Static properties
26
-EasyMDE.toggleItalic = (editor: EasyMDE) => { console.log('SomeButtonOverride'); };
28
+EasyMDE.toggleItalic = (editor: EasyMDE) => {
29
+    console.log('SomeButtonOverride');
30
+};

+ 11
- 3
types/easymde.d.ts View File

@@ -54,6 +54,7 @@ declare namespace EasyMDE {
54 54
 
55 55
     interface Shortcuts {
56 56
         [action: string]: string | undefined | null;
57
+
57 58
         toggleBlockquote?: string | null;
58 59
         toggleBold?: string | null;
59 60
         cleanBlock?: string | null;
@@ -78,7 +79,7 @@ declare namespace EasyMDE {
78 79
 
79 80
     interface ToolbarIcon {
80 81
         name: string;
81
-        action: string|((editor: EasyMDE) => void);
82
+        action: string | ((editor: EasyMDE) => void);
82 83
         className: string;
83 84
         title: string;
84 85
         noDisable?: boolean;
@@ -105,10 +106,10 @@ declare namespace EasyMDE {
105 106
         shortcuts?: Shortcuts;
106 107
         showIcons?: ReadonlyArray<string>;
107 108
         spellChecker?: boolean;
108
-        status?: boolean|ReadonlyArray<string|StatusBarItem>;
109
+        status?: boolean | ReadonlyArray<string | StatusBarItem>;
109 110
         styleSelectedText?: boolean;
110 111
         tabSize?: number;
111
-        toolbar?: boolean|ReadonlyArray<string|ToolbarIcon>;
112
+        toolbar?: boolean | ReadonlyArray<string | ToolbarIcon>;
112 113
         toolbarTips?: boolean;
113 114
         onToggleFullScreen?: (goingIntoFullScreen: boolean) => void;
114 115
         theme?: string;
@@ -117,13 +118,20 @@ declare namespace EasyMDE {
117 118
 
118 119
 declare class EasyMDE {
119 120
     constructor(options?: EasyMDE.Options);
121
+
120 122
     value(): string;
121 123
     value(val: string): void;
124
+
122 125
     codemirror: CodeMirror.Editor;
126
+
123 127
     toTextArea(): void;
128
+
124 129
     isPreviewActive(): boolean;
130
+
125 131
     isSideBySideActive(): boolean;
132
+
126 133
     isFullscreenActive(): boolean;
134
+
127 135
     clearAutosavedValue(): void;
128 136
 
129 137
     static toggleBold: (editor: EasyMDE) => void;

Loading…
Cancel
Save