2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-09-24 16:40:55 -06:00

Compare commits

..

225 Commits

Author SHA1 Message Date
Jeroen Akkerman
2996b67ec9
Update README.md 2025-05-01 18:41:05 +02:00
Jeroen akkerman
1708e40c42 2.20.0 2025-03-04 18:01:55 +01:00
Jeroen akkerman
f1e229f5b8 Update changelog for 2.20.0 2025-03-04 17:59:40 +01:00
Jeroen akkerman
a602d3b826 Add support for marked extensions
Fixes #514
Fixes #611
2025-02-21 22:31:16 +01:00
Jeroen akkerman
fe680f09f6 2.19.0 2025-02-18 01:12:05 +01:00
Jeroen akkerman
0eddf94930 Update changelog for 2.19.0 2025-02-18 01:10:31 +01:00
Jeroen Akkerman
22ce228b07
Merge pull request #608 from mayraamaral/master
chore: adjust the regex for previewing images so that it only attempts to render if the image has a bracket immediately preceding the parentheses
2025-02-18 00:56:58 +01:00
Jeroen akkerman
e7a56e11dd Add a test for the parentheses problem 2025-02-18 00:53:11 +01:00
Mayra Amaral
f20ff16b81
Merge branch 'Ionaru:master' into master 2025-02-17 20:39:59 -03:00
Jeroen Akkerman
c93033bb4e
Merge pull request #609 from mayraamaral/v4
chore: update actions to v4
2025-02-18 00:05:45 +01:00
Jeroen akkerman
c1b06a9613 Add Node.js version to artifact name 2025-02-18 00:01:28 +01:00
Mayra Amaral
bdfd0da5ff chore: update actions to v4 2025-02-14 21:41:15 -03:00
Mayra Amaral
138c198852 chore: adjust regex from previewing images to only try to render if image has bracket before of parentheses 2025-02-11 16:05:13 -03:00
Jeroen Akkerman
a6b121f2e6
Merge pull request #592 from p1gp1g/fix/image-processing
Avoid processing many times the same image
2024-06-07 12:34:49 +02:00
Jeroen Akkerman
65dfecf484
Merge pull request #591 from p1gp1g/fix/relative-img-url
Fix relative image url fetched from stylesheet domain
2024-06-07 12:18:18 +02:00
S1m
97bf9ce8fd Avoid processing many times the same image
Cache img key during processing to avoid having to process it
thousands of times
2024-06-04 14:39:15 +02:00
S1m
9b420ac103 Fix relative image url fetched from stylesheet domain
Partial URLs are interpreted relative to the source of
the style sheet, not relative to the document
https://www.w3.org/TR/CSS1/
2024-06-04 14:32:24 +02:00
Jeroen Akkerman
f039bae67f
Merge pull request #573 from robinvandernoord/custom-image-input-name-option
Allow setting a custom `name` for the upload-image input
2023-12-21 21:35:00 +01:00
Robin van der Noord
c68bdf148a
Allow setting a custom name for the upload-image input 2023-12-18 10:57:48 +01:00
Jeroen Akkerman
35587a9477 Update dependencies, fixes #562 2023-09-27 00:52:59 +02:00
Jeroen Akkerman
d9ab397b88
Update demo URL
fixes #526
2023-04-28 02:40:34 +02:00
Jeroen Akkerman
abead2a068
Update build status badge 2023-01-12 15:34:45 +01:00
Jeroen Akkerman
c25adab400
Merge pull request #519 from borodean/update-status-bar-typing 2023-01-12 15:14:11 +01:00
Jeroen Akkerman
a49e867930
Merge pull request #520 from borodean/upload-image-typing 2023-01-12 15:14:04 +01:00
Vadym Borodin
cb5564e1b2 Expose the "upload-image" variant for ToolbarButton 2023-01-12 14:44:10 +02:00
Vadym Borodin
fbc181f5c8 Expose the updateStatusBar type 2023-01-12 14:38:17 +02:00
Jeroen akkerman
041594ae4a 2.18.0 2022-09-20 16:45:08 +02:00
Jeroen akkerman
6ab32d9fd6 Update changelog for 2.18.0 2022-09-20 16:44:48 +02:00
Jeroen akkerman
950f689dc7 Update codemirror 2022-09-20 16:41:06 +02:00
Jeroen akkerman
6560950b65 Update workflow file 2022-09-18 02:20:36 +02:00
Jeroen akkerman
f60c9b24c5 Update dependencies 2022-09-18 01:08:09 +02:00
Jeroen akkerman
4b48564730 Revert example html 2022-09-17 23:08:33 +02:00
Jeroen akkerman
d26b4e399b Add toolbarButtonClassPrefix option
Fixes #493
2022-09-17 23:07:24 +02:00
Jeroen akkerman
84aafddd92 Add extra typing tests for previewRender 2022-08-20 18:19:18 +02:00
Jeroen akkerman
4a73c911d0 2.17.0 2022-08-20 18:14:26 +02:00
Jeroen akkerman
086e73b835 Update changelog for 2.17.0 2022-08-20 18:14:21 +02:00
Jeroen akkerman
aa2f225340 Add past merges to README 2022-08-20 18:10:14 +02:00
Jeroen akkerman
0062ba38e1 Update dependencies 2022-08-20 17:26:20 +02:00
Jeroen akkerman
f8a66b120b Edit regex pattern for Safari browser, fixes #478 2022-08-20 17:25:49 +02:00
Jeroen Akkerman
b4c55d9075
Merge pull request #471 from LevitatingOrange/detachedPreviewRendering 2022-08-20 17:24:15 +02:00
Jeroen Akkerman
c27f5d1d23
Merge pull request #492 from vanillajonathan/patch-1 2022-08-17 01:45:27 +02:00
Jonathan
f7b4fbfda5
Add support for Header size 4, 5, 6 2022-08-12 12:15:42 +02:00
Jeroen Akkerman
d22fd40625
Merge pull request #488 from LoyalPotato/master 2022-07-28 17:51:08 +02:00
David Bazílio Ribeiro
9ddbc4a585 Fix type for hideIcons 2022-07-27 17:58:51 +01:00
Jeroen akkerman
03f018a472 Migrate cypress files 2022-07-27 18:35:35 +02:00
Jeroen akkerman
9232608bf3 Fix changelog 2022-07-27 18:19:50 +02:00
Jeroen akkerman
2930abdd50 Update dependencies 2022-07-27 18:18:24 +02:00
Jeroen Akkerman
b347a911c1
Merge pull request #486 from hlf20010508/master 2022-07-27 18:09:50 +02:00
Jeroen Akkerman
3e653dc900
Merge pull request #484 from kicksent/patch-1
Fix typo in readme
2022-07-27 18:09:14 +02:00
L-ING
acbed01b34
Add missed "upload-image" icon 2022-07-24 13:58:19 +08:00
Nick Trierweiler
ef827ba61f
Fix typo in readme
This is meant to be "italic" not "italics" which will render an empty icon here. The docs specify this as well and I tested locally while working through implementing this on a project.
2022-07-15 15:07:19 -04:00
Jeroen Akkerman
37561e4458
Merge pull request #479 from hackerwins/fix-invalid-icons 2022-06-27 18:36:08 +02:00
hackerwins
03fec127eb Fix invalid icons 2022-06-27 09:30:56 +09:00
Jeroen Akkerman
4d065c361e
Merge pull request #454 from vanillajonathan/patch-8
Refactor into using a map for icon classes
2022-06-16 17:25:43 +02:00
Jonathan
78fcda535d
Update easymde.js 2022-06-16 14:09:13 +02:00
Jeroen Akkerman
c84af4c3ed Fix hyperlink doubling
Closes #25
Closes #95
Closes #281
2022-06-16 10:52:01 +02:00
Jeroen Akkerman
c311b7b8da Merge branch 'master' of https://github.com/Ionaru/easy-markdown-editor 2022-06-16 10:48:49 +02:00
Jeroen Akkerman
3d6d56edef
Merge pull request #467 from vanillajonathan/patch-1
Use classList.add and classList.remove
2022-06-16 10:47:54 +02:00
Lennart Vogelsang
67f75535ad
Updated documentation 2022-06-07 20:11:27 +02:00
Lennart Vogelsang
8295aa6a5a
Changed: ignore output of previewRender if it is null 2022-06-07 19:55:27 +02:00
Jeroen Akkerman
7338ddb6e3 Replace remaining className usages 2022-05-24 12:25:09 +02:00
Jeroen Akkerman
96a5aac921 Add testing on Node.js 18 2022-05-24 11:46:38 +02:00
Jeroen Akkerman
0c31e06928 Update dependencies 2022-05-24 11:39:56 +02:00
Jonathan
23f241bd47
Use classList.add and classList.remove 2022-05-23 19:05:42 +02:00
Jonathan
fc839e8dc8
Update README.md 2022-05-22 21:17:59 +02:00
Jonathan
0eab3e11e8
Update easymde.js 2022-05-22 20:43:55 +02:00
Jeroen Akkerman
e4610b3763
Merge pull request #452 from vanillajonathan/patch-4
Use Responsive Font Sizes
2022-05-22 18:55:07 +02:00
Jeroen Akkerman
24feffcba6
Merge pull request #464 from vanillajonathan/patch-1
Add ARIA role=application
2022-05-22 18:47:33 +02:00
Jeroen Akkerman
e57c16bc5c
Merge pull request #461 from vanillajonathan/patch-12 2022-05-22 18:45:14 +02:00
Jeroen Akkerman
eb51f0fe53
Merge pull request #466 from vanillajonathan/patch-5
Fix inconsistent border color
2022-05-22 18:41:39 +02:00
Jonathan
554112b05f
Update easymde.css 2022-05-22 18:25:49 +02:00
Jonathan
2972b280a5
Update easymde.css 2022-05-22 18:19:21 +02:00
Jonathan
eee701ef86
Update easymde.js 2022-05-22 18:15:02 +02:00
Jonathan
7f9ba6abc8
Fix inconsistent border color 2022-05-22 17:57:58 +02:00
Jeroen Akkerman
3895e0a607
Merge pull request #451 from vanillajonathan/patch-7
Add keyboard shortcuts for headings
2022-05-22 14:14:45 +02:00
Jonathan
b675e611a4
Update easymde.css 2022-05-22 12:22:39 +02:00
Jonathan
3cc99e47ae
Add ARIA role=application 2022-05-22 12:04:03 +02:00
Jonathan
f4a02e39a9
Update README.md 2022-05-22 11:38:09 +02:00
Jonathan
4714577c36
Update easymde.js 2022-05-22 11:34:31 +02:00
Jeroen Akkerman
45e0f36685
Merge pull request #463 from vanillajonathan/patch-1
Add ARIA attribute to button
2022-05-22 02:08:17 +02:00
Jonathan
cd9bbe7939
Add ARIA attribute to button 2022-05-22 00:17:53 +02:00
Jonathan
5a4af7e38a
Update easymde.css 2022-05-22 00:02:10 +02:00
Jeroen Akkerman
611aa50443
Merge pull request #455 from vanillajonathan/patch-9
Set role attribute on the toolbar
2022-05-21 11:38:52 +02:00
Jeroen Akkerman
68d33ec2c1
Merge pull request #459 from vanillajonathan/patch-2
Accept APNG for image uploads
2022-05-19 23:54:33 +02:00
Jonathan
855a5d72f5
Update README.md 2022-05-19 22:57:16 +02:00
Jonathan
38717daffe
Add support for text buttons 2022-05-19 22:49:29 +02:00
Jonathan
146a5e3fb1
Accept APNG for image uploads 2022-05-19 19:02:14 +02:00
Jeroen Akkerman
c311bfa6b0
Merge pull request #458 from vanillajonathan/patch-2
Accept AVIF for image uploads
2022-05-19 14:40:51 +02:00
Jonathan
b31cf2bf7c
Accept AVIF for image uploads 2022-05-19 12:20:40 +02:00
Jonathan
bed6b493c8
Update easymde.js 2022-05-19 10:14:11 +02:00
Jeroen Akkerman
2b178671ca
Merge pull request #449 from vanillajonathan/patch-2
Add actions for header size 4, 5 and 6
2022-05-19 09:37:22 +02:00
Jonathan
2666001eda
Set role attribute on the toolbar 2022-05-18 22:03:48 +02:00
Jonathan
21fda66d3d
Update easymde.js 2022-05-18 19:45:35 +02:00
Jonathan
9d74ea296c
Refactor into using a map for icon classes 2022-05-18 19:39:39 +02:00
Jonathan
1706b4b0cf
Use Responsive Font Sizes 2022-05-18 18:35:45 +02:00
Jeroen Akkerman
aca4b5c816
Merge pull request #450 from vanillajonathan/patch-6
Accept GIF for image uploads
2022-05-18 01:54:43 +02:00
Jonathan
757d5eb729
Add keyboard shortcuts for headings 2022-05-18 00:54:20 +02:00
Jonathan
be1d994322
Update easymde.js 2022-05-18 00:50:08 +02:00
Jonathan
0dd2f99f9d
Accept GIF for image uploads 2022-05-18 00:39:54 +02:00
Jonathan
9a57f00d92
Update easymde.js 2022-05-17 23:25:02 +02:00
Jonathan
332cf61086
Add header size 4, 5 and 6 2022-05-17 23:17:04 +02:00
Jonathan
c1071c8539
Add header size 4, 5 and 6 2022-05-17 23:15:13 +02:00
Jeroen Akkerman
16b1de652e Update dependencies 2022-05-17 14:42:41 +02:00
Jeroen Akkerman
8b9cf3e812
Merge pull request #444 from vanillajonathan/patch-2 2022-05-17 13:24:08 +02:00
Jonathan
a433f72891
Update README.md
Co-authored-by: Jeroen Akkerman <Jeroen_akkerman1@hotmail.com>
2022-05-17 11:12:46 +02:00
Jonathan
4b3930c4a7
Update README.md 2022-05-17 00:26:02 +02:00
Jeroen Akkerman
a7fb5d8f06
Merge pull request #436 from vanillajonathan/patch-2
Add missing undo and redo actions
2022-05-16 23:01:58 +02:00
Jeroen Akkerman
7b4c6dae9e
Merge pull request #438 from vanillajonathan/patch-3
Use <kbd> markup element for keyboard shortcuts
2022-05-16 23:00:06 +02:00
Jeroen Akkerman
b6f207d235
Merge pull request #440 from vanillajonathan/patch-5
Fix broken markdown
2022-05-16 22:57:47 +02:00
Jonathan
591e278745
Fix broken markdown 2022-05-16 21:57:06 +02:00
Jonathan
764ce93d59
Use <kbd> markup element for keyboard shortcuts 2022-05-16 16:38:53 +02:00
Jonathan
af81424b78
Add missing undo and redo actions 2022-05-16 16:23:25 +02:00
Jeroen Akkerman
3d07f0eb97 Update dependencies 2022-04-23 22:06:59 +02:00
Jeroen Akkerman
16f2dde59d Fix #399 autofocus property 2022-04-04 15:45:12 +02:00
Jeroen Akkerman
57f72bd5ae Merge branch 'master' of https://github.com/Ionaru/simplemde-markdown-editor 2022-04-04 15:43:02 +02:00
Jeroen Akkerman
8765cf197b
Merge pull request #417 from sghoweri/patch-1 2022-03-23 20:32:49 +01:00
Salem Cobalt
bf9b0108d7
Handle Webp Image Uploads
With this fix, uploaded WebP images render as links in the markdown (vs images).
2022-03-23 14:45:32 -04:00
Jeroen Akkerman
f283f76f5c Update dependencies 2022-03-19 23:25:58 +01:00
Jeroen Akkerman
a1ad87986d Merge branch 'master' of https://github.com/Ionaru/simplemde-markdown-editor 2022-03-12 01:54:17 +01:00
Jeroen Akkerman
76fda35bf9
Merge pull request #411 from diego-gw/imagePreviewHandler 2022-03-12 01:53:27 +01:00
Jeroen Akkerman
1f30a11773 Add changelog entry 2022-03-12 01:45:14 +01:00
Diego Garcia Weber
aa711787b2 clarified readme description of parameter, removed extra parantheses from type 2022-03-07 10:58:09 -05:00
Jeroen Akkerman
853efd8a5e Update dependencies 2022-03-06 21:30:06 +01:00
Diego Garcia Weber
ed196be5a0 added option to readme, imagesPreviewHandler to types and defensive check that the handler provided by the user returns a string 2022-03-01 20:47:30 -05:00
Diego Garcia Weber
d8fa00e460 Adds the option to add a handler for images preview 2022-03-01 17:15:35 -05:00
Jeroen Akkerman
f573560bb4 Update dependencies 2022-02-15 01:19:04 +01:00
Jeroen Akkerman
a021bdf8ae
Merge pull request #394 from ZsgsDesign/master
Add robust CSRF support and provide default values for CSRF fields
2022-02-14 15:15:00 +01:00
ZsgsDesign
aa6fe59e93 fixed default image configuration typo 2022-01-25 16:46:06 +08:00
ZsgsDesign
8805c379d8 fixed comment typo for csrf token 2022-01-24 12:24:27 +08:00
ZsgsDesign
b0d20adc6e add instances example for imageCSRFToken 2022-01-24 12:07:07 +08:00
ZsgsDesign
f3dca2e82a add robust CSRF support and provide default values for CSRF fields 2022-01-24 12:05:00 +08:00
Jeroen Akkerman
50d3680017
Merge pull request #393 from Zignature/escape-url-via-prompt
Fix #373 Encode and escape URLs entered via prompt
2022-01-17 00:17:36 +01:00
Jeroen Akkerman
81ec7780bc Update changelog 2022-01-17 00:13:40 +01:00
Jeroen Akkerman
d8eae5d74c Improve readability of encode/escape functionality 2022-01-17 00:13:40 +01:00
Jeroen Akkerman
0c2cf4cd51 Add tests for url prompts 2022-01-17 00:13:40 +01:00
Zignature
16545eb0e1 Made escaping prompt URLs automatic instead of optional again 2022-01-16 00:14:00 +01:00
Zignature
47f1e4f892 Updated readme and easymde.d.ts to reflect escapePrompURLs option 2022-01-15 23:56:27 +01:00
Zignature
c174b6f149 Changed function name escapeURI to escapedPromptURL and option escapeURLs to option escapePromptURLs 2022-01-15 23:34:05 +01:00
Zignature
33489ab616 URL encoding and escaping for JS prompt URLs
- URL encoding and escaping added for JS prompt entered URLs
- added option escapeURLs (boolean)
2022-01-15 23:26:10 +01:00
Zignature
5d0294f5f5 Fix issue #373 problems in urls with special characters
Added function to escape URLs entered via JS prompt.

