mirror of https://github.com/status-im/codimd.git
Add support of exporting raw html
This commit is contained in:
parent
4d24476316
commit
cb1e00d1d1
|
@ -430,10 +430,7 @@ function postProcess(code) {
|
|||
return result;
|
||||
}
|
||||
|
||||
//extract markdown body to html and compile to template
|
||||
function exportToHTML(view) {
|
||||
var title = renderTitle(ui.area.markdown);
|
||||
var filename = renderFilename(ui.area.markdown) + '.html';
|
||||
function generateCleanHTML(view) {
|
||||
var src = view.clone();
|
||||
var eles = src.find('*');
|
||||
//remove syncscroll parts
|
||||
|
@ -469,6 +466,25 @@ function exportToHTML(view) {
|
|||
$(value).html(iframe);
|
||||
}
|
||||
});
|
||||
return src;
|
||||
}
|
||||
|
||||
function exportToRawHTML(view) {
|
||||
var filename = renderFilename(ui.area.markdown) + '.html';
|
||||
var src = generateCleanHTML(view);
|
||||
$(src).find('a.anchor').remove();
|
||||
var html = src[0].outerHTML;
|
||||
var blob = new Blob([html], {
|
||||
type: "text/html;charset=utf-8"
|
||||
});
|
||||
saveAs(blob, filename);
|
||||
}
|
||||
|
||||
//extract markdown body to html and compile to template
|
||||
function exportToHTML(view) {
|
||||
var title = renderTitle(ui.area.markdown);
|
||||
var filename = renderFilename(ui.area.markdown) + '.html';
|
||||
var src = generateCleanHTML(view);
|
||||
//generate toc
|
||||
var toc = $('#toc').clone();
|
||||
toc.find('*').removeClass('active');
|
||||
|
|
|
@ -505,7 +505,8 @@ var ui = {
|
|||
publish: $(".ui-publish"),
|
||||
download: {
|
||||
markdown: $(".ui-download-markdown"),
|
||||
html: $(".ui-download-html")
|
||||
html: $(".ui-download-html"),
|
||||
rawhtml: $(".ui-download-raw-html")
|
||||
},
|
||||
export: {
|
||||
dropbox: $(".ui-save-dropbox"),
|
||||
|
@ -1174,6 +1175,12 @@ ui.toolbar.download.html.click(function (e) {
|
|||
e.stopPropagation();
|
||||
exportToHTML(ui.area.markdown);
|
||||
});
|
||||
// raw html
|
||||
ui.toolbar.download.rawhtml.click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
exportToRawHTML(ui.area.markdown);
|
||||
});
|
||||
//export to dropbox
|
||||
ui.toolbar.export.dropbox.click(function () {
|
||||
var filename = renderFilename(ui.area.markdown) + '.md';
|
||||
|
|
|
@ -68,6 +68,8 @@
|
|||
</li>
|
||||
<li role="presentation"><a role="menuitem" class="ui-download-html" tabindex="-1" href="#" target="_self"><i class="fa fa-file-code-o fa-fw"></i> HTML</a>
|
||||
</li>
|
||||
<li role="presentation"><a role="menuitem" class="ui-download-raw-html" tabindex="-1" href="#" target="_self"><i class="fa fa-file-code-o fa-fw"></i> Raw HTML</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li role="presentation"><a role="menuitem" class="ui-help" href="#" data-toggle="modal" data-target=".help-modal"><i class="fa fa-question-circle fa-fw"></i> Help</a>
|
||||
</li>
|
||||
|
@ -163,6 +165,8 @@
|
|||
</li>
|
||||
<li role="presentation"><a role="menuitem" class="ui-download-html" tabindex="-1" href="#" target="_self"><i class="fa fa-file-code-o fa-fw"></i> HTML</a>
|
||||
</li>
|
||||
<li role="presentation"><a role="menuitem" class="ui-download-raw-html" tabindex="-1" href="#" target="_self"><i class="fa fa-file-code-o fa-fw"></i> Raw HTML</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue