Skip to content

Commit 4910ff5

Browse files
committed
switch editor from mdedit to simplemde
1 parent 2020a46 commit 4910ff5

File tree

230 files changed

+37775
-13180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+37775
-13180
lines changed

css/notes.css

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,24 @@
6262
}
6363

6464
/* special styling to make editor subtle and fit the window */
65-
#app-content pre {
66-
display: block;
65+
.CodeMirror {
66+
position: relative;
6767
min-height: 100%;
68-
width: 100%;
69-
margin: 0 0 -50px;
70-
padding: 30px 20px 90px 30px;
7168
font-size: 16px;
72-
line-height: 170%;
73-
background: none;
74-
resize: none;
75-
-moz-box-sizing: border-box; box-sizing: border-box;
76-
font-family: inherit;
69+
margin: 0 0 -50px;
70+
padding: 30px 0 90px;
71+
border: none;
7772
}
7873

7974
#app-content .note-meta {
75+
position: relative;
8076
padding: 0 45px 30px 45px;
8177
margin: -10px 0 0;
8278
opacity: .2;
8379
-ms-user-select: none;
8480
-moz-user-select: none;
8581
-webkit-user-select: none;
82+
z-index: 5;
8683
}
8784

8885
#app-content .saving {
@@ -95,65 +92,61 @@
9592

9693
/* markdown styling */
9794