It's a partial fix because people cannot be stopped entering URLs manually and forgetting to escape them.
2022-01-15 13:20:28 +01:00
Jeroen Akkerman
4fb35f2758 2.16.1 2022-01-14 23:27:44 +01:00
Jeroen Akkerman
d0116608e6 Update changelog for 2.16.1 2022-01-14 23:27:23 +01:00
Jeroen Akkerman
6159ed1383 Update marked to resolve security vulnerability 2022-01-14 23:23:54 +01:00
Jeroen Akkerman
a56badd0dc Add test for markdown rendering 2022-01-14 23:09:20 +01:00
Jeroen Akkerman
24d86491da Fix incorrect initial line and column count 2022-01-14 22:33:35 +01:00
Jeroen Akkerman
56532f9ce4 Add cypress tests 2022-01-14 22:27:43 +01:00
Jeroen Akkerman
722fb61ed2 Remove old travis build status badge 2022-01-11 21:51:01 +01:00
Jeroen Akkerman
33a4043dbb Update build status badge 2022-01-11 21:50:30 +01:00
Jeroen Akkerman
75fe53f062 2.16.0 2022-01-11 21:44:56 +01:00
Jeroen Akkerman
384655f968 Update changelog for 2.16.0 2022-01-11 21:44:50 +01:00
Jeroen Akkerman
6445f3c2d9
Merge pull request #388 from Zignature/options-toolbarbutton-attributes
Fix for issue #380 Custom attributes for toolbar buttons
2022-01-11 21:41:22 +01:00
Jeroen Akkerman
7a2373eae5 Update changelog 2022-01-11 21:40:13 +01:00
Jeroen Akkerman
4ddb5b8e1b Add toolbar button attributes to type declaration 2022-01-11 21:38:36 +01:00
Jeroen Akkerman
98d9049728 Move adding custom attributes above all others 2022-01-11 21:30:34 +01:00
Jeroen Akkerman
565c42e0ff Add hasOwnProperty check 2022-01-11 21:28:22 +01:00
Jeroen Akkerman
1c656d5712 Merge branch 'master' into options-toolbarbutton-attributes 2022-01-11 21:23:42 +01:00
Jeroen Akkerman
c1da7424e9
Merge pull request #389 from Zignature/options-liststyle
Fix for issue #386 Show '-' instead of '*' for unordered list
2022-01-11 21:22:31 +01:00
Jeroen Akkerman
e2db3c6946 Attempt at improving submenus in Safari for #362 2022-01-11 20:10:00 +01:00
Jeroen Akkerman
267db2dbe3 Update changelog 2022-01-11 19:56:18 +01:00
Jeroen Akkerman
9862ecf98c Add unorderedListStyle option to type declaration 2022-01-11 19:49:39 +01:00
Zignature
2cdc11848a Requested changes applied 2022-01-11 17:16:38 +01:00
Zignature
5df842b630 Fix for issue #386 Show '-' instead of '*' for unordered list
Added unorderedListStyle to the options
2022-01-11 15:45:36 +01:00
Zignature
a9d9993dae Fix for issue #380 Custom attributes for toolbar buttons
Added "attributes" option to custom toolbar button
2022-01-11 11:00:56 +01:00
Jeroen Akkerman
59a676bc8a
Merge pull request #384 from Zignature/ZignatureEasyMDE
Fix #381 Accurate line and column count in status bar
2022-01-08 21:53:54 +01:00
Zignature
2936fc3383 Accurate line and column count in status bar
Both Line and column (character) count are increased by 1.

This fixes issue #381
2022-01-08 21:03:25 +01:00
Zignature
a7170b9392 Fix issue #381 2022-01-08 16:01:19 +01:00
Jeroen Akkerman
598821b6bb Add typings and tests for 'direction' option 2021-10-28 11:33:17 +02:00
Jeroen Akkerman
de1cd3b293 Update changelog for 2.16.0 2021-10-28 11:29:44 +02:00
Jeroen Akkerman
d27adc6a16 Update dependencies 2021-10-28 01:59:33 +02:00
Jeroen Akkerman
c15c699a52 Update changelog for PR #364 2021-10-28 01:53:59 +02:00
Jeroen Akkerman
8ad896fb40
Merge pull request #364 from robjean9/master
update easymde.css, fix issue #362
2021-10-27 23:51:32 +02:00
Robson Jean Penteado
b640429f19 fix issue #362 2021-10-27 14:47:43 -03:00
Robson Jean Penteado
8ef68936b0 update easymde.css, fix issue #362 2021-10-27 14:42:25 -03:00
Jeroen Akkerman
f004c2d0c3 More small README improvements 2021-10-10 01:04:28 +02:00
Jeroen Akkerman
551c84bc01 Fix indenting and some leftover old JS 2021-10-06 01:51:02 +02:00
Jeroen Akkerman
86e40bcf4a Update README with some more modern JS 2021-10-06 01:43:47 +02:00
Jeroen Akkerman
35b42c404a Update changelog 2021-10-05 22:42:24 +02:00
Jeroen Akkerman
42304e8a87 Update editorconfig and automatic code format 2021-10-05 22:28:22 +02:00
Jeroen Akkerman
dc38624378 Update dependencies 2021-10-05 22:19:04 +02:00
Jeroen Akkerman
c24dd01880 Drop testing support on older Node.js versions 2021-10-05 22:18:55 +02:00
Jeroen Akkerman
b364a6095a Use Github Actions instead of Tavis 2021-10-05 22:07:43 +02:00
Jeroen Akkerman
cda237031f
Merge pull request #357 from ukjinjang/fix/compare_image_extension
Convert media file extension to lowercase before check if image
2021-10-05 21:59:15 +02:00
Jeroen Akkerman
534e2cadee
Merge pull request #358 from souljuse/master
Add support for RTL languages
2021-10-05 21:59:05 +02:00
Irene Oppo
aafd40f35b Add direction option to README 2021-10-05 10:04:05 +02:00
Irene Oppo
53223c4de0 Support rtl languages by adding a direction option 2021-10-05 09:51:51 +02:00
Uk-Jin Jang
b121795887 fix: convert media file extension to lowercase before check if image 2021-10-05 15:50:48 +09:00
Jeroen Akkerman
0f559258c5
Merge pull request #338 from mrlugilugi/fix-error-formatting-asterisks-as-unordered-list
fix: Formatting asterisks divided by space results in console error #337
2021-06-16 21:30:53 +02:00
Jeroen Akkerman
3e403d9712
Merge pull request #339 from CamilleDrapier/add-cleanup-to-ts
Add the cleanup function to TypeScript definition
2021-06-16 21:30:43 +02:00
Camille Drapier
cb351333d1 Add cleanup function to TypeScript definition 2021-06-10 16:18:35 +09:00
mrlugilugi
f52f9807a2
fix: Escaping asterisk to produce valid RegEx 2021-06-09 13:14:20 +02:00
Jeroen Akkerman
c1d35b04c5
Merge pull request #333 from smundro/custom-spellchecker
Allow for specifying a custom spell-checker
2021-05-23 16:13:24 +02:00
Steve
737aa13709 add a dash 2021-05-18 16:12:44 -07:00
Steve
038a9204b4 Allow for specifying a custom spell-checker for EasyMDE 2021-05-18 16:05:40 -07:00
Jeroen Akkerman
dbab7e95e7 2.15.0 2021-04-22 22:41:34 +02:00
Jeroen Akkerman
51d496aea6 Update changelog for 2.15.0 2021-04-22 22:41:27 +02:00
Jeroen Akkerman
735d31fb29 Update dependencies 2021-04-22 22:39:01 +02:00
Jeroen Akkerman
ebcc835ee9 Update changelog 2021-04-22 22:37:27 +02:00
Jeroen Akkerman
c58eb54379
Merge pull request #322 from marekdedic/320-fix
Exposing types as non-dev dependencies
2021-04-12 19:33:22 +02:00
Marek Dědič
529c7bf04d
Fixes #320 2021-04-12 13:05:26 +02:00
Jeroen Akkerman
e3480c2f60 Update dependencies 2021-04-09 19:22:31 +02:00
Jeroen Akkerman
fc0ecfa77e
Merge pull request #313 from wwsalmon/absolute-image-paths
Absolute image paths
2021-04-08 18:05:14 +02:00
Jeroen Akkerman
113c5b45b1
Merge pull request #316 from smundro/bugfix-fullscreen-sidebyside-handle
Bugfix: Correctly keep preview active during fullscreen-toggle
2021-03-27 16:29:15 +01:00
Steve
b61fe7945a Add simple class handling utiltity to DRY adding/removing class names.
Note that this isn't necessary and can be rolled back, but could be used throughout the code to make class handling more clear and consistent.
2021-03-17 11:17:14 -07:00
Steve
82a8e4a8ce restore removed comment 2021-03-17 10:46:18 -07:00
Steve
548229dd1a remove added comment 2021-03-17 10:45:45 -07:00
Steve
40ddcea4e3 remove extra comment updates 2021-03-17 10:44:46 -07:00
Steve
d0f69390ce a little comment/cleanup 2021-03-17 10:41:38 -07:00
Steve
1ee8519e50 Unwind all the onlyCleanup stuff and set classes directly. 2021-03-17 10:25:39 -07:00
Steve
4533dd4776 clarify comments in togglePreview 2021-03-16 09:21:03 -07:00
Steve
d636eb7407 clean up diff 2021-03-16 09:17:19 -07:00
Steve
7069fd1031 Move from multiple "no-fullscreen" classes to one using inheritance 2021-03-16 09:08:54 -07:00
Steve
d76872f4ff undo some comment changes to make diff cleaner 2021-03-15 20:15:39 -07:00
Steve
8ed6cd699e make toggle cleanup flag clearer 2021-03-15 20:13:26 -07:00
Steve
25db654cf0 more code cleanup for readibilty 2021-03-15 20:08:38 -07:00
Steve
8702dd22d0 correct test page title 2021-03-15 19:57:47 -07:00
Steve
fa8855e3be code refactoring to improve readability 2021-03-15 19:40:57 -07:00
Steve
61e93a3d53 handle fullscreen toggle consistently by adusting toggleSideBySide 2021-03-15 19:30:56 -07:00
Steve
abbec5bde1 bugfix: move sidebyside accessor outside of options check 2021-03-15 13:53:08 -07:00
Samson Zhang
3b755026d6 update readme with imagePathAbsolute option info 2021-03-11 12:14:44 -07:00
Samson Zhang
6e7e8f9b82 add imagePathAbsolute option 2021-03-11 12:09:09 -07:00
Jeroen Akkerman
072176a86e
Merge pull request #311 from deerboy/patch-1
Fixed extension acquisition logic
2021-03-08 15:59:03 +01:00
Daichi Ninomiya
c2dbe77615
fix(easymde.js): Fixed extension acquisition logic 2021-03-08 23:48:57 +09:00
Jeroen Akkerman
95b848a825
Merge pull request #308 from ChronosMasterOfAllTime/307-fix-toolbaricon-typing
Resolve Issue #307 - add optional icon field to ToolbarIcon interface in easymde.d.ts
2021-02-26 17:13:21 +01:00
ChronosMasterOfAllTime
6527a311a3 #307 - add optional icon field to ToolbarIcon interface in easymde.d.ts 2021-02-26 09:06:01 -06:00
Jeroen Akkerman
8fa54c496f Fix changelog version link 2021-02-14 13:13:25 +01:00
36 changed files with 15251 additions and 1745 deletions

View File

