mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2024-06-02 14:02:22 +02:00
Compare commits
457 commits
Author | SHA1 | Date | |
---|---|---|---|
6abda7ab68 | |||
1471a4e662 | |||
0d9f7d9012 | |||
2c35e6782f | |||
cb10536dd4 | |||
00e0f69d93 | |||
98bc1e52a1 | |||
47b2667e86 | |||
316b8a58f8 | |||
6676411766 | |||
3653d4f81d | |||
7dc2a8f7fe | |||
021e705242 | |||
e74572ac4a | |||
487ff36385 | |||
d963582f16 | |||
69bff3ed78 | |||
b4d4e89129 | |||
c949cad2d8 | |||
c8f23a3aa9 | |||
dbb1c25843 | |||
a30d8f6183 | |||
51ef0cd81d | |||
97154e2bfc | |||
bd33cd3c2b | |||
7187fb26fb | |||
f21cca3068 | |||
b6b1f7c1ef | |||
0ce450a7a7 | |||
d9d0cd50d5 | |||
7b1e8deeaa | |||
e72e51c94f | |||
4ec9ab8be0 | |||
6ed8344248 | |||
2f4e7e4d9b | |||
318b4c175f | |||
fe1318dd39 | |||
4a8ce0bd12 | |||
490e57ded1 | |||
9eb0411d82 | |||
be3fbf15b5 | |||
6eae597a69 | |||
507e8ce67d | |||
24ec612c44 | |||
747b3ef065 | |||
26391efa26 | |||
d77d4b318b | |||
1def5aabc2 | |||
711af1b472 | |||
75b6c82940 | |||
1a79eefadb | |||
6bda28300d | |||
435b39f96d | |||
787ed40fe6 | |||
ecff05833b | |||
20f5b54a46 | |||
0fb087ca38 | |||
71d979ad61 | |||
56705bfd20 | |||
8618543fab | |||
5a53199586 | |||
eb568ddbde | |||
047c0ef2c7 | |||
0166b2b367 | |||
2c09c829ee | |||
5e204ae66e | |||
bce5372947 | |||
26519235c6 | |||
99e4cba72e | |||
fd8e6a7825 | |||
b6bee016c2 | |||
da5e309ffe | |||
d1445222aa | |||
6318fc1b19 | |||
4b75a4e38e | |||
cc4cd7acdd | |||
1e51e98649 | |||
3da94ef677 | |||
6b6bb408cf | |||
a318e44ffe | |||
dba58abd59 | |||
f1865e5536 | |||
120d7e5c85 | |||
7904c44036 | |||
7bc2cb3c41 | |||
91a27e314a | |||
62caea601e | |||
7aedb8623a | |||
0d9078c98d | |||
131e5d8beb | |||
b61c64d63c | |||
eccfbe5f20 | |||
664c081876 | |||
144d724a41 | |||
8469cbc839 | |||
16042564a1 | |||
2bac0bbcec | |||
b092fe5ee0 | |||
aa2ebfe983 | |||
2f24d571b0 | |||
68be24121f | |||
0ce602f68d | |||
9fb97e0d5e | |||
e27a0933a3 | |||
e96fddffcb | |||
4fe8ad6cdf | |||
e89b0e4049 | |||
6c61b1a4aa | |||
b9f77e0bea | |||
6e659cf0ab | |||
3178aab2cb | |||
95cfe5a353 | |||
c92f4e3bd3 | |||
f891cfb787 | |||
5f3a67dae2 | |||
7a2e75eb48 | |||
3f54710784 | |||
5706319644 | |||
4eec6e6e3a | |||
d30d9b7d00 | |||
36f97604f4 | |||
4dbe95fe80 | |||
17dad384bc | |||
396de5f46c | |||
4b308e0c89 | |||
b21808ed12 | |||
cac5699594 | |||
c2cf41fc16 | |||
169752eb9d | |||
170cbd0b2f | |||
b4ee8a06e4 | |||
e7c45cfeec | |||
8a1d8fd285 | |||
19463486ef | |||
54fa76d798 | |||
abedc7371d | |||
c7c940c614 | |||
42c4a0bbef | |||
d850ff7f0c | |||
a31e978659 | |||
342e853c19 | |||
e8bdc03120 | |||
dac02f2698 | |||
9d0b313320 | |||
a64f07e1c3 | |||
a70b4978cb | |||
52ed959be9 | |||
7d5bd5f27e | |||
eb7f5cac53 | |||
90733ec404 | |||
e05962d91c | |||
69e65ac0d1 | |||
06454332ba | |||
becd1317ff | |||
6d44a0aa14 | |||
e295645d93 | |||
9aa32df7e1 | |||
0cd00edb93 | |||
e42b85304d | |||
adda6665c1 | |||
a98665a0a7 | |||
08fc75b909 | |||
2c77d032e6 | |||
804427835b | |||
a9c100fe6c | |||
4e1d01bcb7 | |||
dbf8f15e34 | |||
2d9e8956a1 | |||
dab0b6be7b | |||
b98ad3fbf6 | |||
73e5e5fb4e | |||
c1c8de5115 | |||
fdcd613199 | |||
b1505af98a | |||
7c908ca39c | |||
16434578f0 | |||
cc7f1b456a | |||
788f371253 | |||
118a61b0d7 | |||
361c097643 | |||
5e0aeee60d | |||
cef2623e2a | |||
9157e862f9 | |||
8bf55b1b34 | |||
e20b64c97a | |||
0e6e466346 | |||
3baa1d1ac8 | |||
16d5a4d894 | |||
e1b70d737e | |||
cfb2f6c046 | |||
063e6f99b1 | |||
de87b0ccd3 | |||
d3a2625bb2 | |||
b59279a3d8 | |||
05f1d47210 | |||
e79b5f14ed | |||
1e3ddd01af | |||
0ec4eafeff | |||
653dde0d5d | |||
0554746fd2 | |||
03b5ed2551 | |||
55f3c243c8 | |||
efc38f43da | |||
6215739a60 | |||
b677adaeb9 | |||
773edca5fa | |||
5662766c1f | |||
4333d2e5eb | |||
7e2508269c | |||
111c5f7858 | |||
7bc9d9b0ff | |||
5b0dd8e50b | |||
dc78ab2c6a | |||
dc5126b4fe | |||
8e53037df9 | |||
6fcc1e6406 | |||
b9e66d326c | |||
bad108966d | |||
cd60814099 | |||
09c9126741 | |||
01306ad105 | |||
effd98d463 | |||
df1e551c0f | |||
d9e66391d0 | |||
30c2844f37 | |||
416d807a92 | |||
be1697e170 | |||
cee66d4873 | |||
1560d4b7d7 | |||
c5e3905ae9 | |||
b5eb5ee318 | |||
ec8bba319d | |||
c55b5c6ecb | |||
f32e103944 | |||
8d07c5e7f4 | |||
443a58cc28 | |||
a52a9a0098 | |||
5466648503 | |||
42068c97f9 | |||
b0193b4110 | |||
d13b3d51cd | |||
a93f7a2570 | |||
0b48f1dc01 | |||
e18beb56f7 | |||
bfda8350ae | |||
c6e3a4bf55 | |||
54f80c1f0f | |||
589386dc8a | |||
57fcf521a0 | |||
cd17552bf6 | |||
263827a690 | |||
f96ca0ecfa | |||
90d7bcce7e | |||
3dcb71e880 | |||
1762dea647 | |||
e6ab126431 | |||
2f6af67480 | |||
53910de1f9 | |||
32cab53986 | |||
ab83c5a5f6 | |||
23359590df | |||
1c369a3cc9 | |||
5ff5766ea6 | |||
7f4491edee | |||
f77dbc6aab | |||
c9db36af67 | |||
2fd52aa629 | |||
646002bff7 | |||
98aa67881d | |||
f14c5f446f | |||
08c9d89662 | |||
4213ec606a | |||
b4dc058bc0 | |||
83718f7f99 | |||
de01fb33bc | |||
06134ae5ef | |||
cb13106671 | |||
7223c32ce8 | |||
6c5a0dbc67 | |||
8dd6262274 | |||
2737ab0808 | |||
d4e5b77a8f | |||
eec0f55969 | |||
03aa254d99 | |||
e291f79bd2 | |||
fe1f2a8d4f | |||
f0f496ae92 | |||
4240da87c0 | |||
6389777c30 | |||
fbf4af9c73 | |||
8ed562431a | |||
35afb015a3 | |||
e9d4205731 | |||
8c32586d73 | |||
d74bf5def3 | |||
eb1a43e91c | |||
c07cd0c5f2 | |||
eba5e8a77d | |||
afa0101e68 | |||
8218391cfd | |||
b43b99e50d | |||
1ccc5b434f | |||
f6a8909c8f | |||
866488b0a9 | |||
41c551c115 | |||
db6d381d1c | |||
8311c8431b | |||
cbeb630a97 | |||
405b99ae92 | |||
2a32e619a4 | |||
2b33f91495 | |||
06867c9ea9 | |||
25bbed7ae8 | |||
74d7519e87 | |||
20cdb4e3fe | |||
d4424f1b1a | |||
1d69c335c4 | |||
f0679a4154 | |||
8923a35891 | |||
28d97ab644 | |||
f9ba981b35 | |||
5814696678 | |||
1ce94de95a | |||
0d730ead05 | |||
daf2c453f6 | |||
6cf9161034 | |||
4a6d21ea1d | |||
d60d0cd80d | |||
ff48a879ea | |||
ebabe1c48b | |||
10ee1e70b5 | |||
438b3ef531 | |||
8754f008fd | |||
ee471abde9 | |||
50bb35d057 | |||
02ef20ba23 | |||
0f9dd5ee56 | |||
e96376c9b1 | |||
28bbe67223 | |||
343b4a8027 | |||
c1967269b6 | |||
927879853f | |||
60705ad0cc | |||
10bbf55c6e | |||
00fa95823e | |||
214045165c | |||
e84f985e3d | |||
f2504d2dfc | |||
dbeef5d711 | |||
b334fc3804 | |||
7ba6bf8dbe | |||
3550aef98d | |||
de7f1a8d11 | |||
2a2a63aac2 | |||
e04e75a1fa | |||
2cffd6cae5 | |||
d02aa31c23 | |||
8e877a70d8 | |||
154723e058 | |||
138d1a80e3 | |||
709a51af19 | |||
586f49d64a | |||
613cdcaf0b | |||
b55fef85ae | |||
14b1bd023c | |||
2f6335e640 | |||
91095a93d5 | |||
4d6194b09c | |||
8a892d4b78 | |||
022ccfd315 | |||
1d263cabb9 | |||
d8ad2959a8 | |||
67b1ac7ca8 | |||
dd85947668 | |||
9af8929945 | |||
fc6fd13025 | |||
1aad2dec4c | |||
c75bf94de8 | |||
0eb0a94ba0 | |||
72a2b011d6 | |||
9d4c6a63e4 | |||
7db42a36c2 | |||
c7dd040ed3 | |||
383c7fdb9e | |||
c8b908fd0e | |||
bb24da9480 | |||
1227bb6abd | |||
5e68508600 | |||
b1e045f5b1 | |||
d3531410ad | |||
dbf3b5a3d4 | |||
c9eb0a479d | |||
72fdf40d3d | |||
619d5dad4c | |||
2a2aa7c36d | |||
d61280d03d | |||
ebf32d01fa | |||
5ba95f1ba6 | |||
148721ee1f | |||
94d02639f9 | |||
fcea866fb4 | |||
474b576521 | |||
888165a9fe | |||
148a3efadf | |||
54a47f3dbc | |||
fa7ef0310e | |||
096f6e9a6d | |||
d05106a0ed | |||
6c3baad29b | |||
5c4ca1f01a | |||
20d66d9a23 | |||
8f1c54b7dd | |||
c089fc5753 | |||
bbcff529ec | |||
1c1f3fdecd | |||
8b3512cd02 | |||
4a2a06c642 | |||
7223c23cdc | |||
2090a9e553 | |||
1229ea0224 | |||
f69c39f5ad | |||
a772676b78 | |||
e072698b78 | |||
47132fc20a | |||
03da7bb02c | |||
ae624852e0 | |||
c347811e29 | |||
83722ff7b2 | |||
f0a2255870 | |||
b02d5dc612 | |||
121726ff01 | |||
6969064b7c | |||
cac8f44891 | |||
91c9b9cb22 | |||
21f3424822 | |||
6c91d90763 | |||
3535ee7cd7 | |||
6e17a82530 | |||
bcf70a53df | |||
aeb86dd418 | |||
d11ecf7eb0 | |||
7eb1bdc0cb | |||
8c9cb5c90d | |||
fd3983ff29 | |||
c45ada1c6b | |||
4ae1aa3874 | |||
9999fd93c1 | |||
958e3c08c7 | |||
d1da791320 | |||
d3f528accb | |||
54de199813 | |||
c190cf0946 | |||
2634910dfd | |||
31e71766de | |||
78e8c0b2cd | |||
c3b3300bcb | |||
da448e733e |
23
.eslintrc
Normal file
23
.eslintrc
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"rules": {
|
||||
"indent": [
|
||||
2,
|
||||
"tab"
|
||||
],
|
||||
"strict": 0,
|
||||
"no-console": 0,
|
||||
"quotes": [
|
||||
2,
|
||||
"double"
|
||||
],
|
||||
"semi": [
|
||||
2,
|
||||
"always"
|
||||
]
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node":true
|
||||
},
|
||||
"extends": "eslint:recommended"
|
||||
}
|
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
localtesting/
|
||||
node_modules/
|
||||
bower_components/
|
||||
|
||||
#For IDE
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
18
.travis.yml
Normal file
18
.travis.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- '6'
|
||||
- '5'
|
||||
- '4'
|
||||
- '0.12'
|
||||
before_script:
|
||||
- npm install -g gulp
|
||||
script: gulp
|
||||
deploy:
|
||||
provider: npm
|
||||
email: support@nextstepwebs.com
|
||||
api_key:
|
||||
secure: nADZupyOhJAhTQgr5uOIydbDEjCTAj+3nGHW7ZBJUrVJcb0uR4pg8ngmwrUpvaCeNXgKPG9Uag75/mPcBre9ly2cigBIG9LHlxImlF8qi1jRJykcNRmBb9N2MJJj+zdAMwLaF5Ns+f2v3zt97qxovbEzunhXGcZeCaxc6y40nDM8OTyo0PESNBjQYqaNblt2gO2KHysrwFL8i4kCCKLa+HOBLu2iqgk/fYVqTmfhEeOiiwQ4lIXJeyPyzgb3OPhKCMV1FI5H0T48fRD0MPczt8ds3Daj1OjCbIZurQ7s1dcKwz1g6TKATN59HcMsSarW4lImrEeYmfQxz2F5NjKDRhnith5V0W2IssrkpDG9teTFQ20eQdl5cpnlGjgBvsjb8GhPLR44GvefyJL4+kJGI3O1KVq3/7wbmu/IXrvhtKHEQSdGL2PTqW8QxKasAoUCnk3LGZKN12g8bg0xDg2tvoCUk5Z3asHLRdCJpDbBq1h8QfZ4HV5VLYjr84xduOUZbEUtfMVAixPpJ4h1E3OXJ1wil97BlHjxOZ8JkkxJg5lgSUZ/O/QWwJokEAYXR9c+ouMoVokChAyleV77cRZ5qLn9zbnUxZtnKX8w0IUKeu95/z8QgiaRcERKVCpZvceo8Qw0Y+JoiEtno7Zg/nsrZGxsS6K/V3yg1QQmT3bjDHQ=
|
||||
on:
|
||||
tags: true
|
||||
repo: NextStepWebs/simplemde-markdown-editor
|
||||
branch: production
|
10
CONTRIBUTING.md
Normal file
10
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
### Overview
|
||||
First of all, thanks for your interest in helping make SimpleMDE even better. Contributions help resolve rare bugs, accomplish neat new features, polish the code, and improve the documentation.
|
||||
|
||||
### Guidelines for contributing
|
||||
- The *most important* guideline for contributing is to compare against the `development` branch when creating a pull request. This allows time to test and modify code changes before merging them into the stable master branch with the next release.
|
||||
- Travis CI is configured to build and verify all PRs. If your PR causes the build to fail, please add an additional commit that resolves any problems.
|
||||
- If you really want to earn some brownie points, create a JSFiddle that demonstrates your code changes. Seriously, this helps immensely and allows one or multiple people to easily provide feedback on the great work you've done.
|
||||
- When creating the JSFiddle, keep in mind that you can use http://rawgit.com for your files.
|
||||
- Do your best to fully test your changes. Anticipate edge-case behavior.
|
||||
- Try to keep your codebase that you're making changes to as up-to-date as possible with the origin. SimpleMDE creates new releases frequently, so it's easy to fall behind if you've been working on something new for a while.
|
343
README.md
343
README.md
|
@ -1,76 +1,331 @@
|
|||
# SimpleMDE - Markdown Editor
|
||||
A drop-in JavaScript textarea replacement for writing beautiful and understandable markdown. The WYSIWYG-esque editor allows users to modify the markdown with toolbar buttons and shortcuts. WYSIWYG editors that produce HTML are often complex and buggy. Markdown solves this problem in many ways, but is less visually clear while editing. SimpleMDE has been designed to bridge this gap for non-technical users who are less familiar with or just learning Markdown syntax.
|
||||
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](http://nextstepwebs.github.io/simplemde-markdown-editor)
|
||||
[**Demo**](https://simplemde.com)
|
||||
|
||||
[![Preview](http://i.imgur.com/b9hFHFT.png)](http://nextstepwebs.github.io/simplemde-markdown-editor)
|
||||
[![Preview](http://i.imgur.com/zqWfJwO.png)](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 [bower](https://www.bower.io).
|
||||
```
|
||||
bower install simplemde --save
|
||||
```
|
||||
|
||||
Via [jsDelivr](https://www.jsdelivr.com/#!simplemde). *Please note, jsDelivr may take a few days to update to the latest release.*
|
||||
|
||||
```HTML
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
|
||||
```
|
||||
|
||||
## Quick start
|
||||
Available on [jsDelivr](http://www.jsdelivr.com/about.php)
|
||||
|
||||
```
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/simplemde/1.1.3/simplemde.min.css">
|
||||
<script src="//cdn.jsdelivr.net/simplemde/1.1.3/simplemde.min.js"></script>
|
||||
```
|
||||
After installing, load SimpleMDE on the first textarea on a page
|
||||
|
||||
And then load SimpleMDE on the first textarea on a page
|
||||
|
||||
```
|
||||
```HTML
|
||||
<script>
|
||||
var simplemde = new SimpleMDE();
|
||||
simplemde.render();
|
||||
</script>
|
||||
```
|
||||
|
||||
#### Use a specific textarea
|
||||
#### Using a specific textarea
|
||||
|
||||
Pure JavaScript method
|
||||
|
||||
```
|
||||
var simplemde = new SimpleMDE(document.getElementById("MyID"));
|
||||
simplemde.render();
|
||||
```HTML
|
||||
<script>
|
||||
var simplemde = new SimpleMDE({ element: document.getElementById("MyID") });
|
||||
</script>
|
||||
```
|
||||
|
||||
jQuery method
|
||||
|
||||
```
|
||||
var simplemde = new SimpleMDE($("#MyID")[0]);
|
||||
simplemde.render();
|
||||
```HTML
|
||||
<script>
|
||||
var simplemde = new SimpleMDE({ element: $("#MyID")[0] });
|
||||
</script>
|
||||
```
|
||||
|
||||
## Get the content
|
||||
## Get/set the content
|
||||
|
||||
```JavaScript
|
||||
simplemde.value();
|
||||
```
|
||||
simplemde.codemirror.getValue();
|
||||
|
||||
```JavaScript
|
||||
simplemde.value("This text will appear in the editor");
|
||||
```
|
||||
|
||||
## 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.
|
||||
- **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.*
|
||||
- **enabled**: If set to `true`, autosave the text. Defaults to `false`.
|
||||
- **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.
|
||||
- **blockStyles**: Customize how certain buttons that style blocks of text behave.
|
||||
- **bold** Can be set to `**` or `__`. Defaults to `**`.
|
||||
- **code** 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.
|
||||
- **status**: If set false, hide the status bar. Defaults to true.
|
||||
- **tools**: If set false, hide the toolbar. Defaults to true.
|
||||
- **forceSync**: If set to `true`, force text changes made in SimpleMDE to be immediately stored in original textarea. 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.
|
||||
- **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
|
||||
- image
|
||||
- link
|
||||
- table
|
||||
- **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`.
|
||||
- **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**: Custom placeholder that should be displayed
|
||||
- **previewRender**: Custom function for parsing the plaintext Markdown and 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`.
|
||||
- **renderingConfig**: Adjust settings for parsing the Markdown during 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 [highlight.js](https://github.com/isagalaev/highlight.js). Defaults to `false`. To use this feature you must include highlight.js on your page. 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">`
|
||||
- **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`.
|
||||
- **tabSize**: If set, customize the tab size. Defaults to `2`.
|
||||
- **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`.
|
||||
|
||||
```
|
||||
new SimpleMDE({
|
||||
element: document.getElementById("MyID"),
|
||||
status: false,
|
||||
tools: false,
|
||||
```JavaScript
|
||||
// Most options demonstrate the non-default behavior
|
||||
var simplemde = new SimpleMDE({
|
||||
autofocus: true,
|
||||
autosave: {
|
||||
enabled: true,
|
||||
uniqueId: "MyUniqueID",
|
||||
delay: 1000,
|
||||
},
|
||||
blockStyles: {
|
||||
bold: "__",
|
||||
italic: "_"
|
||||
},
|
||||
element: document.getElementById("MyID"),
|
||||
forceSync: true,
|
||||
hideIcons: ["guide", "heading"],
|
||||
indentWithTabs: false,
|
||||
initialValue: "Hello world!",
|
||||
insertTexts: {
|
||||
horizontalRule: ["", "\n\n-----\n\n"],
|
||||
image: ["![](http://", ")"],
|
||||
link: ["[", "](http://)"],
|
||||
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
|
||||
},
|
||||
lineWrapping: false,
|
||||
parsingConfig: {
|
||||
allowAtxHeaderWithoutSpace: true,
|
||||
strikethrough: false,
|
||||
underscoresBreakWords: true,
|
||||
},
|
||||
placeholder: "Type here...",
|
||||
previewRender: function(plainText) {
|
||||
return customMarkdownParser(plainText); // Returns HTML from a custom parser
|
||||
},
|
||||
previewRender: function(plainText, preview) { // Async method
|
||||
setTimeout(function(){
|
||||
preview.innerHTML = customMarkdownParser(plainText);
|
||||
}, 250);
|
||||
|
||||
return "Loading...";
|
||||
},
|
||||
promptURLs: true,
|
||||
renderingConfig: {
|
||||
singleLineBreaks: false,
|
||||
codeSyntaxHighlighting: true,
|
||||
},
|
||||
shortcuts: {
|
||||
drawTable: "Cmd-Alt-T"
|
||||
},
|
||||
showIcons: ["code", "table"],
|
||||
spellChecker: false,
|
||||
status: false,
|
||||
status: ["autosave", "lines", "words", "cursor"], // Optional usage
|
||||
status: ["autosave", "lines", "words", "cursor", {
|
||||
className: "keystrokes",
|
||||
defaultValue: function(el) {
|
||||
this.keystrokes = 0;
|
||||
el.innerHTML = "0 Keystrokes";
|
||||
},
|
||||
onUpdate: function(el) {
|
||||
el.innerHTML = ++this.keystrokes + " Keystrokes";
|
||||
}
|
||||
}], // Another optional usage, with a custom status bar item that counts keystrokes
|
||||
styleSelectedText: false,
|
||||
tabSize: 4,
|
||||
toolbar: false,
|
||||
toolbarTips: false,
|
||||
});
|
||||
```
|
||||
|
||||
#### 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)").
|
||||
|
||||
Additionally, you can add a separator between any icons by adding `"|"` to the toolbar array.
|
||||
|
||||
Name | Action | Tooltip<br>Class
|
||||
:--- | :----- | :--------------
|
||||
bold | toggleBold | Bold<br>fa fa-bold
|
||||
italic | toggleItalic | Italic<br>fa fa-italic
|
||||
strikethrough | toggleStrikethrough | Strikethrough<br>fa fa-strikethrough
|
||||
heading | toggleHeadingSmaller | Heading<br>fa fa-header
|
||||
heading-smaller | toggleHeadingSmaller | Smaller Heading<br>fa fa-header
|
||||
heading-bigger | toggleHeadingBigger | Bigger Heading<br>fa fa-lg fa-header
|
||||
heading-1 | toggleHeading1 | Big Heading<br>fa fa-header fa-header-x fa-header-1
|
||||
heading-2 | toggleHeading2 | Medium Heading<br>fa fa-header fa-header-x fa-header-2
|
||||
heading-3 | toggleHeading3 | Small Heading<br>fa fa-header fa-header-x fa-header-3
|
||||
code | toggleCodeBlock | Code<br>fa fa-code
|
||||
quote | toggleBlockquote | Quote<br>fa fa-quote-left
|
||||
unordered-list | toggleUnorderedList | Generic List<br>fa fa-list-ul
|
||||
ordered-list | toggleOrderedList | Numbered List<br>fa fa-list-ol
|
||||
clean-block | cleanBlock | Clean block<br>fa fa-eraser fa-clean-block
|
||||
link | drawLink | Create Link<br>fa fa-link
|
||||
image | drawImage | Insert Image<br>fa fa-picture-o
|
||||
table | drawTable | Insert Table<br>fa fa-table
|
||||
horizontal-rule | drawHorizontalRule | Insert Horizontal Line<br>fa fa-minus
|
||||
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
|
||||
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
|
||||
|
||||
Customize the toolbar using the `toolbar` option like:
|
||||
|
||||
```JavaScript
|
||||
// Customize only the order of existing buttons
|
||||
var simplemde = new SimpleMDE({
|
||||
toolbar: ["bold", "italic", "heading", "|", "quote"],
|
||||
});
|
||||
|
||||
// Customize all information and/or add your own icons
|
||||
var simplemde = new SimpleMDE({
|
||||
toolbar: [{
|
||||
name: "bold",
|
||||
action: SimpleMDE.toggleBold,
|
||||
className: "fa fa-bold",
|
||||
title: "Bold",
|
||||
},
|
||||
{
|
||||
name: "custom",
|
||||
action: function customFunction(editor){
|
||||
// Add your own code
|
||||
},
|
||||
className: "fa fa-star",
|
||||
title: "Custom Button",
|
||||
},
|
||||
"|", // 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:
|
||||
|
||||
Shortcut | Action
|
||||
:------- | :-----
|
||||
*Cmd-'* | "toggleBlockquote"
|
||||
*Cmd-B* | "toggleBold"
|
||||
*Cmd-E* | "cleanBlock"
|
||||
*Cmd-H* | "toggleHeadingSmaller"
|
||||
*Cmd-I* | "toggleItalic"
|
||||
*Cmd-K* | "drawLink"
|
||||
*Cmd-L* | "toggleUnorderedList"
|
||||
*Cmd-P* | "togglePreview"
|
||||
*Cmd-Alt-C* | "toggleCodeBlock"
|
||||
*Cmd-Alt-I* | "drawImage"
|
||||
*Cmd-Alt-L* | "toggleOrderedList"
|
||||
*Shift-Cmd-H* | "toggleHeadingBigger"
|
||||
*F9* | "toggleSideBySide"
|
||||
*F11* | "toggleFullScreen"
|
||||
|
||||
Here is how you can change a few, while leaving others untouched:
|
||||
|
||||
```JavaScript
|
||||
var simplemde = new SimpleMDE({
|
||||
shortcuts: {
|
||||
"toggleOrderedList": "Ctrl-Alt-K", // alter the shortcut for toggleOrderedList
|
||||
"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
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
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).
|
||||
|
||||
#### Height
|
||||
|
||||
To change the minimum height (before it starts auto-growing):
|
||||
|
||||
```CSS
|
||||
.CodeMirror, .CodeMirror-scroll {
|
||||
min-height: 200px;
|
||||
}
|
||||
```
|
||||
|
||||
Or, you can keep the height static:
|
||||
|
||||
```CSS
|
||||
.CodeMirror {
|
||||
height: 300px;
|
||||
}
|
||||
```
|
||||
|
||||
## Event handling
|
||||
You can catch the following list of events: https://codemirror.net/doc/manual.html#events
|
||||
|
||||
```JavaScript
|
||||
var simplemde = new SimpleMDE();
|
||||
simplemde.codemirror.on("change", function(){
|
||||
console.log(simplemde.value());
|
||||
});
|
||||
```
|
||||
|
||||
## Removing SimpleMDE from textarea
|
||||
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.
|
||||
|
||||
```JavaScript
|
||||
var simplemde = new SimpleMDE();
|
||||
...
|
||||
simplemde.toTextArea();
|
||||
simplemde = null;
|
||||
```
|
||||
|
||||
## Useful methods
|
||||
The following self-explanatory methods may be of use while developing with SimpleMDE.
|
||||
|
||||
```js
|
||||
var simplemde = new SimpleMDE();
|
||||
simplemde.isPreviewActive(); // returns boolean
|
||||
simplemde.isSideBySideActive(); // returns boolean
|
||||
simplemde.isFullscreenActive(); // returns boolean
|
||||
simplemde.clearAutosavedValue(); // no returned value
|
||||
```
|
||||
|
||||
## How it works
|
||||
SimpleMDE is an improvement of [lepture's Editor project](https://github.com/lepture/editor) and includes a great many number of changes. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and [Font Awesome](http://fortawesome.github.io/Font-Awesome/).
|
||||
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 has been added to the top and bottom, respectively. Previews are rendered by [Marked](https://github.com/chjj/marked).
|
||||
|
||||
## What's changed?
|
||||
As mentioned earlier, SimpleMDE is an improvement of [lepture's Editor project](https://github.com/lepture/editor). So you might be wondering, what's changed? Quite a bit actually. Here's some notable changes:
|
||||
|
||||
- Upgraded from CodeMirror 3 to CodeMirror 5
|
||||
- Many changes to the style, appearance, and userfriendliness
|
||||
- Interface more closely resembles Bootstrap
|
||||
- Now mobile friendly
|
||||
- The text editor now automatically grows as you type more
|
||||
- Fixed a large amount of bugs
|
||||
- Switched to Font Awesome icons
|
||||
- Improved preview rendering in many ways
|
||||
- Improved as-you-type appearance of headers and code blocks
|
||||
- Simplified the toolbar
|
||||
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.
|
||||
|
|
23
bower.json
Normal file
23
bower.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "simplemde",
|
||||
"version": "1.11.2",
|
||||
"homepage": "https://github.com/NextStepWebs/simplemde-markdown-editor",
|
||||
"authors": [
|
||||
"Wes Cossick <https://wescossick.com>"
|
||||
],
|
||||
"description": "A simple, beautiful, and embeddable JavaScript Markdown editor.",
|
||||
"main": ["src/js/simplemde.js", "src/css/simplemde.css"],
|
||||
"keywords": [
|
||||
"embeddable",
|
||||
"markdown",
|
||||
"editor",
|
||||
"javascript",
|
||||
"wysiwyg"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components"
|
||||
]
|
||||
}
|
676
debug/simplemde.css
Normal file
676
debug/simplemde.css
Normal file
|
@ -0,0 +1,676 @@
|
|||
/**
|
||||
* simplemde v1.11.2
|
||||
* Copyright Next Step Webs, Inc.
|
||||
* @link https://github.com/NextStepWebs/simplemde-markdown-editor
|
||||
* @license MIT
|
||||
*/
|
||||
/* BASICS */
|
||||
|
||||
.CodeMirror {
|
||||
/* Set height, width, borders, and global font properties here */
|
||||
font-family: monospace;
|
||||
height: 300px;
|
||||
color: black;
|
||||
}
|
||||
|
||||
/* PADDING */
|
||||
|
||||
.CodeMirror-lines {
|
||||
padding: 4px 0; /* Vertical padding around content */
|
||||
}
|
||||
.CodeMirror pre {
|
||||
padding: 0 4px; /* Horizontal padding of content */
|
||||
}
|
||||
|
||||
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||
background-color: white; /* The little square between H and V scrollbars */
|
||||
}
|
||||
|
||||
/* GUTTER */
|
||||
|
||||
.CodeMirror-gutters {
|
||||
border-right: 1px solid #ddd;
|
||||
background-color: #f7f7f7;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.CodeMirror-linenumbers {}
|
||||
.CodeMirror-linenumber {
|
||||
padding: 0 3px 0 5px;
|
||||
min-width: 20px;
|
||||
text-align: right;
|
||||
color: #999;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.CodeMirror-guttermarker { color: black; }
|
||||
.CodeMirror-guttermarker-subtle { color: #999; }
|
||||
|
||||
/* CURSOR */
|
||||
|
||||
.CodeMirror-cursor {
|
||||
border-left: 1px solid black;
|
||||
border-right: none;
|
||||
width: 0;
|
||||
}
|
||||
/* Shown when moving in bi-directional text */
|
||||
.CodeMirror div.CodeMirror-secondarycursor {
|
||||
border-left: 1px solid silver;
|
||||
}
|
||||
.cm-fat-cursor .CodeMirror-cursor {
|
||||
width: auto;
|
||||
border: 0 !important;
|
||||
background: #7e7;
|
||||
}
|
||||
.cm-fat-cursor div.CodeMirror-cursors {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.cm-animate-fat-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
-webkit-animation: blink 1.06s steps(1) infinite;
|
||||
-moz-animation: blink 1.06s steps(1) infinite;
|
||||
animation: blink 1.06s steps(1) infinite;
|
||||
background-color: #7e7;
|
||||
}
|
||||
@-moz-keyframes blink {
|
||||
0% {}
|
||||
50% { background-color: transparent; }
|
||||
100% {}
|
||||
}
|
||||
@-webkit-keyframes blink {
|
||||
0% {}
|
||||
50% { background-color: transparent; }
|
||||
100% {}
|
||||
}
|
||||
@keyframes blink {
|
||||
0% {}
|
||||
50% { background-color: transparent; }
|
||||
100% {}
|
||||
}
|
||||
|
||||
/* Can style cursor different in overwrite (non-insert) mode */
|
||||
.CodeMirror-overwrite .CodeMirror-cursor {}
|
||||
|
||||
.cm-tab { display: inline-block; text-decoration: inherit; }
|
||||
|
||||
.CodeMirror-ruler {
|
||||
border-left: 1px solid #ccc;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
/* DEFAULT THEME */
|
||||
|
||||
.cm-s-default .cm-header {color: blue;}
|
||||
.cm-s-default .cm-quote {color: #090;}
|
||||
.cm-negative {color: #d44;}
|
||||
.cm-positive {color: #292;}
|
||||
.cm-header, .cm-strong {font-weight: bold;}
|
||||
.cm-em {font-style: italic;}
|
||||
.cm-link {text-decoration: underline;}
|
||||
.cm-strikethrough {text-decoration: line-through;}
|
||||
|
||||
.cm-s-default .cm-keyword {color: #708;}
|
||||
.cm-s-default .cm-atom {color: #219;}
|
||||
.cm-s-default .cm-number {color: #164;}
|
||||
.cm-s-default .cm-def {color: #00f;}
|
||||
.cm-s-default .cm-variable,
|
||||
.cm-s-default .cm-punctuation,
|
||||
.cm-s-default .cm-property,
|
||||
.cm-s-default .cm-operator {}
|
||||
.cm-s-default .cm-variable-2 {color: #05a;}
|
||||
.cm-s-default .cm-variable-3 {color: #085;}
|
||||
.cm-s-default .cm-comment {color: #a50;}
|
||||
.cm-s-default .cm-string {color: #a11;}
|
||||
.cm-s-default .cm-string-2 {color: #f50;}
|
||||
.cm-s-default .cm-meta {color: #555;}
|
||||
.cm-s-default .cm-qualifier {color: #555;}
|
||||
.cm-s-default .cm-builtin {color: #30a;}
|
||||
.cm-s-default .cm-bracket {color: #997;}
|
||||
.cm-s-default .cm-tag {color: #170;}
|
||||
.cm-s-default .cm-attribute {color: #00c;}
|
||||
.cm-s-default .cm-hr {color: #999;}
|
||||
.cm-s-default .cm-link {color: #00c;}
|
||||
|
||||
.cm-s-default .cm-error {color: #f00;}
|
||||
.cm-invalidchar {color: #f00;}
|
||||
|
||||
.CodeMirror-composing { border-bottom: 2px solid; }
|
||||
|
||||
/* Default styles for common addons */
|
||||
|
||||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
|
||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
|
||||
.CodeMirror-activeline-background {background: #e8f2ff;}
|
||||
|
||||
/* STOP */
|
||||
|
||||
/* The rest of this file contains styles related to the mechanics of
|
||||
the editor. You probably shouldn't touch them. */
|
||||
|
||||
.CodeMirror {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.CodeMirror-scroll {
|
||||
overflow: scroll !important; /* Things will break if this is overridden */
|
||||
/* 30px is the magic margin used to hide the element's real scrollbars */
|
||||
/* See overflow: hidden in .CodeMirror */
|
||||
margin-bottom: -30px; margin-right: -30px;
|
||||
padding-bottom: 30px;
|
||||
height: 100%;
|
||||
outline: none; /* Prevent dragging from highlighting the element */
|
||||
position: relative;
|
||||
}
|
||||
.CodeMirror-sizer {
|
||||
position: relative;
|
||||
border-right: 30px solid transparent;
|
||||
}
|
||||
|
||||
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
||||
before actual scrolling happens, thus preventing shaking and
|
||||
flickering artifacts. */
|
||||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
display: none;
|
||||
}
|
||||
.CodeMirror-vscrollbar {
|
||||
right: 0; top: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
.CodeMirror-hscrollbar {
|
||||
bottom: 0; left: 0;
|
||||
overflow-y: hidden;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
.CodeMirror-scrollbar-filler {
|
||||
right: 0; bottom: 0;
|
||||
}
|
||||
.CodeMirror-gutter-filler {
|
||||
left: 0; bottom: 0;
|
||||
}
|
||||
|
||||
.CodeMirror-gutters {
|
||||
position: absolute; left: 0; top: 0;
|
||||
min-height: 100%;
|
||||
z-index: 3;
|
||||
}
|
||||
.CodeMirror-gutter {
|
||||
white-space: normal;
|
||||
height: 100%;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
margin-bottom: -30px;
|
||||
/* Hack to make IE7 behave */
|
||||
*zoom:1;
|
||||
*display:inline;
|
||||
}
|
||||
.CodeMirror-gutter-wrapper {
|
||||
position: absolute;
|
||||
z-index: 4;
|
||||
background: none !important;
|
||||
border: none !important;
|
||||
}
|
||||
.CodeMirror-gutter-background {
|
||||
position: absolute;
|
||||
top: 0; bottom: 0;
|
||||
z-index: 4;
|
||||
}
|
||||
.CodeMirror-gutter-elt {
|
||||
position: absolute;
|
||||
cursor: default;
|
||||
z-index: 4;
|
||||
}
|
||||
.CodeMirror-gutter-wrapper {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.CodeMirror-lines {
|
||||
cursor: text;
|
||||
min-height: 1px; /* prevents collapsing before first draw */
|
||||
}
|
||||
.CodeMirror pre {
|
||||
/* Reset some styles that the rest of the page might have set */
|
||||
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
||||
border-width: 0;
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
margin: 0;
|
||||
white-space: pre;
|
||||
word-wrap: normal;
|
||||
line-height: inherit;
|
||||
color: inherit;
|
||||
z-index: 2;
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
-webkit-font-variant-ligatures: none;
|
||||
font-variant-ligatures: none;
|
||||
}
|
||||
.CodeMirror-wrap pre {
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
.CodeMirror-linebackground {
|
||||
position: absolute;
|
||||
left: 0; right: 0; top: 0; bottom: 0;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.CodeMirror-linewidget {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.CodeMirror-widget {}
|
||||
|
||||
.CodeMirror-code {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* Force content-box sizing for the elements where we expect it */
|
||||
.CodeMirror-scroll,
|
||||
.CodeMirror-sizer,
|
||||
.CodeMirror-gutter,
|
||||
.CodeMirror-gutters,
|
||||
.CodeMirror-linenumber {
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
.CodeMirror-measure {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.CodeMirror-cursor { position: absolute; }
|
||||
.CodeMirror-measure pre { position: static; }
|
||||
|
||||
div.CodeMirror-cursors {
|
||||
visibility: hidden;
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
div.CodeMirror-dragcursors {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.CodeMirror-focused div.CodeMirror-cursors {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.CodeMirror-selected { background: #d9d9d9; }
|
||||
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
||||
.CodeMirror-crosshair { cursor: crosshair; }
|
||||
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
|
||||
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
|
||||
|
||||
.cm-searching {
|
||||
background: #ffa;
|
||||
background: rgba(255, 255, 0, .4);
|
||||
}
|
||||
|
||||
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
||||
.CodeMirror span { *vertical-align: text-bottom; }
|
||||
|
||||
/* Used to force a border model for a node */
|
||||
.cm-force-border { padding-right: .1px; }
|
||||
|
||||
@media print {
|
||||
/* Hide the cursor when printing */
|
||||
.CodeMirror div.CodeMirror-cursors {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
/* See issue #2901 */
|
||||
.cm-tab-wrap-hack:after { content: ''; }
|
||||
|
||||
/* Help users use markselection to safely style text background */
|
||||
span.CodeMirror-selectedtext { background: none; }
|
||||
|
||||
.CodeMirror {
|
||||
height: auto;
|
||||
min-height: 300px;
|
||||
border: 1px solid #ddd;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
padding: 10px;
|
||||
font: inherit;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.CodeMirror-scroll {
|
||||
min-height: 300px
|
||||
}
|
||||
|
||||
.CodeMirror-fullscreen {
|
||||
background: #fff;
|
||||
position: fixed !important;
|
||||
top: 50px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
height: auto;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
.CodeMirror-sided {
|
||||
width: 50% !important;
|
||||
}
|
||||
|
||||
.editor-toolbar {
|
||||
position: relative;
|
||||
opacity: .6;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-o-user-select: none;
|
||||
user-select: none;
|
||||
padding: 0 10px;
|
||||
border-top: 1px solid #bbb;
|
||||
border-left: 1px solid #bbb;
|
||||
border-right: 1px solid #bbb;
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
|
||||
.editor-toolbar:after,
|
||||
.editor-toolbar:before {
|
||||
display: block;
|
||||
content: ' ';
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
.editor-toolbar:before {
|
||||
margin-bottom: 8px
|
||||
}
|
||||
|
||||
.editor-toolbar:after {
|
||||
margin-top: 8px
|
||||
}
|
||||
|
||||
.editor-toolbar:hover,
|
||||
.editor-wrapper input.title:focus,
|
||||
.editor-wrapper input.title:hover {
|
||||
opacity: .8
|
||||
}
|
||||
|
||||
.editor-toolbar.fullscreen {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
white-space: nowrap;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
border: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
opacity: 1;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
.editor-toolbar.fullscreen::before {
|
||||
width: 20px;
|
||||
height: 50px;
|
||||
background: -moz-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 1)), color-stop(100%, rgba(255, 255, 255, 0)));
|
||||
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
background: -o-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
background: -ms-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
background: linear-gradient(to right, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.editor-toolbar.fullscreen::after {
|
||||
width: 20px;
|
||||
height: 50px;
|
||||
background: -moz-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(100%, rgba(255, 255, 255, 1)));
|
||||
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
background: -o-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
background: -ms-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.editor-toolbar a {
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
text-decoration: none!important;
|
||||
color: #2c3e50!important;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin: 0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.editor-toolbar a.active,
|
||||
.editor-toolbar a:hover {
|
||||
background: #fcfcfc;
|
||||
border-color: #95a5a6;
|
||||
}
|
||||
|
||||
.editor-toolbar a:before {
|
||||
line-height: 30px
|
||||
}
|
||||
|
||||
.editor-toolbar i.separator {
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
border-left: 1px solid #d9d9d9;
|
||||
border-right: 1px solid #fff;
|
||||
color: transparent;
|
||||
text-indent: -10px;
|
||||
margin: 0 6px;
|
||||
}
|
||||
|
||||
.editor-toolbar a.fa-header-x:after {
|
||||
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
|
||||
font-size: 65%;
|
||||
vertical-align: text-bottom;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.editor-toolbar a.fa-header-1:after {
|
||||
content: "1";
|
||||
}
|
||||
|
||||
.editor-toolbar a.fa-header-2:after {
|
||||
content: "2";
|
||||
}
|
||||
|
||||
.editor-toolbar a.fa-header-3:after {
|
||||
content: "3";
|
||||
}
|
||||
|
||||
.editor-toolbar a.fa-header-bigger:after {
|
||||
content: "▲";
|
||||
}
|
||||
|
||||
.editor-toolbar a.fa-header-smaller:after {
|
||||
content: "▼";
|
||||
}
|
||||
|
||||
.editor-toolbar.disabled-for-preview a:not(.no-disable) {
|
||||
pointer-events: none;
|
||||
background: #fff;
|
||||
border-color: transparent;
|
||||
text-shadow: inherit;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 700px) {
|
||||
.editor-toolbar a.no-mobile {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.editor-statusbar {
|
||||
padding: 8px 10px;
|
||||
font-size: 12px;
|
||||
color: #959694;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.editor-statusbar span {
|
||||
display: inline-block;
|
||||
min-width: 4em;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.editor-statusbar .lines:before {
|
||||
content: 'lines: '
|
||||
}
|
||||
|
||||
.editor-statusbar .words:before {
|
||||
content: 'words: '
|
||||
}
|
||||
|
||||
.editor-statusbar .characters:before {
|
||||
content: 'characters: '
|
||||
}
|
||||
|
||||
.editor-preview {
|
||||
padding: 10px;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: #fafafa;
|
||||
z-index: 7;
|
||||
overflow: auto;
|
||||
display: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.editor-preview-side {
|
||||
padding: 10px;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 50%;
|
||||
top: 50px;
|
||||
right: 0;
|
||||
background: #fafafa;
|
||||
z-index: 9;
|
||||
overflow: auto;
|
||||
display: none;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.editor-preview-active-side {
|
||||
display: block
|
||||
}
|
||||
|
||||
.editor-preview-active {
|
||||
display: block
|
||||
}
|
||||
|
||||
.editor-preview>p,
|
||||
.editor-preview-side>p {
|
||||
margin-top: 0
|
||||
}
|
||||
|
||||
.editor-preview pre,
|
||||
.editor-preview-side pre {
|
||||
background: #eee;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.editor-preview table td,
|
||||
.editor-preview table th,
|
||||
.editor-preview-side table td,
|
||||
.editor-preview-side table th {
|
||||
border: 1px solid #ddd;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-tag {
|
||||
color: #63a35c;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-attribute {
|
||||
color: #795da3;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-string {
|
||||
color: #183691;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-selected {
|
||||
background: #d9d9d9;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-header-1 {
|
||||
font-size: 200%;
|
||||
line-height: 200%;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-header-2 {
|
||||
font-size: 160%;
|
||||
line-height: 160%;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-header-3 {
|
||||
font-size: 125%;
|
||||
line-height: 125%;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-header-4 {
|
||||
font-size: 110%;
|
||||
line-height: 110%;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-comment {
|
||||
background: rgba(0, 0, 0, .05);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-link {
|
||||
color: #7f8c8d;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-url {
|
||||
color: #aab2b3;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-strikethrough {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-placeholder {
|
||||
opacity: .5;
|
||||
}
|
||||
.CodeMirror .cm-spell-error:not(.cm-url):not(.cm-comment):not(.cm-tag):not(.cm-word) {
|
||||
background: rgba(255, 0, 0, .15);
|
||||
}
|
17023
debug/simplemde.debug.js
Normal file
17023
debug/simplemde.debug.js
Normal file
File diff suppressed because one or more lines are too long
17019
debug/simplemde.js
Normal file
17019
debug/simplemde.js
Normal file
File diff suppressed because it is too large
Load diff
7
dist/simplemde.min.css
vendored
Normal file
7
dist/simplemde.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
15
dist/simplemde.min.js
vendored
Normal file
15
dist/simplemde.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
96
gulpfile.js
Normal file
96
gulpfile.js
Normal file
|
@ -0,0 +1,96 @@
|
|||
"use strict";
|
||||
|
||||
var gulp = require("gulp"),
|
||||
minifycss = require("gulp-clean-css"),
|
||||
uglify = require("gulp-uglify"),
|
||||
concat = require("gulp-concat"),
|
||||
header = require("gulp-header"),
|
||||
buffer = require("vinyl-buffer"),
|
||||
pkg = require("./package.json"),
|
||||
debug = require("gulp-debug"),
|
||||
eslint = require("gulp-eslint"),
|
||||
prettify = require("gulp-jsbeautifier"),
|
||||
browserify = require("browserify"),
|
||||
source = require("vinyl-source-stream"),
|
||||
rename = require("gulp-rename");
|
||||
|
||||
var banner = ["/**",
|
||||
" * <%= pkg.name %> v<%= pkg.version %>",
|
||||
" * Copyright <%= pkg.company %>",
|
||||
" * @link <%= pkg.homepage %>",
|
||||
" * @license <%= pkg.license %>",
|
||||
" */",
|
||||
""].join("\n");
|
||||
|
||||
gulp.task("prettify-js", [], function() {
|
||||
return gulp.src("./src/js/simplemde.js")
|
||||
.pipe(prettify({js: {brace_style: "collapse", indent_char: "\t", indent_size: 1, max_preserve_newlines: 3, space_before_conditional: false}}))
|
||||
.pipe(gulp.dest("./src/js"));
|
||||
});
|
||||
|
||||
gulp.task("prettify-css", [], function() {
|
||||
return gulp.src("./src/css/simplemde.css")
|
||||
.pipe(prettify({css: {indentChar: "\t", indentSize: 1}}))
|
||||
.pipe(gulp.dest("./src/css"));
|
||||
});
|
||||
|
||||
gulp.task("lint", ["prettify-js"], function() {
|
||||
gulp.src("./src/js/**/*.js")
|
||||
.pipe(debug())
|
||||
.pipe(eslint())
|
||||
.pipe(eslint.format())
|
||||
.pipe(eslint.failAfterError());
|
||||
});
|
||||
|
||||
function taskBrowserify(opts) {
|
||||
return browserify("./src/js/simplemde.js", opts)
|
||||
.bundle();
|
||||
}
|
||||
|
||||
gulp.task("browserify:debug", ["lint"], function() {
|
||||
return taskBrowserify({debug:true, standalone:"SimpleMDE"})
|
||||
.pipe(source("simplemde.debug.js"))
|
||||
.pipe(buffer())
|
||||
.pipe(header(banner, {pkg: pkg}))
|
||||
.pipe(gulp.dest("./debug/"));
|
||||
});
|
||||
|
||||
gulp.task("browserify", ["lint"], function() {
|
||||
return taskBrowserify({standalone:"SimpleMDE"})
|
||||
.pipe(source("simplemde.js"))
|
||||
.pipe(buffer())
|
||||
.pipe(header(banner, {pkg: pkg}))
|
||||
.pipe(gulp.dest("./debug/"));
|
||||
});
|
||||
|
||||
gulp.task("scripts", ["browserify:debug", "browserify", "lint"], function() {
|
||||
var js_files = ["./debug/simplemde.js"];
|
||||
|
||||
return gulp.src(js_files)
|
||||
.pipe(concat("simplemde.min.js"))
|
||||
.pipe(uglify())
|
||||
.pipe(buffer())
|
||||
.pipe(header(banner, {pkg: pkg}))
|
||||
.pipe(gulp.dest("./dist/"));
|
||||
});
|
||||
|
||||
gulp.task("styles", ["prettify-css"], function() {
|
||||
var css_files = [
|
||||
"./node_modules/codemirror/lib/codemirror.css",
|
||||
"./src/css/*.css",
|
||||
"./node_modules/codemirror-spell-checker/src/css/spell-checker.css"
|
||||
];
|
||||
|
||||
return gulp.src(css_files)
|
||||
.pipe(concat("simplemde.css"))
|
||||
.pipe(buffer())
|
||||
.pipe(header(banner, {pkg: pkg}))
|
||||
.pipe(gulp.dest("./debug/"))
|
||||
.pipe(minifycss())
|
||||
.pipe(rename("simplemde.min.css"))
|
||||
.pipe(buffer())
|
||||
.pipe(header(banner, {pkg: pkg}))
|
||||
.pipe(gulp.dest("./dist/"));
|
||||
});
|
||||
|
||||
gulp.task("default", ["scripts", "styles"]);
|
48
package.json
Normal file
48
package.json
Normal file
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"name": "simplemde",
|
||||
"version": "1.11.2",
|
||||
"description": "A simple, beautiful, and embeddable JavaScript Markdown editor. Features autosaving and spell checking.",
|
||||
"keywords": [
|
||||
"embeddable",
|
||||
"markdown",
|
||||
"editor",
|
||||
"javascript",
|
||||
"wysiwyg"
|
||||
],
|
||||
"homepage": "https://github.com/NextStepWebs/simplemde-markdown-editor",
|
||||
"main": "./src/js/simplemde.js",
|
||||
"license": "MIT",
|
||||
"company": "Next Step Webs, Inc.",
|
||||
"author": {
|
||||
"name": "Wes Cossick",
|
||||
"url": "http://www.WesCossick.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"codemirror": "*",
|
||||
"codemirror-spell-checker": "*",
|
||||
"marked": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "*",
|
||||
"debug": "*",
|
||||
"eslint": "*",
|
||||
"gulp": "*",
|
||||
"gulp-concat": "*",
|
||||
"gulp-debug": "*",
|
||||
"gulp-eslint": "*",
|
||||
"gulp-header": "*",
|
||||
"gulp-jsbeautifier": "*",
|
||||
"gulp-clean-css": "*",
|
||||
"gulp-rename": "*",
|
||||
"gulp-uglify": "*",
|
||||
"vinyl-source-stream": "*",
|
||||
"vinyl-buffer": "*"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor"
|
||||
}
|
||||
}
|
4
simplemde.min.css
vendored
4
simplemde.min.css
vendored
File diff suppressed because one or more lines are too long
6
simplemde.min.js
vendored
6
simplemde.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,14 +0,0 @@
|
|||
# How to compile
|
||||
Minify the JS in this order:
|
||||
|
||||
1. `codemirror/codemirror.js`
|
||||
1. `codemirror/continuelist.js`
|
||||
1. `codemirror/markdown.js`
|
||||
1. `codemirror/xml.js`
|
||||
1. `marked.js`
|
||||
1. `markdownify.js`
|
||||
|
||||
Minify the CSS in this order:
|
||||
|
||||
1. `theme.css`
|
||||
1. `font-awesome.css`
|
File diff suppressed because it is too large
Load diff
|
@ -1,51 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\s*)/,
|
||||
emptyListRE = /^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,
|
||||
unorderedListRE = /[*+-]\s/;
|
||||
|
||||
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections(), replacements = [];
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var pos = ranges[i].head;
|
||||
var eolState = cm.getStateAfter(pos.line);
|
||||
var inList = eolState.list !== false;
|
||||
var inQuote = eolState.quote !== 0;
|
||||
|
||||
var line = cm.getLine(pos.line), match = listRE.exec(line);
|
||||
if (!ranges[i].empty() || (!inList && !inQuote) || !match) {
|
||||
cm.execCommand("newlineAndIndent");
|
||||
return;
|
||||
}
|
||||
if (emptyListRE.test(line)) {
|
||||
cm.replaceRange("", {
|
||||
line: pos.line, ch: 0
|
||||
}, {
|
||||
line: pos.line, ch: pos.ch + 1
|
||||
});
|
||||
replacements[i] = "\n";
|
||||
} else {
|
||||
var indent = match[1], after = match[5];
|
||||
var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0
|
||||
? match[2]
|
||||
: (parseInt(match[3], 10) + 1) + match[4];
|
||||
|
||||
replacements[i] = "\n" + indent + bullet + after;
|
||||
}
|
||||
}
|
||||
|
||||
cm.replaceSelections(replacements);
|
||||
};
|
||||
});
|
|
@ -1,781 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../xml/xml"), require("../meta"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../xml/xml", "../meta"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
||||
|
||||
var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
|
||||
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain");
|
||||
|
||||
function getMode(name) {
|
||||
if (CodeMirror.findModeByName) {
|
||||
var found = CodeMirror.findModeByName(name);
|
||||
if (found) name = found.mime || found.mimes[0];
|
||||
}
|
||||
var mode = CodeMirror.getMode(cmCfg, name);
|
||||
return mode.name == "null" ? null : mode;
|
||||
}
|
||||
|
||||
// Should characters that affect highlighting be highlighted separate?
|
||||
// Does not include characters that will be output (such as `1.` and `-` for lists)
|
||||
if (modeCfg.highlightFormatting === undefined)
|
||||
modeCfg.highlightFormatting = false;
|
||||
|
||||
// Maximum number of nested blockquotes. Set to 0 for infinite nesting.
|
||||
// Excess `>` will emit `error` token.
|
||||
if (modeCfg.maxBlockquoteDepth === undefined)
|
||||
modeCfg.maxBlockquoteDepth = 0;
|
||||
|
||||
// Should underscores in words open/close em/strong?
|
||||
if (modeCfg.underscoresBreakWords === undefined)
|
||||
modeCfg.underscoresBreakWords = true;
|
||||
|
||||
// Turn on fenced code blocks? ("```" to start/end)
|
||||
if (modeCfg.fencedCodeBlocks === undefined) modeCfg.fencedCodeBlocks = false;
|
||||
|
||||
// Turn on task lists? ("- [ ] " and "- [x] ")
|
||||
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
|
||||
|
||||
// Turn on strikethrough syntax
|
||||
if (modeCfg.strikethrough === undefined)
|
||||
modeCfg.strikethrough = false;
|
||||
|
||||
var codeDepth = 0;
|
||||
|
||||
var header = 'header'
|
||||
, code = 'comment'
|
||||
, quote = 'quote'
|
||||
, list1 = 'variable-2'
|
||||
, list2 = 'variable-3'
|
||||
, list3 = 'keyword'
|
||||
, hr = 'hr'
|
||||
, image = 'tag'
|
||||
, formatting = 'formatting'
|
||||
, linkinline = 'link'
|
||||
, linkemail = 'link'
|
||||
, linktext = 'link'
|
||||
, linkhref = 'string'
|
||||
, em = 'em'
|
||||
, strong = 'strong'
|
||||
, strikethrough = 'strikethrough';
|
||||
|
||||
var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/
|
||||
, ulRE = /^[*\-+]\s+/
|
||||
, olRE = /^[0-9]+([.)])\s+/
|
||||
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
|
||||
, atxHeaderRE = /^(#+)(?: |$)/
|
||||
, setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
|
||||
, textRE = /^[^#!\[\]*_\\<>` "'(~]+/;
|
||||
|
||||
function switchInline(stream, state, f) {
|
||||
state.f = state.inline = f;
|
||||
return f(stream, state);
|
||||
}
|
||||
|
||||
function switchBlock(stream, state, f) {
|
||||
state.f = state.block = f;
|
||||
return f(stream, state);
|
||||
}
|
||||
|
||||
|
||||
// Blocks
|
||||
|
||||
function blankLine(state) {
|
||||
// Reset linkTitle state
|
||||
state.linkTitle = false;
|
||||
// Reset EM state
|
||||
state.em = false;
|
||||
// Reset STRONG state
|
||||
state.strong = false;
|
||||
// Reset strikethrough state
|
||||
state.strikethrough = false;
|
||||
// Reset state.quote
|
||||
state.quote = 0;
|
||||
// Reset state.indentedCode
|
||||
state.indentedCode = false;
|
||||
if (!htmlFound && state.f == htmlBlock) {
|
||||
state.f = inlineNormal;
|
||||
state.block = blockNormal;
|
||||
}
|
||||
// Reset state.trailingSpace
|
||||
state.trailingSpace = 0;
|
||||
state.trailingSpaceNewLine = false;
|
||||
// Mark this line as blank
|
||||
state.thisLineHasContent = false;
|
||||
return null;
|
||||
}
|
||||
|
||||
function blockNormal(stream, state) {
|
||||
|
||||
var sol = stream.sol();
|
||||
|
||||
var prevLineIsList = state.list !== false,
|
||||
prevLineIsIndentedCode = state.indentedCode;
|
||||
|
||||
state.indentedCode = false;
|
||||
|
||||
if (prevLineIsList) {
|
||||
if (state.indentationDiff >= 0) { // Continued list
|
||||
if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
|
||||
state.indentation -= state.indentationDiff;
|
||||
}
|
||||
state.list = null;
|
||||
} else if (state.indentation > 0) {
|
||||
state.list = null;
|
||||
state.listDepth = Math.floor(state.indentation / 4);
|
||||
} else { // No longer a list
|
||||
state.list = false;
|
||||
state.listDepth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
var match = null;
|
||||
if (state.indentationDiff >= 4) {
|
||||
stream.skipToEnd();
|
||||
if (prevLineIsIndentedCode || !state.prevLineHasContent) {
|
||||
state.indentation -= 4;
|
||||
state.indentedCode = true;
|
||||
return code;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (stream.eatSpace()) {
|
||||
return null;
|
||||
} else if ((match = stream.match(atxHeaderRE)) && match[1].length <= 6) {
|
||||
state.header = match[1].length;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||
state.f = state.inline;
|
||||
return getType(state);
|
||||
} else if (state.prevLineHasContent && !state.quote && !prevLineIsList && !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) {
|
||||
state.header = match[0].charAt(0) == '=' ? 1 : 2;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||
state.f = state.inline;
|
||||
return getType(state);
|
||||
} else if (stream.eat('>')) {
|
||||
state.quote = sol ? 1 : state.quote + 1;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "quote";
|
||||
stream.eatSpace();
|
||||
return getType(state);
|
||||
} else if (stream.peek() === '[') {
|
||||
return switchInline(stream, state, footnoteLink);
|
||||
} else if (stream.match(hrRE, true)) {
|
||||
state.hr = true;
|
||||
return hr;
|
||||
} else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
|
||||
var listType = null;
|
||||
if (stream.match(ulRE, true)) {
|
||||
listType = 'ul';
|
||||
} else {
|
||||
stream.match(olRE, true);
|
||||
listType = 'ol';
|
||||
}
|
||||
state.indentation += 4;
|
||||
state.list = true;
|
||||
state.listDepth++;
|
||||
if (modeCfg.taskLists && stream.match(taskListRE, false)) {
|
||||
state.taskList = true;
|
||||
}
|
||||
state.f = state.inline;
|
||||
if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
|
||||
return getType(state);
|
||||
} else if (modeCfg.fencedCodeBlocks && stream.match(/^```[ \t]*([\w+#]*)/, true)) {
|
||||
// try switching mode
|
||||
state.localMode = getMode(RegExp.$1);
|
||||
if (state.localMode) state.localState = state.localMode.startState();
|
||||
state.f = state.block = local;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||
state.code = true;
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
return switchInline(stream, state, state.inline);
|
||||
}
|
||||
|
||||
function htmlBlock(stream, state) {
|
||||
var style = htmlMode.token(stream, state.htmlState);
|
||||
if ((htmlFound && state.htmlState.tagStart === null && !state.htmlState.context) ||
|
||||
(state.md_inside && stream.current().indexOf(">") > -1)) {
|
||||
state.f = inlineNormal;
|
||||
state.block = blockNormal;
|
||||
state.htmlState = null;
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
function local(stream, state) {
|
||||
if (stream.sol() && stream.match("```", false)) {
|
||||
state.localMode = state.localState = null;
|
||||
state.f = state.block = leavingLocal;
|
||||
return null;
|
||||
} else if (state.localMode) {
|
||||
return state.localMode.token(stream, state.localState);
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
function leavingLocal(stream, state) {
|
||||
stream.match("```");
|
||||
state.block = blockNormal;
|
||||
state.f = inlineNormal;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||
state.code = true;
|
||||
var returnType = getType(state);
|
||||
state.code = false;
|
||||
return returnType;
|
||||
}
|
||||
|
||||
// Inline
|
||||
function getType(state) {
|
||||
var styles = [];
|
||||
|
||||
if (state.formatting) {
|
||||
styles.push(formatting);
|
||||
|
||||
if (typeof state.formatting === "string") state.formatting = [state.formatting];
|
||||
|
||||
for (var i = 0; i < state.formatting.length; i++) {
|
||||
styles.push(formatting + "-" + state.formatting[i]);
|
||||
|
||||
if (state.formatting[i] === "header") {
|
||||
styles.push(formatting + "-" + state.formatting[i] + "-" + state.header);
|
||||
}
|
||||
|
||||
// Add `formatting-quote` and `formatting-quote-#` for blockquotes
|
||||
// Add `error` instead if the maximum blockquote nesting depth is passed
|
||||
if (state.formatting[i] === "quote") {
|
||||
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
|
||||
styles.push(formatting + "-" + state.formatting[i] + "-" + state.quote);
|
||||
} else {
|
||||
styles.push("error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state.taskOpen) {
|
||||
styles.push("meta");
|
||||
return styles.length ? styles.join(' ') : null;
|
||||
}
|
||||
if (state.taskClosed) {
|
||||
styles.push("property");
|
||||
return styles.length ? styles.join(' ') : null;
|
||||
}
|
||||
|
||||
if (state.linkHref) {
|
||||
styles.push(linkhref, "url");
|
||||
} else { // Only apply inline styles to non-url text
|
||||
if (state.strong) { styles.push(strong); }
|
||||
if (state.em) { styles.push(em); }
|
||||
if (state.strikethrough) { styles.push(strikethrough); }
|
||||
|
||||
if (state.linkText) { styles.push(linktext); }
|
||||
|
||||
if (state.code) { styles.push(code); }
|
||||
}
|
||||
|
||||
if (state.header) { styles.push(header); styles.push(header + "-" + state.header); }
|
||||
|
||||
if (state.quote) {
|
||||
styles.push(quote);
|
||||
|
||||
// Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
|
||||
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
|
||||
styles.push(quote + "-" + state.quote);
|
||||
} else {
|
||||
styles.push(quote + "-" + modeCfg.maxBlockquoteDepth);
|
||||
}
|
||||
}
|
||||
|
||||
if (state.list !== false) {
|
||||
var listMod = (state.listDepth - 1) % 3;
|
||||
if (!listMod) {
|
||||
styles.push(list1);
|
||||
} else if (listMod === 1) {
|
||||
styles.push(list2);
|
||||
} else {
|
||||
styles.push(list3);
|
||||
}
|
||||
}
|
||||
|
||||
if (state.trailingSpaceNewLine) {
|
||||
styles.push("trailing-space-new-line");
|
||||
} else if (state.trailingSpace) {
|
||||
styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
|
||||
}
|
||||
|
||||
return styles.length ? styles.join(' ') : null;
|
||||
}
|
||||
|
||||
function handleText(stream, state) {
|
||||
if (stream.match(textRE, true)) {
|
||||
return getType(state);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function inlineNormal(stream, state) {
|
||||
var style = state.text(stream, state);
|
||||
if (typeof style !== 'undefined')
|
||||
return style;
|
||||
|
||||
if (state.list) { // List marker (*, +, -, 1., etc)
|
||||
state.list = null;
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
if (state.taskList) {
|
||||
var taskOpen = stream.match(taskListRE, true)[1] !== "x";
|
||||
if (taskOpen) state.taskOpen = true;
|
||||
else state.taskClosed = true;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "task";
|
||||
state.taskList = false;
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
state.taskOpen = false;
|
||||
state.taskClosed = false;
|
||||
|
||||
if (state.header && stream.match(/^#+$/, true)) {
|
||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
// Get sol() value now, before character is consumed
|
||||
var sol = stream.sol();
|
||||
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === '\\') {
|
||||
stream.next();
|
||||
if (modeCfg.highlightFormatting) {
|
||||
var type = getType(state);
|
||||
return type ? type + " formatting-escape" : "formatting-escape";
|
||||
}
|
||||
}
|
||||
|
||||
// Matches link titles present on next line
|
||||
if (state.linkTitle) {
|
||||
state.linkTitle = false;
|
||||
var matchCh = ch;
|
||||
if (ch === '(') {
|
||||
matchCh = ')';
|
||||
}
|
||||
matchCh = (matchCh+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
|
||||
var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh;
|
||||
if (stream.match(new RegExp(regex), true)) {
|
||||
return linkhref;
|
||||
}
|
||||
}
|
||||
|
||||
// If this block is changed, it may need to be updated in GFM mode
|
||||
if (ch === '`') {
|
||||
var previousFormatting = state.formatting;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "code";
|
||||
var t = getType(state);
|
||||
var before = stream.pos;
|
||||
stream.eatWhile('`');
|
||||
var difference = 1 + stream.pos - before;
|
||||
if (!state.code) {
|
||||
codeDepth = difference;
|
||||
state.code = true;
|
||||
return getType(state);
|
||||
} else {
|
||||
if (difference === codeDepth) { // Must be exact
|
||||
state.code = false;
|
||||
return t;
|
||||
}
|
||||
state.formatting = previousFormatting;
|
||||
return getType(state);
|
||||
}
|
||||
} else if (state.code) {
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
|
||||
stream.match(/\[[^\]]*\]/);
|
||||
state.inline = state.f = linkHref;
|
||||
return image;
|
||||
}
|
||||
|
||||
if (ch === '[' && stream.match(/.*\](\(.*\)| ?\[.*\])/, false)) {
|
||||
state.linkText = true;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
if (ch === ']' && state.linkText && stream.match(/\(.*\)| ?\[.*\]/, false)) {
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
state.linkText = false;
|
||||
state.inline = state.f = linkHref;
|
||||
return type;
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) {
|
||||
state.f = state.inline = linkInline;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
if (type){
|
||||
type += " ";
|
||||
} else {
|
||||
type = "";
|
||||
}
|
||||
return type + linkinline;
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
|
||||
state.f = state.inline = linkInline;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
if (type){
|
||||
type += " ";
|
||||
} else {
|
||||
type = "";
|
||||
}
|
||||
return type + linkemail;
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^\w/, false)) {
|
||||
if (stream.string.indexOf(">") != -1) {
|
||||
var atts = stream.string.substring(1,stream.string.indexOf(">"));
|
||||
if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) {
|
||||
state.md_inside = true;
|
||||
}
|
||||
}
|
||||
stream.backUp(1);
|
||||
state.htmlState = CodeMirror.startState(htmlMode);
|
||||
return switchBlock(stream, state, htmlBlock);
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^\/\w*?>/)) {
|
||||
state.md_inside = false;
|
||||
return "tag";
|
||||
}
|
||||
|
||||
var ignoreUnderscore = false;
|
||||
if (!modeCfg.underscoresBreakWords) {
|
||||
if (ch === '_' && stream.peek() !== '_' && stream.match(/(\w)/, false)) {
|
||||
var prevPos = stream.pos - 2;
|
||||
if (prevPos >= 0) {
|
||||
var prevCh = stream.string.charAt(prevPos);
|
||||
if (prevCh !== '_' && prevCh.match(/(\w)/, false)) {
|
||||
ignoreUnderscore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ch === '*' || (ch === '_' && !ignoreUnderscore)) {
|
||||
if (sol && stream.peek() === ' ') {
|
||||
// Do nothing, surrounded by newline and space
|
||||
} else if (state.strong === ch && stream.eat(ch)) { // Remove STRONG
|
||||
if (modeCfg.highlightFormatting) state.formatting = "strong";
|
||||
var t = getType(state);
|
||||
state.strong = false;
|
||||
return t;
|
||||
} else if (!state.strong && stream.eat(ch)) { // Add STRONG
|
||||
state.strong = ch;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "strong";
|
||||
return getType(state);
|
||||
} else if (state.em === ch) { // Remove EM
|
||||
if (modeCfg.highlightFormatting) state.formatting = "em";
|
||||
var t = getType(state);
|
||||
state.em = false;
|
||||
return t;
|
||||
} else if (!state.em) { // Add EM
|
||||
state.em = ch;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "em";
|
||||
return getType(state);
|
||||
}
|
||||
} else if (ch === ' ') {
|
||||
if (stream.eat('*') || stream.eat('_')) { // Probably surrounded by spaces
|
||||
if (stream.peek() === ' ') { // Surrounded by spaces, ignore
|
||||
return getType(state);
|
||||
} else { // Not surrounded by spaces, back up pointer
|
||||
stream.backUp(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modeCfg.strikethrough) {
|
||||
if (ch === '~' && stream.eatWhile(ch)) {
|
||||
if (state.strikethrough) {// Remove strikethrough
|
||||
if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
|
||||
var t = getType(state);
|
||||
state.strikethrough = false;
|
||||
return t;
|
||||
} else if (stream.match(/^[^\s]/, false)) {// Add strikethrough
|
||||
state.strikethrough = true;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
|
||||
return getType(state);
|
||||
}
|
||||
} else if (ch === ' ') {
|
||||
if (stream.match(/^~~/, true)) { // Probably surrounded by space
|
||||
if (stream.peek() === ' ') { // Surrounded by spaces, ignore
|
||||
return getType(state);
|
||||
} else { // Not surrounded by spaces, back up pointer
|
||||
stream.backUp(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ch === ' ') {
|
||||
if (stream.match(/ +$/, false)) {
|
||||
state.trailingSpace++;
|
||||
} else if (state.trailingSpace) {
|
||||
state.trailingSpaceNewLine = true;
|
||||
}
|
||||
}
|
||||
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
function linkInline(stream, state) {
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === ">") {
|
||||
state.f = state.inline = inlineNormal;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
if (type){
|
||||
type += " ";
|
||||
} else {
|
||||
type = "";
|
||||
}
|
||||
return type + linkinline;
|
||||
}
|
||||
|
||||
stream.match(/^[^>]+/, true);
|
||||
|
||||
return linkinline;
|
||||
}
|
||||
|
||||
function linkHref(stream, state) {
|
||||
// Check if space, and return NULL if so (to avoid marking the space)
|
||||
if(stream.eatSpace()){
|
||||
return null;
|
||||
}
|
||||
var ch = stream.next();
|
||||
if (ch === '(' || ch === '[') {
|
||||
state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]");
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link-string";
|
||||
state.linkHref = true;
|
||||
return getType(state);
|
||||
}
|
||||
return 'error';
|
||||
}
|
||||
|
||||
function getLinkHrefInside(endChar) {
|
||||
return function(stream, state) {
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === endChar) {
|
||||
state.f = state.inline = inlineNormal;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link-string";
|
||||
var returnState = getType(state);
|
||||
state.linkHref = false;
|
||||
return returnState;
|
||||
}
|
||||
|
||||
if (stream.match(inlineRE(endChar), true)) {
|
||||
stream.backUp(1);
|
||||
}
|
||||
|
||||
state.linkHref = true;
|
||||
return getType(state);
|
||||
};
|
||||
}
|
||||
|
||||
function footnoteLink(stream, state) {
|
||||
if (stream.match(/^[^\]]*\]:/, false)) {
|
||||
state.f = footnoteLinkInside;
|
||||
stream.next(); // Consume [
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
state.linkText = true;
|
||||
return getType(state);
|
||||
}
|
||||
return switchInline(stream, state, inlineNormal);
|
||||
}
|
||||
|
||||
function footnoteLinkInside(stream, state) {
|
||||
if (stream.match(/^\]:/, true)) {
|
||||
state.f = state.inline = footnoteUrl;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var returnType = getType(state);
|
||||
state.linkText = false;
|
||||
return returnType;
|
||||
}
|
||||
|
||||
stream.match(/^[^\]]+/, true);
|
||||
|
||||
return linktext;
|
||||
}
|
||||
|
||||
function footnoteUrl(stream, state) {
|
||||
// Check if space, and return NULL if so (to avoid marking the space)
|
||||
if(stream.eatSpace()){
|
||||
return null;
|
||||
}
|
||||
// Match URL
|
||||
stream.match(/^[^\s]+/, true);
|
||||
// Check for link title
|
||||
if (stream.peek() === undefined) { // End of line, set flag to check next line
|
||||
state.linkTitle = true;
|
||||
} else { // More content on line, check if link title
|
||||
stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
|
||||
}
|
||||
state.f = state.inline = inlineNormal;
|
||||
return linkhref + " url";
|
||||
}
|
||||
|
||||
var savedInlineRE = [];
|
||||
function inlineRE(endChar) {
|
||||
if (!savedInlineRE[endChar]) {
|
||||
// Escape endChar for RegExp (taken from http://stackoverflow.com/a/494122/526741)
|
||||
endChar = (endChar+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
|
||||
// Match any non-endChar, escaped character, as well as the closing
|
||||
// endChar.
|
||||
savedInlineRE[endChar] = new RegExp('^(?:[^\\\\]|\\\\.)*?(' + endChar + ')');
|
||||
}
|
||||
return savedInlineRE[endChar];
|
||||
}
|
||||
|
||||
var mode = {
|
||||
startState: function() {
|
||||
return {
|
||||
f: blockNormal,
|
||||
|
||||
prevLineHasContent: false,
|
||||
thisLineHasContent: false,
|
||||
|
||||
block: blockNormal,
|
||||
htmlState: null,
|
||||
indentation: 0,
|
||||
|
||||
inline: inlineNormal,
|
||||
text: handleText,
|
||||
|
||||
formatting: false,
|
||||
linkText: false,
|
||||
linkHref: false,
|
||||
linkTitle: false,
|
||||
em: false,
|
||||
strong: false,
|
||||
header: 0,
|
||||
hr: false,
|
||||
taskList: false,
|
||||
list: false,
|
||||
listDepth: 0,
|
||||
quote: 0,
|
||||
trailingSpace: 0,
|
||||
trailingSpaceNewLine: false,
|
||||
strikethrough: false
|
||||
};
|
||||
},
|
||||
|
||||
copyState: function(s) {
|
||||
return {
|
||||
f: s.f,
|
||||
|
||||
prevLineHasContent: s.prevLineHasContent,
|
||||
thisLineHasContent: s.thisLineHasContent,
|
||||
|
||||
block: s.block,
|
||||
htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
|
||||
indentation: s.indentation,
|
||||
|
||||
localMode: s.localMode,
|
||||
localState: s.localMode ? CodeMirror.copyState(s.localMode, s.localState) : null,
|
||||
|
||||
inline: s.inline,
|
||||
text: s.text,
|
||||
formatting: false,
|
||||
linkTitle: s.linkTitle,
|
||||
em: s.em,
|
||||
strong: s.strong,
|
||||
strikethrough: s.strikethrough,
|
||||
header: s.header,
|
||||
hr: s.hr,
|
||||
taskList: s.taskList,
|
||||
list: s.list,
|
||||
listDepth: s.listDepth,
|
||||
quote: s.quote,
|
||||
indentedCode: s.indentedCode,
|
||||
trailingSpace: s.trailingSpace,
|
||||
trailingSpaceNewLine: s.trailingSpaceNewLine,
|
||||
md_inside: s.md_inside
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
|
||||
// Reset state.formatting
|
||||
state.formatting = false;
|
||||
|
||||
if (stream.sol()) {
|
||||
var forceBlankLine = !!state.header || state.hr;
|
||||
|
||||
// Reset state.header and state.hr
|
||||
state.header = 0;
|
||||
state.hr = false;
|
||||
|
||||
if (stream.match(/^\s*$/, true) || forceBlankLine) {
|
||||
state.prevLineHasContent = false;
|
||||
blankLine(state);
|
||||
return forceBlankLine ? this.token(stream, state) : null;
|
||||
} else {
|
||||
state.prevLineHasContent = state.thisLineHasContent;
|
||||
state.thisLineHasContent = true;
|
||||
}
|
||||
|
||||
// Reset state.taskList
|
||||
state.taskList = false;
|
||||
|
||||
// Reset state.code
|
||||
state.code = false;
|
||||
|
||||
// Reset state.trailingSpace
|
||||
state.trailingSpace = 0;
|
||||
state.trailingSpaceNewLine = false;
|
||||
|
||||
state.f = state.block;
|
||||
var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length;
|
||||
var difference = Math.floor((indentation - state.indentation) / 4) * 4;
|
||||
if (difference > 4) difference = 4;
|
||||
var adjustedIndentation = state.indentation + difference;
|
||||
state.indentationDiff = adjustedIndentation - state.indentation;
|
||||
state.indentation = adjustedIndentation;
|
||||
if (indentation > 0) return null;
|
||||
}
|
||||
return state.f(stream, state);
|
||||
},
|
||||
|
||||
innerMode: function(state) {
|
||||
if (state.block == htmlBlock) return {state: state.htmlState, mode: htmlMode};
|
||||
if (state.localState) return {state: state.localState, mode: state.localMode};
|
||||
return {state: state, mode: mode};
|
||||
},
|
||||
|
||||
blankLine: blankLine,
|
||||
|
||||
getType: getType,
|
||||
|
||||
fold: "markdown"
|
||||
};
|
||||
return mode;
|
||||
}, "xml");
|
||||
|
||||
CodeMirror.defineMIME("text/x-markdown", "markdown");
|
||||
|
||||
});
|
|
@ -1,384 +0,0 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
|
||||
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag;
|
||||
if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true;
|
||||
|
||||
var Kludges = parserConfig.htmlMode ? {
|
||||
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
||||
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
||||
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
||||
'track': true, 'wbr': true, 'menuitem': true},
|
||||
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
|
||||
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
|
||||
'th': true, 'tr': true},
|
||||
contextGrabbers: {
|
||||
'dd': {'dd': true, 'dt': true},
|
||||
'dt': {'dd': true, 'dt': true},
|
||||
'li': {'li': true},
|
||||
'option': {'option': true, 'optgroup': true},
|
||||
'optgroup': {'optgroup': true},
|
||||
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
|
||||
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
|
||||
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
|
||||
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
|
||||
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
|
||||
'rp': {'rp': true, 'rt': true},
|
||||
'rt': {'rp': true, 'rt': true},
|
||||
'tbody': {'tbody': true, 'tfoot': true},
|
||||
'td': {'td': true, 'th': true},
|
||||
'tfoot': {'tbody': true},
|
||||
'th': {'td': true, 'th': true},
|
||||
'thead': {'tbody': true, 'tfoot': true},
|
||||
'tr': {'tr': true}
|
||||
},
|
||||
doNotIndent: {"pre": true},
|
||||
allowUnquoted: true,
|
||||
allowMissing: true,
|
||||
caseFold: true
|
||||
} : {
|
||||
autoSelfClosers: {},
|
||||
implicitlyClosed: {},
|
||||
contextGrabbers: {},
|
||||
doNotIndent: {},
|
||||
allowUnquoted: false,
|
||||
allowMissing: false,
|
||||
caseFold: false
|
||||
};
|
||||
var alignCDATA = parserConfig.alignCDATA;
|
||||
|
||||
// Return variables for tokenizers
|
||||
var type, setStyle;
|
||||
|
||||
function inText(stream, state) {
|
||||
function chain(parser) {
|
||||
state.tokenize = parser;
|
||||
return parser(stream, state);
|
||||
}
|
||||
|
||||
var ch = stream.next();
|
||||
if (ch == "<") {
|
||||
if (stream.eat("!")) {
|
||||
if (stream.eat("[")) {
|
||||
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
|
||||
else return null;
|
||||
} else if (stream.match("--")) {
|
||||
return chain(inBlock("comment", "-->"));
|
||||
} else if (stream.match("DOCTYPE", true, true)) {
|
||||
stream.eatWhile(/[\w\._\-]/);
|
||||
return chain(doctype(1));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (stream.eat("?")) {
|
||||
stream.eatWhile(/[\w\._\-]/);
|
||||
state.tokenize = inBlock("meta", "?>");
|
||||
return "meta";
|
||||
} else {
|
||||
type = stream.eat("/") ? "closeTag" : "openTag";
|
||||
state.tokenize = inTag;
|
||||
return "tag bracket";
|
||||
}
|
||||
} else if (ch == "&") {
|
||||
var ok;
|
||||
if (stream.eat("#")) {
|
||||
if (stream.eat("x")) {
|
||||
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
|
||||
}
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
|
||||
}
|
||||
return ok ? "atom" : "error";
|
||||
} else {
|
||||
stream.eatWhile(/[^&<]/);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function inTag(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
|
||||
state.tokenize = inText;
|
||||
type = ch == ">" ? "endTag" : "selfcloseTag";
|
||||
return "tag bracket";
|
||||
} else if (ch == "=") {
|
||||
type = "equals";
|
||||
return null;
|
||||
} else if (ch == "<") {
|
||||
state.tokenize = inText;
|
||||
state.state = baseState;
|
||||
state.tagName = state.tagStart = null;
|
||||
var next = state.tokenize(stream, state);
|
||||
return next ? next + " tag error" : "tag error";
|
||||
} else if (/[\'\"]/.test(ch)) {
|
||||
state.tokenize = inAttribute(ch);
|
||||
state.stringStartCol = stream.column();
|
||||
return state.tokenize(stream, state);
|
||||
} else {
|
||||
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
|
||||
return "word";
|
||||
}
|
||||
}
|
||||
|
||||
function inAttribute(quote) {
|
||||
var closure = function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.next() == quote) {
|
||||
state.tokenize = inTag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "string";
|
||||
};
|
||||
closure.isInAttribute = true;
|
||||
return closure;
|
||||
}
|
||||
|
||||
function inBlock(style, terminator) {
|
||||
return function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.match(terminator)) {
|
||||
state.tokenize = inText;
|
||||
break;
|
||||
}
|
||||
stream.next();
|
||||
}
|
||||
return style;
|
||||
};
|
||||
}
|
||||
function doctype(depth) {
|
||||
return function(stream, state) {
|
||||
var ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == "<") {
|
||||
state.tokenize = doctype(depth + 1);
|
||||
return state.tokenize(stream, state);
|
||||
} else if (ch == ">") {
|
||||
if (depth == 1) {
|
||||
state.tokenize = inText;
|
||||
break;
|
||||
} else {
|
||||
state.tokenize = doctype(depth - 1);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "meta";
|
||||
};
|
||||
}
|
||||
|
||||
function Context(state, tagName, startOfLine) {
|
||||
this.prev = state.context;
|
||||
this.tagName = tagName;
|
||||
this.indent = state.indented;
|
||||
this.startOfLine = startOfLine;
|
||||
if (Kludges.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
|
||||
this.noIndent = true;
|
||||
}
|
||||
function popContext(state) {
|
||||
if (state.context) state.context = state.context.prev;
|
||||
}
|
||||
function maybePopContext(state, nextTagName) {
|
||||
var parentTagName;
|
||||
while (true) {
|
||||
if (!state.context) {
|
||||
return;
|
||||
}
|
||||
parentTagName = state.context.tagName;
|
||||
if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
|
||||
!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
||||
return;
|
||||
}
|
||||
popContext(state);
|
||||
}
|
||||
}
|
||||
|
||||
function baseState(type, stream, state) {
|
||||
if (type == "openTag") {
|
||||
state.tagStart = stream.column();
|
||||
return tagNameState;
|
||||
} else if (type == "closeTag") {
|
||||
return closeTagNameState;
|
||||
} else {
|
||||
return baseState;
|
||||
}
|
||||
}
|
||||
function tagNameState(type, stream, state) {
|
||||
if (type == "word") {
|
||||
state.tagName = stream.current();
|
||||
setStyle = "tag";
|
||||
return attrState;
|
||||
} else {
|
||||
setStyle = "error";
|
||||
return tagNameState;
|
||||
}
|
||||
}
|
||||
function closeTagNameState(type, stream, state) {
|
||||
if (type == "word") {
|
||||
var tagName = stream.current();
|
||||
if (state.context && state.context.tagName != tagName &&
|
||||
Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName))
|
||||
popContext(state);
|
||||
if (state.context && state.context.tagName == tagName) {
|
||||
setStyle = "tag";
|
||||
return closeState;
|
||||
} else {
|
||||
setStyle = "tag error";
|
||||
return closeStateErr;
|
||||
}
|
||||
} else {
|
||||
setStyle = "error";
|
||||
return closeStateErr;
|
||||
}
|
||||
}
|
||||
|
||||
function closeState(type, _stream, state) {
|
||||
if (type != "endTag") {
|
||||
setStyle = "error";
|
||||
return closeState;
|
||||
}
|
||||
popContext(state);
|
||||
return baseState;
|
||||
}
|
||||
function closeStateErr(type, stream, state) {
|
||||
setStyle = "error";
|
||||
return closeState(type, stream, state);
|
||||
}
|
||||
|
||||
function attrState(type, _stream, state) {
|
||||
if (type == "word") {
|
||||
setStyle = "attribute";
|
||||
return attrEqState;
|
||||
} else if (type == "endTag" || type == "selfcloseTag") {
|
||||
var tagName = state.tagName, tagStart = state.tagStart;
|
||||
state.tagName = state.tagStart = null;
|
||||
if (type == "selfcloseTag" ||
|
||||
Kludges.autoSelfClosers.hasOwnProperty(tagName)) {
|
||||
maybePopContext(state, tagName);
|
||||
} else {
|
||||
maybePopContext(state, tagName);
|
||||
state.context = new Context(state, tagName, tagStart == state.indented);
|
||||
}
|
||||
return baseState;
|
||||
}
|
||||
setStyle = "error";
|
||||
return attrState;
|
||||
}
|
||||
function attrEqState(type, stream, state) {
|
||||
if (type == "equals") return attrValueState;
|
||||
if (!Kludges.allowMissing) setStyle = "error";
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
function attrValueState(type, stream, state) {
|
||||
if (type == "string") return attrContinuedState;
|
||||
if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return attrState;}
|
||||
setStyle = "error";
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
function attrContinuedState(type, stream, state) {
|
||||
if (type == "string") return attrContinuedState;
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {tokenize: inText,
|
||||
state: baseState,
|
||||
indented: 0,
|
||||
tagName: null, tagStart: null,
|
||||
context: null};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (!state.tagName && stream.sol())
|
||||
state.indented = stream.indentation();
|
||||
|
||||
if (stream.eatSpace()) return null;
|
||||
type = null;
|
||||
var style = state.tokenize(stream, state);
|
||||
if ((style || type) && style != "comment") {
|
||||
setStyle = null;
|
||||
state.state = state.state(type || style, stream, state);
|
||||
if (setStyle)
|
||||
style = setStyle == "error" ? style + " error" : setStyle;
|
||||
}
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter, fullLine) {
|
||||
var context = state.context;
|
||||
// Indent multi-line strings (e.g. css).
|
||||
if (state.tokenize.isInAttribute) {
|
||||
if (state.tagStart == state.indented)
|
||||
return state.stringStartCol + 1;
|
||||
else
|
||||
return state.indented + indentUnit;
|
||||
}
|
||||
if (context && context.noIndent) return CodeMirror.Pass;
|
||||
if (state.tokenize != inTag && state.tokenize != inText)
|
||||
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
||||
// Indent the starts of attribute names.
|
||||
if (state.tagName) {
|
||||
if (multilineTagIndentPastTag)
|
||||
return state.tagStart + state.tagName.length + 2;
|
||||
else
|
||||
return state.tagStart + indentUnit * multilineTagIndentFactor;
|
||||
}
|
||||
if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
|
||||
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
|
||||
if (tagAfter && tagAfter[1]) { // Closing tag spotted
|
||||
while (context) {
|
||||
if (context.tagName == tagAfter[2]) {
|
||||
context = context.prev;
|
||||
break;
|
||||
} else if (Kludges.implicitlyClosed.hasOwnProperty(context.tagName)) {
|
||||
context = context.prev;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (tagAfter) { // Opening tag spotted
|
||||
while (context) {
|
||||
var grabbers = Kludges.contextGrabbers[context.tagName];
|
||||
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
|
||||
context = context.prev;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (context && !context.startOfLine)
|
||||
context = context.prev;
|
||||
if (context) return context.indent + indentUnit;
|
||||
else return 0;
|
||||
},
|
||||
|
||||
electricInput: /<\/[\s\w:]+>$/,
|
||||
blockCommentStart: "<!--",
|
||||
blockCommentEnd: "-->",
|
||||
|
||||
configuration: parserConfig.htmlMode ? "html" : "xml",
|
||||
helperType: parserConfig.htmlMode ? "html" : "xml"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/xml", "xml");
|
||||
CodeMirror.defineMIME("application/xml", "xml");
|
||||
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
|
||||
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
||||
|
||||
});
|
1801
source files/font-awesome.css
vendored
1801
source files/font-awesome.css
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,694 +0,0 @@
|
|||
var isMac = /Mac/.test(navigator.platform);
|
||||
|
||||
var shortcuts = {
|
||||
'Cmd-B': toggleBold,
|
||||
'Cmd-I': toggleItalic,
|
||||
'Cmd-K': drawLink,
|
||||
'Cmd-Alt-I': drawImage,
|
||||
"Cmd-'": toggleBlockquote,
|
||||
'Cmd-Alt-L': toggleOrderedList,
|
||||
'Cmd-L': toggleUnOrderedList
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Fix shortcut. Mac use Command, others use Ctrl.
|
||||
*/
|
||||
function fixShortcut(name) {
|
||||
if (isMac) {
|
||||
name = name.replace('Ctrl', 'Cmd');
|
||||
} else {
|
||||
name = name.replace('Cmd', 'Ctrl');
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create icon element for toolbar.
|
||||
*/
|
||||
function createIcon(name, options) {
|
||||
options = options || {};
|
||||
var el = document.createElement('a');
|
||||
|
||||
var shortcut = options.shortcut || shortcuts[name];
|
||||
if (shortcut) {
|
||||
shortcut = fixShortcut(shortcut);
|
||||
el.title = shortcut;
|
||||
el.title = el.title.replace('Cmd', '⌘');
|
||||
if (isMac) {
|
||||
el.title = el.title.replace('Alt', '⌥');
|
||||
}
|
||||
}
|
||||
|
||||
el.className = options.className || 'icon-' + name;
|
||||
return el;
|
||||
}
|
||||
|
||||
function createSep() {
|
||||
el = document.createElement('i');
|
||||
el.className = 'separator';
|
||||
el.innerHTML = '|';
|
||||
return el;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The state of CodeMirror at the given position.
|
||||
*/
|
||||
function getState(cm, pos) {
|
||||
pos = pos || cm.getCursor('start');
|
||||
var stat = cm.getTokenAt(pos);
|
||||
if (!stat.type) return {};
|
||||
|
||||
var types = stat.type.split(' ');
|
||||
|
||||
var ret = {},
|
||||
data, text;
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
data = types[i];
|
||||
if (data === 'strong') {
|
||||
ret.bold = true;
|
||||
} else if (data === 'variable-2') {
|
||||
text = cm.getLine(pos.line);
|
||||
if (/^\s*\d+\.\s/.test(text)) {
|
||||
ret['ordered-list'] = true;
|
||||
} else {
|
||||
ret['unordered-list'] = true;
|
||||
}
|
||||
} else if (data === 'atom') {
|
||||
ret.quote = true;
|
||||
} else if (data === 'em') {
|
||||
ret.italic = true;
|
||||
} else if (data === 'quote') {
|
||||
ret.quote = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Toggle full screen of the editor.
|
||||
*/
|
||||
function toggleFullScreen(editor) {
|
||||
var el = editor.codemirror.getWrapperElement();
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode
|
||||
var doc = document;
|
||||
var isFull = doc.fullScreen || doc.mozFullScreen || doc.webkitFullScreen;
|
||||
var request = function() {
|
||||
if (el.requestFullScreen) {
|
||||
el.requestFullScreen();
|
||||
} else if (el.mozRequestFullScreen) {
|
||||
el.mozRequestFullScreen();
|
||||
} else if (el.webkitRequestFullScreen) {
|
||||
el.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
||||
}
|
||||
};
|
||||
var cancel = function() {
|
||||
if (doc.cancelFullScreen) {
|
||||
doc.cancelFullScreen();
|
||||
} else if (doc.mozCancelFullScreen) {
|
||||
doc.mozCancelFullScreen();
|
||||
} else if (doc.webkitCancelFullScreen) {
|
||||
doc.webkitCancelFullScreen();
|
||||
}
|
||||
};
|
||||
if (!isFull) {
|
||||
request();
|
||||
} else if (cancel) {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action for toggling bold.
|
||||
*/
|
||||
function toggleBold(editor) {
|
||||
_toggleBlock(editor, 'bold', '**');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action for toggling italic.
|
||||
*/
|
||||
function toggleItalic(editor) {
|
||||
_toggleBlock(editor, 'italic', '*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Action for toggling code block.
|
||||
*/
|
||||
function toggleCodeBlock(editor) {
|
||||
_toggleBlock(editor, 'code', '```\r\n', '\r\n```');
|
||||
}
|
||||
|
||||
/**
|
||||
* Action for toggling blockquote.
|
||||
*/
|
||||
function toggleBlockquote(editor) {
|
||||
var cm = editor.codemirror;
|
||||
_toggleLine(cm, 'quote');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action for toggling ul.
|
||||
*/
|
||||
function toggleUnOrderedList(editor) {
|
||||
var cm = editor.codemirror;
|
||||
_toggleLine(cm, 'unordered-list');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action for toggling ol.
|
||||
*/
|
||||
function toggleOrderedList(editor) {
|
||||
var cm = editor.codemirror;
|
||||
_toggleLine(cm, 'ordered-list');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action for drawing a link.
|
||||
*/
|
||||
function drawLink(editor) {
|
||||
var cm = editor.codemirror;
|
||||
var stat = getState(cm);
|
||||
_replaceSelection(cm, stat.link, '[', '](http://)');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action for drawing an img.
|
||||
*/
|
||||
function drawImage(editor) {
|
||||
var cm = editor.codemirror;
|
||||
var stat = getState(cm);
|
||||
_replaceSelection(cm, stat.image, '![Short description of image](http://', ')');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Undo action.
|
||||
*/
|
||||
function undo(editor) {
|
||||
var cm = editor.codemirror;
|
||||
cm.undo();
|
||||
cm.focus();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Redo action.
|
||||
*/
|
||||
function redo(editor) {
|
||||
var cm = editor.codemirror;
|
||||
cm.redo();
|
||||
cm.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview action.
|
||||
*/
|
||||
function togglePreview(editor) {
|
||||
var toolbar_div = document.getElementsByClassName('editor-toolbar')[0];
|
||||
var toolbar = editor.toolbar.preview;
|
||||
var parse = editor.constructor.markdown;
|
||||
var cm = editor.codemirror;
|
||||
var wrapper = cm.getWrapperElement();
|
||||
var preview = wrapper.lastChild;
|
||||
if (!/editor-preview/.test(preview.className)) {
|
||||
preview = document.createElement('div');
|
||||
preview.className = 'editor-preview';
|
||||
wrapper.appendChild(preview);
|
||||
}
|
||||
if (/editor-preview-active/.test(preview.className)) {
|
||||
preview.className = preview.className.replace(
|
||||
/\s*editor-preview-active\s*/g, ''
|
||||
);
|
||||
toolbar.className = toolbar.className.replace(/\s*active\s*/g, '');
|
||||
toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview\s*/g, '');
|
||||
} else {
|
||||
/* When the preview button is clicked for the first time,
|
||||
* give some time for the transition from editor.css to fire and the view to slide from right to left,
|
||||
* instead of just appearing.
|
||||
*/
|
||||
setTimeout(function() {
|
||||
preview.className += ' editor-preview-active'
|
||||
}, 1);
|
||||
toolbar.className += ' active';
|
||||
toolbar_div.className += ' disabled-for-preview';
|
||||
}
|
||||
var text = cm.getValue();
|
||||
preview.innerHTML = parse(text);
|
||||
}
|
||||
|
||||
function _replaceSelection(cm, active, start, end) {
|
||||
if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
|
||||
return;
|
||||
|
||||
var text;
|
||||
var startPoint = cm.getCursor('start');
|
||||
var endPoint = cm.getCursor('end');
|
||||
if (active) {
|
||||
text = cm.getLine(startPoint.line);
|
||||
start = text.slice(0, startPoint.ch);
|
||||
end = text.slice(startPoint.ch);
|
||||
cm.replaceRange(start + end, {
|
||||
line: startPoint.line,
|
||||
ch: 0
|
||||
});
|
||||
} else {
|
||||
text = cm.getSelection();
|
||||
cm.replaceSelection(start + text + end);
|
||||
|
||||
startPoint.ch += start.length;
|
||||
endPoint.ch += start.length;
|
||||
}
|
||||
cm.setSelection(startPoint, endPoint);
|
||||
cm.focus();
|
||||
}
|
||||
|
||||
|
||||
function _toggleLine(cm, name) {
|
||||
if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
|
||||
return;
|
||||
|
||||
var stat = getState(cm);
|
||||
var startPoint = cm.getCursor('start');
|
||||
var endPoint = cm.getCursor('end');
|
||||
var repl = {
|
||||
'quote': /^(\s*)\>\s+/,
|
||||
'unordered-list': /^(\s*)(\*|\-|\+)\s+/,
|
||||
'ordered-list': /^(\s*)\d+\.\s+/
|
||||
};
|
||||
var map = {
|
||||
'quote': '> ',
|
||||
'unordered-list': '* ',
|
||||
'ordered-list': '1. '
|
||||
};
|
||||
for (var i = startPoint.line; i <= endPoint.line; i++) {
|
||||
(function(i) {
|
||||
var text = cm.getLine(i);
|
||||
if (stat[name]) {
|
||||
text = text.replace(repl[name], '$1');
|
||||
} else {
|
||||
text = map[name] + text;
|
||||
}
|
||||
cm.replaceRange(text, {
|
||||
line: i,
|
||||
ch: 0
|
||||
}, {
|
||||
line: i,
|
||||
ch: 99999999999999
|
||||
});
|
||||
})(i);
|
||||
}
|
||||
cm.focus();
|
||||
}
|
||||
|
||||
function _toggleBlock(editor, type, start_chars, end_chars) {
|
||||
if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
|
||||
return;
|
||||
|
||||
end_chars = (typeof end_chars === 'undefined') ? start_chars : end_chars;
|
||||
var cm = editor.codemirror;
|
||||
var stat = getState(cm);
|
||||
|
||||
var text;
|
||||
var start = start_chars;
|
||||
var end = end_chars;
|
||||
|
||||
var startPoint = cm.getCursor('start');
|
||||
var endPoint = cm.getCursor('end');
|
||||
|
||||
if (stat[type]) {
|
||||
text = cm.getLine(startPoint.line);
|
||||
start = text.slice(0, startPoint.ch);
|
||||
end = text.slice(startPoint.ch);
|
||||
if (type == "bold") {
|
||||
start = start.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/, "");
|
||||
end = end.replace(/(\*\*|__)/, "");
|
||||
} else if (type == "italic") {
|
||||
start = start.replace(/(\*|_)(?![\s\S]*(\*|_))/, "");
|
||||
end = end.replace(/(\*|_)/, "");
|
||||
}
|
||||
cm.replaceRange(start + end, {
|
||||
line: startPoint.line,
|
||||
ch: 0
|
||||
}, {
|
||||
line: startPoint.line,
|
||||
ch: 99999999999999
|
||||
});
|
||||
|
||||
if (type == "bold") {
|
||||
startPoint.ch -= 2;
|
||||
endPoint.ch -= 2;
|
||||
} else if (type == "italic") {
|
||||
startPoint.ch -= 1;
|
||||
endPoint.ch -= 1;
|
||||
}
|
||||
} else {
|
||||
text = cm.getSelection();
|
||||
if (type == "bold") {
|
||||
text = text.split("**").join("");
|
||||
text = text.split("__").join("");
|
||||
} else if (type == "italic") {
|
||||
text = text.split("*").join("");
|
||||
text = text.split("_").join("");
|
||||
}
|
||||
cm.replaceSelection(start + text + end);
|
||||
|
||||
startPoint.ch += start_chars.length;
|
||||
endPoint.ch = startPoint.ch + text.length;
|
||||
}
|
||||
|
||||
cm.setSelection(startPoint, endPoint);
|
||||
cm.focus();
|
||||
}
|
||||
|
||||
|
||||
/* The right word count in respect for CJK. */
|
||||
function wordCount(data) {
|
||||
var pattern = /[a-zA-Z0-9_\u0392-\u03c9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
|
||||
var m = data.match(pattern);
|
||||
var count = 0;
|
||||
if (m === null) return count;
|
||||
for (var i = 0; i < m.length; i++) {
|
||||
if (m[i].charCodeAt(0) >= 0x4E00) {
|
||||
count += m[i].length;
|
||||
} else {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
var toolbar = [{
|
||||
name: 'bold',
|
||||
action: toggleBold,
|
||||
className: "fa fa-bold"
|
||||
}, {
|
||||
name: 'italic',
|
||||
action: toggleItalic,
|
||||
className: "fa fa-italic"
|
||||
},
|
||||
'|',
|
||||
|
||||
{
|
||||
name: 'quote',
|
||||
action: toggleBlockquote,
|
||||
className: "fa fa-quote-left"
|
||||
}, {
|
||||
name: 'unordered-list',
|
||||
action: toggleUnOrderedList,
|
||||
className: "fa fa-list-ul"
|
||||
}, {
|
||||
name: 'ordered-list',
|
||||
action: toggleOrderedList,
|
||||
className: "fa fa-list-ol"
|
||||
},
|
||||
'|',
|
||||
|
||||
{
|
||||
name: 'link',
|
||||
action: drawLink,
|
||||
className: "fa fa-link"
|
||||
}, {
|
||||
name: 'image',
|
||||
action: drawImage,
|
||||
className: "fa fa-picture-o"
|
||||
},
|
||||
'|',
|
||||
|
||||
{
|
||||
name: 'preview',
|
||||
action: togglePreview,
|
||||
className: "fa fa-eye"
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Interface of SimpleMDE.
|
||||
*/
|
||||
function SimpleMDE(options) {
|
||||
options = options || {};
|
||||
|
||||
if (options.element) {
|
||||
this.element = options.element;
|
||||
}
|
||||
|
||||
options.toolbar = options.toolbar || SimpleMDE.toolbar;
|
||||
// you can customize toolbar with object
|
||||
// [{name: 'bold', shortcut: 'Ctrl-B', className: 'icon-bold'}]
|
||||
|
||||
if (!options.hasOwnProperty('status')) {
|
||||
options.status = ['lines', 'words', 'cursor'];
|
||||
}
|
||||
|
||||
this.options = options;
|
||||
|
||||
// If user has passed an element, it should auto rendered
|
||||
if (this.element) {
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default toolbar elements.
|
||||
*/
|
||||
SimpleMDE.toolbar = toolbar;
|
||||
|
||||
/**
|
||||
* Default markdown render.
|
||||
*/
|
||||
SimpleMDE.markdown = function(text) {
|
||||
if (window.marked) {
|
||||
// use marked as markdown parser
|
||||
return marked(text);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Render editor to the given element.
|
||||
*/
|
||||
SimpleMDE.prototype.render = function(el) {
|
||||
if (!el) {
|
||||
el = this.element || document.getElementsByTagName('textarea')[0];
|
||||
}
|
||||
|
||||
if (this._rendered && this._rendered === el) {
|
||||
// Already rendered.
|
||||
return;
|
||||
}
|
||||
|
||||
this.element = el;
|
||||
var options = this.options;
|
||||
|
||||
var self = this;
|
||||
var keyMaps = {};
|
||||
|
||||
for (var key in shortcuts) {
|
||||
(function(key) {
|
||||
keyMaps[fixShortcut(key)] = function(cm) {
|
||||
shortcuts[key](self);
|
||||
};
|
||||
})(key);
|
||||
}
|
||||
|
||||
keyMaps["Enter"] = "newlineAndIndentContinueMarkdownList";
|
||||
keyMaps['Tab'] = 'tabAndIndentContinueMarkdownList';
|
||||
keyMaps['Shift-Tab'] = 'shiftTabAndIndentContinueMarkdownList';
|
||||
|
||||
this.codemirror = CodeMirror.fromTextArea(el, {
|
||||
mode: 'markdown',
|
||||
theme: 'paper',
|
||||
tabSize: '2',
|
||||
indentWithTabs: true,
|
||||
lineNumbers: false,
|
||||
autofocus: false,
|
||||
extraKeys: keyMaps,
|
||||
lineWrapping: true
|
||||
});
|
||||
|
||||
if (options.toolbar !== false) {
|
||||
this.createToolbar();
|
||||
}
|
||||
if (options.status !== false) {
|
||||
this.createStatusbar();
|
||||
}
|
||||
|
||||
this._rendered = this.element;
|
||||
};
|
||||
|
||||
SimpleMDE.prototype.createToolbar = function(items) {
|
||||
items = items || this.options.toolbar;
|
||||
|
||||
if (!items || items.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var bar = document.createElement('div');
|
||||
bar.className = 'editor-toolbar';
|
||||
|
||||
var self = this;
|
||||
|
||||
var el;
|
||||
self.toolbar = {};
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
(function(item) {
|
||||
var el;
|
||||
if (item.name) {
|
||||
el = createIcon(item.name, item);
|
||||
} else if (item === '|') {
|
||||
el = createSep();
|
||||
} else {
|
||||
el = createIcon(item);
|
||||
}
|
||||
|
||||
// bind events, special for info
|
||||
if (item.action) {
|
||||
if (typeof item.action === 'function') {
|
||||
el.onclick = function(e) {
|
||||
item.action(self);
|
||||
};
|
||||
} else if (typeof item.action === 'string') {
|
||||
el.href = item.action;
|
||||
el.target = '_blank';
|
||||
}
|
||||
}
|
||||
self.toolbar[item.name || item] = el;
|
||||
bar.appendChild(el);
|
||||
})(items[i]);
|
||||
}
|
||||
|
||||
var cm = this.codemirror;
|
||||
cm.on('cursorActivity', function() {
|
||||
var stat = getState(cm);
|
||||
|
||||
for (var key in self.toolbar) {
|
||||
(function(key) {
|
||||
var el = self.toolbar[key];
|
||||
if (stat[key]) {
|
||||
el.className += ' active';
|
||||
} else {
|
||||
el.className = el.className.replace(/\s*active\s*/g, '');
|
||||
}
|
||||
})(key);
|
||||
}
|
||||
});
|
||||
|
||||
var cmWrapper = cm.getWrapperElement();
|
||||
cmWrapper.parentNode.insertBefore(bar, cmWrapper);
|
||||
return bar;
|
||||
};
|
||||
|
||||
SimpleMDE.prototype.createStatusbar = function(status) {
|
||||
status = status || this.options.status;
|
||||
|
||||
if (!status || status.length === 0) return;
|
||||
|
||||
var bar = document.createElement('div');
|
||||
bar.className = 'editor-statusbar';
|
||||
|
||||
var pos, cm = this.codemirror;
|
||||
for (var i = 0; i < status.length; i++) {
|
||||
(function(name) {
|
||||
var el = document.createElement('span');
|
||||
el.className = name;
|
||||
if (name === 'words') {
|
||||
el.innerHTML = '0';
|
||||
cm.on('update', function() {
|
||||
el.innerHTML = wordCount(cm.getValue());
|
||||
});
|
||||
} else if (name === 'lines') {
|
||||
el.innerHTML = '0';
|
||||
cm.on('update', function() {
|
||||
el.innerHTML = cm.lineCount();
|
||||
});
|
||||
} else if (name === 'cursor') {
|
||||
el.innerHTML = '0:0';
|
||||
cm.on('cursorActivity', function() {
|
||||
pos = cm.getCursor();
|
||||
el.innerHTML = pos.line + ':' + pos.ch;
|
||||
});
|
||||
}
|
||||
bar.appendChild(el);
|
||||
})(status[i]);
|
||||
}
|
||||
var cmWrapper = this.codemirror.getWrapperElement();
|
||||
cmWrapper.parentNode.insertBefore(bar, cmWrapper.nextSibling);
|
||||
return bar;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get or set the text content.
|
||||
*/
|
||||
SimpleMDE.prototype.value = function(val) {
|
||||
if (val) {
|
||||
this.codemirror.getDoc().setValue(val);
|
||||
return this;
|
||||
} else {
|
||||
return this.codemirror.getValue();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Bind static methods for exports.
|
||||
*/
|
||||
SimpleMDE.toggleBold = toggleBold;
|
||||
SimpleMDE.toggleItalic = toggleItalic;
|
||||
SimpleMDE.toggleBlockquote = toggleBlockquote;
|
||||
SimpleMDE.toggleUnOrderedList = toggleUnOrderedList;
|
||||
SimpleMDE.toggleOrderedList = toggleOrderedList;
|
||||
SimpleMDE.drawLink = drawLink;
|
||||
SimpleMDE.drawImage = drawImage;
|
||||
SimpleMDE.undo = undo;
|
||||
SimpleMDE.redo = redo;
|
||||
SimpleMDE.togglePreview = togglePreview;
|
||||
SimpleMDE.toggleFullScreen = toggleFullScreen;
|
||||
|
||||
/**
|
||||
* Bind instance methods for exports.
|
||||
*/
|
||||
SimpleMDE.prototype.toggleBold = function() {
|
||||
toggleBold(this);
|
||||
};
|
||||
SimpleMDE.prototype.toggleItalic = function() {
|
||||
toggleItalic(this);
|
||||
};
|
||||
SimpleMDE.prototype.toggleBlockquote = function() {
|
||||
toggleBlockquote(this);
|
||||
};
|
||||
SimpleMDE.prototype.toggleUnOrderedList = function() {
|
||||
toggleUnOrderedList(this);
|
||||
};
|
||||
SimpleMDE.prototype.toggleOrderedList = function() {
|
||||
toggleOrderedList(this);
|
||||
};
|
||||
SimpleMDE.prototype.drawLink = function() {
|
||||
drawLink(this);
|
||||
};
|
||||
SimpleMDE.prototype.drawImage = function() {
|
||||
drawImage(this);
|
||||
};
|
||||
SimpleMDE.prototype.undo = function() {
|
||||
undo(this);
|
||||
};
|
||||
SimpleMDE.prototype.redo = function() {
|
||||
redo(this);
|
||||
};
|
||||
SimpleMDE.prototype.togglePreview = function() {
|
||||
togglePreview(this);
|
||||
};
|
||||
SimpleMDE.prototype.toggleFullScreen = function() {
|
||||
toggleFullScreen(this);
|
||||
};
|
File diff suppressed because it is too large
Load diff
|
@ -1,396 +0,0 @@
|
|||
.CodeMirror {
|
||||
height: auto;
|
||||
min-height: 300px;
|
||||
border: 1px solid #ddd;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
padding: 10px
|
||||
}
|
||||
.CodeMirror-scroll {
|
||||
min-height: 300px;
|
||||
}
|
||||
:-webkit-full-screen {
|
||||
background: #f9f9f5;
|
||||
padding: .5em 1em;
|
||||
width: 100%;
|
||||
height: 100%
|
||||
}
|
||||
:-moz-full-screen {
|
||||
padding: .5em 1em;
|
||||
background: #f9f9f5;
|
||||
width: 100%;
|
||||
height: 100%
|
||||
}
|
||||
.editor-wrapper {
|
||||
font: 16px/1.62 "Helvetica Neue", "Xin Gothic", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft YaHei", sans-serif;
|
||||
color: #2c3e50
|
||||
}
|
||||
.editor-wrapper input.title {
|
||||
font: 18px "Helvetica Neue", "Xin Gothic", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft YaHei", sans-serif;
|
||||
background: 0 0;
|
||||
padding: 4px;
|
||||
width: 100%;
|
||||
border: none;
|
||||
outline: 0;
|
||||
opacity: .6
|
||||
}
|
||||
.editor-toolbar {
|
||||
position: relative;
|
||||
opacity: .6;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-o-user-select: none;
|
||||
user-select: none;
|
||||
padding: 0 10px;
|
||||
border-top: 1px solid #bbb;
|
||||
border-left: 1px solid #bbb;
|
||||
border-right: 1px solid #bbb;
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px
|
||||
}
|
||||
.editor-toolbar:after,
|
||||
.editor-toolbar:before {
|
||||
display: block;
|
||||
content: ' ';
|
||||
height: 1px
|
||||
}
|
||||
.editor-toolbar:before {
|
||||
margin-bottom: 8px
|
||||
}
|
||||
.editor-toolbar:after {
|
||||
margin-top: 8px
|
||||
}
|
||||
.editor-toolbar:hover,
|
||||
.editor-wrapper input.title:focus,
|
||||
.editor-wrapper input.title:hover {
|
||||
opacity: .8
|
||||
}
|
||||
.editor-toolbar a {
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
text-decoration: none!important;
|
||||
color: #2c3e50!important;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin: 0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 3px;
|
||||
cursor: pointer
|
||||
}
|
||||
.editor-toolbar a.active,
|
||||
.editor-toolbar a:hover {
|
||||
background: #fcfcfc;
|
||||
border-color: #95a5a6
|
||||
}
|
||||
.editor-toolbar a:before {
|
||||
line-height: 30px
|
||||
}
|
||||
.editor-toolbar i.separator {
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
border-left: 1px solid #d9d9d9;
|
||||
border-right: 1px solid #fff;
|
||||
color: transparent;
|
||||
text-indent: -10px;
|
||||
margin: 0 6px
|
||||
}
|
||||
.editor-toolbar a.icon-fullscreen {
|
||||
position: absolute;
|
||||
right: 10px
|
||||
}
|
||||
.editor-toolbar.disabled-for-preview a:not(.fa-eye){
|
||||
pointer-events:none;
|
||||
background:#fff;
|
||||
border:none;
|
||||
}
|
||||
.editor-statusbar {
|
||||
padding: 8px 10px;
|
||||
font-size: 12px;
|
||||
color: #959694;
|
||||
text-align: right
|
||||
}
|
||||
.editor-statusbar span {
|
||||
display: inline-block;
|
||||
min-width: 4em;
|
||||
margin-left: 1em
|
||||
}
|
||||
.editor-statusbar .lines:before {
|
||||
content: 'lines: '
|
||||
}
|
||||
.editor-statusbar .words:before {
|
||||
content: 'words: '
|
||||
}
|
||||
.editor-preview {
|
||||
padding: 10px;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: #fafafa;
|
||||
z-index: 9999;
|
||||
overflow: auto;
|
||||
display: none
|
||||
}
|
||||
.editor-preview-active {
|
||||
display: block
|
||||
}
|
||||
.editor-preview>p {
|
||||
margin-top: 0
|
||||
}
|
||||
.editor-preview pre {
|
||||
background: #eee;
|
||||
margin-bottom: 10px
|
||||
}
|
||||
.CodeMirror-scroll {
|
||||
overflow: auto
|
||||
}
|
||||
.CodeMirror-lines {
|
||||
padding: 4px 0
|
||||
}
|
||||
.CodeMirror pre {
|
||||
padding: 0 4px
|
||||
}
|
||||
.CodeMirror-scrollbar-filler {
|
||||
background-color: #fff
|
||||
}
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
border-left: 1px solid #000;
|
||||
z-index: 3
|
||||
}
|
||||
.CodeMirror div.CodeMirror-secondarycursor {
|
||||
border-left: 1px solid silver
|
||||
}
|
||||
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
background: #7e7;
|
||||
z-index: 1
|
||||
}
|
||||
.cm-s-paper .cm-keyword {
|
||||
color: #555
|
||||
}
|
||||
.cm-s-paper .cm-atom,
|
||||
.cm-s-paper .cm-number {
|
||||
color: #7f8c8d
|
||||
}
|
||||
.cm-s-paper .cm-def {
|
||||
color: #00f
|
||||
}
|
||||
.cm-s-paper .cm-variable {
|
||||
color: #000
|
||||
}
|
||||
.cm-s-paper .cm-variable-2 {
|
||||
color: #555
|
||||
}
|
||||
.cm-s-paper .cm-variable-3 {
|
||||
color: #085
|
||||
}
|
||||
.cm-s-paper .cm-operator,
|
||||
.cm-s-paper .cm-property {
|
||||
color: #000
|
||||
}
|
||||
.cm-s-paper .cm-comment {
|
||||
color: #959595
|
||||
}
|
||||
.cm-s-paper .cm-string {
|
||||
color: #7f8c8d
|
||||
}
|
||||
.cm-s-paper .cm-string-2 {
|
||||
color: #f50
|
||||
}
|
||||
.cm-s-paper .cm-meta {
|
||||
color: #555
|
||||
}
|
||||
.cm-s-paper .cm-error {
|
||||
color: red
|
||||
}
|
||||
.cm-s-paper .cm-builtin,
|
||||
.cm-s-paper .cm-qualifier {
|
||||
color: #555
|
||||
}
|
||||
.cm-s-paper .cm-bracket {
|
||||
color: #997
|
||||
}
|
||||
.cm-s-paper .cm-attribute,
|
||||
.cm-s-paper .cm-tag {
|
||||
color: #7f8c8d
|
||||
}
|
||||
.cm-s-paper .cm-header {
|
||||
color: #000
|
||||
}
|
||||
.cm-s-paper .cm-quote {
|
||||
color: #888
|
||||
}
|
||||
.cm-s-paper .cm-hr {
|
||||
color: #999
|
||||
}
|
||||
.cm-s-paper .cm-link {
|
||||
color: #7f8c8d
|
||||
}
|
||||
.cm-negative {
|
||||
color: #d44
|
||||
}
|
||||
.cm-positive {
|
||||
color: #292
|
||||
}
|
||||
.cm-header,
|
||||
.cm-strong {
|
||||
font-weight: 700
|
||||
}
|
||||
.cm-em {
|
||||
font-style: italic
|
||||
}
|
||||
.cm-link {
|
||||
text-decoration: underline
|
||||
}
|
||||
.cm-invalidchar {
|
||||
color: red
|
||||
}
|
||||
div.CodeMirror span.CodeMirror-matchingbracket {
|
||||
color: #0f0
|
||||
}
|
||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {
|
||||
color: #f22
|
||||
}
|
||||
.CodeMirror {
|
||||
position: relative;
|
||||
overflow: hidden
|
||||
}
|
||||
.CodeMirror-scroll {
|
||||
margin-bottom: -30px;
|
||||
margin-right: -30px;
|
||||
padding-bottom: 30px;
|
||||
padding-right: 30px;
|
||||
height: 100%;
|
||||
min-height: 300px;
|
||||
outline: 0;
|
||||
position: relative
|
||||
}
|
||||
.CodeMirror-sizer {
|
||||
position: relative
|
||||
}
|
||||
.CodeMirror-hscrollbar,
|
||||
.CodeMirror-scrollbar-filler,
|
||||
.CodeMirror-vscrollbar {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
display: none
|
||||
}
|
||||
.CodeMirror-vscrollbar {
|
||||
right: 0;
|
||||
top: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll
|
||||
}
|
||||
.CodeMirror-hscrollbar {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
overflow-y: hidden;
|
||||
overflow-x: scroll
|
||||
}
|
||||
.CodeMirror-scrollbar-filler {
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 6
|
||||
}
|
||||
.CodeMirror-lines {
|
||||
cursor: text
|
||||
}
|
||||
.CodeMirror pre {
|
||||
-moz-border-radius: 0;
|
||||
-webkit-border-radius: 0;
|
||||
-o-border-radius: 0;
|
||||
border-radius: 0;
|
||||
border-width: 0;
|
||||
background: 0 0;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: normal;
|
||||
line-height: inherit;
|
||||
color: inherit;
|
||||
z-index: 2;
|
||||
position: relative;
|
||||
overflow: visible
|
||||
}
|
||||
.CodeMirror-wrap pre {
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
word-break: normal
|
||||
}
|
||||
.CodeMirror-linebackground {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
z-index: 0
|
||||
}
|
||||
.CodeMirror-linewidget {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
overflow: auto
|
||||
}
|
||||
.CodeMirror-widget {
|
||||
display: inline-block
|
||||
}
|
||||
.CodeMirror-wrap .CodeMirror-scroll {
|
||||
overflow-x: hidden
|
||||
}
|
||||
.CodeMirror-measure {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
visibility: hidden
|
||||
}
|
||||
.CodeMirror-measure pre {
|
||||
position: static
|
||||
}
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
border-right: none;
|
||||
width: 0
|
||||
}
|
||||
.CodeMirror-focused div.CodeMirror-cursor {
|
||||
visibility: visible
|
||||
}
|
||||
.CodeMirror-selected {
|
||||
background: #d9d9d9
|
||||
}
|
||||
.CodeMirror-focused .CodeMirror-selected {
|
||||
background: #BDC3C7
|
||||
}
|
||||
.cm-searching {
|
||||
background: #ffa;
|
||||
background: rgba(255, 255, 0, .4)
|
||||
}
|
||||
@media print {
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
visibility: hidden
|
||||
}
|
||||
}
|
||||
.CodeMirror .CodeMirror-code .cm-header-1 {
|
||||
font-size: 200%;
|
||||
line-height: 200%
|
||||
}
|
||||
.CodeMirror .CodeMirror-code .cm-header-2 {
|
||||
font-size: 160%;
|
||||
line-height: 160%
|
||||
}
|
||||
.CodeMirror .CodeMirror-code .cm-header-3 {
|
||||
font-size: 125%;
|
||||
line-height: 125%
|
||||
}
|
||||
.CodeMirror .CodeMirror-code .cm-header-4 {
|
||||
font-size: 110%;
|
||||
line-height: 110%
|
||||
}
|
||||
.CodeMirror .CodeMirror-code .cm-comment {
|
||||
background: #eee;
|
||||
border-radius: 2px
|
||||
}
|
328
src/css/simplemde.css
Normal file
328
src/css/simplemde.css
Normal file
|
@ -0,0 +1,328 @@
|
|||
.CodeMirror {
|
||||
height: auto;
|
||||
min-height: 300px;
|
||||
border: 1px solid #ddd;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
padding: 10px;
|
||||
font: inherit;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.CodeMirror-scroll {
|
||||
min-height: 300px
|
||||
}
|
||||
|
||||
.CodeMirror-fullscreen {
|
||||
background: #fff;
|
||||
position: fixed !important;
|
||||
top: 50px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
height: auto;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
.CodeMirror-sided {
|
||||
width: 50% !important;
|
||||
}
|
||||
|
||||
.editor-toolbar {
|
||||
position: relative;
|
||||
opacity: .6;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-o-user-select: none;
|
||||
user-select: none;
|
||||
padding: 0 10px;
|
||||
border-top: 1px solid #bbb;
|
||||
border-left: 1px solid #bbb;
|
||||
border-right: 1px solid #bbb;
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
|
||||
.editor-toolbar:after,
|
||||
.editor-toolbar:before {
|
||||
display: block;
|
||||
content: ' ';
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
.editor-toolbar:before {
|
||||
margin-bottom: 8px
|
||||
}
|
||||
|
||||
.editor-toolbar:after {
|
||||
margin-top: 8px
|
||||
}
|
||||
|
||||
.editor-toolbar:hover,
|
||||
.editor-wrapper input.title:focus,
|
||||
.editor-wrapper input.title:hover {
|
||||
opacity: .8
|
||||
}
|
||||
|
||||
.editor-toolbar.fullscreen {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
white-space: nowrap;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
border: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
opacity: 1;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
.editor-toolbar.fullscreen::before {
|
||||
width: 20px;
|
||||
height: 50px;
|
||||
background: -moz-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 1)), color-stop(100%, rgba(255, 255, 255, 0)));
|
||||
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
background: -o-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
background: -ms-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
background: linear-gradient(to right, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.editor-toolbar.fullscreen::after {
|
||||
width: 20px;
|
||||
height: 50px;
|
||||
background: -moz-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(100%, rgba(255, 255, 255, 1)));
|
||||
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
background: -o-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
background: -ms-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.editor-toolbar a {
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
text-decoration: none!important;
|
||||
color: #2c3e50!important;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin: 0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.editor-toolbar a.active,
|
||||
.editor-toolbar a:hover {
|
||||
background: #fcfcfc;
|
||||
border-color: #95a5a6;
|
||||
}
|
||||
|
||||
.editor-toolbar a:before {
|
||||
line-height: 30px
|
||||
}
|
||||
|
||||
.editor-toolbar i.separator {
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
border-left: 1px solid #d9d9d9;
|
||||
border-right: 1px solid #fff;
|
||||
color: transparent;
|
||||
text-indent: -10px;
|
||||
margin: 0 6px;
|
||||
}
|
||||
|
||||
.editor-toolbar a.fa-header-x:after {
|
||||
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
|
||||
font-size: 65%;
|
||||
vertical-align: text-bottom;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.editor-toolbar a.fa-header-1:after {
|
||||
content: "1";
|
||||
}
|
||||
|
||||
.editor-toolbar a.fa-header-2:after {
|
||||
content: "2";
|
||||
}
|
||||
|
||||
.editor-toolbar a.fa-header-3:after {
|
||||
content: "3";
|
||||
}
|
||||
|
||||
.editor-toolbar a.fa-header-bigger:after {
|
||||
content: "▲";
|
||||
}
|
||||
|
||||
.editor-toolbar a.fa-header-smaller:after {
|
||||
content: "▼";
|
||||
}
|
||||
|
||||
.editor-toolbar.disabled-for-preview a:not(.no-disable) {
|
||||
pointer-events: none;
|
||||
background: #fff;
|
||||
border-color: transparent;
|
||||
text-shadow: inherit;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 700px) {
|
||||
.editor-toolbar a.no-mobile {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.editor-statusbar {
|
||||
padding: 8px 10px;
|
||||
font-size: 12px;
|
||||
color: #959694;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.editor-statusbar span {
|
||||
display: inline-block;
|
||||
min-width: 4em;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.editor-statusbar .lines:before {
|
||||
content: 'lines: '
|
||||
}
|
||||
|
||||
.editor-statusbar .words:before {
|
||||
content: 'words: '
|
||||
}
|
||||
|
||||
.editor-statusbar .characters:before {
|
||||
content: 'characters: '
|
||||
}
|
||||
|
||||
.editor-preview {
|
||||
padding: 10px;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: #fafafa;
|
||||
z-index: 7;
|
||||
overflow: auto;
|
||||
display: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.editor-preview-side {
|
||||
padding: 10px;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 50%;
|
||||
top: 50px;
|
||||
right: 0;
|
||||
background: #fafafa;
|
||||
z-index: 9;
|
||||
overflow: auto;
|
||||
display: none;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.editor-preview-active-side {
|
||||
display: block
|
||||
}
|
||||
|
||||
.editor-preview-active {
|
||||
display: block
|
||||
}
|
||||
|
||||
.editor-preview>p,
|
||||
.editor-preview-side>p {
|
||||
margin-top: 0
|
||||
}
|
||||
|
||||
.editor-preview pre,
|
||||
.editor-preview-side pre {
|
||||
background: #eee;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.editor-preview table td,
|
||||
.editor-preview table th,
|
||||
.editor-preview-side table td,
|
||||
.editor-preview-side table th {
|
||||
border: 1px solid #ddd;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-tag {
|
||||
color: #63a35c;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-attribute {
|
||||
color: #795da3;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-string {
|
||||
color: #183691;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-selected {
|
||||
background: #d9d9d9;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-header-1 {
|
||||
font-size: 200%;
|
||||
line-height: 200%;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-header-2 {
|
||||
font-size: 160%;
|
||||
line-height: 160%;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-header-3 {
|
||||
font-size: 125%;
|
||||
line-height: 125%;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-header-4 {
|
||||
font-size: 110%;
|
||||
line-height: 110%;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-comment {
|
||||
background: rgba(0, 0, 0, .05);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-link {
|
||||
color: #7f8c8d;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-url {
|
||||
color: #aab2b3;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-strikethrough {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-placeholder {
|
||||
opacity: .5;
|
||||
}
|
44
src/js/codemirror/tablist.js
Normal file
44
src/js/codemirror/tablist.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
var CodeMirror = require("codemirror");
|
||||
|
||||
CodeMirror.commands.tabAndIndentMarkdownList = function (cm) {
|
||||
var ranges = cm.listSelections();
|
||||
var pos = ranges[0].head;
|
||||
var eolState = cm.getStateAfter(pos.line);
|
||||
var inList = eolState.list !== false;
|
||||
|
||||
if (inList) {
|
||||
cm.execCommand("indentMore");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cm.options.indentWithTabs) {
|
||||
cm.execCommand("insertTab");
|
||||
}
|
||||
else {
|
||||
var spaces = Array(cm.options.tabSize + 1).join(" ");
|
||||
cm.replaceSelection(spaces);
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.commands.shiftTabAndUnindentMarkdownList = function (cm) {
|
||||
var ranges = cm.listSelections();
|
||||
var pos = ranges[0].head;
|
||||
var eolState = cm.getStateAfter(pos.line);
|
||||
var inList = eolState.list !== false;
|
||||
|
||||
if (inList) {
|
||||
cm.execCommand("indentLess");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cm.options.indentWithTabs) {
|
||||
cm.execCommand("insertTab");
|
||||
}
|
||||
else {
|
||||
var spaces = Array(cm.options.tabSize + 1).join(" ");
|
||||
cm.replaceSelection(spaces);
|
||||
}
|
||||
};
|
2028
src/js/simplemde.js
Normal file
2028
src/js/simplemde.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue