Stackedit/js/extensions/markdown-extra.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

2013-05-27 19:45:33 +00:00
define([
"utils",
2013-06-10 21:22:32 +00:00
"text!html/markdownExtraSettingsBloc.html",
"libs/Markdown.Extra",
], function(utils, markdownExtraSettingsBlocHTML) {
2013-05-29 19:55:23 +00:00
2013-05-25 00:34:04 +00:00
var markdownExtra = {
extensionId: "markdownExtra",
extensionName: "Markdown Extra",
2013-05-25 18:13:59 +00:00
optional: true,
2013-05-25 00:34:04 +00:00
defaultConfig: {
2013-05-29 19:55:23 +00:00
prettify: true
},
2013-06-10 21:22:32 +00:00
settingsBloc: markdownExtraSettingsBlocHTML
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;
});