@ -1,9 +1,17 @@
[*] # Editor configuration, see https://editorconfig.org
charset=utf-8 root = true
end_of_line=lf
insert_final_newline=true
indent_style=space
indent_size=4
[*.{yml,yaml}] [*]
indent_size=2 charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
[*.yaml]
indent_size = 2
[*.md]
max_line_length = off
trim_trailing_whitespace = false

View File

@ -1,4 +1,5 @@
{ {
"root": true,
"rules": { "rules": {
"strict": 0, "strict": 0,
"no-console": 0, "no-console": 0,
@ -10,11 +11,17 @@
"error", "error",
"always" "always"
], ],
"comma-dangle": ["error", "always-multiline"] "comma-dangle": [
"error",
"always-multiline"
]
}, },
"env": { "env": {
"browser": true, "browser": true,
"node": true "node": true
}, },
"parserOptions": {
"ecmaVersion": 2018
},
"extends": "eslint:recommended" "extends": "eslint:recommended"
} }

View File

@ -23,7 +23,7 @@ A clear and concise description of what you expected to happen.
**Screenshots** **Screenshots**
If applicable, add screenshots to help explain your problem. If applicable, add screenshots to help explain your problem.
** Version information ** **Version information**
- OS: [e.g. Windows, MacOS] - OS: [e.g. Windows, MacOS]
- Browser: [e.g. Chrome 72] - Browser: [e.g. Chrome 72]
- EasyMDE version: [e.g. 2.5.1] - EasyMDE version: [e.g. 2.5.1]

95
.github/workflows/cd.yaml vendored Normal file
View File

@ -0,0 +1,95 @@
name: Test & Deploy
on:
workflow_dispatch:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: current
- uses: actions/checkout@v4
- run: npm audit --omit=dev
test:
needs: [ audit ]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ '14', '16', '18' ]
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v4
- run: npm ci
- name: Test
run: npm test
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots-nodejs-${{ matrix.node-version }}
path: cypress/screenshots
retention-days: 7
- uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-videos-nodejs-${{ matrix.node-version }}
path: cypress/videos
retention-days: 7
deploy:
needs: [ test ]
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/setup-node@v4
with:
node-version: current
- uses: actions/checkout@v4
- run: npm ci
- name: Deploy @latest version to npm
if: startsWith(github.ref, 'refs/tags/')
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
- name: Update @next version
if: startsWith(github.ref, 'refs/heads/')
run: npm version prerelease --no-git-tag-version --preid "$GITHUB_RUN_NUMBER"
- name: Deploy @next version to npm
if: startsWith(github.ref, 'refs/heads/')
uses: JS-DevTools/npm-publish@v1
with:
tag: next
token: ${{ secrets.NPM_TOKEN }}
check-version: false

4
.gitignore vendored
View File

@ -11,3 +11,7 @@ node_modules/
.idea/ .idea/
.vscode/ .vscode/
dev_test/ dev_test/
# Test artifacts
cypress/screenshots
cypress/videos

View File

@ -1,33 +0,0 @@
language: node_js
node_js:
- '14' # EOL: April 2023
- '12' # EOL: April 2022
- '11' # EOL: June 2019
- '10' # EOL: April 2021
- '8' # EOL: December 2019
jobs:
include:
- stage: deploy
node_js: "lts/*"
script: skip
before_deploy: if [ "$TRAVIS_BRANCH" = master ] && [ "$TRAVIS_PULL_REQUEST" = false ]; then npm version prerelease --no-git-tag-version --preid "$TRAVIS_BUILD_NUMBER"; fi
deploy:
- provider: npm
email: info@saturnserver.org
api_key:
secure: rp4P11u0Vvz6iTkC1uj9LfNVOJASnTjffpqpe9lhuC/php7+fdoYvZ4e1EwKj2RVbi7YNqZE6w+Y6fsxZk72N4RGVO6HROm6gNv2wl+qk0B1XwciONO9y5FhTcdZrsq5Vx5WdoZThs5CSkXpvtHiavAnAt1ufYjqKGBZOENdxJ40kkn9WdQG2WvG7iZWDlDpDoqof2uO9k89d2UuTG5DKAoMpN+4UH0Fr0gV0u11IcBeH7rlSo2btlMaMsSO9Nb10Zf1rC0USHfyrui/BKvVGeRh7FASYrHwjqt4bwqzKZlP5bZ4zGIPMYXXsGLcidxIvSsNIRp7cgkWvsywe8cIi5XzaM48afWsbMUfMgXi9BDNjK7vBiuPBnGWYS3ylJZn/7SvMuqsoj4De5GWrCJ5pTsEKD5yw5+iqQv7v2ZYhuN7/tTSoEy/BOMdN43zWquJp57LXkyFQ9esGoI0bfeYojV2BvcpwY/UFS27e/9bH+RBlXsLfP0kEtosVGZ6i3AuUKtsYOxo4QZSI4yHtP7fKsoCoJIvpW3hcWjrnI8N7IC18/KihsUByuMgDgTTXXtDKxLbNVjbiVvFJeuClwe1oc1uusY1v/EkNpGDFZX5zFEVv3zC76NaLB75kCUN3gGC0RRFk0J9i3k8qa42TLjbOqvxgRxOEtVeRxowBNrymIQ=
tag: next
skip_cleanup: true
on:
branch: master
repo: Ionaru/easy-markdown-editor
- provider: npm
email: info@saturnserver.org
api_key:
secure: rp4P11u0Vvz6iTkC1uj9LfNVOJASnTjffpqpe9lhuC/php7+fdoYvZ4e1EwKj2RVbi7YNqZE6w+Y6fsxZk72N4RGVO6HROm6gNv2wl+qk0B1XwciONO9y5FhTcdZrsq5Vx5WdoZThs5CSkXpvtHiavAnAt1ufYjqKGBZOENdxJ40kkn9WdQG2WvG7iZWDlDpDoqof2uO9k89d2UuTG5DKAoMpN+4UH0Fr0gV0u11IcBeH7rlSo2btlMaMsSO9Nb10Zf1rC0USHfyrui/BKvVGeRh7FASYrHwjqt4bwqzKZlP5bZ4zGIPMYXXsGLcidxIvSsNIRp7cgkWvsywe8cIi5XzaM48afWsbMUfMgXi9BDNjK7vBiuPBnGWYS3ylJZn/7SvMuqsoj4De5GWrCJ5pTsEKD5yw5+iqQv7v2ZYhuN7/tTSoEy/BOMdN43zWquJp57LXkyFQ9esGoI0bfeYojV2BvcpwY/UFS27e/9bH+RBlXsLfP0kEtosVGZ6i3AuUKtsYOxo4QZSI4yHtP7fKsoCoJIvpW3hcWjrnI8N7IC18/KihsUByuMgDgTTXXtDKxLbNVjbiVvFJeuClwe1oc1uusY1v/EkNpGDFZX5zFEVv3zC76NaLB75kCUN3gGC0RRFk0J9i3k8qa42TLjbOqvxgRxOEtVeRxowBNrymIQ=
skip_cleanup: true
on:
branch: master
repo: Ionaru/easy-markdown-editor
tags: true

View File

