');
231 | });
232 | });
233 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # EasyMDE Changelog
2 | All notable changes to EasyMDE will be documented in this file.
3 |
4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6 |
7 |
8 | ## [2.20.0] - 2025-03-04
9 | ### Added
10 | - Support for `marked` extensions (Thanks to [@codingjoe], [#611], [#514]).
11 |
12 | ## [2.19.0] - 2025-02-18
13 | ### Added
14 | - `updateStatusBar` type to typescript definitions (Thanks to [@borodean], [#519]).
15 | - `"upload-image"` option to the `ToolbarButton` typescript definitions (Thanks to [@borodean], [#520]).
16 | - `imageInputName` option to set a custom "name" attribute for the image input (Thanks to [@robinvandernoord], [#573]).
17 |
18 | ### Fixed
19 | - Relative image paths using the stylesheet as the source instead of the document (Thanks to [@p1gp1g], [#591]).
20 | - Excessive memory usage with the `previewImagesInEditor` option (Thanks to [@p1gp1g], [#592]).
21 | - Parentheses in the alt text of images causing the image not to load then using `previewImagesInEditor` (Thanks to [@mayraamaral], [#608]).
22 |
23 | ## [2.18.0] - 2022-09-20
24 | ### Added
25 | - `toolbarButtonClassPrefix` option to resolve conflicts with Bootstrap classes ([#493]).
26 |
27 | ## [2.17.0] - 2022-08-20
28 | ### Added
29 | - Improved CSRF support for uploading images (Thanks to [@ZsgsDesign], [#394]).
30 | - Option to register an image preview handler: `imagesPreviewHandler` (Thanks to [@diego-gw], [#411]).
31 | - Support for `.webp` image formats (Thanks to [@sghoweri], [#417]).
32 | - `toggleHeading` methods for headings 4, 5 and 6 (Thanks to [@vanillajonathan], [#449] and [#492]).
33 | - Support for `.gif`, `.avif` and `.apng` image formats (Thanks to [@vanillajonathan], [#450], [#458] and [#459]).
34 | - Keyboard shortcuts for `toggleHeading` methods (Thanks to [@vanillajonathan], [#451]).
35 | - `iconClassMap` option to specify icon class names for toolbar buttons (Thanks to [@vanillajonathan], [#454]).
36 | - `role="toolbar"` on the toolbar element (Thanks to [@vanillajonathan], [#455]).
37 | - Support for text buttons in the toolbar (Thanks to [@vanillajonathan], [#461]).
38 | - `aria-label` attribute for toolbar buttons (uses the `title` option) (Thanks to [@vanillajonathan], [#463]).
39 | - `role="application"` on the editor container element (Thanks to [@vanillajonathan], [#464]).
40 | - Option to not overwrite the preview HTML by returning `null` from `previewRender` (Thanks to [@LevitatingOrange], [#471]).
41 |
42 | ### Fixed
43 | - Hyperlink doubling (Thanks to [@danielok1993], [#95]).
44 | - URLs with certain characters entered through prompts causing invalid markdown (Thanks to [@Zignature], [#393]).
45 | - Autofocus option not working properly ([#399]).
46 | - Inconsistent border colour (Thanks to [@vanillajonathan], [#466]).
47 | - Invalid regex on Safari browsers ([#478])
48 | - `hideIcons` option type (Thanks to [@LoyalPotato], [#488]).
49 |
50 | ### Changed
51 | - Editor now uses responsive font sizes (Thanks to [@vanillajonathan], [#452]).
52 |
53 | ### Documentation
54 | - Added several improvements to README (Thanks to [@vanillajonathan], [#436], [#438], [#440], [#444]).
55 | - Fixed typo in README (Thanks to [@kicksent], [#484]).
56 | - Added missing icon for `upload-image` in README (Thanks to [@hlf20010508], [#486]).
57 |
58 | ## [2.16.1] - 2022-01-14
59 | ### Fixed
60 | - Incorrect initial line and column count in status bar.
61 | - Security issue in `marked` dependency.
62 |
63 | ## [2.16.0] - 2022-01-11
64 | ### Added
65 | - `direction` option to enable RTL mode (Thanks to [@souljuse], [#358]).
66 | - `attributes` option to add custom attributes to toolbar buttons (Thanks to [@Zignature], [#388]).
67 | - `unorderedListStyle` option to change the character used for unordered lists (Thanks to [@Zignature], [#389]).
68 |
69 | ### Fixed
70 | - Image extension detection when extension is uppercase (Thanks to [@ukjinjang], [#357]).
71 | - Submenu actions not working in Chromium Browsers (Thanks to [@Offerel], [@robjean9] and [@kelvinj], [#364]).
72 | - Incorrect line and column count in status bar (Thanks to [@Zignature], [#384]).
73 |
74 | ## [2.15.0] - 2021-04-22
75 | ### Added
76 | - `imagePathAbsolute` option to return the absolute path when uploading an image (Thanks to [@wwsalmon], [#313]).
77 |
78 | ### Fixed
79 | - `ToolbarIcon` typings, added `icon` (Thanks to [@ChronosMasterOfAllTime], [#308]).
80 | - Image link extension when it was not the last part of the URL (Thanks to [@deerboy], [#311]).
81 | - Preview mode did not stay enabled when toggling to fullscreen (Thanks to [@smundro], [#316]).
82 | - Required typings not being included in `dependencies` (Thanks to [@marekdedic], [#322]).
83 |
84 | ## [2.14.0] - 2021-02-14
85 | ### Added
86 | - The `scrollbarStyle` option to change the style of the scrollbar (Thanks to [@danice], [#250]).
87 |
88 | ### Fixed
89 | - Issues with images not displaying correctly in the preview screen (Thanks to [@ivictbor], [#253]).
90 | - An error when both `sideBySideFullscreen` and `status` were set to `false` (Thanks to [@joahim], [#272]).
91 | - Editor trying to display non-image files (Thanks to [@Juupaa], [#277])
92 | - Unneeded call to `window.removeEventListener` (Thanks to [@emirotin], [#280])
93 | - Spell checker (Thanks to [@Fanvadar], [#284]).
94 | - Focus issues with toolbar dropdown menus (Thanks to [@Situphen], [#285]).
95 | - Interaction between the `sideBySideFullscreen` and the preview state (Thanks to [@smundro], [#286])
96 | - Refactored strange method of padding the toolbar into regular padding (Thanks to [@sn3p], [#293]).
97 | - Security issue in `marked` dependency (Thanks to [@dependabot], [#298]).
98 |
99 | ## [2.13.0] - 2020-11-11
100 | ### Added
101 | - CodeMirror autorefresh plugin and autoRefresh option (Thanks to [@mbolli], [#249]).
102 | - `lineNumbers` option to display line numbers in the editor (Thanks to [@nhymxu], [#267]).
103 |
104 | ### Fixed
105 | - CSS scoping issues when the editor is used in combination with other CodeMirror instances ([#252]).
106 |
107 | ## [2.12.1] - 2020-10-06
108 | ### Changed
109 | - Set `previewImagesInEditor` option to `false` by default ([#251]).
110 |
111 | ## [2.12.0] - 2020-09-29
112 | ### Added
113 | - `this` context in imageUploadFunction (Thanks to [@JoshuaLicense], [#225]).
114 | - `previewImagesInEditor` option to display images in editor mode (Thanks to [@ivictbor], [#235]).
115 | - `overlayMode` options to supply an additional codemirror mode (Thanks to [@czynskee], [#244]).
116 |
117 | ### Fixed
118 | - Corrected default size units from `b,Kb,Mb` to ` B, KB, MB` ([#239]).
119 | - Max height less than min height (Thanks to [@nick-denry], [#222]).
120 | - toTextArea issue (Thanks to [@nick-denry], [#223]).
121 | - Error when updateStatusBar was called during image upload, but the status bar is disabled (Thanks to [@JoshuaLicense], [#224]).
122 |
123 | ## [2.11.0] - 2020-07-16
124 | ### Added
125 | - Support for Node.js 14.
126 | - Preview without fullscreen (Thanks to [@nick-denry], [#196]).
127 |
128 | ### Fixed
129 | - Fix cursor displayed position on activity (Thanks to [@firm1], [#184]).
130 | - Checkboxes always have bullets in front of them ([#136]).
131 | - Save the text only when modifying the content of the easymde instance (Thanks to [@firm1], [#181]).
132 |
133 | ## [2.10.1] - 2020-04-06
134 | ### Fixed
135 | - Typescript error when entering certain strings for toolbar buttons ([#178]).
136 |
137 | ## [2.10.0] - 2020-04-02
138 | ### Added
139 | - `inputStyle` and `nativeSpellcheck` options to manage the native language of the browser (Thanks to [@firm1], [#143]).
140 | - Group buttons in drop-down lists by adding a sub-option `children` for the items in the toolbar (Thanks to [@firm1], [#141]).
141 | - `sanitizerFunction` option to allow custom HTML sanitizing in the markdown preview (Thanks to [@adamb70], [#147]).
142 | - Time formatting and custom text options for the autosave message (Thanks to [@dima-bzz], [#170]).
143 |
144 | ### Changed
145 | - Delay before assuming that submit of the form as failed is `autosave.submit_delay` instead of `autosave.delay` (Thanks to [@Situphen], [#139]).
146 | - Add `watch` task for gulp (Thanks to [@A-312], [#150]).
147 |
148 | ### Fixed
149 | - Issue with Marked when using IE11 and webpack (Thanks to [@felipefdl], [#169]).
150 | - Updated codemirror to version 5.52.2 (Thanks to [@A-312], [#173]).
151 | - Editor displaying on top of other elements on a webpage (Thanks to [@StefKors], [#175]).
152 |
153 | ## [2.9.0] - 2020-01-13
154 | ### Added
155 | - Missing minHeight option in type definition (Thanks to [@t49tran], [#123]).
156 | - Other missing type definitions ([#126]).
157 |
158 | ### Changed
159 | - The editor will remove its saved contents when the editor is emptied, allowing to reload a default value (Thanks to [@Situphen], [#132]).
160 |
161 | ## [2.8.0] - 2019-08-20
162 | ### Added
163 | - Upload images functionality (Thanks to [@roipoussiere] and [@JeroenvO], [#71], [#101]).
164 | - Allow custom image upload function (Thanks to [@sperezp], [#106]).
165 | - More polish to the upload images functionality (Thanks to [@jfly], [#109]).
166 | - Improved React compatibility (Thanks to [@richtera], [#97]).
167 |
168 | ### Fixed
169 | - Missing link in dist file header.
170 |
171 | ## [2.7.0] - 2019-07-13
172 | ### Added
173 | - `previewClass` option for overwriting the preview screen class ([#99]).
174 |
175 | ### Fixed
176 | - Updated dependencies to resolve potential security issue.
177 | - Resolved small code style issues shown by new eslint rules.
178 |
179 | ## [2.6.1] - 2019-06-17
180 | ### Fixed
181 | - Error when toggling between ordered and unordered lists (Thanks to [@roryok], [#93]).
182 | - Keyboard shortcuts for custom actions not working (Thanks to [@ysykzheng], [#75]).
183 |
184 | ## [2.6.0] - 2019-04-15
185 | ### Added
186 | - Contributing guide (Thanks to [@roipoussiere], [#54]).
187 | - Issue templates.
188 | - Standardized changelog file.
189 |
190 | ### Changed
191 | - Finish rewrite of README (Thanks to [@roipoussiere], [#54]).
192 | - Image and link prompt fill with "https://" by default.
193 | - Link to markdown guide to .
194 |
195 | ### Fixed
196 | - Backwards compatibility in the API with SimpleMDE 1.0.0 ([#41]).
197 | - Automatic publish of master branch to `@next`
198 |
199 | ### Removed
200 | - Distribution files from source-control.
201 |
202 | ## [2.5.1] - 2019-01-17
203 | ### Fixed
204 | - `role="button"` needed to be `type="button"` ([#45]).
205 |
206 | ## [2.5.0] - 2019-01-17
207 | ### Added
208 | - Typescript support (Thanks to [@FranklinWhale], [#44]).
209 | - `role="button"` to toolbar buttons ([#38]).
210 |
211 | ### Fixed
212 | - Eraser icon not working with FontAwesome 5.
213 |
214 | ## [2.4.2] - 2018-11-09
215 | ### Added
216 | - Node.js 11 support.
217 |
218 | ### Fixed
219 | - Header button icons not showing sub-icons with FontAwesome 5.
220 | - Inconsistent autosave behaviour when submitting a form (Thanks to [@Furgas] and [@adamb70], [#31]).
221 |
222 | ## [2.4.1] - 2018-10-15
223 | ### Added
224 | - `fa-redo` class to redo button for FA5 compatibility (Thanks to [@Summon528], [#27]).
225 |
226 | ## [2.4.0] - 2018-10-15
227 | ### Added
228 | - Theming support (Thanks to [@LeviticusMB], [#17]).
229 | - onToggleFullscreen event hook (Thanks to [@n-3-0], [#16]).
230 |
231 | ### Fixed
232 | - Fullscreen not working with `toolbar: false` (Thanks to [@aphitiel], [#19]).
233 |
234 | ## [2.2.2] - 2019-07-03
235 | ### Fixed
236 | - Automatic publish only publishing tags.
237 |
238 | ## [2.2.1] - 2019-06-29
239 | ### Changed
240 | - Attempt automatic publish `@next` version on npm.
241 | - Links in the preview window will open in a new tab by default.
242 |
243 | ### Fixed
244 | - Multi-text select issue by disabling multi-select in the editor ([#10]).
245 | - `main` file in package.json (Thanks to [@sne11ius], [#11]).
246 |
247 | ## [2.0.1] - 2018-05-13
248 | ### Changed
249 | - Rewrote part of the documentation for EasyMDE.
250 | - Updated gulp to version 4.0.0.
251 |
252 | ### Fixed
253 | - Icons for `heading-smaller`, `heading-bigger`, `heading-1`, `heading-2` and `heading-3` not showing ([#9]).
254 |
255 | ## [2.0.0] - 2018-04-23
256 | Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown-editor)
257 |
258 | ### BREAKING CHANGES
259 | - Dropped Bower support.
260 | - Dropped support for older Node.js versions.
261 |
262 | ### Added
263 | - FontAwesome 5 support.
264 | - Support for newer Node.js versions.
265 |
266 | ### Changed
267 | - Packages are now version-locked.
268 | - Simplified build script.
269 | - Markdown guide button is no longer disabled in preview mode.
270 |
271 | ### Fixed
272 | - Cursor not always showing in "text" mode over the edit field
273 |
274 |
275 | [#611]: https://github.com/Ionaru/easy-markdown-editor/issues/611
276 | [#514]: https://github.com/Ionaru/easy-markdown-editor/issues/514
277 | [#493]: https://github.com/Ionaru/easy-markdown-editor/issues/493
278 | [#478]: https://github.com/Ionaru/easy-markdown-editor/issues/478
279 | [#399]: https://github.com/Ionaru/easy-markdown-editor/issues/399
280 | [#252]: https://github.com/Ionaru/easy-markdown-editor/issues/252
281 | [#251]: https://github.com/Ionaru/easy-markdown-editor/issues/251
282 | [#239]: https://github.com/Ionaru/easy-markdown-editor/issues/239
283 | [#178]: https://github.com/Ionaru/easy-markdown-editor/issues/178
284 | [#136]: https://github.com/Ionaru/easy-markdown-editor/issues/136
285 | [#126]: https://github.com/Ionaru/easy-markdown-editor/issues/126
286 | [#99]: https://github.com/Ionaru/easy-markdown-editor/issues/99
287 | [#45]: https://github.com/Ionaru/easy-markdown-editor/issues/45
288 | [#44]: https://github.com/Ionaru/easy-markdown-editor/issues/44
289 | [#41]: https://github.com/Ionaru/easy-markdown-editor/issues/41
290 | [#38]: https://github.com/Ionaru/easy-markdown-editor/issues/38
291 | [#17]: https://github.com/Ionaru/easy-markdown-editor/issues/17
292 | [#16]: https://github.com/Ionaru/easy-markdown-editor/issues/16
293 | [#11]: https://github.com/Ionaru/easy-markdown-editor/issues/11
294 | [#10]: https://github.com/Ionaru/easy-markdown-editor/issues/10
295 | [#9]: https://github.com/Ionaru/easy-markdown-editor/issues/9
296 |
297 |
298 | [#608]: https://github.com/Ionaru/easy-markdown-editor/pull/608
299 | [#592]: https://github.com/Ionaru/easy-markdown-editor/pull/592
300 | [#591]: https://github.com/Ionaru/easy-markdown-editor/pull/591
301 | [#573]: https://github.com/Ionaru/easy-markdown-editor/pull/573
302 | [#520]: https://github.com/Ionaru/easy-markdown-editor/pull/520
303 | [#519]: https://github.com/Ionaru/easy-markdown-editor/pull/519
304 | [#492]: https://github.com/Ionaru/easy-markdown-editor/pull/492
305 | [#488]: https://github.com/Ionaru/easy-markdown-editor/pull/488
306 | [#486]: https://github.com/Ionaru/easy-markdown-editor/pull/486
307 | [#484]: https://github.com/Ionaru/easy-markdown-editor/pull/484
308 | [#479]: https://github.com/Ionaru/easy-markdown-editor/pull/479
309 | [#471]: https://github.com/Ionaru/easy-markdown-editor/pull/471
310 | [#467]: https://github.com/Ionaru/easy-markdown-editor/pull/467
311 | [#466]: https://github.com/Ionaru/easy-markdown-editor/pull/466
312 | [#464]: https://github.com/Ionaru/easy-markdown-editor/pull/464
313 | [#463]: https://github.com/Ionaru/easy-markdown-editor/pull/463
314 | [#461]: https://github.com/Ionaru/easy-markdown-editor/pull/461
315 | [#459]: https://github.com/Ionaru/easy-markdown-editor/pull/459
316 | [#458]: https://github.com/Ionaru/easy-markdown-editor/pull/458
317 | [#455]: https://github.com/Ionaru/easy-markdown-editor/pull/455
318 | [#454]: https://github.com/Ionaru/easy-markdown-editor/pull/454
319 | [#452]: https://github.com/Ionaru/easy-markdown-editor/pull/452
320 | [#451]: https://github.com/Ionaru/easy-markdown-editor/pull/451
321 | [#450]: https://github.com/Ionaru/easy-markdown-editor/pull/450
322 | [#449]: https://github.com/Ionaru/easy-markdown-editor/pull/449
323 | [#444]: https://github.com/Ionaru/easy-markdown-editor/pull/444
324 | [#440]: https://github.com/Ionaru/easy-markdown-editor/pull/440
325 | [#438]: https://github.com/Ionaru/easy-markdown-editor/pull/438
326 | [#436]: https://github.com/Ionaru/easy-markdown-editor/pull/436
327 | [#417]: https://github.com/Ionaru/easy-markdown-editor/pull/417
328 | [#411]: https://github.com/Ionaru/easy-markdown-editor/pull/411
329 | [#394]: https://github.com/Ionaru/easy-markdown-editor/pull/394
330 | [#393]: https://github.com/Ionaru/easy-markdown-editor/pull/393
331 | [#389]: https://github.com/Ionaru/easy-markdown-editor/pull/389
332 | [#388]: https://github.com/Ionaru/easy-markdown-editor/pull/388
333 | [#384]: https://github.com/Ionaru/easy-markdown-editor/pull/384
334 | [#364]: https://github.com/Ionaru/easy-markdown-editor/pull/364
335 | [#358]: https://github.com/Ionaru/easy-markdown-editor/pull/358
336 | [#357]: https://github.com/Ionaru/easy-markdown-editor/pull/357
337 | [#322]: https://github.com/Ionaru/easy-markdown-editor/pull/322
338 | [#316]: https://github.com/Ionaru/easy-markdown-editor/pull/316
339 | [#313]: https://github.com/Ionaru/easy-markdown-editor/pull/313
340 | [#311]: https://github.com/Ionaru/easy-markdown-editor/pull/311
341 | [#308]: https://github.com/Ionaru/easy-markdown-editor/pull/308
342 | [#298]: https://github.com/Ionaru/easy-markdown-editor/pull/298
343 | [#293]: https://github.com/Ionaru/easy-markdown-editor/pull/293
344 | [#286]: https://github.com/Ionaru/easy-markdown-editor/pull/286
345 | [#285]: https://github.com/Ionaru/easy-markdown-editor/pull/285
346 | [#284]: https://github.com/Ionaru/easy-markdown-editor/pull/284
347 | [#280]: https://github.com/Ionaru/easy-markdown-editor/pull/280
348 | [#277]: https://github.com/Ionaru/easy-markdown-editor/pull/277
349 | [#272]: https://github.com/Ionaru/easy-markdown-editor/pull/272
350 | [#267]: https://github.com/Ionaru/easy-markdown-editor/pull/267
351 | [#253]: https://github.com/Ionaru/easy-markdown-editor/pull/253
352 | [#250]: https://github.com/Ionaru/easy-markdown-editor/pull/250
353 | [#249]: https://github.com/Ionaru/easy-markdown-editor/pull/249
354 | [#244]: https://github.com/Ionaru/easy-markdown-editor/pull/244
355 | [#235]: https://github.com/Ionaru/easy-markdown-editor/pull/235
356 | [#225]: https://github.com/Ionaru/easy-markdown-editor/pull/225
357 | [#224]: https://github.com/Ionaru/easy-markdown-editor/pull/224
358 | [#223]: https://github.com/Ionaru/easy-markdown-editor/pull/223
359 | [#222]: https://github.com/Ionaru/easy-markdown-editor/pull/222
360 | [#196]: https://github.com/Ionaru/easy-markdown-editor/pull/196
361 | [#184]: https://github.com/Ionaru/easy-markdown-editor/pull/184
362 | [#181]: https://github.com/Ionaru/easy-markdown-editor/pull/181
363 | [#175]: https://github.com/Ionaru/easy-markdown-editor/pull/175
364 | [#173]: https://github.com/Ionaru/easy-markdown-editor/pull/173
365 | [#170]: https://github.com/Ionaru/easy-markdown-editor/pull/170
366 | [#169]: https://github.com/Ionaru/easy-markdown-editor/pull/169
367 | [#150]: https://github.com/Ionaru/easy-markdown-editor/pull/150
368 | [#147]: https://github.com/Ionaru/easy-markdown-editor/pull/147
369 | [#143]: https://github.com/Ionaru/easy-markdown-editor/pull/143
370 | [#141]: https://github.com/Ionaru/easy-markdown-editor/pull/141
371 | [#139]: https://github.com/Ionaru/easy-markdown-editor/pull/139
372 | [#132]: https://github.com/Ionaru/easy-markdown-editor/pull/132
373 | [#123]: https://github.com/Ionaru/easy-markdown-editor/pull/123
374 | [#109]: https://github.com/Ionaru/easy-markdown-editor/pull/109
375 | [#106]: https://github.com/Ionaru/easy-markdown-editor/pull/106
376 | [#101]: https://github.com/Ionaru/easy-markdown-editor/pull/101
377 | [#97]: https://github.com/Ionaru/easy-markdown-editor/pull/97
378 | [#95]: https://github.com/Ionaru/easy-markdown-editor/pull/95
379 | [#93]: https://github.com/Ionaru/easy-markdown-editor/pull/93
380 | [#75]: https://github.com/Ionaru/easy-markdown-editor/pull/75
381 | [#71]: https://github.com/Ionaru/easy-markdown-editor/pull/71
382 | [#54]: https://github.com/Ionaru/easy-markdown-editor/pull/54
383 | [#31]: https://github.com/Ionaru/easy-markdown-editor/pull/31
384 | [#27]: https://github.com/Ionaru/easy-markdown-editor/pull/27
385 | [#19]: https://github.com/Ionaru/easy-markdown-editor/pull/19
386 |
387 |
388 | [@dependabot]: https://github.com/dependabot
389 | [@wwsalmon]: https://github.com/wwsalmon
390 | [@ChronosMasterOfAllTime]: https://github.com/ChronosMasterOfAllTime
391 | [@deerboy]: https://github.com/deerboy
392 | [@marekdedic]: https://github.com/marekdedic
393 | [@emirotin]: https://github.com/emirotin
394 | [@smundro]: https://github.com/smundro
395 | [@Juupaa]: https://github.com/Juupaa
396 | [@Fanvadar]: https://github.com/Fanvadar
397 | [@danice]: https://github.com/danice
398 | [@joahim]: https://github.com/joahim
399 | [@nhymxu]: https://github.com/nhymxu
400 | [@mbolli]: https://github.com/mbolli
401 | [@ivictbor]: https://github.com/ivictbor
402 | [@JoshuaLicense]: https://github.com/JoshuaLicense
403 | [@czynskee]: https://github.com/czynskee
404 | [@nick-denry]: https://github.com/nick-denry
405 | [@StefKors]: https://github.com/StefKors
406 | [@felipefdl]: https://github.com/felipefdl
407 | [@A-312]: https://github.com/A-312
408 | [@dima-bzz]: https://github.com/dima-bzz
409 | [@firm1]: https://github.com/firm1
410 | [@Situphen]: https://github.com/Situphen
411 | [@t49tran]: https://github.com/t49tran
412 | [@richtera]: https://github.com/richtera
413 | [@jfly]: https://github.com/jfly
414 | [@sperezp]: https://github.com/sperezp
415 | [@JeroenvO]: https://github.com/JeroenvO
416 | [@sn3p]: https://github.com/sn3p
417 | [@roryok]: https://github.com/roryok
418 | [@ysykzheng]: https://github.com/ysykzheng
419 | [@roipoussiere]: https://github.com/roipoussiere
420 | [@FranklinWhale]: https://github.com/FranklinWhale
421 | [@Furgas]: https://github.com/Furgas
422 | [@adamb70]: https://github.com/adamb70
423 | [@Summon528]: https://github.com/Summon528
424 | [@LeviticusMB]: https://github.com/LeviticusMB
425 | [@n-3-0]: https://github.com/n-3-0
426 | [@aphitiel]: https://github.com/aphitiel
427 | [@sne11ius]: https://github.com/sne11ius
428 | [@souljuse]: https://github.com/souljuse
429 | [@ukjinjang]: https://github.com/ukjinjang
430 | [@robjean9]: https://github.com/robjean9
431 | [@Offerel]: https://github.com/Offerel
432 | [@Zignature]: https://github.com/Zignature
433 | [@kelvinj]: https://github.com/kelvinj
434 | [@diego-gw]: https://github.com/diego-gw
435 | [@danielok1993]: https://github.com/danielok1993
436 | [@vanillajonathan]: https://github.com/vanillajonathan
437 | [@LevitatingOrange]: https://github.com/LevitatingOrange
438 | [@LoyalPotato]: https://github.com/LoyalPotato
439 | [@kicksent]: https://github.com/kicksent
440 | [@hlf20010508]: https://github.com/hlf20010508
441 | [@ZsgsDesign]: https://github.com/ZsgsDesign
442 | [@sghoweri]: https://github.com/sghoweri
443 | [@borodean]: https://github.com/borodean
444 | [@robinvandernoord]: https://github.com/robinvandernoord
445 | [@p1gp1g]: https://github.com/p1gp1g
446 | [@mayraamaral]: https://github.com/mayraamaral
447 | [@codingjoe]: https://github.com/codingjoe
448 |
449 |
450 | [Unreleased]: https://github.com/Ionaru/easy-markdown-editor/compare/2.20.0...HEAD
451 | [2.20.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.19.0...2.20.0
452 | [2.19.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.18.0...2.19.0
453 | [2.18.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.17.0...2.18.0
454 | [2.17.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.16.1...2.17.0
455 | [2.16.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.16.0...2.16.1
456 | [2.16.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.15.0...2.16.0
457 | [2.15.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.14.0...2.15.0
458 | [2.14.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.13.0...2.14.0
459 | [2.13.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.12.1...2.13.0
460 | [2.12.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.12.0...2.12.1
461 | [2.12.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.11.0...2.12.0
462 | [2.11.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.10.1...2.11.0
463 | [2.10.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.10.0...2.10.1
464 | [2.10.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.9.0...2.10.0
465 | [2.9.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.8.0...2.9.0
466 | [2.8.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.7.0...2.8.0
467 | [2.7.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.6.1...2.7.0
468 | [2.6.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.6.0...2.6.1
469 | [2.6.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.5.1...2.6.0
470 | [2.5.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.5.0...2.5.1
471 | [2.5.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.4.2...2.5.0
472 | [2.4.2]: https://github.com/Ionaru/easy-markdown-editor/compare/2.4.1...2.4.2
473 | [2.4.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.4.0...2.4.1
474 | [2.4.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.2.2...2.4.0
475 | [2.2.2]: https://github.com/Ionaru/easy-markdown-editor/compare/2.2.1...2.2.2
476 | [2.2.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.0.1...2.2.1
477 | [2.0.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.0.0...2.0.1
478 | [2.0.0]: https://github.com/Ionaru/easy-markdown-editor/compare/1.11.2...2.0.0
479 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # EasyMDE - Markdown Editor
2 |
3 | [](https://www.npmjs.com/package/easymde)
4 | [](https://www.npmjs.com/package/easymde/v/next)
5 | [](https://www.npmjs.com/package/easymde/v/v3-alpha)
6 | [](https://github.com/Ionaru/easy-markdown-editor/actions?query=branch%3Amaster)
7 |
8 | > This repository is a fork of
9 | [SimpleMDE, made by Sparksuite](https://github.com/sparksuite/simplemde-markdown-editor/).
10 | Go to the [dedicated section](#simplemde-fork) for more information.
11 |
12 | A drop-in JavaScript text area replacement for writing beautiful and understandable Markdown.
13 | EasyMDE allows users who may be less experienced with Markdown to use familiar toolbar buttons and shortcuts.
14 |
15 | In addition, the syntax is rendered while editing to clearly show the expected result. Headings are larger, emphasized words are italicized, links are underlined, etc.
16 |
17 | EasyMDE also features both built-in auto saving and spell checking.
18 | The editor is entirely customizable, from theming to toolbar buttons and javascript hooks.
19 |
20 | [**Try the demo**](https://stackblitz.com/edit/easymde/)
21 |
22 | [](https://stackblitz.com/edit/easymde/)
23 |
24 |
25 | ## Quick access
26 |
27 | - [EasyMDE - Markdown Editor](#easymde---markdown-editor)
28 | - [Quick access](#quick-access)
29 | - [Install EasyMDE](#install-easymde)
30 | - [How to use](#how-to-use)
31 | - [Loading the editor](#loading-the-editor)
32 | - [Editor functions](#editor-functions)
33 | - [Configuration](#configuration)
34 | - [Options list](#options-list)
35 | - [Options example](#options-example)
36 | - [Toolbar icons](#toolbar-icons)
37 | - [Toolbar customization](#toolbar-customization)
38 | - [Keyboard shortcuts](#keyboard-shortcuts)
39 | - [Advanced use](#advanced-use)
40 | - [Event handling](#event-handling)
41 | - [Removing EasyMDE from text area](#removing-easymde-from-text-area)
42 | - [Useful methods](#useful-methods)
43 | - [How it works](#how-it-works)
44 | - [SimpleMDE fork](#simplemde-fork)
45 | - [Hacking EasyMDE](#hacking-easymde)
46 | - [Contributing](#contributing)
47 | - [License](#license)
48 |
49 |
50 | ## Install EasyMDE
51 |
52 | Via [npm](https://www.npmjs.com/package/easymde):
53 |
54 | ```
55 | npm install easymde
56 | ```
57 |
58 | Via the *UNPKG* CDN:
59 |
60 | ```html
61 |
62 |
63 | ```
64 |
65 | Or *jsDelivr*:
66 | ```html
67 |
68 |
69 | ```
70 |
71 | ## How to use
72 |
73 | ### Loading the editor
74 |
75 | After installing and/or importing the module, you can load EasyMDE onto the first `textarea` element on the web page:
76 |
77 | ```html
78 |
79 |
82 | ```
83 |
84 | Alternatively you can select a specific `textarea`, via JavaScript:
85 |
86 | ```html
87 |
88 |
91 | ```
92 |
93 | ### Editor functions
94 |
95 | Use `easyMDE.value()` to get the content of the editor:
96 |
97 | ```html
98 |
101 | ```
102 |
103 | Use `easyMDE.value(val)` to set the content of the editor:
104 |
105 | ```html
106 |
109 | ```
110 |
111 |
112 | ## Configuration
113 |
114 | ### Options list
115 |
116 | - **autoDownloadFontAwesome**: If set to `true`, force downloads Font Awesome (used for icons). If set to `false`, prevents downloading. Defaults to `undefined`, which will intelligently check whether Font Awesome has already been included, then download accordingly.
117 | - **autofocus**: If set to `true`, focuses the editor automatically. Defaults to `false`.
118 | - **autosave**: *Saves the text that's being written and will load it back in the future. It will forget the text when the form it's contained in is submitted.*
119 | - **enabled**: If set to `true`, saves the text automatically. Defaults to `false`.
120 | - **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10 seconds).
121 | - **submit_delay**: Delay before assuming that submit of the form failed and saving the text, in milliseconds. Defaults to `autosave.delay` or `10000` (10 seconds).
122 | - **uniqueId**: You must set a unique string identifier so that EasyMDE can autosave. Something that separates this from other instances of EasyMDE elsewhere on your website.
123 | - **timeFormat**: Set DateTimeFormat. More information see [DateTimeFormat instances](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat). Default `locale: en-US, format: hour:minute`.
124 | - **text**: Set text for autosave.
125 | - **autoRefresh**: Useful, when initializing the editor in a hidden DOM node. If set to `{ delay: 300 }`, it will check every 300 ms if the editor is visible and if positive, call CodeMirror's [`refresh()`](https://codemirror.net/doc/manual.html#refresh).
126 | - **blockStyles**: Customize how certain buttons that style blocks of text behave.
127 | - **bold**: Can be set to `**` or `__`. Defaults to `**`.
128 | - **code**: Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````.
129 | - **italic**: Can be set to `*` or `_`. Defaults to `*`.
130 | - **unorderedListStyle**: can be `*`, `-` or `+`. Defaults to `*`.
131 | - **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.
132 | - **element**: The DOM element for the `textarea` element to use. Defaults to the first `textarea` element on the page.
133 | - **forceSync**: If set to `true`, force text changes made in EasyMDE to be immediately stored in original text area. Defaults to `false`.
134 | - **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar.
135 | - **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`.
136 | - **initialValue**: If set, will customize the initial value of the editor.
137 | - **previewImagesInEditor**: - EasyMDE will show preview of images, `false` by default, preview for images will appear only for images on separate lines.
138 | - **imagesPreviewHandler**: - A custom function for handling the preview of images. Takes the parsed string between the parantheses of the image markdown `` as argument and returns a string that serves as the `src` attribute of the `` tag in the preview. Enables dynamic previewing of images in the frontend without having to upload them to a server, allows copy-pasting of images to the editor with preview.
139 | - **insertTexts**: Customize how certain buttons that insert text behave. Takes an array with two elements. The first element will be the text inserted before the cursor or highlight, and the second element will be inserted after. For example, this is the default link value: `["[", "](http://)"]`.
140 | - horizontalRule
141 | - image
142 | - link
143 | - table
144 | - **lineNumbers**: If set to `true`, enables line numbers in the editor.
145 | - **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`.
146 | - **minHeight**: Sets the minimum height for the composition area, before it starts auto-growing. Should be a string containing a valid CSS value like `"500px"`. Defaults to `"300px"`.
147 | - **maxHeight**: Sets fixed height for the composition area. `minHeight` option will be ignored. Should be a string containing a valid CSS value like `"500px"`. Defaults to `undefined`.
148 | - **onToggleFullScreen**: A function that gets called when the editor's full screen mode is toggled. The function will be passed a boolean as parameter, `true` when the editor is currently going into full screen mode, or `false`.
149 | - **parsingConfig**: Adjust settings for parsing the Markdown during editing (not previewing).
150 | - **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers without a space after the `#`. Defaults to `false`.
151 | - **strikethrough**: If set to `false`, will not process GFM strikethrough syntax. Defaults to `true`.
152 | - **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`.
153 | - **overlayMode**: Pass a custom codemirror [overlay mode](https://codemirror.net/doc/manual.html#modeapi) to parse and style the Markdown during editing.
154 | - **mode**: A codemirror mode object.
155 | - **combine**: If set to `false`, will *replace* CSS classes returned by the default Markdown mode. Otherwise the classes returned by the custom mode will be combined with the classes returned by the default mode. Defaults to `true`.
156 | - **placeholder**: If set, displays a custom placeholder message.
157 | - **previewClass**: A string or array of strings that will be applied to the preview screen when activated. Defaults to `"editor-preview"`.
158 | - **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
159 | - **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`.
160 | - **promptTexts**: Customize the text used to prompt for URLs.
161 | - **image**: The text to use when prompting for an image's URL. Defaults to `URL of the image:`.
162 | - **link**: The text to use when prompting for a link's URL. Defaults to `URL for the link:`.
163 | - **iconClassMap**: Used to specify the icon class names for the various toolbar buttons.
164 | - **uploadImage**: If set to `true`, enables the image upload functionality, which can be triggered by drag and drop, copy-paste and through the browse-file window (opened when the user click on the *upload-image* icon). Defaults to `false`.
165 | - **imageMaxSize**: Maximum image size in bytes, checked before upload (note: never trust client, always check the image size at server-side). Defaults to `1024 * 1024 * 2` (2 MB).
166 | - **imageAccept**: A comma-separated list of mime-types used to check image type before upload (note: never trust client, always check file types at server-side). Defaults to `image/png, image/jpeg`.
167 | - **imageUploadFunction**: A custom function for handling the image upload. Using this function will render the options `imageMaxSize`, `imageAccept`, `imageUploadEndpoint` and `imageCSRFToken` ineffective.
168 | - The function gets a file and `onSuccess` and `onError` callback functions as parameters. `onSuccess(imageUrl: string)` and `onError(errorMessage: string)`
169 | - **imageUploadEndpoint**: The endpoint where the images data will be sent, via an asynchronous *POST* request. The server is supposed to save this image, and return a JSON response.
170 | - if the request was successfully processed (HTTP 200 OK): `{"data": {"filePath": ""}}` where *filePath* is the path of the image (absolute if `imagePathAbsolute` is set to true, relative if otherwise);
171 | - otherwise: `{"error": ""}`, where *errorCode* can be `noFileGiven` (HTTP 400 Bad Request), `typeNotAllowed` (HTTP 415 Unsupported Media Type), `fileTooLarge` (HTTP 413 Payload Too Large) or `importError` (see *errorMessages* below). If *errorCode* is not one of the *errorMessages*, it is alerted unchanged to the user. This allows for server-side error messages.
172 | No default value.
173 | - **imagePathAbsolute**: If set to `true`, will treat `imageUrl` from `imageUploadFunction` and *filePath* returned from `imageUploadEndpoint` as an absolute rather than relative path, i.e. not prepend `window.location.origin` to it.
174 | - **imageCSRFToken**: CSRF token to include with AJAX call to upload image. For various instances like Django, Spring and Laravel.
175 | - **imageCSRFName**: CSRF token filed name to include with AJAX call to upload image, applied when `imageCSRFToken` has value, defaults to `csrfmiddlewaretoken`.
176 | - **imageCSRFHeader**: If set to `true`, passing CSRF token via header. Defaults to `false`, which pass CSRF through request body.
177 | - **imageTexts**: Texts displayed to the user (mainly on the status bar) for the import image feature, where `#image_name#`, `#image_size#` and `#image_max_size#` will replaced by their respective values, that can be used for customization or internationalization:
178 | - **sbInit**: Status message displayed initially if `uploadImage` is set to `true`. Defaults to `Attach files by drag and dropping or pasting from clipboard.`.
179 | - **sbOnDragEnter**: Status message displayed when the user drags a file to the text area. Defaults to `Drop image to upload it.`.
180 | - **sbOnDrop**: Status message displayed when the user drops a file in the text area. Defaults to `Uploading images #images_names#`.
181 | - **sbProgress**: Status message displayed to show uploading progress. Defaults to `Uploading #file_name#: #progress#%`.
182 | - **sbOnUploaded**: Status message displayed when the image has been uploaded. Defaults to `Uploaded #image_name#`.
183 | - **sizeUnits**: A comma-separated list of units used to display messages with human-readable file sizes. Defaults to ` B, KB, MB` (example: `218 KB`). You can use `B,KB,MB` instead if you prefer without whitespaces (`218KB`).
184 | - **errorMessages**: Errors displayed to the user, using the `errorCallback` option, where `#image_name#`, `#image_size#` and `#image_max_size#` will replaced by their respective values, that can be used for customization or internationalization:
185 | - **noFileGiven**: The server did not receive any file from the user. Defaults to `You must select a file.`.
186 | - **typeNotAllowed**: The user send a file type which doesn't match the `imageAccept` list, or the server returned this error code. Defaults to `This image type is not allowed.`.
187 | - **fileTooLarge**: The size of the image being imported is bigger than the `imageMaxSize`, or if the server returned this error code. Defaults to `Image #image_name# is too big (#image_size#).\nMaximum file size is #image_max_size#.`.
188 | - **importError**: An unexpected error occurred when uploading the image. Defaults to `Something went wrong when uploading the image #image_name#.`.
189 | - **errorCallback**: A callback function used to define how to display an error message. Defaults to `(errorMessage) => alert(errorMessage)`.
190 | - **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
191 | - **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: `` ``
192 | - **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`.
193 | - **markedOptions**: Set the internal Markdown renderer's [options](https://marked.js.org/#/USING_ADVANCED.md#options). Other `renderingConfig` options will take precedence.
194 | - **singleLineBreaks**: If set to `false`, disable parsing [GitHub Flavored Markdown](https://github.github.com/gfm/) (GFM) single line breaks. Defaults to `true`.
195 | - **sanitizerFunction**: Custom function for sanitizing the HTML output of Markdown renderer.
196 | - **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts).
197 | - **showIcons**: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar.
198 | - **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`. Optionally pass a CodeMirrorSpellChecker-compliant function.
199 | - **inputStyle**: `textarea` or `contenteditable`. Defaults to `textarea` for desktop and `contenteditable` for mobile. `contenteditable` option is necessary to enable nativeSpellcheck.
200 | - **nativeSpellcheck**: If set to `false`, disable native spell checker. Defaults to `true`.
201 | - **sideBySideFullscreen**: If set to `false`, allows side-by-side editing without going into fullscreen. Defaults to `true`.
202 | - **status**: If set to `false`, hide the status bar. Defaults to the array of built-in status bar items.
203 | - Optionally, you can set an array of status bar items to include, and in what order. You can even define your own custom status bar items.
204 | - **styleSelectedText**: If set to `false`, remove the `CodeMirror-selectedtext` class from selected lines. Defaults to `true`.
205 | - **syncSideBySidePreviewScroll**: If set to `false`, disable syncing scroll in side by side mode. Defaults to `true`.
206 | - **tabSize**: If set, customize the tab size. Defaults to `2`.
207 | - **theme**: Override the theme. Defaults to `easymde`.
208 | - **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons).
209 | - **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`.
210 | - **toolbarButtonClassPrefix**: Adds a prefix to the toolbar button classes when set. For example, a value of `"mde"` results in `"mde-bold"` for the Bold button.
211 | - **direction**: `rtl` or `ltr`. Changes text direction to support right-to-left languages. Defaults to `ltr`.
212 |
213 |
214 | ### Options example
215 |
216 | Most options demonstrate the non-default behavior:
217 |
218 | ```js
219 | const editor = new EasyMDE({
220 | autofocus: true,
221 | autosave: {
222 | enabled: true,
223 | uniqueId: "MyUniqueID",
224 | delay: 1000,
225 | submit_delay: 5000,
226 | timeFormat: {
227 | locale: 'en-US',
228 | format: {
229 | year: 'numeric',
230 | month: 'long',
231 | day: '2-digit',
232 | hour: '2-digit',
233 | minute: '2-digit',
234 | },
235 | },
236 | text: "Autosaved: "
237 | },
238 | blockStyles: {
239 | bold: "__",
240 | italic: "_",
241 | },
242 | unorderedListStyle: "-",
243 | element: document.getElementById("MyID"),
244 | forceSync: true,
245 | hideIcons: ["guide", "heading"],
246 | indentWithTabs: false,
247 | initialValue: "Hello world!",
248 | insertTexts: {
249 | horizontalRule: ["", "\n\n-----\n\n"],
250 | image: [""],
251 | link: ["[", "](https://)"],
252 | table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
253 | },
254 | lineWrapping: false,
255 | minHeight: "500px",
256 | parsingConfig: {
257 | allowAtxHeaderWithoutSpace: true,
258 | strikethrough: false,
259 | underscoresBreakWords: true,
260 | },
261 | placeholder: "Type here...",
262 |
263 | previewClass: "my-custom-styling",
264 | previewClass: ["my-custom-styling", "more-custom-styling"],
265 |
266 | previewRender: (plainText) => customMarkdownParser(plainText), // Returns HTML from a custom parser
267 | previewRender: (plainText, preview) => { // Async method
268 | setTimeout(() => {
269 | preview.innerHTML = customMarkdownParser(plainText);
270 | }, 250);
271 |
272 | // If you return null, the innerHTML of the preview will not
273 | // be overwritten. Useful if you control the preview node's content via
274 | // vdom diffing.
275 | // return null;
276 |
277 | return "Loading...";
278 | },
279 | promptURLs: true,
280 | promptTexts: {
281 | image: "Custom prompt for URL:",
282 | link: "Custom prompt for URL:",
283 | },
284 | renderingConfig: {
285 | singleLineBreaks: false,
286 | codeSyntaxHighlighting: true,
287 | sanitizerFunction: (renderedHTML) => {
288 | // Using DOMPurify and only allowing tags
289 | return DOMPurify.sanitize(renderedHTML, {ALLOWED_TAGS: ['b']})
290 | },
291 | },
292 | shortcuts: {
293 | drawTable: "Cmd-Alt-T"
294 | },
295 | showIcons: ["code", "table"],
296 | spellChecker: false,
297 | status: false,
298 | status: ["autosave", "lines", "words", "cursor"], // Optional usage
299 | status: ["autosave", "lines", "words", "cursor", {
300 | className: "keystrokes",
301 | defaultValue: (el) => {
302 | el.setAttribute('data-keystrokes', 0);
303 | },
304 | onUpdate: (el) => {
305 | const keystrokes = Number(el.getAttribute('data-keystrokes')) + 1;
306 | el.innerHTML = `${keystrokes} Keystrokes`;
307 | el.setAttribute('data-keystrokes', keystrokes);
308 | },
309 | }], // Another optional usage, with a custom status bar item that counts keystrokes
310 | styleSelectedText: false,
311 | sideBySideFullscreen: false,
312 | syncSideBySidePreviewScroll: false,
313 | tabSize: 4,
314 | toolbar: false,
315 | toolbarTips: false,
316 | toolbarButtonClassPrefix: "mde",
317 | });
318 | ```
319 |
320 |
321 | ### Toolbar icons
322 |
323 | Below are the built-in toolbar icons (only some of which are enabled by default), which can be reorganized however you like. "Name" is the name of the icon, referenced in the JavaScript. "Action" is either a function or a URL to open. "Class" is the class given to the icon. "Tooltip" is the small tooltip that appears via the `title=""` attribute. Note that shortcut hints are added automatically and reflect the specified action if it has a key bind assigned to it (i.e. with the value of `action` set to `bold` and that of `tooltip` set to `Bold`, the final text the user will see would be "Bold (Ctrl-B)").
324 |
325 | Additionally, you can add a separator between any icons by adding `"|"` to the toolbar array.
326 |
327 | Name | Action | Tooltip Class
328 | :--- | :----- | :--------------
329 | bold | toggleBold | Bold fa fa-bold
330 | italic | toggleItalic | Italic fa fa-italic
331 | strikethrough | toggleStrikethrough | Strikethrough fa fa-strikethrough
332 | heading | toggleHeadingSmaller | Heading fa fa-header
333 | heading-smaller | toggleHeadingSmaller | Smaller Heading fa fa-header
334 | heading-bigger | toggleHeadingBigger | Bigger Heading fa fa-lg fa-header
335 | heading-1 | toggleHeading1 | Big Heading fa fa-header header-1
336 | heading-2 | toggleHeading2 | Medium Heading fa fa-header header-2
337 | heading-3 | toggleHeading3 | Small Heading fa fa-header header-3
338 | code | toggleCodeBlock | Code fa fa-code
339 | quote | toggleBlockquote | Quote fa fa-quote-left
340 | unordered-list | toggleUnorderedList | Generic List fa fa-list-ul
341 | ordered-list | toggleOrderedList | Numbered List fa fa-list-ol
342 | clean-block | cleanBlock | Clean block fa fa-eraser
343 | link | drawLink | Create Link fa fa-link
344 | image | drawImage | Insert Image fa fa-picture-o
345 | upload-image | drawUploadedImage | Raise browse-file window fa fa-image
346 | table | drawTable | Insert Table fa fa-table
347 | horizontal-rule | drawHorizontalRule | Insert Horizontal Line fa fa-minus
348 | preview | togglePreview | Toggle Preview fa fa-eye no-disable
349 | side-by-side | toggleSideBySide | Toggle Side by Side fa fa-columns no-disable no-mobile
350 | fullscreen | toggleFullScreen | Toggle Fullscreen fa fa-arrows-alt no-disable no-mobile
351 | guide | [This link](https://www.markdownguide.org/basic-syntax/) | Markdown Guide fa fa-question-circle
352 | undo | undo | Undo fa fa-undo
353 | redo | redo | Redo fa fa-redo
354 |
355 |
356 | ### Toolbar customization
357 |
358 | Customize the toolbar using the `toolbar` option.
359 |
360 | Only the order of existing buttons:
361 |
362 | ```js
363 | const easyMDE = new EasyMDE({
364 | toolbar: ["bold", "italic", "heading", "|", "quote"]
365 | });
366 | ```
367 |
368 | All information and/or add your own icons or text
369 |
370 | ```js
371 | const easyMDE = new EasyMDE({
372 | toolbar: [
373 | {
374 | name: "bold",
375 | action: EasyMDE.toggleBold,
376 | className: "fa fa-bold",
377 | title: "Bold",
378 | },
379 | "italic", // shortcut to pre-made button
380 | {
381 | name: "custom",
382 | action: (editor) => {
383 | // Add your own code
384 | },
385 | className: "fa fa-star",
386 | text: "Starred",
387 | title: "Custom Button",
388 | attributes: { // for custom attributes
389 | id: "custom-id",
390 | "data-value": "custom value" // HTML5 data-* attributes need to be enclosed in quotation marks ("") because of the dash (-) in its name.
391 | }
392 | },
393 | "|" // Separator
394 | // [, ...]
395 | ]
396 | });
397 | ```
398 |
399 | Put some buttons on dropdown menu
400 |
401 | ```js
402 | const easyMDE = new EasyMDE({
403 | toolbar: [{
404 | name: "heading",
405 | action: EasyMDE.toggleHeadingSmaller,
406 | className: "fa fa-header",
407 | title: "Headers",
408 | },
409 | "|",
410 | {
411 | name: "others",
412 | className: "fa fa-blind",
413 | title: "others buttons",
414 | children: [
415 | {
416 | name: "image",
417 | action: EasyMDE.drawImage,
418 | className: "fa fa-picture-o",
419 | title: "Image",
420 | },
421 | {
422 | name: "quote",
423 | action: EasyMDE.toggleBlockquote,
424 | className: "fa fa-percent",
425 | title: "Quote",
426 | },
427 | {
428 | name: "link",
429 | action: EasyMDE.drawLink,
430 | className: "fa fa-link",
431 | title: "Link",
432 | }
433 | ]
434 | },
435 | // [, ...]
436 | ]
437 | });
438 | ```
439 |
440 | ### Keyboard shortcuts
441 |
442 | EasyMDE comes with an array of predefined keyboard shortcuts, but they can be altered with a configuration option. The list of default ones is as follows:
443 |
444 | Shortcut (Windows / Linux) | Shortcut (macOS) | Action
445 | :--- | :--- | :---
446 | Ctrl-' | Cmd-' | "toggleBlockquote"
447 | Ctrl-B | Cmd-B | "toggleBold"
448 | Ctrl-E | Cmd-E | "cleanBlock"
449 | Ctrl-H | Cmd-H | "toggleHeadingSmaller"
450 | Ctrl-I | Cmd-I | "toggleItalic"
451 | Ctrl-K | Cmd-K | "drawLink"
452 | Ctrl-L | Cmd-L | "toggleUnorderedList"
453 | Ctrl-P | Cmd-P | "togglePreview"
454 | Ctrl-Alt-C | Cmd-Alt-C | "toggleCodeBlock"
455 | Ctrl-Alt-I | Cmd-Alt-I | "drawImage"
456 | Ctrl-Alt-L | Cmd-Alt-L | "toggleOrderedList"
457 | Shift-Ctrl-H | Shift-Cmd-H | "toggleHeadingBigger"
458 | F9 | F9 | "toggleSideBySide"
459 | F11 | F11 | "toggleFullScreen"
460 | Ctrl-Alt-1 | Cmd-Alt-1 | "toggleHeading1"
461 | Ctrl-Alt-2 | Cmd-Alt-2 | "toggleHeading2"
462 | Ctrl-Alt-3 | Cmd-Alt-3 | "toggleHeading3"
463 | Ctrl-Alt-4 | Cmd-Alt-4 | "toggleHeading4"
464 | Ctrl-Alt-5 | Cmd-Alt-5 | "toggleHeading5"
465 | Ctrl-Alt-6 | Cmd-Alt-6 | "toggleHeading6"
466 |
467 | Here is how you can change a few, while leaving others untouched:
468 |
469 | ```js
470 | const editor = new EasyMDE({
471 | shortcuts: {
472 | "toggleOrderedList": "Ctrl-Alt-K", // alter the shortcut for toggleOrderedList
473 | "toggleCodeBlock": null, // unbind Ctrl-Alt-C
474 | "drawTable": "Cmd-Alt-T", // bind Cmd-Alt-T to drawTable action, which doesn't come with a default shortcut
475 | }
476 | });
477 | ```
478 |
479 | Shortcuts are automatically converted between platforms. If you define a shortcut as "Cmd-B", on PC that shortcut will be changed to "Ctrl-B". Conversely, a shortcut defined as "Ctrl-B" will become "Cmd-B" for Mac users.
480 |
481 | The list of actions that can be bound is the same as the list of built-in actions available for [toolbar buttons](#toolbar-icons).
482 |
483 |
484 | ## Advanced use
485 |
486 | ### Event handling
487 |
488 | You can catch the following list of events: https://codemirror.net/doc/manual.html#events
489 |
490 | ```js
491 | const easyMDE = new EasyMDE();
492 | easyMDE.codemirror.on("change", () => {
493 | console.log(easyMDE.value());
494 | });
495 | ```
496 |
497 |
498 | ### Removing EasyMDE from text area
499 |
500 | You can revert to the initial text area by calling the `toTextArea` method. Note that this clears up the autosave (if enabled) associated with it. The text area will retain any text from the destroyed EasyMDE instance.
501 |
502 | ```js
503 | const easyMDE = new EasyMDE();
504 | // ...
505 | easyMDE.toTextArea();
506 | easyMDE = null;
507 | ```
508 |
509 | If you need to remove registered event listeners (when the editor is not needed anymore), call `easyMDE.cleanup()`.
510 |
511 |
512 | ### Useful methods
513 |
514 | The following self-explanatory methods may be of use while developing with EasyMDE.
515 |
516 | ```js
517 | const easyMDE = new EasyMDE();
518 | easyMDE.isPreviewActive(); // returns boolean
519 | easyMDE.isSideBySideActive(); // returns boolean
520 | easyMDE.isFullscreenActive(); // returns boolean
521 | easyMDE.clearAutosavedValue(); // no returned value
522 | ```
523 |
524 |
525 | ## How it works
526 |
527 | EasyMDE is a continuation of SimpleMDE.
528 |
529 | SimpleMDE began as an improvement of [lepture's Editor project](https://github.com/lepture/editor), but has now taken on an identity of its own. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and depends on [Font Awesome](http://fontawesome.io).
530 |
531 | CodeMirror is the backbone of the project and parses much of the Markdown syntax as it's being written. This allows us to add styles to the Markdown that's being written. Additionally, a toolbar and status bar have been added to the top and bottom, respectively. Previews are rendered by [Marked](https://github.com/chjj/marked) using GitHub Flavored Markdown (GFM).
532 |
533 |
534 | ## SimpleMDE fork
535 |
536 | I originally made this fork to implement FontAwesome 5 compatibility into SimpleMDE. When that was done I submitted a [pull request](https://github.com/sparksuite/simplemde-markdown-editor/pull/666), which has not been accepted yet. This, and the project being inactive since May 2017, triggered me to make more changes and try to put new life into the project.
537 |
538 | Changes include:
539 | * FontAwesome 5 compatibility
540 | * Guide button works when editor is in preview mode
541 | * Links are now `https://` by default
542 | * Small styling changes
543 | * Support for Node 8 and beyond
544 | * Lots of refactored code
545 | * Links in preview will open in a new tab by default
546 | * TypeScript support
547 |
548 | My intention is to continue development on this project, improving it and keeping it alive.
549 |
550 |
551 | ## Hacking EasyMDE
552 |
553 | You may want to edit this library to adapt its behavior to your needs. This can be done in some quick steps:
554 |
555 | 1. Follow the [prerequisites](./CONTRIBUTING.md#prerequisites) and [installation](./CONTRIBUTING.md#installation) instructions in the contribution guide;
556 | 2. Do your changes;
557 | 3. Run `gulp` command, which will generate files: `dist/easymde.min.css` and `dist/easymde.min.js`;
558 | 4. Copy-paste those files to your code base, and you are done.
559 |
560 |
561 | ## Contributing
562 |
563 | Want to contribute to EasyMDE? Thank you! We have a [contribution guide](./CONTRIBUTING.md) just for you!
564 |
565 |
566 | ## License
567 |
568 | This project is released under the [MIT License](./LICENSE).
569 |
570 | - Copyright (c) 2015 Sparksuite, Inc.
571 | - Copyright (c) 2017 Jeroen Akkerman.
572 |
--------------------------------------------------------------------------------