Stackedit/js/extensions/markdownExtra.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2013-05-27 19:45:33 +00:00
define([
"utils",
2013-06-22 23:48:57 +00:00
"classes/Extension",
"text!html/markdownExtraSettingsBlock.html",
2013-06-10 21:22:32 +00:00
"libs/Markdown.Extra",
2013-06-22 23:48:57 +00:00
], function(utils, Extension, markdownExtraSettingsBlockHTML) {
2013-05-29 19:55:23 +00:00
2013-06-22 23:48:57 +00:00
var markdownExtra = new Extension("markdownExtra", "Markdown Extra", true);
markdownExtra.settingsBlock = markdownExtraSettingsBlockHTML;
markdownExtra.defaultConfig = {
prettify: true
2013-05-25 18:13:59 +00:00
};
2013-05-29 19:55:23 +00:00
2013-05-25 18:13:59 +00:00
markdownExtra.onLoadSettings = function() {
2013-05-29 19:55:23 +00:00
utils.setInputChecked("#input-markdownextra-prettify", markdownExtra.config.prettify);
2013-05-25 18:13:59 +00:00
};
2013-05-29 19:55:23 +00:00
2013-05-25 18:13:59 +00:00
markdownExtra.onSaveSettings = function(newConfig, event) {
2013-05-29 19:55:23 +00:00
newConfig.prettify = utils.getInputChecked("#input-markdownextra-prettify");
2013-05-25 00:34:04 +00:00
};
2013-05-29 19:55:23 +00:00
2013-05-25 00:34:04 +00:00
markdownExtra.onEditorConfigure = function(editor) {
2013-05-29 19:55:23 +00:00
var converter = editor.getConverter();
var options = {};
if(markdownExtra.config.prettify === true) {
options.highlighter = "prettify";
editor.hooks.chain("onPreviewRefresh", prettyPrint);
}
Markdown.Extra.init(converter, options);
};
2013-05-25 00:34:04 +00:00
return markdownExtra;
});