@tryghost/kg-simplemde 1.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +24 -0
- package/.nvmrc +1 -0
- package/.travis.yml +18 -0
- package/CONTRIBUTING.md +10 -0
- package/LICENSE +22 -0
- package/README.md +331 -0
- package/bower.json +23 -0
- package/debug/simplemde.css +684 -0
- package/debug/simplemde.debug.js +16904 -0
- package/debug/simplemde.js +16902 -0
- package/dist/simplemde.min.css +7 -0
- package/dist/simplemde.min.js +7 -0
- package/gulpfile.js +96 -0
- package/package.json +47 -0
- package/src/css/simplemde.css +328 -0
- package/src/js/codemirror/tablist.js +44 -0
- package/src/js/simplemde.js +2046 -0
package/gulpfile.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var gulp = require("gulp"),
|
|
4
|
+
minifycss = require("gulp-clean-css"),
|
|
5
|
+
uglify = require("gulp-uglify"),
|
|
6
|
+
concat = require("gulp-concat"),
|
|
7
|
+
header = require("gulp-header"),
|
|
8
|
+
buffer = require("vinyl-buffer"),
|
|
9
|
+
pkg = require("./package.json"),
|
|
10
|
+
debug = require("gulp-debug"),
|
|
11
|
+
eslint = require("gulp-eslint"),
|
|
12
|
+
prettify = require("gulp-jsbeautifier"),
|
|
13
|
+
browserify = require("browserify"),
|
|
14
|
+
source = require("vinyl-source-stream"),
|
|
15
|
+
rename = require("gulp-rename");
|
|
16
|
+
|
|
17
|
+
var banner = ["/**",
|
|
18
|
+
" * <%= pkg.name %> v<%= pkg.version %>",
|
|
19
|
+
" * Copyright <%= pkg.company %>",
|
|
20
|
+
" * @link <%= pkg.homepage %>",
|
|
21
|
+
" * @license <%= pkg.license %>",
|
|
22
|
+
" */",
|
|
23
|
+
""].join("\n");
|
|
24
|
+
|
|
25
|
+
gulp.task("prettify-js", [], function() {
|
|
26
|
+
return gulp.src("./src/js/simplemde.js")
|
|
27
|
+
.pipe(prettify({js: {brace_style: "collapse", indent_char: "\t", indent_size: 1, max_preserve_newlines: 3, space_before_conditional: false}}))
|
|
28
|
+
.pipe(gulp.dest("./src/js"));
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
gulp.task("prettify-css", [], function() {
|
|
32
|
+
return gulp.src("./src/css/simplemde.css")
|
|
33
|
+
.pipe(prettify({css: {indentChar: "\t", indentSize: 1}}))
|
|
34
|
+
.pipe(gulp.dest("./src/css"));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
gulp.task("lint", ["prettify-js"], function() {
|
|
38
|
+
gulp.src("./src/js/**/*.js")
|
|
39
|
+
.pipe(debug())
|
|
40
|
+
.pipe(eslint())
|
|
41
|
+
.pipe(eslint.format())
|
|
42
|
+
.pipe(eslint.failAfterError());
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
function taskBrowserify(opts) {
|
|
46
|
+
return browserify("./src/js/simplemde.js", opts)
|
|
47
|
+
.bundle();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
gulp.task("browserify:debug", ["lint"], function() {
|
|
51
|
+
return taskBrowserify({debug:true, standalone:"SimpleMDE"})
|
|
52
|
+
.pipe(source("simplemde.debug.js"))
|
|
53
|
+
.pipe(buffer())
|
|
54
|
+
.pipe(header(banner, {pkg: pkg}))
|
|
55
|
+
.pipe(gulp.dest("./debug/"));
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
gulp.task("browserify", ["lint"], function() {
|
|
59
|
+
return taskBrowserify({standalone:"SimpleMDE"})
|
|
60
|
+
.pipe(source("simplemde.js"))
|
|
61
|
+
.pipe(buffer())
|
|
62
|
+
.pipe(header(banner, {pkg: pkg}))
|
|
63
|
+
.pipe(gulp.dest("./debug/"));
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
gulp.task("scripts", ["browserify:debug", "browserify", "lint"], function() {
|
|
67
|
+
var js_files = ["./debug/simplemde.js"];
|
|
68
|
+
|
|
69
|
+
return gulp.src(js_files)
|
|
70
|
+
.pipe(concat("simplemde.min.js"))
|
|
71
|
+
.pipe(uglify())
|
|
72
|
+
.pipe(buffer())
|
|
73
|
+
.pipe(header(banner, {pkg: pkg}))
|
|
74
|
+
.pipe(gulp.dest("./dist/"));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
gulp.task("styles", ["prettify-css"], function() {
|
|
78
|
+
var css_files = [
|
|
79
|
+
"./node_modules/codemirror/lib/codemirror.css",
|
|
80
|
+
"./src/css/*.css",
|
|
81
|
+
"./node_modules/codemirror-spell-checker/src/css/spell-checker.css"
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
return gulp.src(css_files)
|
|
85
|
+
.pipe(concat("simplemde.css"))
|
|
86
|
+
.pipe(buffer())
|
|
87
|
+
.pipe(header(banner, {pkg: pkg}))
|
|
88
|
+
.pipe(gulp.dest("./debug/"))
|
|
89
|
+
.pipe(minifycss())
|
|
90
|
+
.pipe(rename("simplemde.min.css"))
|
|
91
|
+
.pipe(buffer())
|
|
92
|
+
.pipe(header(banner, {pkg: pkg}))
|
|
93
|
+
.pipe(gulp.dest("./dist/"));
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
gulp.task("default", ["scripts", "styles"]);
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tryghost/kg-simplemde",
|
|
3
|
+
"version": "1.11.2",
|
|
4
|
+
"description": "A simple, beautiful, and embeddable JavaScript Markdown editor. Features autosaving and spell checking.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"embeddable",
|
|
7
|
+
"markdown",
|
|
8
|
+
"editor",
|
|
9
|
+
"javascript",
|
|
10
|
+
"wysiwyg"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/NextStepWebs/simplemde-markdown-editor",
|
|
13
|
+
"main": "./src/js/simplemde.js",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"company": "Next Step Webs, Inc.",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Wes Cossick",
|
|
18
|
+
"url": "http://www.WesCossick.com"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor/issues"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"browserify": "16.2.3",
|
|
25
|
+
"codemirror": "5.48.0",
|
|
26
|
+
"codemirror-spell-checker": "*",
|
|
27
|
+
"debug": "*",
|
|
28
|
+
"eslint": "4.19.1",
|
|
29
|
+
"gulp": "*",
|
|
30
|
+
"gulp-clean-css": "3.9.4",
|
|
31
|
+
"gulp-concat": "*",
|
|
32
|
+
"gulp-debug": "*",
|
|
33
|
+
"gulp-eslint": "4.0.2",
|
|
34
|
+
"gulp-header": "*",
|
|
35
|
+
"gulp-jsbeautifier": "*",
|
|
36
|
+
"gulp-rename": "*",
|
|
37
|
+
"gulp-uglify": "3.0.1",
|
|
38
|
+
"marked": "0.3.19",
|
|
39
|
+
"vinyl-buffer": "*",
|
|
40
|
+
"vinyl-source-stream": "*"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/NextStepWebs/simplemde-markdown-editor"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "a374ef9780864468ae43ee7b3283206b522899e8"
|
|
47
|
+
}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
.CodeMirror {
|
|
2
|
+
height: auto;
|
|
3
|
+
min-height: 300px;
|
|
4
|
+
border: 1px solid #ddd;
|
|
5
|
+
border-bottom-left-radius: 4px;
|
|
6
|
+
border-bottom-right-radius: 4px;
|
|
7
|
+
padding: 10px;
|
|
8
|
+
font: inherit;
|
|
9
|
+
z-index: 1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.CodeMirror-scroll {
|
|
13
|
+
min-height: 300px
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.CodeMirror-fullscreen {
|
|
17
|
+
background: #fff;
|
|
18
|
+
position: fixed !important;
|
|
19
|
+
top: 50px;
|
|
20
|
+
left: 0;
|
|
21
|
+
right: 0;
|
|
22
|
+
bottom: 0;
|
|
23
|
+
height: auto;
|
|
24
|
+
z-index: 9;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.CodeMirror-sided {
|
|
28
|
+
width: 50% !important;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.editor-toolbar {
|
|
32
|
+
position: relative;
|
|
33
|
+
opacity: .6;
|
|
34
|
+
-webkit-user-select: none;
|
|
35
|
+
-moz-user-select: none;
|
|
36
|
+
-ms-user-select: none;
|
|
37
|
+
-o-user-select: none;
|
|
38
|
+
user-select: none;
|
|
39
|
+
padding: 0 10px;
|
|
40
|
+
border-top: 1px solid #bbb;
|
|
41
|
+
border-left: 1px solid #bbb;
|
|
42
|
+
border-right: 1px solid #bbb;
|
|
43
|
+
border-top-left-radius: 4px;
|
|
44
|
+
border-top-right-radius: 4px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.editor-toolbar:after,
|
|
48
|
+
.editor-toolbar:before {
|
|
49
|
+
display: block;
|
|
50
|
+
content: ' ';
|
|
51
|
+
height: 1px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.editor-toolbar:before {
|
|
55
|
+
margin-bottom: 8px
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.editor-toolbar:after {
|
|
59
|
+
margin-top: 8px
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.editor-toolbar:hover,
|
|
63
|
+
.editor-wrapper input.title:focus,
|
|
64
|
+
.editor-wrapper input.title:hover {
|
|
65
|
+
opacity: .8
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.editor-toolbar.fullscreen {
|
|
69
|
+
width: 100%;
|
|
70
|
+
height: 50px;
|
|
71
|
+
overflow-x: auto;
|
|
72
|
+
overflow-y: hidden;
|
|
73
|
+
white-space: nowrap;
|
|
74
|
+
padding-top: 10px;
|
|
75
|
+
padding-bottom: 10px;
|
|
76
|
+
box-sizing: border-box;
|
|
77
|
+
background: #fff;
|
|
78
|
+
border: 0;
|
|
79
|
+
position: fixed;
|
|
80
|
+
top: 0;
|
|
81
|
+
left: 0;
|
|
82
|
+
opacity: 1;
|
|
83
|
+
z-index: 9;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.editor-toolbar.fullscreen::before {
|
|
87
|
+
width: 20px;
|
|
88
|
+
height: 50px;
|
|
89
|
+
background: -moz-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
|
90
|
+
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 1)), color-stop(100%, rgba(255, 255, 255, 0)));
|
|
91
|
+
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
|
92
|
+
background: -o-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
|
93
|
+
background: -ms-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
|
94
|
+
background: linear-gradient(to right, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
|
95
|
+
position: fixed;
|
|
96
|
+
top: 0;
|
|
97
|
+
left: 0;
|
|
98
|
+
margin: 0;
|
|
99
|
+
padding: 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.editor-toolbar.fullscreen::after {
|
|
103
|
+
width: 20px;
|
|
104
|
+
height: 50px;
|
|
105
|
+
background: -moz-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
|
106
|
+
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(100%, rgba(255, 255, 255, 1)));
|
|
107
|
+
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
|
108
|
+
background: -o-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
|
109
|
+
background: -ms-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
|
110
|
+
background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
|
111
|
+
position: fixed;
|
|
112
|
+
top: 0;
|
|
113
|
+
right: 0;
|
|
114
|
+
margin: 0;
|
|
115
|
+
padding: 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.editor-toolbar a {
|
|
119
|
+
display: inline-block;
|
|
120
|
+
text-align: center;
|
|
121
|
+
text-decoration: none !important;
|
|
122
|
+
color: #2c3e50 !important;
|
|
123
|
+
width: 30px;
|
|
124
|
+
height: 30px;
|
|
125
|
+
margin: 0;
|
|
126
|
+
border: 1px solid transparent;
|
|
127
|
+
border-radius: 3px;
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.editor-toolbar a.active,
|
|
132
|
+
.editor-toolbar a:hover {
|
|
133
|
+
background: #fcfcfc;
|
|
134
|
+
border-color: #95a5a6;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.editor-toolbar a:before {
|
|
138
|
+
line-height: 30px
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.editor-toolbar i.separator {
|
|
142
|
+
display: inline-block;
|
|
143
|
+
width: 0;
|
|
144
|
+
border-left: 1px solid #d9d9d9;
|
|
145
|
+
border-right: 1px solid #fff;
|
|
146
|
+
color: transparent;
|
|
147
|
+
text-indent: -10px;
|
|
148
|
+
margin: 0 6px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.editor-toolbar a.fa-header-x:after {
|
|
152
|
+
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
|
|
153
|
+
font-size: 65%;
|
|
154
|
+
vertical-align: text-bottom;
|
|
155
|
+
position: relative;
|
|
156
|
+
top: 2px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.editor-toolbar a.fa-header-1:after {
|
|
160
|
+
content: "1";
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.editor-toolbar a.fa-header-2:after {
|
|
164
|
+
content: "2";
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.editor-toolbar a.fa-header-3:after {
|
|
168
|
+
content: "3";
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.editor-toolbar a.fa-header-bigger:after {
|
|
172
|
+
content: "▲";
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.editor-toolbar a.fa-header-smaller:after {
|
|
176
|
+
content: "▼";
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.editor-toolbar.disabled-for-preview a:not(.no-disable) {
|
|
180
|
+
pointer-events: none;
|
|
181
|
+
background: #fff;
|
|
182
|
+
border-color: transparent;
|
|
183
|
+
text-shadow: inherit;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@media only screen and (max-width: 700px) {
|
|
187
|
+
.editor-toolbar a.no-mobile {
|
|
188
|
+
display: none;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.editor-statusbar {
|
|
193
|
+
padding: 8px 10px;
|
|
194
|
+
font-size: 12px;
|
|
195
|
+
color: #959694;
|
|
196
|
+
text-align: right;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.editor-statusbar span {
|
|
200
|
+
display: inline-block;
|
|
201
|
+
min-width: 4em;
|
|
202
|
+
margin-left: 1em;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.editor-statusbar .lines:before {
|
|
206
|
+
content: 'lines: '
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.editor-statusbar .words:before {
|
|
210
|
+
content: 'words: '
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.editor-statusbar .characters:before {
|
|
214
|
+
content: 'characters: '
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.editor-preview {
|
|
218
|
+
padding: 10px;
|
|
219
|
+
position: absolute;
|
|
220
|
+
width: 100%;
|
|
221
|
+
height: 100%;
|
|
222
|
+
top: 0;
|
|
223
|
+
left: 0;
|
|
224
|
+
background: #fafafa;
|
|
225
|
+
z-index: 7;
|
|
226
|
+
overflow: auto;
|
|
227
|
+
display: none;
|
|
228
|
+
box-sizing: border-box;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.editor-preview-side {
|
|
232
|
+
padding: 10px;
|
|
233
|
+
position: fixed;
|
|
234
|
+
bottom: 0;
|
|
235
|
+
width: 50%;
|
|
236
|
+
top: 50px;
|
|
237
|
+
right: 0;
|
|
238
|
+
background: #fafafa;
|
|
239
|
+
z-index: 9;
|
|
240
|
+
overflow: auto;
|
|
241
|
+
display: none;
|
|
242
|
+
box-sizing: border-box;
|
|
243
|
+
border: 1px solid #ddd;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.editor-preview-active-side {
|
|
247
|
+
display: block
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.editor-preview-active {
|
|
251
|
+
display: block
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.editor-preview>p,
|
|
255
|
+
.editor-preview-side>p {
|
|
256
|
+
margin-top: 0
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.editor-preview pre,
|
|
260
|
+
.editor-preview-side pre {
|
|
261
|
+
background: #eee;
|
|
262
|
+
margin-bottom: 10px;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.editor-preview table td,
|
|
266
|
+
.editor-preview table th,
|
|
267
|
+
.editor-preview-side table td,
|
|
268
|
+
.editor-preview-side table th {
|
|
269
|
+
border: 1px solid #ddd;
|
|
270
|
+
padding: 5px;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.CodeMirror .CodeMirror-code .cm-tag {
|
|
274
|
+
color: #63a35c;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.CodeMirror .CodeMirror-code .cm-attribute {
|
|
278
|
+
color: #795da3;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.CodeMirror .CodeMirror-code .cm-string {
|
|
282
|
+
color: #183691;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.CodeMirror .CodeMirror-selected {
|
|
286
|
+
background: #d9d9d9;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.CodeMirror .CodeMirror-code .cm-header-1 {
|
|
290
|
+
font-size: 200%;
|
|
291
|
+
line-height: 200%;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.CodeMirror .CodeMirror-code .cm-header-2 {
|
|
295
|
+
font-size: 160%;
|
|
296
|
+
line-height: 160%;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.CodeMirror .CodeMirror-code .cm-header-3 {
|
|
300
|
+
font-size: 125%;
|
|
301
|
+
line-height: 125%;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.CodeMirror .CodeMirror-code .cm-header-4 {
|
|
305
|
+
font-size: 110%;
|
|
306
|
+
line-height: 110%;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.CodeMirror .CodeMirror-code .cm-comment {
|
|
310
|
+
background: rgba(0, 0, 0, .05);
|
|
311
|
+
border-radius: 2px;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.CodeMirror .CodeMirror-code .cm-link {
|
|
315
|
+
color: #7f8c8d;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.CodeMirror .CodeMirror-code .cm-url {
|
|
319
|
+
color: #aab2b3;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.CodeMirror .CodeMirror-code .cm-strikethrough {
|
|
323
|
+
text-decoration: line-through;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.CodeMirror .CodeMirror-placeholder {
|
|
327
|
+
opacity: .5;
|
|
328
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
|
3
|
+
|
|
4
|
+
var CodeMirror = require("codemirror");
|
|
5
|
+
|
|
6
|
+
CodeMirror.commands.tabAndIndentMarkdownList = function (cm) {
|
|
7
|
+
var ranges = cm.listSelections();
|
|
8
|
+
var pos = ranges[0].head;
|
|
9
|
+
var eolState = cm.getStateAfter(pos.line);
|
|
10
|
+
var inList = eolState.list !== false;
|
|
11
|
+
|
|
12
|
+
if (inList) {
|
|
13
|
+
cm.execCommand("indentMore");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (cm.options.indentWithTabs) {
|
|
18
|
+
cm.execCommand("insertTab");
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
var spaces = Array(cm.options.tabSize + 1).join(" ");
|
|
22
|
+
cm.replaceSelection(spaces);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
CodeMirror.commands.shiftTabAndUnindentMarkdownList = function (cm) {
|
|
27
|
+
var ranges = cm.listSelections();
|
|
28
|
+
var pos = ranges[0].head;
|
|
29
|
+
var eolState = cm.getStateAfter(pos.line);
|
|
30
|
+
var inList = eolState.list !== false;
|
|
31
|
+
|
|
32
|
+
if (inList) {
|
|
33
|
+
cm.execCommand("indentLess");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (cm.options.indentWithTabs) {
|
|
38
|
+
cm.execCommand("insertTab");
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
var spaces = Array(cm.options.tabSize + 1).join(" ");
|
|
42
|
+
cm.replaceSelection(spaces);
|
|
43
|
+
}
|
|
44
|
+
};
|