forked from shuding/innsbruck-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkdown-editor.js
32 lines (29 loc) · 1021 Bytes
/
markdown-editor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Created by shuding on 5/22/16.
*/
module.exports = {
init: _db => {
},
render: (template, options) => {
let context = {};
if (['post-new', 'post-edit', 'page-new', 'page-edit'].includes(template)) {
context.head =
`<link rel="stylesheet" href="//cdn.jsdelivr.net/editor/0.1.0/editor.css">
<script src="//cdn.jsdelivr.net/editor/0.1.0/editor.js"></script>
<script src="//cdn.jsdelivr.net/editor/0.1.0/marked.js"></script>`;
context.editorBottom =
`<script type="text/javascript">
// lepture's markdown editor: https://github.com/lepture/editor
// license: MIT. Copyright (c) 2013 - 2014 by Hsiaoming Yang
var editor = new Editor();
editor.render();
window.onFileUploaded = function (value) {
// add image insert hook
editor.codemirror.setValue(editor.codemirror.getValue() + ' ' + value);
};
</script>`;
}
return context;
}
};