mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-09-24 16:40:55 -06:00
readme rework
This commit is contained in:
parent
9c779bf85c
commit
48692424d2
428
README.md
428
README.md
@ -1,41 +1,85 @@
|
|||||||
# EasyMDE is a fork of SimpleMDE
|
# EasyMDE - Markdown Editor
|
||||||
This repository is a fork of [SimpleMDE, made by Sparksuite](https://github.com/sparksuite/simplemde-markdown-editor/).
|
|
||||||
|
|
||||||
I originally made this fork to implement FontAwesome 5 compatibility into SimpleMDE. When that was done I submitted a [pull request](https://github.com/sparksuite/simplemde-markdown-editor/pull/666), which has not been accepted yet. This, and the project being inactive since May 2017, triggered me to make more changes and try to put new life into the project.
|
|
||||||
|
|
||||||
Changes include:
|
|
||||||
* FontAwesome 5 compatibility
|
|
||||||
* Guide button works when editor is in preview mode
|
|
||||||
* Links are now `https://` by default
|
|
||||||
* Small styling changes
|
|
||||||
* Support for Node 8 and beyond
|
|
||||||
* Lots of refactored code
|
|
||||||
* Links in preview will open in a new tab by default
|
|
||||||
* Typescript support
|
|
||||||
|
|
||||||
My intention is to continue development on this project, improving it and keeping it alive.
|
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/easymde)
|
[](https://www.npmjs.com/package/easymde)
|
||||||
[](https://www.npmjs.com/package/easymde/v/next)
|
[](https://www.npmjs.com/package/easymde/v/next)
|
||||||
[](https://travis-ci.org/Ionaru/easy-markdown-editor)
|
[](https://travis-ci.org/Ionaru/easy-markdown-editor)
|
||||||
|
|
||||||
|
> This repository is a fork of
|
||||||
|
[SimpleMDE, made by Sparksuite](https://github.com/sparksuite/simplemde-markdown-editor/).
|
||||||
|
Go to the [dedicated section](#simplemde-fork) for more information.
|
||||||
|
|
||||||
|
A drop-in JavaScript *textarea* replacement for writing beautiful and
|
||||||
|
understandable Markdown. The WYSIWYG-esque editor allows users who may be less
|
||||||
|
experienced with Markdown to use familiar toolbar buttons and shortcuts.
|
||||||
|
|
||||||
|
In addition, the syntax is rendered while editing to clearly show the expected
|
||||||
|
result. Headings are larger, emphasized words are italicized, links are
|
||||||
|
underlined, etc. EasyMDE is one of the first editors to feature both built-in
|
||||||
|
auto-saving and spell checking.
|
||||||
|
|
||||||
|
Try [**the demo**](https://easymde.tk/)!
|
||||||
|
|
||||||
|
[](https://easymde.tk/)
|
||||||
|
|
||||||
|
|
||||||
|
## Quick access
|
||||||
|
|
||||||
|
- [Why not a WYSIWYG editor or pure Markdown?](#why-not-a-wysiwyg-editor-or-pure-markdown)
|
||||||
|
- [Install EasyMDE](#install-easymde)
|
||||||
|
- [How to use](#how-to-use)
|
||||||
|
- [Loading the editor](#loading-the-editor)
|
||||||
|
- [Editor functions](#editor-functions)
|
||||||
|
- [Configuration](#configuration)
|
||||||
|
- [Options list](#options-list)
|
||||||
|
-[Options example](#options-example)
|
||||||
|
- [Toolbar icons](#toolbar-icons)
|
||||||
|
- [Toolbar customization](#toolbar-customization)
|
||||||
|
- [Keyboard shortcuts](#keyboard-shortcuts)
|
||||||
|
- [Advanced use](#advanced-use)
|
||||||
|
- [Event handling](#event-handling)
|
||||||
|
- [Removing EasyMDE from text area](#removing-easymde-from-text-area)
|
||||||
|
- [Useful methods](#useful-methods)
|
||||||
|
- [How it works](#how-it-works)
|
||||||
|
- [EasyMDE fork](#easymde-fork)
|
||||||
|
- [License](#license)
|
||||||
|
|
||||||
|
## Why not a WYSIWYG editor or pure Markdown?
|
||||||
|
|
||||||
|
WYSIWYG editors that produce HTML are often complex and buggy. Markdown solves
|
||||||
|
this problem in many ways, plus Markdown can be rendered natively on more
|
||||||
|
platforms than HTML.
|
||||||
|
|
||||||
|
However, Markdown is not a syntax that an average user will
|
||||||
|
be familiar with, nor is it visually clear while editing. In other words, for an
|
||||||
|
unfamiliar user, the syntax they write will make little sense until they click
|
||||||
|
the preview button. EasyMDE has been designed to bridge this gap for
|
||||||
|
non-technical users who are less familiar with or just learning Markdown syntax.
|
||||||
|
|
||||||
|
|
||||||
## Install EasyMDE
|
## Install EasyMDE
|
||||||
Via [npm](https://www.npmjs.com/package/easymde).
|
|
||||||
|
Via [npm](https://www.npmjs.com/package/easymde):
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install easymde --save
|
npm install easymde --save
|
||||||
```
|
```
|
||||||
|
|
||||||
Via the UNPKG CDN.
|
Via the *UNPKG* CDN:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="https://unpkg.com/easymde/dist/easymde.min.css">
|
<link rel="stylesheet" href="https://unpkg.com/easymde/dist/easymde.min.css">
|
||||||
<script src="https://unpkg.com/easymde/dist/easymde.min.js"></script>
|
<script src="https://unpkg.com/easymde/dist/easymde.min.js"></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
#### Loading the editor
|
|
||||||
|
|
||||||
After installing and/or importing the module, you can load EasyMDE onto the first TextArea on the webpage.
|
### Loading the editor
|
||||||
|
|
||||||
|
After installing and/or importing the module, you can load EasyMDE onto the
|
||||||
|
first TextArea on the web page:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<textarea></textarea>
|
<textarea></textarea>
|
||||||
<script>
|
<script>
|
||||||
@ -43,7 +87,8 @@ var 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>
|
||||||
@ -51,7 +96,8 @@ var easyMDE = new EasyMDE({element: document.getElementById('my-text-area')});
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
Or via jQuery.
|
Or via jQuery:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<textarea id="my-text-area"></textarea>
|
<textarea id="my-text-area"></textarea>
|
||||||
<script>
|
<script>
|
||||||
@ -59,16 +105,19 @@ var easyMDE = new EasyMDE({element: $('#my-text-area')[0]});
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Editor functions
|
|
||||||
|
|
||||||
Use EasyMDE.value() to get the content of the editor.
|
### Editor functions
|
||||||
|
|
||||||
|
Use `EasyMDE.value()` to get the content of the editor:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
easyMDE.value();
|
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>
|
||||||
easyMDE.value('New input for **EasyMDE**');
|
easyMDE.value('New input for **EasyMDE**');
|
||||||
@ -76,125 +125,112 @@ easyMDE.value('New input for **EasyMDE**');
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Below is the original [README](https://github.com/sparksuite/simplemde-markdown-editor/), rewrite for EasyMDE in progress.
|
|
||||||
|
|
||||||
# SimpleMDE - Markdown Editor
|
|
||||||
A drop-in JavaScript textarea replacement for writing beautiful and understandable Markdown. The WYSIWYG-esque editor allows users who may be less experienced with Markdown to use familiar toolbar buttons and shortcuts. In addition, the syntax is rendered while editing to clearly show the expected result. Headings are larger, emphasized words are italicized, links are underlined, etc. SimpleMDE is one of the first editors to feature both built-in autosaving and spell checking.
|
|
||||||
|
|
||||||
[**Demo**](https://simplemde.com)
|
|
||||||
|
|
||||||
[](https://simplemde.com)
|
|
||||||
|
|
||||||
## Why not a WYSIWYG editor or pure Markdown?
|
|
||||||
WYSIWYG editors that produce HTML are often complex and buggy. Markdown solves this problem in many ways, plus Markdown can be rendered natively on more platforms than HTML. However, Markdown is not a syntax that an average user will be familiar with, nor is it visually clear while editing. In otherwords, for an unfamiliar user, the syntax they write will make little sense until they click the preview button. SimpleMDE has been designed to bridge this gap for non-technical users who are less familiar with or just learning Markdown syntax.
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
Via [npm](https://www.npmjs.com/package/simplemde).
|
|
||||||
```
|
|
||||||
npm install simplemde --save
|
|
||||||
```
|
|
||||||
|
|
||||||
Via [jsDelivr](https://www.jsdelivr.com/).
|
|
||||||
|
|
||||||
```HTML
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sparksuite/simplemde-markdown-editor@1/dist/simplemde.min.css">
|
|
||||||
<script src="https://cdn.jsdelivr.net/gh/sparksuite/simplemde-markdown-editor@1/dist/simplemde.min.js"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Quick start
|
|
||||||
|
|
||||||
After installing, load SimpleMDE on the first textarea on a page
|
|
||||||
|
|
||||||
```HTML
|
|
||||||
<script>
|
|
||||||
var simplemde = new SimpleMDE();
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Using a specific textarea
|
|
||||||
|
|
||||||
Pure JavaScript method
|
|
||||||
|
|
||||||
```HTML
|
|
||||||
<script>
|
|
||||||
var simplemde = new SimpleMDE({ element: document.getElementById("MyID") });
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
jQuery method
|
|
||||||
|
|
||||||
```HTML
|
|
||||||
<script>
|
|
||||||
var simplemde = new SimpleMDE({ element: $("#MyID")[0] });
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Get/set the content
|
|
||||||
|
|
||||||
```JavaScript
|
|
||||||
simplemde.value();
|
|
||||||
```
|
|
||||||
|
|
||||||
```JavaScript
|
|
||||||
simplemde.value("This text will appear in the editor");
|
|
||||||
```
|
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
- **autoDownloadFontAwesome**: If set to `true`, force downloads Font Awesome (used for icons). If set to `false`, prevents downloading. Defaults to `undefined`, which will intelligently check whether Font Awesome has already been included, then download accordingly.
|
### Options list
|
||||||
- **autofocus**: If set to `true`, autofocuses the editor. 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.*
|
- **autoDownloadFontAwesome**: If set to `true`, force downloads Font Awesome
|
||||||
- **enabled**: If set to `true`, autosave the text. Defaults to `false`.
|
(used for icons). If set to `false`, prevents downloading. Defaults to
|
||||||
|
`undefined`, which will intelligently check whether Font Awesome has already
|
||||||
|
been included, then download accordingly.
|
||||||
|
- **autofocus**: If set to `true`, auto-focuses the editor. 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.*
|
||||||
|
- **enabled**: If set to `true`, auto-save the text. Defaults to `false`.
|
||||||
- **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s).
|
- **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s).
|
||||||
- **uniqueId**: You must set a unique string identifier so that SimpleMDE can autosave. Something that separates this from other instances of SimpleMDE elsewhere on your website.
|
- **uniqueId**: You must set a unique string identifier so that EasyMDE can
|
||||||
|
auto-save. Something that separates this from other instances of EasyMDE
|
||||||
|
elsewhere on your website.
|
||||||
- **blockStyles**: Customize how certain buttons that style blocks of text behave.
|
- **blockStyles**: Customize how certain buttons that style blocks of text behave.
|
||||||
- **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 `*`.
|
||||||
- **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page.
|
- **element**: The DOM element for the text area to use. Defaults to the first
|
||||||
- **forceSync**: If set to `true`, force text changes made in SimpleMDE to be immediately stored in original textarea. Defaults to `false`.
|
text area on the page.
|
||||||
- **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar.
|
- **forceSync**: If set to `true`, force text changes made in EasyMDE to be
|
||||||
- **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`.
|
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.
|
||||||
|
- **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.
|
||||||
- **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
|
||||||
- link
|
- link
|
||||||
- table
|
- table
|
||||||
- **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`.
|
- **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`.
|
||||||
- **minHeight**: Sets the minimum height for the composition area, before it starts auto-growing. Should be a string containing a valid CSS value like `"500px"`. Dafaults to `"300px"`.
|
- **minHeight**: Sets the minimum height for the composition area, before it
|
||||||
- **onToggleFullScreen**: A function that gets called when the editor's fullscreen mode is toggled. The function will be passed a boolean as parameter, `true` when the editor is currently going into fullscreen mode, or `false`.
|
starts auto-growing. Should be a string containing a valid CSS value like
|
||||||
- **parsingConfig**: Adjust settings for parsing the Markdown during editing (not previewing).
|
`"500px"`. Defaults to `"300px"`.
|
||||||
- **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers without a space after the `#`. Defaults to `false`.
|
- **onToggleFullScreen**: A function that gets called when the editor's
|
||||||
- **strikethrough**: If set to `false`, will not process GFM strikethrough syntax. Defaults to `true`.
|
full screen mode is toggled. The function will be passed a boolean as parameter,
|
||||||
- **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`.
|
`true` when the editor is currently going into full screen mode, or `false`.
|
||||||
|
- **parsingConfig**: Adjust settings for parsing the Markdown during editing
|
||||||
|
(not previewing).
|
||||||
|
- **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers
|
||||||
|
without a space after the `#`. Defaults to `false`.
|
||||||
|
- **strikethrough**: If set to `false`, will not process GFM strikethrough
|
||||||
|
syntax. Defaults to `true`.
|
||||||
|
- **underscoresBreakWords**: If set to `true`, let underscores be a delimiter
|
||||||
|
for separating words. Defaults to `false`.
|
||||||
- **placeholder**: If set, displays a custom placeholder message.
|
- **placeholder**: If set, displays a custom placeholder message.
|
||||||
- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
|
- **previewRender**: Custom function for parsing the plaintext Markdown and
|
||||||
- **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`.
|
returning HTML. Used when user previews.
|
||||||
|
- **promptURLs**: If set to `true`, a JS alert window appears asking for the
|
||||||
|
link or image URL. Defaults to `false`.
|
||||||
- **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
|
||||||
- **link**: The text to use when prompting for a link's URL. Defaults to `URL for the link:`.
|
`URL of the image:`.
|
||||||
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
|
- **link**: The text to use when prompting for a link's URL. Defaults to
|
||||||
- **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">`
|
`URL for the link:`.
|
||||||
- **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`.
|
- **renderingConfig**: Adjust settings for parsing the Markdown during
|
||||||
- **markedOptions**: Set the internal Markdown renderer's [options](https://github.com/chjj/marked#options-1). Other `renderingConfig` options will take precedence.
|
previewing (not editing).
|
||||||
- **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`.
|
- **codeSyntaxHighlighting**: If set to `true`, will highlight using
|
||||||
- **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts).
|
[highlight.js](https://github.com/isagalaev/highlight.js). Defaults to `false`.
|
||||||
- **showIcons**: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar.
|
To use this feature you must include highlight.js on your page or pass in using
|
||||||
- **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`.
|
the `hljs` option. For example, include the script and the CSS files like:
|
||||||
- **status**: If set to `false`, hide the status bar. Defaults to the array of built-in status bar items.
|
<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">`
|
||||||
- Optionally, you can set an array of status bar items to include, and in what order. You can even define your own custom status bar items.
|
- **hljs**: An injectible instance of
|
||||||
- **styleSelectedText**: If set to `false`, remove the `CodeMirror-selectedtext` class from selected lines. Defaults to `true`.
|
[highlight.js](https://github.com/isagalaev/highlight.js). If you don't want to
|
||||||
- **syncSideBySidePreviewScroll**: If set to `false`, disable syncing scroll in side by side mode. Defaults to `true`.
|
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://github.com/chjj/marked#options-1). Other `renderingConfig`
|
||||||
|
options will take precedence.
|
||||||
|
- **singleLineBreaks**: If set to `false`, disable parsing GFM single line
|
||||||
|
breaks. Defaults to `true`.
|
||||||
|
- **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.
|
||||||
|
- **spellChecker**: If set to `false`, disable the spell checker. Defaults to
|
||||||
|
`true`.
|
||||||
|
- **status**: If set to `false`, hide the status bar. Defaults to the array of
|
||||||
|
built-in status bar items.
|
||||||
|
- Optionally, you can set an array of status bar items to include, and in what
|
||||||
|
order. You can even define your own custom status bar items.
|
||||||
|
- **styleSelectedText**: If set to `false`, remove the `CodeMirror-selectedtext`
|
||||||
|
class from selected lines. Defaults to `true`.
|
||||||
|
- **syncSideBySidePreviewScroll**: If set to `false`, disable syncing scroll in
|
||||||
|
side by side mode. Defaults to `true`.
|
||||||
- **tabSize**: If set, customize the tab size. Defaults to `2`.
|
- **tabSize**: If set, customize the tab size. Defaults to `2`.
|
||||||
- **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
|
||||||
- **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`.
|
[array of icons](#toolbar-icons).
|
||||||
|
- **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to
|
||||||
|
`true`.
|
||||||
|
|
||||||
|
|
||||||
|
### Options example
|
||||||
|
|
||||||
|
Most options demonstrate the non-default behavior:
|
||||||
|
|
||||||
```JavaScript
|
```JavaScript
|
||||||
// Most options demonstrate the non-default behavior
|
var easyMDE = new EasyMDE({
|
||||||
var simplemde = new SimpleMDE({
|
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
autosave: {
|
autosave: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
@ -268,11 +304,20 @@ var simplemde = new SimpleMDE({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 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 keybind 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)").
|
### Toolbar icons
|
||||||
|
|
||||||
Additionally, you can add a separator between any icons by adding `"|"` to the toolbar array.
|
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)").
|
||||||
|
|
||||||
|
Additionally, you can add a separator between any icons by adding `"|"` to the
|
||||||
|
toolbar array.
|
||||||
|
|
||||||
Name | Action | Tooltip<br>Class
|
Name | Action | Tooltip<br>Class
|
||||||
:--- | :----- | :--------------
|
:--- | :----- | :--------------
|
||||||
@ -299,19 +344,25 @@ side-by-side | toggleSideBySide | Toggle Side by Side<br>fa fa-columns no-disabl
|
|||||||
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://simplemde.com/markdown-guide) | Markdown Guide<br>fa fa-question-circle
|
guide | [This link](https://simplemde.com/markdown-guide) | Markdown Guide<br>fa fa-question-circle
|
||||||
|
|
||||||
Customize the toolbar using the `toolbar` option like:
|
### Toolbar customization
|
||||||
|
|
||||||
|
You can customize the toolbar using the `toolbar` option.
|
||||||
|
|
||||||
|
Only the order of existing buttons:
|
||||||
|
|
||||||
```JavaScript
|
```JavaScript
|
||||||
// Customize only the order of existing buttons
|
var easyMDE = new EasyMDE({
|
||||||
var simplemde = new SimpleMDE({
|
|
||||||
toolbar: ["bold", "italic", "heading", "|", "quote"],
|
toolbar: ["bold", "italic", "heading", "|", "quote"],
|
||||||
});
|
});
|
||||||
|
```
|
||||||
|
|
||||||
// Customize all information and/or add your own icons
|
Or all information and/or add your own icons:
|
||||||
var simplemde = new SimpleMDE({
|
|
||||||
|
```JavaScript
|
||||||
|
var easyMDE = new EasyMDE({
|
||||||
toolbar: [{
|
toolbar: [{
|
||||||
name: "bold",
|
name: "bold",
|
||||||
action: SimpleMDE.toggleBold,
|
action: EasyMDE.toggleBold,
|
||||||
className: "fa fa-bold",
|
className: "fa fa-bold",
|
||||||
title: "Bold",
|
title: "Bold",
|
||||||
},
|
},
|
||||||
@ -324,14 +375,16 @@ var simplemde = new SimpleMDE({
|
|||||||
title: "Custom Button",
|
title: "Custom Button",
|
||||||
},
|
},
|
||||||
"|", // Separator
|
"|", // Separator
|
||||||
...
|
// ...
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Keyboard shortcuts
|
|
||||||
|
|
||||||
SimpleMDE comes with an array of predefined keyboard shortcuts, but they can be altered with a configuration option. The list of default ones is as follows:
|
### Keyboard shortcuts
|
||||||
|
|
||||||
|
EasyMDE comes with an array of predefined keyboard shortcuts, but they can be
|
||||||
|
altered with a configuration option. The list of default ones is as follows:
|
||||||
|
|
||||||
Shortcut (Windows / Linux) | Shortcut (macOS) | Action
|
Shortcut (Windows / Linux) | Shortcut (macOS) | Action
|
||||||
:--- | :--- | :---
|
:--- | :--- | :---
|
||||||
@ -353,7 +406,7 @@ Shortcut (Windows / Linux) | Shortcut (macOS) | Action
|
|||||||
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
|
```JavaScript
|
||||||
var simplemde = new SimpleMDE({
|
var easyMDE = 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
|
||||||
@ -362,42 +415,95 @@ var simplemde = new SimpleMDE({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Shortcuts are automatically converted between platforms. If you define a shortcut as "Cmd-B", on PC that shortcut will be changed to "Ctrl-B". Conversely, a shortcut defined as "Ctrl-B" will become "Cmd-B" for Mac users.
|
Shortcuts are automatically converted between platforms. If you define a
|
||||||
|
shortcut as "Cmd-B", on PC that shortcut will be changed to "Ctrl-B". Conversely,
|
||||||
|
a shortcut defined as "Ctrl-B" will become "Cmd-B" for Mac users.
|
||||||
|
|
||||||
The list of actions that can be bound is the same as the list of built-in actions available for [toolbar buttons](#toolbar-icons).
|
The list of actions that can be bound is the same as the list of built-in
|
||||||
|
actions available for [toolbar buttons](#toolbar-icons).
|
||||||
|
|
||||||
## Event handling
|
|
||||||
You can catch the following list of events: https://codemirror.net/doc/manual.html#events
|
## Advanced use
|
||||||
|
|
||||||
|
### Event handling
|
||||||
|
|
||||||
|
You can catch the following list of events:
|
||||||
|
https://codemirror.net/doc/manual.html#events
|
||||||
|
|
||||||
```JavaScript
|
```JavaScript
|
||||||
var simplemde = new SimpleMDE();
|
var easyMDE = new EasyMDE();
|
||||||
simplemde.codemirror.on("change", function(){
|
easyMDE.codemirror.on("change", function(){
|
||||||
console.log(simplemde.value());
|
console.log(easyMDE.value());
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## Removing SimpleMDE from textarea
|
### Removing EasyMDE from text area
|
||||||
You can revert to the initial textarea by calling the `toTextArea` method. Note that this clears up the autosave (if enabled) associated with it. The textarea will retain any text from the destroyed SimpleMDE instance.
|
|
||||||
|
You can revert to the initial text area by calling the `toTextArea` method. Note
|
||||||
|
that this clears up the auto-save (if enabled) associated with it. The text area
|
||||||
|
will retain any text from the destroyed EasyMDE instance.
|
||||||
|
|
||||||
```JavaScript
|
```JavaScript
|
||||||
var simplemde = new SimpleMDE();
|
var easyMDE = new EasyMDE();
|
||||||
...
|
// ...
|
||||||
simplemde.toTextArea();
|
easyMDE.toTextArea();
|
||||||
simplemde = null;
|
easyMDE = null;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Useful methods
|
|
||||||
The following self-explanatory methods may be of use while developing with SimpleMDE.
|
### Useful methods
|
||||||
|
|
||||||
|
The following self-explanatory methods may be of use while developing with
|
||||||
|
EasyMDE.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var simplemde = new SimpleMDE();
|
var easyMDE = new EasyMDE();
|
||||||
simplemde.isPreviewActive(); // returns boolean
|
easyMDE.isPreviewActive(); // returns boolean
|
||||||
simplemde.isSideBySideActive(); // returns boolean
|
easyMDE.isSideBySideActive(); // returns boolean
|
||||||
simplemde.isFullscreenActive(); // returns boolean
|
easyMDE.isFullscreenActive(); // returns boolean
|
||||||
simplemde.clearAutosavedValue(); // no returned value
|
easyMDE.clearAutosavedValue(); // no returned value
|
||||||
```
|
```
|
||||||
|
|
||||||
## How it works
|
|
||||||
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.
|
## How it works
|
||||||
|
|
||||||
|
EasyMDE 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.
|
||||||
|
|
||||||
|
|
||||||
|
## EasyMDE fork
|
||||||
|
|
||||||
|
I originally made this fork to implement FontAwesome 5 compatibility into
|
||||||
|
EasyMDE. When that was done I submitted a
|
||||||
|
[pull request](https://github.com/sparksuite/simplemde-markdown-editor/pull/666),
|
||||||
|
which has not been accepted yet. This, and the project being inactive since May
|
||||||
|
2017, triggered me to make more changes and try to put new life into the project.
|
||||||
|
|
||||||
|
Changes include:
|
||||||
|
* FontAwesome 5 compatibility;
|
||||||
|
* guide button works when editor is in preview mode;
|
||||||
|
* links are now `https://` by default;
|
||||||
|
* small styling changes;
|
||||||
|
* support for Node 8 and beyond;
|
||||||
|
* lots of refactored code;
|
||||||
|
* links in preview will open in a new tab by default;
|
||||||
|
* Typescript support.
|
||||||
|
|
||||||
|
My intention is to continue development on this project, improving it and
|
||||||
|
keeping it alive.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is released under the [MIT License](./LICENSE).
|
||||||
|
|
||||||
|
- Copyright (c) 2015 Sparksuite, Inc.
|
||||||
|
- Copyright (c) 2017 Jeroen Akkerman.
|
||||||
|
BIN
doc/screenshot.png
Normal file
BIN
doc/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
Loading…
x
Reference in New Issue
Block a user