98-
.mdedit .heading {
95+
.CodeMirror .CodeMirror-code .cm-header {
9996
/* break from core in using semibold, otherwise not emphasized in texts */
10097
font-weight: 600;
10198
}
102-
.mdedit .heading.heading-1 {
99+
.CodeMirror .CodeMirror-code .cm-header-1 {
103100
font-size: 40px;
104101
margin: 50px 0 20px;
105102
line-height: 120%;
106103
}
107-
.mdedit .heading.heading-2 {
104+
.CodeMirror .CodeMirror-code .cm-header-2 {
108105
font-size: 20px;
109106
margin-top: 12px;
110107
line-height: 150%;
111108
}
112-
.mdedit .heading.heading-3,
113-
.mdedit .heading.heading-4,
114-
.mdedit .heading.heading-5,
115-
.mdedit .heading.heading-6 {
109+
.CodeMirror .CodeMirror-code .cm-header-3,
110+
.CodeMirror .CodeMirror-code .cm-header-4,
111+
.CodeMirror .CodeMirror-code .cm-header-5,
112+
.CodeMirror .CodeMirror-code .cm-header-6 {
116113
font-size: 16px;
117114
margin: 0;
118115
font-weight: 300;
119116
}
120-
.mdedit .heading.heading-3 {
117+
.CodeMirror .CodeMirror-code .cm-header-3 {
121118
font-weight: 600;
122119
}
123120

124-
.mdedit .hr {
121+
.CodeMirror .CodeMirror-code .cm-hr {
125122
position: relative;
126123
display: inline-block;
127124
width: 100%;
128-
margin: .5em 0;
129-
}
130-
.mdedit .hr-marker {
131-
background-color: white;
132-
}
133-
.mdedit .hr-marker:last-child {
134-
padding-right: 10px;
135125
}
136-
.mdedit .hr:before {
126+
127+
.CodeMirror .CodeMirror-code .cm-hr:before {
137128
position: absolute;
138129
content: "";
139130
top: 50%;
140131
width: 100%;
141132
z-index: -1;
142-
border-top: 1px solid rgba(120, 120, 120, 0.5);
133+
border-top: 5px solid rgba(120, 120, 120, 0.2);
143134
}
144135

145136

146137
/* hanging punctuation */
147-
#app-content .mdedit {
138+
.CodeMirror .CodeMirror-code .CodeMirror-line {
148139
padding-left: 45px;
149-
display: inline-block;
150140
}
151-
.mdedit > div > .token > .heading-hash,
152-
.mdedit > div > .token > .li > .list-item,
153-
.mdedit > div > .token > .quote-marker {
141+
142+
.CodeMirror .CodeMirror-code .cm-formatting-header:not(:only-child),
143+
.CodeMirror .CodeMirror-code .cm-formatting-list,
144+
.CodeMirror .CodeMirror-code .cm-formatting-quote {
145+
position: absolute;
146+
display: inline-block;
154147
width: 90px;
148+
margin-top: 0;
155149
margin-left: -90px;
156-
display: inline-block;
157150
text-align: right;
158151
white-space: pre;
159152
}
@@ -162,7 +155,7 @@
162155
/* larger screen sizes */
163156
@media only screen and (min-width: 769px) {
164157
/* use slightly more space on the left so all # signs of h3–h6 show */
165-
#app-content .mdedit,
158+
.CodeMirror .CodeMirror-code .CodeMirror-line,
166159
#app-content .note-meta {
167160
padding-left: 90px;
168161
}

js/app/controllers/notecontroller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
app.controller('NoteController', function($routeParams, $scope, NotesModel,
9-
SaveQueue, note) {
9+
SaveQueue, note, debounce) {
1010
'use strict';
1111

1212
NotesModel.updateIfExists(note);
@@ -22,9 +22,9 @@ app.controller('NoteController', function($routeParams, $scope, NotesModel,
2222
t('notes', 'New note');
2323
};
2424

25-
$scope.save = function() {
25+
$scope.save = debounce(function() {
2626
var note = $scope.note;
2727
SaveQueue.add(note);
28-
};
28+
}, 300);
2929

3030
});

js/app/directives/editor.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1-
/*global mdEdit*/
1+
/*global SimpleMDE*/
22
app.directive('editor', ['$timeout', function ($timeout) {
33
'use strict';
44
return {
55
restrict: 'A',
66
link: function(scope, element) {
7-
var editor = mdEdit(element[0], {change: function(value) {
8-
$timeout(function(){
9-
scope.$apply(function() {
10-
scope.note.content = value;
7+
8+
var simplemde = new SimpleMDE({
9+
element: element[0],
10+
spellChecker: false,
11+
autoDownloadFontAwesome: false,
12+
toolbar: false,
13+
status: false,
14+
forceSync: true
15+
});
16+
var editorElement = $(simplemde.codemirror.getWrapperElement());
17+
18+
simplemde.value(scope.note.content);
19+
20+
simplemde.codemirror.on('change', function() {
21+
$timeout(function() {
22+
scope.$apply(function () {
23+
scope.note.content = simplemde.value();
24+
scope.save();
1125
scope.updateTitle();
1226
});
1327
});
14-
}});
15-
editor.setValue(scope.note.content);
16-
element.on('click', '.link', function(event) {
17-
if(event.ctrlKey) {
18-
var url = $(this).find('.link-params-inner').text();
19-
window.open(url, '_blank');
20-
}
2128
});
2229
}
2330
};

js/app/directives/timeoutchange.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

js/app/services/debounce.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (c) 2016, Hendrik Leppelsack
3+
* This file is licensed under the Affero General Public License version 3 or
4+
* later.
5+
* See the COPYING file.
6+
*/
7+
8+
app.factory('debounce', ['$timeout', function($timeout) {
9+
'use strict';
10+
11+
return function debounce(func, delay) {
12+
var timeout;
13+
14+
return function() {
15+
var context = this, args = arguments;
16+
17+
if(timeout) {
18+
$timeout.cancel(timeout);
19+
}
20+
timeout = $timeout(function() {
21+
func.apply(context, args);
22+
}, delay);
23+
};
24+
};
25+
}]);

js/bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"angular-mocks": "1.4.*",
1010
"angular-route": "1.4.*",
1111
"prism": "~1.0.1",
12-
"mdEdit": "https://github.com/jbt/mdEdit.git#master"
12+
"simplemde": "^1.11.2"
1313
}
1414
}

js/gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ var sources = {
1919
config: ['karma.conf.js', 'gulpfile.js']
2020
};
2121

22-
var wrappers = '(function(angular, $, requestToken, mdEdit, undefined){'+
22+
var wrappers = '(function(angular, $, requestToken, SimpleMDE, undefined){'+
2323
'\'use strict\';<%= contents %>' +
24-
'})(angular, jQuery, oc_requesttoken, mdEdit);';
24+
'})(angular, jQuery, oc_requesttoken, SimpleMDE);';
2525

2626

2727
/**

js/karma.conf.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ module.exports = function(config) {
3232
// list of files / patterns to load in the browser
3333
files: [
3434
'vendor/jquery/dist/jquery.js',
35-
'vendor/prism/prism.js',
36-
'vendor/mdEdit/mdedit.js',
35+
'vendor/simplemde/dist/simplemde.min.js',
3736
'vendor/angular/angular.js',
3837
'vendor/underscore/underscore.js',
3938
'vendor/angular-route/angular-route.js',

js/public/app.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/public/app.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/vendor/mdEdit/.bower.json

Lines changed: 0 additions & 39 deletions
This file was deleted.

js/vendor/mdEdit/LICENSE.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

js/vendor/mdEdit/README.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)