@ -1,10 +1,86 @@
# EasyMDE Changelog # EasyMDE Changelog
All notable changes to easymde will be documented in this file. 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).
[comment]: <> (## [Unreleased]) <!-- ## [Unreleased] -->
## [2.20.0] - 2025-03-04
### Added
- Support for `marked` extensions (Thanks to [@codingjoe], [#611], [#514]).
## [2.19.0] - 2025-02-18
### Added
- `updateStatusBar` type to typescript definitions (Thanks to [@borodean], [#519]).
- `"upload-image"` option to the `ToolbarButton` typescript definitions (Thanks to [@borodean], [#520]).
- `imageInputName` option to set a custom "name" attribute for the image input (Thanks to [@robinvandernoord], [#573]).
### Fixed
- Relative image paths using the stylesheet as the source instead of the document (Thanks to [@p1gp1g], [#591]).
- Excessive memory usage with the `previewImagesInEditor` option (Thanks to [@p1gp1g], [#592]).
- Parentheses in the alt text of images causing the image not to load then using `previewImagesInEditor` (Thanks to [@mayraamaral], [#608]).
## [2.18.0] - 2022-09-20
### Added
- `toolbarButtonClassPrefix` option to resolve conflicts with Bootstrap classes ([#493]).
## [2.17.0] - 2022-08-20
### Added
- Improved CSRF support for uploading images (Thanks to [@ZsgsDesign], [#394]).
- Option to register an image preview handler: `imagesPreviewHandler` (Thanks to [@diego-gw], [#411]).
- Support for `.webp` image formats (Thanks to [@sghoweri], [#417]).
- `toggleHeading` methods for headings 4, 5 and 6 (Thanks to [@vanillajonathan], [#449] and [#492]).
- Support for `.gif`, `.avif` and `.apng` image formats (Thanks to [@vanillajonathan], [#450], [#458] and [#459]).
- Keyboard shortcuts for `toggleHeading` methods (Thanks to [@vanillajonathan], [#451]).
- `iconClassMap` option to specify icon class names for toolbar buttons (Thanks to [@vanillajonathan], [#454]).
- `role="toolbar"` on the toolbar element (Thanks to [@vanillajonathan], [#455]).
- Support for text buttons in the toolbar (Thanks to [@vanillajonathan], [#461]).
- `aria-label` attribute for toolbar buttons (uses the `title` option) (Thanks to [@vanillajonathan], [#463]).
- `role="application"` on the editor container element (Thanks to [@vanillajonathan], [#464]).
- Option to not overwrite the preview HTML by returning `null` from `previewRender` (Thanks to [@LevitatingOrange], [#471]).
### Fixed
- Hyperlink doubling (Thanks to [@danielok1993], [#95]).
- URLs with certain characters entered through prompts causing invalid markdown (Thanks to [@Zignature], [#393]).
- Autofocus option not working properly ([#399]).
- Inconsistent border colour (Thanks to [@vanillajonathan], [#466]).
- Invalid regex on Safari browsers ([#478])
- `hideIcons` option type (Thanks to [@LoyalPotato], [#488]).
### Changed
- Editor now uses responsive font sizes (Thanks to [@vanillajonathan], [#452]).
### Documentation
- Added several improvements to README (Thanks to [@vanillajonathan], [#436], [#438], [#440], [#444]).
- Fixed typo in README (Thanks to [@kicksent], [#484]).
- Added missing icon for `upload-image` in README (Thanks to [@hlf20010508], [#486]).
## [2.16.1] - 2022-01-14
### Fixed
- Incorrect initial line and column count in status bar.
- Security issue in `marked` dependency.
## [2.16.0] - 2022-01-11
### Added
- `direction` option to enable RTL mode (Thanks to [@souljuse], [#358]).
- `attributes` option to add custom attributes to toolbar buttons (Thanks to [@Zignature], [#388]).
- `unorderedListStyle` option to change the character used for unordered lists (Thanks to [@Zignature], [#389]).
### Fixed
- Image extension detection when extension is uppercase (Thanks to [@ukjinjang], [#357]).
- Submenu actions not working in Chromium Browsers (Thanks to [@Offerel], [@robjean9] and [@kelvinj], [#364]).
- Incorrect line and column count in status bar (Thanks to [@Zignature], [#384]).
## [2.15.0] - 2021-04-22
### Added
- `imagePathAbsolute` option to return the absolute path when uploading an image (Thanks to [@wwsalmon], [#313]).
### Fixed
- `ToolbarIcon` typings, added `icon` (Thanks to [@ChronosMasterOfAllTime], [#308]).
- Image link extension when it was not the last part of the URL (Thanks to [@deerboy], [#311]).
- Preview mode did not stay enabled when toggling to fullscreen (Thanks to [@smundro], [#316]).
- Required typings not being included in `dependencies` (Thanks to [@marekdedic], [#322]).
## [2.14.0] - 2021-02-14 ## [2.14.0] - 2021-02-14
### Added ### Added
- The `scrollbarStyle` option to change the style of the scrollbar (Thanks to [@danice], [#250]). - The `scrollbarStyle` option to change the style of the scrollbar (Thanks to [@danice], [#250]).
@ -64,9 +140,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Group buttons in drop-down lists by adding a sub-option `children` for the items in the toolbar (Thanks to [@firm1], [#141]). - Group buttons in drop-down lists by adding a sub-option `children` for the items in the toolbar (Thanks to [@firm1], [#141]).
- `sanitizerFunction` option to allow custom HTML sanitizing in the markdown preview (Thanks to [@adamb70], [#147]). - `sanitizerFunction` option to allow custom HTML sanitizing in the markdown preview (Thanks to [@adamb70], [#147]).
- Time formatting and custom text options for the autosave message (Thanks to [@dima-bzz], [#170]). - Time formatting and custom text options for the autosave message (Thanks to [@dima-bzz], [#170]).
### Changed ### Changed
- Delay before assuming that submit of the form as failed is `autosave.submit_delay` instead of `autosave.delay` (Thanks to [@Situphen], [#139]). - Delay before assuming that submit of the form as failed is `autosave.submit_delay` instead of `autosave.delay` (Thanks to [@Situphen], [#139]).
- Add `watch` task for gulp (Thanks to [@A-312], [#150]). - Add `watch` task for gulp (Thanks to [@A-312], [#150]).
### Fixed ### Fixed
- Issue with Marked when using IE11 and webpack (Thanks to [@felipefdl], [#169]). - Issue with Marked when using IE11 and webpack (Thanks to [@felipefdl], [#169]).
- Updated codemirror to version 5.52.2 (Thanks to [@A-312], [#173]). - Updated codemirror to version 5.52.2 (Thanks to [@A-312], [#173]).
@ -194,6 +272,11 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown
- Cursor not always showing in "text" mode over the edit field - Cursor not always showing in "text" mode over the edit field
<!-- Linked issues --> <!-- Linked issues -->
[#611]: https://github.com/Ionaru/easy-markdown-editor/issues/611
[#514]: https://github.com/Ionaru/easy-markdown-editor/issues/514
[#493]: https://github.com/Ionaru/easy-markdown-editor/issues/493
[#478]: https://github.com/Ionaru/easy-markdown-editor/issues/478
[#399]: https://github.com/Ionaru/easy-markdown-editor/issues/399
[#252]: https://github.com/Ionaru/easy-markdown-editor/issues/252 [#252]: https://github.com/Ionaru/easy-markdown-editor/issues/252
[#251]: https://github.com/Ionaru/easy-markdown-editor/issues/251 [#251]: https://github.com/Ionaru/easy-markdown-editor/issues/251
[#239]: https://github.com/Ionaru/easy-markdown-editor/issues/239 [#239]: https://github.com/Ionaru/easy-markdown-editor/issues/239
@ -212,6 +295,50 @@ 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 -->
[#608]: https://github.com/Ionaru/easy-markdown-editor/pull/608
[#592]: https://github.com/Ionaru/easy-markdown-editor/pull/592
[#591]: https://github.com/Ionaru/easy-markdown-editor/pull/591
[#573]: https://github.com/Ionaru/easy-markdown-editor/pull/573
[#520]: https://github.com/Ionaru/easy-markdown-editor/pull/520
[#519]: https://github.com/Ionaru/easy-markdown-editor/pull/519
[#492]: https://github.com/Ionaru/easy-markdown-editor/pull/492
[#488]: https://github.com/Ionaru/easy-markdown-editor/pull/488
[#486]: https://github.com/Ionaru/easy-markdown-editor/pull/486
[#484]: https://github.com/Ionaru/easy-markdown-editor/pull/484
[#479]: https://github.com/Ionaru/easy-markdown-editor/pull/479
[#471]: https://github.com/Ionaru/easy-markdown-editor/pull/471
[#467]: https://github.com/Ionaru/easy-markdown-editor/pull/467
[#466]: https://github.com/Ionaru/easy-markdown-editor/pull/466
[#464]: https://github.com/Ionaru/easy-markdown-editor/pull/464
[#463]: https://github.com/Ionaru/easy-markdown-editor/pull/463
[#461]: https://github.com/Ionaru/easy-markdown-editor/pull/461
[#459]: https://github.com/Ionaru/easy-markdown-editor/pull/459
[#458]: https://github.com/Ionaru/easy-markdown-editor/pull/458
[#455]: https://github.com/Ionaru/easy-markdown-editor/pull/455
[#454]: https://github.com/Ionaru/easy-markdown-editor/pull/454
[#452]: https://github.com/Ionaru/easy-markdown-editor/pull/452
[#451]: https://github.com/Ionaru/easy-markdown-editor/pull/451
[#450]: https://github.com/Ionaru/easy-markdown-editor/pull/450
[#449]: https://github.com/Ionaru/easy-markdown-editor/pull/449
[#444]: https://github.com/Ionaru/easy-markdown-editor/pull/444
[#440]: https://github.com/Ionaru/easy-markdown-editor/pull/440
[#438]: https://github.com/Ionaru/easy-markdown-editor/pull/438
[#436]: https://github.com/Ionaru/easy-markdown-editor/pull/436
[#417]: https://github.com/Ionaru/easy-markdown-editor/pull/417
[#411]: https://github.com/Ionaru/easy-markdown-editor/pull/411
[#394]: https://github.com/Ionaru/easy-markdown-editor/pull/394
[#393]: https://github.com/Ionaru/easy-markdown-editor/pull/393
[#389]: https://github.com/Ionaru/easy-markdown-editor/pull/389
[#388]: https://github.com/Ionaru/easy-markdown-editor/pull/388
[#384]: https://github.com/Ionaru/easy-markdown-editor/pull/384
[#364]: https://github.com/Ionaru/easy-markdown-editor/pull/364
[#358]: https://github.com/Ionaru/easy-markdown-editor/pull/358
[#357]: https://github.com/Ionaru/easy-markdown-editor/pull/357
[#322]: https://github.com/Ionaru/easy-markdown-editor/pull/322
[#316]: https://github.com/Ionaru/easy-markdown-editor/pull/316
[#313]: https://github.com/Ionaru/easy-markdown-editor/pull/313
[#311]: https://github.com/Ionaru/easy-markdown-editor/pull/311
[#308]: https://github.com/Ionaru/easy-markdown-editor/pull/308
[#298]: https://github.com/Ionaru/easy-markdown-editor/pull/298 [#298]: https://github.com/Ionaru/easy-markdown-editor/pull/298
[#293]: https://github.com/Ionaru/easy-markdown-editor/pull/293 [#293]: https://github.com/Ionaru/easy-markdown-editor/pull/293
[#286]: https://github.com/Ionaru/easy-markdown-editor/pull/286 [#286]: https://github.com/Ionaru/easy-markdown-editor/pull/286
@ -221,6 +348,7 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown
[#277]: https://github.com/Ionaru/easy-markdown-editor/pull/277 [#277]: https://github.com/Ionaru/easy-markdown-editor/pull/277
[#272]: https://github.com/Ionaru/easy-markdown-editor/pull/272 [#272]: https://github.com/Ionaru/easy-markdown-editor/pull/272
[#267]: https://github.com/Ionaru/easy-markdown-editor/pull/267 [#267]: https://github.com/Ionaru/easy-markdown-editor/pull/267
[#253]: https://github.com/Ionaru/easy-markdown-editor/pull/253
[#250]: https://github.com/Ionaru/easy-markdown-editor/pull/250 [#250]: https://github.com/Ionaru/easy-markdown-editor/pull/250
[#249]: https://github.com/Ionaru/easy-markdown-editor/pull/249 [#249]: https://github.com/Ionaru/easy-markdown-editor/pull/249
[#244]: https://github.com/Ionaru/easy-markdown-editor/pull/244 [#244]: https://github.com/Ionaru/easy-markdown-editor/pull/244
@ -247,6 +375,7 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown
[#106]: https://github.com/Ionaru/easy-markdown-editor/pull/106 [#106]: https://github.com/Ionaru/easy-markdown-editor/pull/106
[#101]: https://github.com/Ionaru/easy-markdown-editor/pull/101 [#101]: https://github.com/Ionaru/easy-markdown-editor/pull/101
[#97]: https://github.com/Ionaru/easy-markdown-editor/pull/97 [#97]: https://github.com/Ionaru/easy-markdown-editor/pull/97
[#95]: https://github.com/Ionaru/easy-markdown-editor/pull/95
[#93]: https://github.com/Ionaru/easy-markdown-editor/pull/93 [#93]: https://github.com/Ionaru/easy-markdown-editor/pull/93
[#75]: https://github.com/Ionaru/easy-markdown-editor/pull/75 [#75]: https://github.com/Ionaru/easy-markdown-editor/pull/75
[#71]: https://github.com/Ionaru/easy-markdown-editor/pull/71 [#71]: https://github.com/Ionaru/easy-markdown-editor/pull/71
@ -257,6 +386,10 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown
<!-- Linked users --> <!-- Linked users -->
[@dependabot]: https://github.com/dependabot [@dependabot]: https://github.com/dependabot
[@wwsalmon]: https://github.com/wwsalmon
[@ChronosMasterOfAllTime]: https://github.com/ChronosMasterOfAllTime
[@deerboy]: https://github.com/deerboy
[@marekdedic]: https://github.com/marekdedic
[@emirotin]: https://github.com/emirotin [@emirotin]: https://github.com/emirotin
[@smundro]: https://github.com/smundro [@smundro]: https://github.com/smundro
[@Juupaa]: https://github.com/Juupaa [@Juupaa]: https://github.com/Juupaa
@ -292,9 +425,37 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown
[@n-3-0]: https://github.com/n-3-0 [@n-3-0]: https://github.com/n-3-0
[@aphitiel]: https://github.com/aphitiel [@aphitiel]: https://github.com/aphitiel
[@sne11ius]: https://github.com/sne11ius [@sne11ius]: https://github.com/sne11ius
[@souljuse]: https://github.com/souljuse
[@ukjinjang]: https://github.com/ukjinjang
[@robjean9]: https://github.com/robjean9
[@Offerel]: https://github.com/Offerel
[@Zignature]: https://github.com/Zignature
[@kelvinj]: https://github.com/kelvinj
[@diego-gw]: https://github.com/diego-gw
[@danielok1993]: https://github.com/danielok1993
[@vanillajonathan]: https://github.com/vanillajonathan
[@LevitatingOrange]: https://github.com/LevitatingOrange
[@LoyalPotato]: https://github.com/LoyalPotato
[@kicksent]: https://github.com/kicksent
[@hlf20010508]: https://github.com/hlf20010508
[@ZsgsDesign]: https://github.com/ZsgsDesign
[@sghoweri]: https://github.com/sghoweri
[@borodean]: https://github.com/borodean
[@robinvandernoord]: https://github.com/robinvandernoord
[@p1gp1g]: https://github.com/p1gp1g
[@mayraamaral]: https://github.com/mayraamaral
[@codingjoe]: https://github.com/codingjoe
<!-- Linked versions --> <!-- Linked versions -->
[Unreleased]: https://github.com/Ionaru/easy-markdown-editor/compare/2.13.0...HEAD [Unreleased]: https://github.com/Ionaru/easy-markdown-editor/compare/2.20.0...HEAD
[2.20.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.19.0...2.20.0
[2.19.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.18.0...2.19.0
[2.18.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.17.0...2.18.0
[2.17.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.16.1...2.17.0
[2.16.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.16.0...2.16.1
[2.16.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.15.0...2.16.0
[2.15.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.14.0...2.15.0
[2.14.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.13.0...2.14.0
[2.13.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.12.1...2.13.0 [2.13.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.12.1...2.13.0
[2.12.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.12.0...2.12.1 [2.12.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.12.0...2.12.1
[2.12.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.11.0...2.12.0 [2.12.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.11.0...2.12.0

398
README.md
View File

@ -1,8 +1,9 @@
# EasyMDE - Markdown Editor # EasyMDE - Markdown Editor
[![npm version](https://img.shields.io/npm/v/easymde.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde) [![npm version](https://img.shields.io/npm/v/easymde.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde)
[![npm version](https://img.shields.io/npm/v/easymde/next.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde/v/next) [![npm @next version](https://img.shields.io/npm/v/easymde/next.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde/v/next)
[![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) [![npm @v3-alpha version](https://img.shields.io/npm/v/easymde/v3-alpha.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde/v/v3-alpha)
[![Build Status](https://img.shields.io/github/actions/workflow/status/ionaru/easy-markdown-editor/cd.yaml?branch=master&style=for-the-badge)](https://github.com/Ionaru/easy-markdown-editor/actions?query=branch%3Amaster)
> This repository is a fork of > This repository is a fork of
[SimpleMDE, made by Sparksuite](https://github.com/sparksuite/simplemde-markdown-editor/). [SimpleMDE, made by Sparksuite](https://github.com/sparksuite/simplemde-markdown-editor/).
@ -16,9 +17,9 @@ In addition, the syntax is rendered while editing to clearly show the expected r
EasyMDE also features both built-in auto saving and spell checking. EasyMDE also features both built-in auto saving and spell checking.
The editor is entirely customizable, from theming to toolbar buttons and javascript hooks. The editor is entirely customizable, from theming to toolbar buttons and javascript hooks.
[**Try the demo**](https://easy-markdown-editor.tk/) [**Try the demo**](https://stackblitz.com/edit/easymde/)
[![Preview](https://user-images.githubusercontent.com/3472373/51319377-26fe6e00-1a5d-11e9-8cc6-3137a566796d.png)](https://easy-markdown-editor.tk/) [![Preview](https://user-images.githubusercontent.com/3472373/51319377-26fe6e00-1a5d-11e9-8cc6-3137a566796d.png)](https://stackblitz.com/edit/easymde/)
## Quick access ## Quick access
@ -51,7 +52,7 @@ The editor is entirely customizable, from theming to toolbar buttons and javascr
Via [npm](https://www.npmjs.com/package/easymde): Via [npm](https://www.npmjs.com/package/easymde):
``` ```
npm install easymde --save npm install easymde
``` ```
Via the *UNPKG* CDN: Via the *UNPKG* CDN:
@ -61,42 +62,37 @@ Via the *UNPKG* CDN:
<script src="https://unpkg.com/easymde/dist/easymde.min.js"></script> <script src="https://unpkg.com/easymde/dist/easymde.min.js"></script>
``` ```
Or *jsDelivr*:
```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css">
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
```
## How to use ## How to use
### Loading the editor ### Loading the editor
After installing and/or importing the module, you can load EasyMDE onto the first TextArea on the web page: After installing and/or importing the module, you can load EasyMDE onto the first `textarea` element on the web page:
```html ```html
<textarea></textarea> <textarea></textarea>
<script> <script>
var easyMDE = new EasyMDE(); const easyMDE = new EasyMDE();
</script> </script>
``` ```
Alternatively you can select a specific TextArea, via Javascript: Alternatively you can select a specific `textarea`, via JavaScript:
```html ```html
<textarea id="my-text-area"></textarea> <textarea id="my-text-area"></textarea>
<script> <script>
var easyMDE = new EasyMDE({element: document.getElementById('my-text-area')}); const easyMDE = new EasyMDE({element: document.getElementById('my-text-area')});
</script> </script>
``` ```
Or via jQuery:
```html
<textarea id="my-text-area"></textarea>
<script>
var easyMDE = new EasyMDE({element: $('#my-text-area')[0]});
</script>
```
### Editor functions ### Editor functions
Use EasyMDE.value() to get the content of the editor: Use `easyMDE.value()` to get the content of the editor:
```html ```html
<script> <script>
@ -104,7 +100,7 @@ easyMDE.value();
</script> </script>
``` ```
Use EasyMDE.value(val) to set the content of the editor: Use `easyMDE.value(val)` to set the content of the editor:
```html ```html
<script> <script>
@ -121,8 +117,8 @@ easyMDE.value('New input for **EasyMDE**');
- **autofocus**: If set to `true`, focuses the editor automatically. Defaults to `false`. - **autofocus**: If set to `true`, focuses the editor automatically. Defaults to `false`.
- **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.* - **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.*
- **enabled**: If set to `true`, saves the text automatically. Defaults to `false`. - **enabled**: If set to `true`, saves the text automatically. Defaults to `false`.
- **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s). - **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10 seconds).
- **submit_delay**: Delay before assuming that submit of the form failed and saving the text, in milliseconds. Defaults to `autosave.delay` or `10000` (10s). - **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).
- **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. - **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.
- **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`. - **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`.
- **text**: Set text for autosave. - **text**: Set text for autosave.
@ -131,13 +127,15 @@ 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` element to use. Defaults to the first `textarea` element 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`.
- **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar. - **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar.
- **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`. - **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`.
- **initialValue**: If set, will customize the initial value of the editor. - **initialValue**: If set, will customize the initial value of the editor.
- **previewImagesInEditor**: - EasyMDE will show preview of images, `false` by default, preview for images will appear only for images on separate lines. - **previewImagesInEditor**: - EasyMDE will show preview of images, `false` by default, preview for images will appear only for images on separate lines.
- **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 `<img>` 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.
- **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://)"]`. - **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://)"]`.
- horizontalRule - horizontalRule
- image - image
@ -154,7 +152,7 @@ easyMDE.value('New input for **EasyMDE**');
- **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`. - **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`.
- **overlayMode**: Pass a custom codemirror [overlay mode](https://codemirror.net/doc/manual.html#modeapi) to parse and style the Markdown during editing. - **overlayMode**: Pass a custom codemirror [overlay mode](https://codemirror.net/doc/manual.html#modeapi) to parse and style the Markdown during editing.
- **mode**: A codemirror mode object. - **mode**: A codemirror mode object.
- **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`. - **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`.
- **placeholder**: If set, displays a custom placeholder message. - **placeholder**: If set, displays a custom placeholder message.
- **previewClass**: A string or array of strings that will be applied to the preview screen when activated. Defaults to `"editor-preview"`. - **previewClass**: A string or array of strings that will be applied to the preview screen when activated. Defaults to `"editor-preview"`.
- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews. - **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
@ -162,16 +160,20 @@ easyMDE.value('New input for **EasyMDE**');
- **promptTexts**: Customize the text used to prompt for URLs. - **promptTexts**: Customize the text used to prompt for URLs.
- **image**: The text to use when prompting for an image's URL. Defaults to `URL of the image:`. - **image**: The text to use when prompting for an image's URL. Defaults to `URL of the image:`.
- **link**: The text to use when prompting for a link's URL. Defaults to `URL for the link:`. - **link**: The text to use when prompting for a link's URL. Defaults to `URL for the link:`.
- **uploadImage**: If set to `true`, enables the image upload functionality, which can be triggered by drag&drop, copy-paste and through the browse-file window (opened when the user click on the *upload-image* icon). Defaults to `false`. - **iconClassMap**: Used to specify the icon class names for the various toolbar buttons.
- **imageMaxSize**: Maximum image size in bytes, checked before upload (note: never trust client, always check image size at server-side). Defaults to `1024*1024*2` (2Mb). - **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`.
- **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).
- **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`. - **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`.
- **imageUploadFunction**: A custom function for handling the image upload. Using this function will render the options `imageMaxSize`, `imageAccept`, `imageUploadEndpoint` and `imageCSRFToken` ineffective. - **imageUploadFunction**: A custom function for handling the image upload. Using this function will render the options `imageMaxSize`, `imageAccept`, `imageUploadEndpoint` and `imageCSRFToken` ineffective.
- The function gets a file and onSuccess and onError callback functions as parameters. `onSuccess(imageUrl: string)` and `onError(errorMessage: string)` - The function gets a file and `onSuccess` and `onError` callback functions as parameters. `onSuccess(imageUrl: string)` and `onError(errorMessage: string)`
- **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. - **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.
- if the request was successfully processed (HTTP 200-OK): `{"data": {"filePath": "<filePath>"}}` where *filePath* is the relative path of the image; - if the request was successfully processed (HTTP 200 OK): `{"data": {"filePath": "<filePath>"}}` where *filePath* is the path of the image (absolute if `imagePathAbsolute` is set to true, relative if otherwise);
- otherwise: `{"error": "<errorCode>"}`, where *errorCode* can be `noFileGiven` (HTTP 400), `typeNotAllowed` (HTTP 415), `fileTooLarge` (HTTP 413) 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. - otherwise: `{"error": "<errorCode>"}`, 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.
No default value. No default value.
- **imageCSRFToken**: CSRF token to include with AJAX call to upload image. For instance used with Django backend. - **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.
- **imageCSRFToken**: CSRF token to include with AJAX call to upload image. For various instances like Django, Spring and Laravel.
- **imageCSRFName**: CSRF token filed name to include with AJAX call to upload image, applied when `imageCSRFToken` has value, defaults to `csrfmiddlewaretoken`.
- **imageCSRFHeader**: If set to `true`, passing CSRF token via header. Defaults to `false`, which pass CSRF through request body.
- **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: - **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:
- **sbInit**: Status message displayed initially if `uploadImage` is set to `true`. Defaults to `Attach files by drag and dropping or pasting from clipboard.`. - **sbInit**: Status message displayed initially if `uploadImage` is set to `true`. Defaults to `Attach files by drag and dropping or pasting from clipboard.`.
- **sbOnDragEnter**: Status message displayed when the user drags a file to the text area. Defaults to `Drop image to upload it.`. - **sbOnDragEnter**: Status message displayed when the user drags a file to the text area. Defaults to `Drop image to upload it.`.
@ -184,16 +186,16 @@ easyMDE.value('New input for **EasyMDE**');
- **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.`. - **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.`.
- **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#.`. - **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#.`.
- **importError**: An unexpected error occurred when uploading the image. Defaults to `Something went wrong when uploading the image #image_name#.`. - **importError**: An unexpected error occurred when uploading the image. Defaults to `Something went wrong when uploading the image #image_name#.`.
- **errorCallback**: A callback function used to define how to display an error message. Defaults to `function(errorMessage) {alert(errorMessage);};`. - **errorCallback**: A callback function used to define how to display an error message. Defaults to `(errorMessage) => alert(errorMessage)`.
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing). - **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
- **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">` - **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">`
- **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`. - **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`.
- **markedOptions**: Set the internal Markdown renderer's [options](https://marked.js.org/#/USING_ADVANCED.md#options). Other `renderingConfig` options will take precedence. - **markedOptions**: Set the internal Markdown renderer's [options](https://marked.js.org/#/USING_ADVANCED.md#options). Other `renderingConfig` options will take precedence.
- **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`. - **singleLineBreaks**: If set to `false`, disable parsing [GitHub Flavored Markdown](https://github.github.com/gfm/) (GFM) single line breaks. Defaults to `true`.
- **sanitizerFunction**: Custom function for sanitizing the HTML output of markdown renderer. - **sanitizerFunction**: Custom function for sanitizing the HTML output of Markdown renderer.
- **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts). - **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts).
- **showIcons**: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar. - **showIcons**: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar.
- **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`. - **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`. Optionally pass a CodeMirrorSpellChecker-compliant function.
- **inputStyle**: `textarea` or `contenteditable`. Defaults to `textarea` for desktop and `contenteditable` for mobile. `contenteditable` option is necessary to enable nativeSpellcheck. - **inputStyle**: `textarea` or `contenteditable`. Defaults to `textarea` for desktop and `contenteditable` for mobile. `contenteditable` option is necessary to enable nativeSpellcheck.
- **nativeSpellcheck**: If set to `false`, disable native spell checker. Defaults to `true`. - **nativeSpellcheck**: If set to `false`, disable native spell checker. Defaults to `true`.
- **sideBySideFullscreen**: If set to `false`, allows side-by-side editing without going into fullscreen. Defaults to `true`. - **sideBySideFullscreen**: If set to `false`, allows side-by-side editing without going into fullscreen. Defaults to `true`.
@ -205,112 +207,120 @@ easyMDE.value('New input for **EasyMDE**');
- **theme**: Override the theme. Defaults to `easymde`. - **theme**: Override the theme. Defaults to `easymde`.
- **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons). - **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons).
- **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`. - **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`.
- **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.
- **direction**: `rtl` or `ltr`. Changes text direction to support right-to-left languages. Defaults to `ltr`.
### Options example ### Options example
Most options demonstrate the non-default behavior: Most options demonstrate the non-default behavior:
```JavaScript ```js
var editor = new EasyMDE({ const editor = new EasyMDE({
autofocus: true, autofocus: true,
autosave: { autosave: {
enabled: true, enabled: true,
uniqueId: "MyUniqueID", uniqueId: "MyUniqueID",
delay: 1000, delay: 1000,
submit_delay: 5000, submit_delay: 5000,
timeFormat: { timeFormat: {
locale: 'en-US', locale: 'en-US',
format: { format: {
year: 'numeric', year: 'numeric',
month: 'long', month: 'long',
day: '2-digit', day: '2-digit',
hour: '2-digit', hour: '2-digit',
minute: '2-digit', minute: '2-digit',
}, },
}, },
text: "Autosaved: " text: "Autosaved: "
}, },
blockStyles: { blockStyles: {
bold: "__", bold: "__",
italic: "_", italic: "_",
}, },
element: document.getElementById("MyID"), unorderedListStyle: "-",
forceSync: true, element: document.getElementById("MyID"),
hideIcons: ["guide", "heading"], forceSync: true,
indentWithTabs: false, hideIcons: ["guide", "heading"],
initialValue: "Hello world!", indentWithTabs: false,
insertTexts: { initialValue: "Hello world!",
horizontalRule: ["", "\n\n-----\n\n"], insertTexts: {
image: ["![](http://", ")"], horizontalRule: ["", "\n\n-----\n\n"],
link: ["[", "](http://)"], image: ["![](http://", ")"],
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"], link: ["[", "](https://)"],
}, table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
lineWrapping: false, },
minHeight: "500px", lineWrapping: false,
parsingConfig: { minHeight: "500px",
allowAtxHeaderWithoutSpace: true, parsingConfig: {
strikethrough: false, allowAtxHeaderWithoutSpace: true,
underscoresBreakWords: true, strikethrough: false,
}, underscoresBreakWords: true,
placeholder: "Type here...", },
placeholder: "Type here...",
previewClass: "my-custom-styling", previewClass: "my-custom-styling",
previewClass: ["my-custom-styling", "more-custom-styling"], previewClass: ["my-custom-styling", "more-custom-styling"],
previewRender: function(plainText) { previewRender: (plainText) => customMarkdownParser(plainText), // Returns HTML from a custom parser
return customMarkdownParser(plainText); // Returns HTML from a custom parser previewRender: (plainText, preview) => { // Async method
}, setTimeout(() => {
previewRender: function(plainText, preview) { // Async method preview.innerHTML = customMarkdownParser(plainText);
setTimeout(function(){ }, 250);
preview.innerHTML = customMarkdownParser(plainText);
}, 250);
return "Loading..."; // If you return null, the innerHTML of the preview will not
}, // be overwritten. Useful if you control the preview node's content via
promptURLs: true, // vdom diffing.
promptTexts: { // return null;
image: "Custom prompt for URL:",
link: "Custom prompt for URL:", return "Loading...";
}, },
renderingConfig: { promptURLs: true,
singleLineBreaks: false, promptTexts: {
codeSyntaxHighlighting: true, image: "Custom prompt for URL:",
sanitizerFunction: function(renderedHTML) { link: "Custom prompt for URL:",
// Using DOMPurify and only allowing <b> tags },
return DOMPurify.sanitize(renderedHTML, {ALLOWED_TAGS: ['b']}) renderingConfig: {
}, singleLineBreaks: false,
}, codeSyntaxHighlighting: true,
shortcuts: { sanitizerFunction: (renderedHTML) => {
drawTable: "Cmd-Alt-T" // Using DOMPurify and only allowing <b> tags
}, return DOMPurify.sanitize(renderedHTML, {ALLOWED_TAGS: ['b']})
showIcons: ["code", "table"], },
spellChecker: false, },
status: false, shortcuts: {
status: ["autosave", "lines", "words", "cursor"], // Optional usage drawTable: "Cmd-Alt-T"
status: ["autosave", "lines", "words", "cursor", { },
className: "keystrokes", showIcons: ["code", "table"],
defaultValue: function(el) { spellChecker: false,
this.keystrokes = 0; status: false,
el.innerHTML = "0 Keystrokes"; status: ["autosave", "lines", "words", "cursor"], // Optional usage
}, status: ["autosave", "lines", "words", "cursor", {
onUpdate: function(el) { className: "keystrokes",
el.innerHTML = ++this.keystrokes + " Keystrokes"; defaultValue: (el) => {
}, el.setAttribute('data-keystrokes', 0);
}], // Another optional usage, with a custom status bar item that counts keystrokes },
styleSelectedText: false, onUpdate: (el) => {
sideBySideFullscreen: false, const keystrokes = Number(el.getAttribute('data-keystrokes')) + 1;
syncSideBySidePreviewScroll: false, el.innerHTML = `${keystrokes} Keystrokes`;
tabSize: 4, el.setAttribute('data-keystrokes', keystrokes);
toolbar: false, },
toolbarTips: false, }], // Another optional usage, with a custom status bar item that counts keystrokes
styleSelectedText: false,
sideBySideFullscreen: false,
syncSideBySidePreviewScroll: false,
tabSize: 4,
toolbar: false,
toolbarTips: false,
toolbarButtonClassPrefix: "mde",
}); });
``` ```
### Toolbar icons ### Toolbar icons
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 JS. "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)"). 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)").
Additionally, you can add a separator between any icons by adding `"|"` to the toolbar array. Additionally, you can add a separator between any icons by adding `"|"` to the toolbar array.
@ -332,12 +342,15 @@ ordered-list | toggleOrderedList | Numbered List<br>fa fa-list-ol
clean-block | cleanBlock | Clean block<br>fa fa-eraser clean-block | cleanBlock | Clean block<br>fa fa-eraser
link | drawLink | Create Link<br>fa fa-link link | drawLink | Create Link<br>fa fa-link
image | drawImage | Insert Image<br>fa fa-picture-o image | drawImage | Insert Image<br>fa fa-picture-o
upload-image | drawUploadedImage | Raise browse-file window<br>fa fa-image
table | drawTable | Insert Table<br>fa fa-table table | drawTable | Insert Table<br>fa fa-table
horizontal-rule | drawHorizontalRule | Insert Horizontal Line<br>fa fa-minus horizontal-rule | drawHorizontalRule | Insert Horizontal Line<br>fa fa-minus
preview | togglePreview | Toggle Preview<br>fa fa-eye no-disable preview | togglePreview | Toggle Preview<br>fa fa-eye no-disable
side-by-side | toggleSideBySide | Toggle Side by Side<br>fa fa-columns no-disable no-mobile side-by-side | toggleSideBySide | Toggle Side by Side<br>fa fa-columns no-disable no-mobile
fullscreen | toggleFullScreen | Toggle Fullscreen<br>fa fa-arrows-alt no-disable no-mobile fullscreen | toggleFullScreen | Toggle Fullscreen<br>fa fa-arrows-alt no-disable no-mobile
guide | [This link](https://www.markdownguide.org/basic-syntax/) | Markdown Guide<br>fa fa-question-circle guide | [This link](https://www.markdownguide.org/basic-syntax/) | Markdown Guide<br>fa fa-question-circle
undo | undo | Undo<br>fa fa-undo
redo | redo | Redo<br>fa fa-redo
### Toolbar customization ### Toolbar customization
@ -346,41 +359,48 @@ Customize the toolbar using the `toolbar` option.
Only the order of existing buttons: Only the order of existing buttons:
```JavaScript ```js
var easyMDE = new EasyMDE({ const easyMDE = new EasyMDE({
toolbar: ["bold", "italic", "heading", "|", "quote"] toolbar: ["bold", "italic", "heading", "|", "quote"]
}); });
``` ```
All information and/or add your own icons All information and/or add your own icons or text
```Javascript ```js
var easyMDE = new EasyMDE({ const easyMDE = new EasyMDE({
toolbar: [{ toolbar: [
name: "bold", {
action: EasyMDE.toggleBold, name: "bold",
className: "fa fa-bold", action: EasyMDE.toggleBold,
title: "Bold", className: "fa fa-bold",
}, title: "Bold",
{ },
name: "custom", "italic", // shortcut to pre-made button
action: function customFunction(editor){ {
// Add your own code name: "custom",
}, action: (editor) => {
className: "fa fa-star", // Add your own code
title: "Custom Button", },
}, className: "fa fa-star",
"|" // Separator text: "Starred",
// [, ...] title: "Custom Button",
] attributes: { // for custom attributes
id: "custom-id",
"data-value": "custom value" // HTML5 data-* attributes need to be enclosed in quotation marks ("") because of the dash (-) in its name.
}
},
"|" // Separator
// [, ...]
]
}); });
``` ```
Put some buttons on dropdown menu Put some buttons on dropdown menu
```Javascript ```js
var easyMDE = new EasyMDE({ const easyMDE = new EasyMDE({
toolbar: [{ toolbar: [{
name: "heading", name: "heading",
action: EasyMDE.toggleHeadingSmaller, action: EasyMDE.toggleHeadingSmaller,
className: "fa fa-header", className: "fa fa-header",
@ -412,8 +432,8 @@ var easyMDE = new EasyMDE({
} }
] ]
}, },
// [, ...] // [, ...]
] ]
}); });
``` ```
@ -423,30 +443,36 @@ EasyMDE comes with an array of predefined keyboard shortcuts, but they can be al
Shortcut (Windows / Linux) | Shortcut (macOS) | Action Shortcut (Windows / Linux) | Shortcut (macOS) | Action
:--- | :--- | :--- :--- | :--- | :---
*Ctrl-'* | *Cmd-'* | "toggleBlockquote" <kbd>Ctrl</kbd>-<kbd>'</kbd> | <kbd>Cmd</kbd>-<kbd>'</kbd> | "toggleBlockquote"
*Ctrl-B* | *Cmd-B* | "toggleBold" <kbd>Ctrl</kbd>-<kbd>B</kbd> | <kbd>Cmd</kbd>-<kbd>B</kbd> | "toggleBold"
*Ctrl-E* | *Cmd-E* | "cleanBlock" <kbd>Ctrl</kbd>-<kbd>E</kbd> | <kbd>Cmd</kbd>-<kbd>E</kbd> | "cleanBlock"
*Ctrl-H* | *Cmd-H* | "toggleHeadingSmaller" <kbd>Ctrl</kbd>-<kbd>H</kbd> | <kbd>Cmd</kbd>-<kbd>H</kbd> | "toggleHeadingSmaller"
*Ctrl-I* | *Cmd-I* | "toggleItalic" <kbd>Ctrl</kbd>-<kbd>I</kbd> | <kbd>Cmd</kbd>-<kbd>I</kbd> | "toggleItalic"
*Ctrl-K* | *Cmd-K* | "drawLink" <kbd>Ctrl</kbd>-<kbd>K</kbd> | <kbd>Cmd</kbd>-<kbd>K</kbd> | "drawLink"
*Ctrl-L* | *Cmd-L* | "toggleUnorderedList" <kbd>Ctrl</kbd>-<kbd>L</kbd> | <kbd>Cmd</kbd>-<kbd>L</kbd> | "toggleUnorderedList"
*Ctrl-P* | *Cmd-P* | "togglePreview" <kbd>Ctrl</kbd>-<kbd>P</kbd> | <kbd>Cmd</kbd>-<kbd>P</kbd> | "togglePreview"
*Ctrl-Alt-C* | *Cmd-Alt-C* | "toggleCodeBlock" <kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>C</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>C</kbd> | "toggleCodeBlock"
*Ctrl-Alt-I* | *Cmd-Alt-I* | "drawImage" <kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>I</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>I</kbd> | "drawImage"
*Ctrl-Alt-L* | *Cmd-Alt-L* | "toggleOrderedList" <kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>L</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>L</kbd> | "toggleOrderedList"
*Shift-Ctrl-H* | *Shift-Cmd-H* | "toggleHeadingBigger" <kbd>Shift</kbd>-<kbd>Ctrl</kbd>-<kbd>H</kbd> | <kbd>Shift</kbd>-<kbd>Cmd</kbd>-<kbd>H</kbd> | "toggleHeadingBigger"
*F9* | *F9* | "toggleSideBySide" <kbd>F9</kbd> | <kbd>F9</kbd> | "toggleSideBySide"
*F11* | *F11* | "toggleFullScreen" <kbd>F11</kbd> | <kbd>F11</kbd> | "toggleFullScreen"
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>1</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>1</kbd> | "toggleHeading1"
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>2</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>2</kbd> | "toggleHeading2"
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>3</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>3</kbd> | "toggleHeading3"
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>4</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>4</kbd> | "toggleHeading4"
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>5</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>5</kbd> | "toggleHeading5"
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>6</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>6</kbd> | "toggleHeading6"
Here is how you can change a few, while leaving others untouched: Here is how you can change a few, while leaving others untouched:
```JavaScript ```js
var editor = new EasyMDE({ const editor = new EasyMDE({
shortcuts: { shortcuts: {
"toggleOrderedList": "Ctrl-Alt-K", // alter the shortcut for toggleOrderedList "toggleOrderedList": "Ctrl-Alt-K", // alter the shortcut for toggleOrderedList
"toggleCodeBlock": null, // unbind Ctrl-Alt-C "toggleCodeBlock": null, // unbind Ctrl-Alt-C
"drawTable": "Cmd-Alt-T", // bind Cmd-Alt-T to drawTable action, which doesn't come with a default shortcut "drawTable": "Cmd-Alt-T", // bind Cmd-Alt-T to drawTable action, which doesn't come with a default shortcut
} }
}); });
``` ```
@ -461,10 +487,10 @@ The list of actions that can be bound is the same as the list of built-in action
You can catch the following list of events: https://codemirror.net/doc/manual.html#events You can catch the following list of events: https://codemirror.net/doc/manual.html#events
```JavaScript ```js
var easyMDE = new EasyMDE(); const easyMDE = new EasyMDE();
easyMDE.codemirror.on("change", function(){ easyMDE.codemirror.on("change", () => {
console.log(easyMDE.value()); console.log(easyMDE.value());
}); });
``` ```
@ -473,14 +499,14 @@ easyMDE.codemirror.on("change", function(){
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. 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.
```JavaScript ```js
var easyMDE = new EasyMDE(); const easyMDE = new EasyMDE();
// ... // ...
easyMDE.toTextArea(); easyMDE.toTextArea();
easyMDE = null; easyMDE = null;
``` ```
If you need to remove installed listeners (when editor not needed anymore), call `easyMDE.cleanup()` If you need to remove registered event listeners (when the editor is not needed anymore), call `easyMDE.cleanup()`.
### Useful methods ### Useful methods
@ -488,7 +514,7 @@ If you need to remove installed listeners (when editor not needed anymore), call
The following self-explanatory methods may be of use while developing with EasyMDE. The following self-explanatory methods may be of use while developing with EasyMDE.
```js ```js
var easyMDE = new EasyMDE(); const easyMDE = new EasyMDE();
easyMDE.isPreviewActive(); // returns boolean easyMDE.isPreviewActive(); // returns boolean
easyMDE.isSideBySideActive(); // returns boolean easyMDE.isSideBySideActive(); // returns boolean
easyMDE.isFullscreenActive(); // returns boolean easyMDE.isFullscreenActive(); // returns boolean
@ -502,7 +528,7 @@ EasyMDE is a continuation of SimpleMDE.
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). 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).
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 GFM. 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).
## SimpleMDE fork ## SimpleMDE fork
@ -517,7 +543,7 @@ Changes include:
* Support for Node 8 and beyond * Support for Node 8 and beyond
* Lots of refactored code * Lots of refactored code
* Links in preview will open in a new tab by default * Links in preview will open in a new tab by default
* Typescript support * TypeScript support
My intention is to continue development on this project, improving it and keeping it alive. My intention is to continue development on this project, improving it and keeping it alive.

10
cypress.config.ts Normal file
View File

@ -0,0 +1,10 @@
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
excludeSpecPattern: [
'**/*.html',
],
video: true,
},
});

14
cypress/.eslintrc Normal file
View File

@ -0,0 +1,14 @@
{
"plugins": [
"cypress"
],
"env": {
"node": true,
"es6": true,
"cypress/globals": true
},
"extends": [
"../.eslintrc",
"plugin:cypress/recommended"
]
}

View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Default</title>
<link rel="stylesheet" href="../../../dist/easymde.min.css">
<script src="../../../dist/easymde.min.js"></script>
</head>
<body>
<textarea id="textarea"></textarea>
<script>
const easyMDE = new EasyMDE();
</script>
</body>
</html>

View File

@ -0,0 +1,31 @@
/// <reference types="cypress" />
describe('Preview', () => {
beforeEach(() => {
cy.visit(__dirname + '/index.html');
});
it('can show a preview of markdown text', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('.EasyMDEContainer .editor-preview').should('not.be.visible');
// Enter markdown text.
cy.get('.EasyMDEContainer .CodeMirror').type('# My Big Title');
cy.get('.EasyMDEContainer .CodeMirror').type('{enter}');
cy.get('.EasyMDEContainer .CodeMirror').type('This is some **important** text!');
cy.get('.EasyMDEContainer .CodeMirror-line').should('contain', '# My Big Title');
cy.get('.EasyMDEContainer .cm-header.cm-header-1').should('contain', '#');
cy.get('.EasyMDEContainer .cm-header.cm-header-1').should('contain', 'My Big Title');
cy.get('.EasyMDEContainer .CodeMirror-line').should('contain', 'This is some **important** text!');
cy.get('.EasyMDEContainer .cm-strong').should('contain', '**');
cy.get('.EasyMDEContainer .cm-strong').should('contain', 'important');
cy.previewOn();
// Check preview window for rendered markdown.
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<h1 id="my-big-title">My Big Title</h1>');
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p>This is some <strong>important</strong> text!</p>');
});
});

View File

@ -0,0 +1,56 @@
/// <reference types="cypress" />
describe('Default statusbar', () => {
beforeEach(() => {
cy.visit(__dirname + '/index.html');
});
it('loads the editor with default statusbar', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('.EasyMDEContainer .editor-statusbar').should('be.visible');
cy.get('.EasyMDEContainer .editor-statusbar .autosave').should('be.empty');
cy.get('.EasyMDEContainer .editor-statusbar .lines').before('content').should('contain', 'lines: ');
cy.get('.EasyMDEContainer .editor-statusbar .lines').should('contain', '1');
cy.get('.EasyMDEContainer .editor-statusbar .words').before('content').should('contain', 'words: ');
cy.get('.EasyMDEContainer .editor-statusbar .words').should('contain', '0');
cy.get('.EasyMDEContainer .editor-statusbar .cursor').should('contain', '1:1');
});
it('updates the statusbar when typing', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('.EasyMDEContainer .editor-statusbar').should('be.visible');
cy.get('.EasyMDEContainer .CodeMirror').type('Hello');
cy.get('.EasyMDEContainer .editor-statusbar .autosave').should('be.empty');
cy.get('.EasyMDEContainer .editor-statusbar .lines').should('contain', '1');
cy.get('.EasyMDEContainer .editor-statusbar .words').should('contain', '1');
cy.get('.EasyMDEContainer .editor-statusbar .cursor').should('contain', '1:6');
cy.get('.EasyMDEContainer .CodeMirror').type(' World');
cy.get('.EasyMDEContainer .editor-statusbar .lines').should('contain', '1');
cy.get('.EasyMDEContainer .editor-statusbar .words').should('contain', '2');
cy.get('.EasyMDEContainer .editor-statusbar .cursor').should('contain', '1:12');
cy.get('.EasyMDEContainer .CodeMirror').type('{enter}');
cy.get('.EasyMDEContainer .editor-statusbar .lines').should('contain', '2');
cy.get('.EasyMDEContainer .editor-statusbar .words').should('contain', '2');
cy.get('.EasyMDEContainer .editor-statusbar .cursor').should('contain', '2:1');
cy.get('.EasyMDEContainer .CodeMirror').type('This is a sample text.{enter}We\'re testing the statusbar.{enter}Did it work?');
cy.get('.EasyMDEContainer .editor-statusbar .autosave').should('be.empty');
cy.get('.EasyMDEContainer .editor-statusbar .lines').before('content').should('contain', 'lines: ');
cy.get('.EasyMDEContainer .editor-statusbar .lines').should('contain', '4');
cy.get('.EasyMDEContainer .editor-statusbar .words').before('content').should('contain', 'words: ');
cy.get('.EasyMDEContainer .editor-statusbar .words').should('contain', '15');
cy.get('.EasyMDEContainer .editor-statusbar .cursor').should('contain', '4:13');
});
});

View File

@ -0,0 +1,17 @@
/// <reference types="cypress" />
describe('Default editor', () => {
beforeEach(() => {
cy.visit(__dirname + '/index.html');
});
it('loads the editor with default settings', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.get('.EasyMDEContainer .editor-toolbar').should('be.visible');
cy.get('.EasyMDEContainer .CodeMirror').should('be.visible');
cy.get('.EasyMDEContainer .editor-preview').should('not.be.visible');
cy.get('.EasyMDEContainer .editor-statusbar').should('be.visible');
});
});

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Default</title>
<link rel="stylesheet" href="../../../dist/easymde.min.css">
<script src="../../../dist/easymde.min.js"></script>
</head>
<body>
<textarea id="textarea"></textarea>
<script>
const easyMDE = new EasyMDE({
promptURLs: true,
});
</script>
</body>
</html>

View File

@ -0,0 +1,232 @@
/// <reference types="cypress" />
describe('URL prompts', () => {
beforeEach(() => {
cy.visit(__dirname + '/index.html');
});
it('must show the correct text for a link prompt', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
const stub = cy.stub($win, 'prompt');
cy.get('button.link').click();
cy.get('button.link').then(() => {
expect(stub).to.be.calledWith('URL for the link:', 'https://');
});
});
});
it('must show the correct text for an image prompt', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
const stub = cy.stub($win, 'prompt');
cy.get('button.image').click();
cy.get('button.image').then(() => {
expect(stub).to.be.calledWith('URL of the image:', 'https://');
});
});
});
it('must enter a link correctly through a prompt', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
cy.stub($win, 'prompt').returns('https://example.com');
cy.get('button.link').click();
});
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com)');
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com" target="_blank">Link to a website!</a></p>');
});
it('can use the prompt multiple times', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
const stub = cy.stub($win, 'prompt');
stub.returns('https://example.com');
cy.get('button.link').click();
cy.get('button.link').then(() => {
expect(stub).to.be.calledWith('URL for the link:', 'https://');
stub.restore();
});
});
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com)');
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!{end}{enter}');
cy.window().then(($win) => {
const stub = cy.stub($win, 'prompt');
stub.returns('https://example.eu');
cy.get('button.link').click();
cy.get('button.link').then(() => {
expect(stub).to.be.calledWith('URL for the link:', 'https://');
stub.restore();
});
});
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.eu)');
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a second website!');
cy.get('.EasyMDEContainer .CodeMirror').contains('[Link to a website!](https://example.com)');
cy.get('.EasyMDEContainer .CodeMirror').contains('[Link to a second website!](https://example.eu)');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should(
'contain.html',
'<p><a href="https://example.com" target="_blank">Link to a website!</a><br><a href="https://example.eu" target="_blank">Link to a second website!</a></p>',
);
});
it('must be able to deal with parameters in links', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
cy.stub($win, 'prompt').returns('https://example.com?some=param&moo=cow');
cy.get('button.link').click();
});
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=param&moo=cow)');
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=param&amp;moo=cow" target="_blank">Link to a website!</a></p>');
});
it('must be able to deal with brackets in links', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
cy.stub($win, 'prompt').returns('https://example.com?some=[]param');
cy.get('button.link').click();
});
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=%5B%5Dparam)');
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=%5B%5Dparam" target="_blank">Link to a website!</a></p>');
});
it('must be able to deal with parentheses in links', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
cy.stub($win, 'prompt').returns('https://example.com?some=(param)');
cy.get('button.link').click();
});
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=\\(param\\))');
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=(param)" target="_blank">Link to a website!</a></p>');
});
it('must be able to deal with parentheses in links (multiple)', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
cy.stub($win, 'prompt').returns('https://example.com?some=(param1,param2)&more=(param3,param4)&end=true');
cy.get('button.link').click();
});
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=\\(param1,param2\\)&more=\\(param3,param4\\)&end=true)');
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=(param1,param2)&amp;more=(param3,param4)&amp;end=true" target="_blank">Link to a website!</a></p>');
});
it('must be able to deal with unbalanced parentheses in links (opening)', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
cy.stub($win, 'prompt').returns('https://example.com?some=(param');
cy.get('button.link').click();
});
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=\\(param)');
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=(param" target="_blank">Link to a website!</a></p>');
});
it('must be able to deal with unbalanced parentheses in links (closing)', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
cy.stub($win, 'prompt').returns('https://example.com?some=)param');
cy.get('button.link').click();
});
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=\\)param)');
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=)param" target="_blank">Link to a website!</a></p>');
});
it('must be able to deal with inequality symbols in links', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
cy.stub($win, 'prompt').returns('https://example.com?some=<param');
cy.get('button.link').click();
});
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=%3Cparam');
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=%3Cparam" target="_blank">Link to a website!</a></p>');
});
it('must be able to deal with emoji in links', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
cy.stub($win, 'prompt').returns('https://example.com?some=👷‍♂️');
cy.get('button.link').click();
});
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=%F0%9F%91%B7%E2%80%8D%E2%99%82%EF%B8%8F');
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a 👌 website!');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=%F0%9F%91%B7%E2%80%8D%E2%99%82%EF%B8%8F" target="_blank">Link to a 👌 website!</a></p>');
});
it('must be able to deal with spaces in links', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.window().then(($win) => {
cy.stub($win, 'prompt').returns('https://example.com?some=very special param');
cy.get('button.link').click();
});
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=very%20special%20param');
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=very%20special%20param" target="_blank">Link to a website!</a></p>');
});
});

View File

@ -0,0 +1,17 @@
/// <reference types="cypress" />
describe('Default editor', () => {
it('table', () => {
cy.visit(__dirname + '/index-no-prefix.html');
cy.get('button.table').should('be.visible');
cy.get('button.table').invoke('outerWidth').should('not.equal', 30);
});
it('loads the editor with default settings', () => {
cy.visit(__dirname + '/index.html');
cy.get('button.mde-table').should('be.visible');
cy.get('button.mde-table').invoke('outerWidth').should('equal', 30);
});
});

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Default</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="../../../dist/easymde.min.css">
<script src="../../../dist/easymde.min.js"></script>
</head>
<body>
<textarea id="textarea"></textarea>
<script>
const easyMDE = new EasyMDE({
showIcons: ["table"],
});
</script>
</body>
</html>

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Default</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="../../../dist/easymde.min.css">
<script src="../../../dist/easymde.min.js"></script>
</head>
<body>
<textarea id="textarea"></textarea>
<script>
const easyMDE = new EasyMDE({
toolbarButtonClassPrefix: 'mde',
showIcons: ["table"],
});
</script>
</body>
</html>

View File

@ -0,0 +1,43 @@
/// <reference types="cypress" />
describe('Image rendering', () => {
const imageUrl = 'https://picsum.photos/id/237/150';
beforeEach(() => {
cy.visit(__dirname + '/index.html');
cy.intercept('GET', imageUrl).as('image');
});
it('must render an image inside the editor', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.get('.EasyMDEContainer .CodeMirror').type(imageUrl);
cy.get('.EasyMDEContainer .CodeMirror').type('{home}![Dog!]({end})');
cy.wait('@image');
cy.get(`.EasyMDEContainer [data-img-src="${imageUrl}"]`).should('be.visible');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', `<p><img src="${imageUrl}" alt="Dog!"></p>`);
});
it('must be able to handle parentheses inside image alt text', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.get('.EasyMDEContainer .CodeMirror').type(imageUrl);
cy.get('.EasyMDEContainer .CodeMirror').type('{home}![Dog! (He\'s a good boy!)]({end})');
cy.wait('@image');
cy.get(`.EasyMDEContainer [data-img-src="${imageUrl}"]`).should('be.visible');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', `<p><img src="${imageUrl}" alt="Dog! (He's a good boy!)"></p>`);
});
});

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Default</title>
<link rel="stylesheet" href="../../../dist/easymde.min.css">
<script src="../../../dist/easymde.min.js"></script>
</head>
<body>
<textarea id="textarea"></textarea>
<script>
const easyMDE = new EasyMDE({
previewImagesInEditor: true,
});
</script>
</body>
</html>

View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Default</title>
<link rel="stylesheet" href="../../../dist/easymde.min.css">
<script src="../../../dist/easymde.min.js"></script>
</head>
<body>
<textarea id="textarea"></textarea>
<script>
const easyMDE = new EasyMDE({
renderingConfig: {
markedOptions: {
headerPrefix: 'header-prefix-',
}
}
});
</script>
</body>
</html>

View File

@ -0,0 +1,18 @@
/// <reference types="cypress" />
describe('Marked options', () => {
beforeEach(() => {
cy.visit(__dirname + '/index.html');
});
it('must apply the markedOptions to the markdown parser', () => {
cy.get('.EasyMDEContainer').should('be.visible');
cy.get('#textarea').should('not.be.visible');
cy.get('.EasyMDEContainer .CodeMirror').type('# Title{enter}');
cy.previewOn();
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<h1 id="header-prefix-title">Title</h1>');
});
});

10
cypress/plugins/index.js Normal file
View File

@ -0,0 +1,10 @@
/// <reference types="cypress" />
/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
};

View File

@ -0,0 +1,31 @@
/// <reference types="cypress" />
const unquote = (str) => str.replace(/(^")|("$)/g, '');
Cypress.Commands.add(
'before',
{
prevSubject: 'element',
},
(element, property) => {
const win = element[0].ownerDocument.defaultView;
const before = win.getComputedStyle(element[0], 'before');
return unquote(before.getPropertyValue(property));
},
);
Cypress.Commands.add('previewOn' , () => {
cy.get('.EasyMDEContainer .editor-preview').should('not.be.visible');
cy.get('.EasyMDEContainer .editor-toolbar button.preview').should('not.have.class', 'active');
cy.get('.EasyMDEContainer .editor-toolbar button.preview').click();
cy.get('.EasyMDEContainer .editor-toolbar button.preview').should('have.class', 'active');
cy.get('.EasyMDEContainer .editor-preview').should('be.visible');
});
Cypress.Commands.add('previewOff' , () => {
cy.get('.EasyMDEContainer .editor-preview').should('be.visible');
cy.get('.EasyMDEContainer .editor-toolbar button.preview').should('have.class', 'active');
cy.get('.EasyMDEContainer .editor-toolbar button.preview').click();
cy.get('.EasyMDEContainer .editor-toolbar button.preview').should('not.have.class', 'active');
cy.get('.EasyMDEContainer .editor-preview').should('not.be.visible');
});

1
cypress/support/e2e.js Normal file
View File

@ -0,0 +1 @@
require('./commands');

View File

@ -13,7 +13,7 @@
<body> <body>
<textarea></textarea> <textarea></textarea>
<script> <script>
var easyMDE = new EasyMDE(); const easyMDE = new EasyMDE();
</script> </script>
</body> </body>

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Example / Preview / sideBySideFullscreen : false</title>
<link rel="stylesheet" href="../dist/easymde.min.css">
<script src="../dist/easymde.min.js"></script>
</head>
<body>
<textarea></textarea>
<script>
const easyMDE = new EasyMDE({sideBySideFullscreen: false});
</script>
</body>
</html>

14788
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "easymde", "name": "easymde",
"version": "2.14.0", "version": "2.20.0",
"description": "A simple, beautiful, and embeddable JavaScript Markdown editor that easy to use. Features include autosaving and spell checking.", "description": "A simple, beautiful, and embeddable JavaScript Markdown editor that easy to use. Features include autosaving and spell checking.",
"files": [ "files": [
"dist/**/*", "dist/**/*",
@ -19,31 +19,37 @@
"license": "MIT", "license": "MIT",
"author": "Jeroen Akkerman", "author": "Jeroen Akkerman",
"dependencies": { "dependencies": {
"codemirror": "^5.59.2", "@types/codemirror": "^5.60.10",
"@types/marked": "^4.0.7",
"codemirror": "^5.65.15",
"codemirror-spell-checker": "1.1.2", "codemirror-spell-checker": "1.1.2",
"marked": "^2.0.0" "marked": "^4.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/codemirror": "0.0.108",
"@types/marked": "^1.2.2",
"browserify": "^17.0.0", "browserify": "^17.0.0",
"cypress": "^13.2.0",
"eslint": "^8.50.0",
"eslint-plugin-cypress": "^2.15.1",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-clean-css": "^4.2.0", "gulp-clean-css": "^4.3.0",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",
"gulp-eslint": "^6.0.0", "gulp-eslint": "^6.0.0",
"gulp-header": "^2.0.9", "gulp-header": "^2.0.9",
"gulp-rename": "^2.0.0", "gulp-rename": "^2.0.0",
"gulp-terser": "^2.0.1", "gulp-terser": "^2.1.0",
"gulp-uglify": "^3.0.2", "gulp-uglify": "^3.0.2",
"typescript": "^4.1.5", "typescript": "^5.2.2",
"vinyl-buffer": "^1.0.0", "vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0" "vinyl-source-stream": "^2.0.0"
}, },
"repository": "github:Ionaru/easy-markdown-editor", "repository": "github:Ionaru/easy-markdown-editor",
"scripts": { "scripts": {
"prepare": "gulp", "prepare": "gulp",
"test": "npm run lint && npm run test:types", "test": "npm run lint && npm run test:types && npm run e2e",
"lint": "gulp lint", "lint": "gulp lint",
"cypress:lint": "eslint cypress",
"cypress:run": "cypress run",
"e2e": "gulp && npm run cypress:lint && npm run cypress:run",
"test:types": "tsc --project types/tsconfig.json" "test:types": "tsc --project types/tsconfig.json"
} }
} }

View File

@ -2,6 +2,10 @@
display: block; display: block;
} }
.CodeMirror-rtl pre {
direction: rtl;
}
.EasyMDEContainer.sided--no-fullscreen { .EasyMDEContainer.sided--no-fullscreen {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -11,7 +15,7 @@
.EasyMDEContainer .CodeMirror { .EasyMDEContainer .CodeMirror {
box-sizing: border-box; box-sizing: border-box;
height: auto; height: auto;
border: 1px solid #ddd; border: 1px solid #ced4da;
border-bottom-left-radius: 4px; border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px; border-bottom-right-radius: 4px;
padding: 10px; padding: 10px;
@ -41,9 +45,9 @@
width: 50% !important; width: 50% !important;
} }
.EasyMDEContainer .CodeMirror-sided.sided--no-fullscreen { .EasyMDEContainer.sided--no-fullscreen .CodeMirror-sided {
border-right: none!important; border-right: none !important;
border-bottom-right-radius: 0px; border-bottom-right-radius: 0;
position: relative; position: relative;
flex: 1 1 auto; flex: 1 1 auto;
} }
@ -64,9 +68,9 @@
-o-user-select: none; -o-user-select: none;
user-select: none; user-select: none;
padding: 9px 10px; padding: 9px 10px;
border-top: 1px solid #bbb; border-top: 1px solid #ced4da;
border-left: 1px solid #bbb; border-left: 1px solid #ced4da;
border-right: 1px solid #bbb; border-right: 1px solid #ced4da;
border-top-left-radius: 4px; border-top-left-radius: 4px;
border-top-right-radius: 4px; border-top-right-radius: 4px;
} }
@ -118,7 +122,7 @@
padding: 0; padding: 0;
} }
.editor-toolbar.sided--no-fullscreen { .EasyMDEContainer.sided--no-fullscreen .editor-toolbar {
width: 100%; width: 100%;
} }
@ -136,7 +140,10 @@
} }
.editor-toolbar button { .editor-toolbar button {
width: 30px; font-weight: bold;
min-width: 30px;
padding: 0 6px;
white-space: nowrap;
} }
.editor-toolbar button.active, .editor-toolbar button.active,
@ -201,7 +208,7 @@
text-align: right; text-align: right;
} }
.editor-statusbar.sided--no-fullscreen { .EasyMDEContainer.sided--no-fullscreen .editor-statusbar {
width: 100%; width: 100%;
} }
@ -253,7 +260,7 @@
display: block display: block
} }
.editor-preview-active-side.sided--no-fullscreen { .EasyMDEContainer.sided--no-fullscreen .editor-preview-active-side {
flex: 1 1 auto; flex: 1 1 auto;
height: auto; height: auto;
position: static; position: static;
@ -296,23 +303,37 @@
} }
.cm-s-easymde .cm-header-1 { .cm-s-easymde .cm-header-1 {
font-size: 200%; font-size: calc(1.375rem + 1.5vw);
line-height: 200%;
} }
.cm-s-easymde .cm-header-2 { .cm-s-easymde .cm-header-2 {
font-size: 160%; font-size: calc(1.325rem + .9vw);
line-height: 160%;
} }
.cm-s-easymde .cm-header-3 { .cm-s-easymde .cm-header-3 {
font-size: 125%; font-size: calc(1.3rem + .6vw);
line-height: 125%;
} }
.cm-s-easymde .cm-header-4 { .cm-s-easymde .cm-header-4 {
font-size: 110%; font-size: calc(1.275rem + .3vw);
line-height: 110%; }
.cm-s-easymde .cm-header-5 {
font-size: 1.25rem;
}
.cm-s-easymde .cm-header-6 {
font-size: 1rem;
}
.cm-s-easymde .cm-header-1,
.cm-s-easymde .cm-header-2,
.cm-s-easymde .cm-header-3,
.cm-s-easymde .cm-header-4,
.cm-s-easymde .cm-header-5,
.cm-s-easymde .cm-header-6 {
margin-bottom: .5rem;
line-height: 1.2;
} }
.cm-s-easymde .cm-comment { .cm-s-easymde .cm-comment {
@ -356,19 +377,27 @@
} }
.easymde-dropdown:active .easymde-dropdown-content, .easymde-dropdown:active .easymde-dropdown-content,
.easymde-dropdown:focus .easymde-dropdown-content { .easymde-dropdown:focus .easymde-dropdown-content,
.easymde-dropdown:focus-within .easymde-dropdown-content {
visibility: visible; visibility: visible;
} }
span[data-img-src]::after{ .easymde-dropdown-content button {
display: block;
}
span[data-img-src]::after {
content: ''; content: '';
/*noinspection CssUnresolvedCustomProperty, added through JS*/
background-image: var(--bg-image); background-image: var(--bg-image);
display: block; display: block;
max-height: 100%; max-height: 100%;
max-width: 100%; max-width: 100%;
background-size: contain; background-size: contain;
height: 0; height: 0;
/*noinspection CssUnresolvedCustomProperty, added through JS*/
padding-top: var(--height); padding-top: var(--height);
/*noinspection CssUnresolvedCustomProperty, added through JS*/
width: var(--width); width: var(--width);
background-repeat: no-repeat; background-repeat: no-repeat;
} }

View File

@ -16,8 +16,7 @@ CodeMirror.commands.tabAndIndentMarkdownList = function (cm) {
if (cm.options.indentWithTabs) { if (cm.options.indentWithTabs) {
cm.execCommand('insertTab'); cm.execCommand('insertTab');
} } else {
else {
var spaces = Array(cm.options.tabSize + 1).join(' '); var spaces = Array(cm.options.tabSize + 1).join(' ');
cm.replaceSelection(spaces); cm.replaceSelection(spaces);
} }
@ -36,8 +35,7 @@ CodeMirror.commands.shiftTabAndUnindentMarkdownList = function (cm) {
if (cm.options.indentWithTabs) { if (cm.options.indentWithTabs) {
cm.execCommand('insertTab'); cm.execCommand('insertTab');
} } else {
else {
var spaces = Array(cm.options.tabSize + 1).join(' '); var spaces = Array(cm.options.tabSize + 1).join(' ');
cm.replaceSelection(spaces); cm.replaceSelection(spaces);
} }

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ const editor = new EasyMDE({
inputStyle: 'textarea', inputStyle: 'textarea',
shortcuts: { shortcuts: {
drawTable: 'Cmd-Alt-T', drawTable: 'Cmd-Alt-T',
toggleFullScreen: null toggleFullScreen: null,
}, },
previewClass: 'my-custom-class', previewClass: 'my-custom-class',
spellChecker: false, spellChecker: false,
@ -16,7 +16,7 @@ const editor = new EasyMDE({
console.log('FullscreenToggled', full); console.log('FullscreenToggled', full);
}, },
theme: 'someOtherTheme', theme: 'someOtherTheme',
minHeight: '200px' minHeight: '200px',
}); });
// Editor functions // Editor functions
@ -38,13 +38,14 @@ 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: [
{ {
name: 'bold', name: 'bold',
action: EasyMDE.toggleBold, action: EasyMDE.toggleBold,
className: 'fa fas fa-bolt', className: 'fa fas fa-bolt',
title: 'Bold' title: 'Bold',
}, },
'|', '|',
'undo', 'undo',
@ -57,7 +58,10 @@ const editor2 = new EasyMDE({
className: 'fa fas fa-star', className: 'fa fas fa-star',
title: 'A Custom Button', title: 'A Custom Button',
noDisable: undefined, noDisable: undefined,
noMobile: false noMobile: false,
attributes: {
'data-custom': 'attribute',
}
}, },
'|', '|',
{ {
@ -66,7 +70,7 @@ const editor2 = new EasyMDE({
className: 'fa fab fa-github', className: 'fa fab fa-github',
title: 'A Custom Link', title: 'A Custom Link',
noDisable: true, noDisable: true,
noMobile: true noMobile: true,
}, },
'preview', 'preview',
{ {
@ -80,21 +84,26 @@ const editor2 = new EasyMDE({
className: 'fa fab fa-github', className: 'fa fab fa-github',
title: 'A Custom Link', title: 'A Custom Link',
noDisable: true, noDisable: true,
noMobile: true noMobile: true,
}, },
'preview', 'preview',
{ {
name: 'bold', name: 'bold',
action: EasyMDE.toggleBold, action: EasyMDE.toggleBold,
className: 'fa fas fa-bold', className: 'fa fas fa-bold',
title: 'Bold' title: 'Bold',
attributes: {
'data-custom': 'some value',
'data-custom-2': 'another value',
}
}, },
] ],
} },
] ],
}); });
editor2.clearAutosavedValue(); editor2.clearAutosavedValue();
editor2.updateStatusBar('upload-image', 'Drag & drop images!');
EasyMDE.togglePreview(editor2); EasyMDE.togglePreview(editor2);
EasyMDE.toggleSideBySide(editor2); EasyMDE.toggleSideBySide(editor2);
@ -104,6 +113,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: {
@ -112,17 +122,17 @@ const editorImages = new EasyMDE({
sbOnDrop: 'Uploading...', sbOnDrop: 'Uploading...',
sbProgress: 'Uploading... (#progress#)', sbProgress: 'Uploading... (#progress#)',
sbOnUploaded: 'Upload complete!', sbOnUploaded: 'Upload complete!',
sizeUnits: 'b,Kb,Mb' sizeUnits: 'b,Kb,Mb',
}, },
errorMessages: { errorMessages: {
noFileGiven: 'Please select a file', noFileGiven: 'Please select a file',
typeNotAllowed: 'This file type is not allowed!', typeNotAllowed: 'This file type is not allowed!',
fileTooLarge: 'Image too big', fileTooLarge: 'Image too big',
importError: 'Something went oops!' importError: 'Something went oops!',
}, },
errorCallback: errorMessage => { errorCallback: errorMessage => {
console.error(errorMessage); console.error(errorMessage);
} },
}); });
const editorImagesCustom = new EasyMDE({ const editorImagesCustom = new EasyMDE({
@ -141,13 +151,13 @@ const editorImagesCustom = new EasyMDE({
sbOnDrop: 'Uploading...', sbOnDrop: 'Uploading...',
sbProgress: 'Uploading... (#progress#)', sbProgress: 'Uploading... (#progress#)',
sbOnUploaded: 'Upload complete!', sbOnUploaded: 'Upload complete!',
sizeUnits: 'b,Kb,Mb' sizeUnits: 'b,Kb,Mb',
}, },
errorMessages: { errorMessages: {
noFileGiven: 'Please select a file', noFileGiven: 'Please select a file',
typeNotAllowed: 'This file type is not allowed!', typeNotAllowed: 'This file type is not allowed!',
fileTooLarge: 'Image too big', fileTooLarge: 'Image too big',
importError: 'Something went oops!' importError: 'Something went oops!',
}, },
errorCallback: errorMessage => { errorCallback: errorMessage => {
console.error(errorMessage); console.error(errorMessage);
@ -157,19 +167,21 @@ const editorImagesCustom = new EasyMDE({
markedOptions: { markedOptions: {
silent: true, silent: true,
highlight(code: string, lang: string, callback?: (error: (any | undefined), code: string) => void): string { highlight(code: string, lang: string, callback?: (error: (any | undefined), code: string) => void): string {
return 'something' return 'something';
}, },
}, },
}, },
promptTexts: { promptTexts: {
image: 'Insert URL' image: 'Insert URL',
}, },
syncSideBySidePreviewScroll: true syncSideBySidePreviewScroll: true,
}); });
new EasyMDE({ new EasyMDE({
toolbarButtonClassPrefix: 'mde',
sideBySideFullscreen: true, sideBySideFullscreen: true,
lineNumbers: false, lineNumbers: false,
unorderedListStyle: '*',
autosave: { autosave: {
enabled: true, enabled: true,
delay: 2000, delay: 2000,
@ -179,10 +191,10 @@ new EasyMDE({
locale: 'en-GB', locale: 'en-GB',
format: { format: {
month: 'long', month: 'long',
} },
}, },
text: 'Stored: ', text: 'Stored: ',
} },
}); });
new EasyMDE({ new EasyMDE({
@ -198,7 +210,29 @@ new EasyMDE({
'unordered-list', 'unordered-list',
'ordered-list', 'ordered-list',
'table', 'table',
'upload-image',
'|', '|',
'link' 'link',
] ],
});
new EasyMDE({
direction: 'ltr',
});
new EasyMDE({
direction: 'rtl',
});
new EasyMDE({
previewRender: (plainText: string) => {
return '<pre>' + plainText + '</pre>';
}
});
new EasyMDE({
previewRender: (plainText: string, preview) => {
preview.innerHTML = '<pre>' + plainText + '</pre>';
return null;
}
}); });

48
types/easymde.d.ts vendored
View File

@ -20,10 +20,11 @@
// SOFTWARE. // SOFTWARE.
/// <reference types="codemirror"/> /// <reference types="codemirror"/>
/// <reference types="marked"/>
import { marked } from 'marked';
interface ArrayOneOrMore<T> extends Array<T> { interface ArrayOneOrMore<T> extends Array<T> {
0: T 0: T;
} }
type ToolbarButton = type ToolbarButton =
@ -34,6 +35,7 @@ type ToolbarButton =
| 'ordered-list' | 'ordered-list'
| 'link' | 'link'
| 'image' | 'image'
| 'upload-image'
| 'strikethrough' | 'strikethrough'
| 'code' | 'code'
| 'table' | 'table'
@ -74,6 +76,10 @@ declare namespace EasyMDE {
italic?: string; italic?: string;
} }
interface CustomAttributes {
[key: string]: string;
}
interface InsertTextOptions { interface InsertTextOptions {
horizontalRule?: ReadonlyArray<string>; horizontalRule?: ReadonlyArray<string>;
image?: ReadonlyArray<string>; image?: ReadonlyArray<string>;
@ -95,7 +101,7 @@ declare namespace EasyMDE {
interface RenderingOptions { interface RenderingOptions {
codeSyntaxHighlighting?: boolean; codeSyntaxHighlighting?: boolean;
hljs?: any; hljs?: any;
markedOptions?: marked.MarkedOptions; markedOptions?: marked.MarkedExtension;
sanitizerFunction?: (html: string) => string; sanitizerFunction?: (html: string) => string;
singleLineBreaks?: boolean; singleLineBreaks?: boolean;
} }
@ -141,6 +147,8 @@ declare namespace EasyMDE {
title: string; title: string;
noDisable?: boolean; noDisable?: boolean;
noMobile?: boolean; noMobile?: boolean;
icon?: string;
attributes?: CustomAttributes;
} }
interface ImageTextsOptions { interface ImageTextsOptions {
@ -160,19 +168,23 @@ declare namespace EasyMDE {
} }
interface OverlayModeOptions { interface OverlayModeOptions {
mode: CodeMirror.Mode<any> mode: CodeMirror.Mode<any>;
combine?: boolean combine?: boolean;
}
interface SpellCheckerOptions {
codeMirrorInstance: CodeMirror.Editor;
} }
interface Options { interface Options {
autoDownloadFontAwesome?: boolean; autoDownloadFontAwesome?: boolean;
autofocus?: boolean; autofocus?: boolean;
autosave?: AutoSaveOptions; autosave?: AutoSaveOptions;
autoRefresh?: boolean | { delay: number }; autoRefresh?: boolean | { delay: number; };
blockStyles?: BlockStyleOptions; blockStyles?: BlockStyleOptions;
element?: HTMLElement; element?: HTMLElement;
forceSync?: boolean; forceSync?: boolean;
hideIcons?: ReadonlyArray<string>; hideIcons?: ReadonlyArray<ToolbarButton>;
indentWithTabs?: boolean; indentWithTabs?: boolean;
initialValue?: string; initialValue?: string;
insertTexts?: InsertTextOptions; insertTexts?: InsertTextOptions;
@ -184,12 +196,13 @@ declare namespace EasyMDE {
placeholder?: string; placeholder?: string;
previewClass?: string | ReadonlyArray<string>; previewClass?: string | ReadonlyArray<string>;
previewImagesInEditor?: boolean; previewImagesInEditor?: boolean;
previewRender?: (markdownPlaintext: string, previewElement: HTMLElement) => string; imagesPreviewHandler?: (src: string) => string,
previewRender?: (markdownPlaintext: string, previewElement: HTMLElement) => string | null;
promptURLs?: boolean; promptURLs?: boolean;
renderingConfig?: RenderingOptions; renderingConfig?: RenderingOptions;
shortcuts?: Shortcuts; shortcuts?: Shortcuts;
showIcons?: ReadonlyArray<ToolbarButton>; showIcons?: ReadonlyArray<ToolbarButton>;
spellChecker?: boolean; spellChecker?: boolean | ((options: SpellCheckerOptions) => void);
inputStyle?: 'textarea' | 'contenteditable'; inputStyle?: 'textarea' | 'contenteditable';
nativeSpellcheck?: boolean; nativeSpellcheck?: boolean;
sideBySideFullscreen?: boolean; sideBySideFullscreen?: boolean;
@ -198,24 +211,32 @@ declare namespace EasyMDE {
tabSize?: number; tabSize?: number;
toolbar?: boolean | ReadonlyArray<'|' | ToolbarButton | ToolbarIcon | ToolbarDropdownIcon>; toolbar?: boolean | ReadonlyArray<'|' | ToolbarButton | ToolbarIcon | ToolbarDropdownIcon>;
toolbarTips?: boolean; toolbarTips?: boolean;
toolbarButtonClassPrefix?: string;
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;
imageAccept?: string; imageAccept?: string;
imageUploadFunction?: (file: File, onSuccess: (url: string) => void, onError: (error: string) => void) => void; imageUploadFunction?: (file: File, onSuccess: (url: string) => void, onError: (error: string) => void) => void;
imageUploadEndpoint?: string; imageUploadEndpoint?: string;
imagePathAbsolute?: boolean;
imageCSRFToken?: string; imageCSRFToken?: string;
imageCSRFName?: string;
imageCSRFHeader?: boolean;
imageTexts?: ImageTextsOptions; imageTexts?: ImageTextsOptions;
imageInputName?: string
errorMessages?: ImageErrorTextsOptions; errorMessages?: ImageErrorTextsOptions;
errorCallback?: (errorMessage: string) => void; errorCallback?: (errorMessage: string) => void;
promptTexts?: PromptTexts; promptTexts?: PromptTexts;
syncSideBySidePreviewScroll?: boolean; syncSideBySidePreviewScroll?: boolean;
overlayMode?: OverlayModeOptions overlayMode?: OverlayModeOptions;
direction?: 'ltr' | 'rtl';
} }
} }
@ -227,6 +248,8 @@ declare class EasyMDE {
codemirror: CodeMirror.Editor; codemirror: CodeMirror.Editor;
cleanup(): void;
toTextArea(): void; toTextArea(): void;
isPreviewActive(): boolean; isPreviewActive(): boolean;
@ -237,6 +260,8 @@ declare class EasyMDE {
clearAutosavedValue(): void; clearAutosavedValue(): void;
updateStatusBar(itemName: string, content: string): void;
static toggleBold: (editor: EasyMDE) => void; static toggleBold: (editor: EasyMDE) => void;
static toggleItalic: (editor: EasyMDE) => void; static toggleItalic: (editor: EasyMDE) => void;
static toggleStrikethrough: (editor: EasyMDE) => void; static toggleStrikethrough: (editor: EasyMDE) => void;
@ -245,6 +270,9 @@ declare class EasyMDE {
static toggleHeading1: (editor: EasyMDE) => void; static toggleHeading1: (editor: EasyMDE) => void;
static toggleHeading2: (editor: EasyMDE) => void; static toggleHeading2: (editor: EasyMDE) => void;
static toggleHeading3: (editor: EasyMDE) => void; static toggleHeading3: (editor: EasyMDE) => void;
static toggleHeading4: (editor: EasyMDE) => void;
static toggleHeading5: (editor: EasyMDE) => void;
static toggleHeading6: (editor: EasyMDE) => void;
static toggleCodeBlock: (editor: EasyMDE) => void; static toggleCodeBlock: (editor: EasyMDE) => void;
static toggleBlockquote: (editor: EasyMDE) => void; static toggleBlockquote: (editor: EasyMDE) => void;
static toggleUnorderedList: (editor: EasyMDE) => void; static toggleUnorderedList: (editor: EasyMDE) => void;

View File

@ -1,6 +1,7 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es3", "target": "es3",
"ignoreDeprecations": "5.0",
"strict": true, "strict": true,
"noImplicitReturns": true, "noImplicitReturns": true,
"noEmit": true "noEmit": true