export dialog to choose export format, closes #207

This commit is contained in:
azivner 2018-11-07 22:58:33 +01:00
parent 13f9007bd6
commit 5f427e37fe
5 changed files with 87 additions and 9 deletions

View File

@ -0,0 +1,36 @@
import treeService from '../services/tree.js';
import server from '../services/server.js';
import treeUtils from "../services/tree_utils.js";
import exportService from "../services/export.js";
const $dialog = $("#export-subtree-dialog");
const $form = $("#export-subtree-form");
const $noteTitle = $dialog.find(".note-title");
const $exportFormat = $dialog.find("input[name='export-format']:checked");
async function showDialog() {
glob.activeDialog = $dialog;
$dialog.modal();
const currentNode = treeService.getCurrentNode();
const noteTitle = await treeUtils.getNoteTitle(currentNode.data.noteId);
$noteTitle.html(noteTitle);
}
$form.submit(() => {
const exportFormat = $exportFormat.val();
const currentNode = treeService.getCurrentNode();
exportService.exportSubtree(currentNode.data.branchId, exportFormat);
$dialog.modal('hide');
return false;
});
export default {
showDialog
};

View File

@ -6,6 +6,7 @@ import protectedSessionService from './protected_session.js';
import treeChangesService from './branches.js';
import treeUtils from './tree_utils.js';
import branchPrefixDialog from '../dialogs/branch_prefix.js';
import exportSubtreeDialog from '../dialogs/export_subtree.js';
import infoService from "./info.js";
import treeCache from "./tree_cache.js";
import syncService from "./sync.js";
@ -177,14 +178,8 @@ function selectContextMenuItem(event, cmd) {
else if (cmd === "delete") {
treeChangesService.deleteNodes(treeService.getSelectedNodes(true));
}
else if (cmd === "exportSubtreeToTar") {
exportService.exportSubtree(node.data.branchId, 'tar');
}
else if (cmd === "exportSubtreeToOpml") {
exportService.exportSubtree(node.data.branchId, 'opml');
}
else if (cmd === "exportSubtreeToMarkdown") {
exportService.exportSubtree(node.data.branchId, 'markdown');
else if (cmd === "exportSubtree") {
exportSubtreeDialog.showDialog();
}
else if (cmd === "importIntoNote") {
exportService.importIntoNote(node.data.noteId);

View File

@ -14,7 +14,7 @@
</div>
</div>
<div class="modal-footer" style="display: flex; justify-content: space-between;">
<button class="btn btn-primary btn-sm">Save</button>
<button class="btn btn-p`rimary btn-sm">Save</button>
<button class="btn btn-sm" type="button" data-help-page="Tree-concepts#prefix">
<i class="glyphicon glyphicon-info-sign"></i> Help

View File

@ -0,0 +1,46 @@
<div id="export-subtree-dialog" class="modal fade mx-auto" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Export subtree</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form id="export-subtree-form">
<div class="modal-body">
<div>Export note "<span class="note-title"></span>" and its subtree in the following format:</div>
<br/>
<div class="form-check">
<input class="form-check-input" type="radio" name="export-format" id="export-format-tar" value="tar" checked>
<label class="form-check-label" for="export-format-tar">Native TAR - this is Trilium's native format which preserves all notes' data & metadata.</label>
</div>
<br/>
<div class="form-check">
<input class="form-check-input" type="radio" name="export-format" id="export-format-opml" value="opml">
<label class="form-check-label" for="export-format-opml">
OPML - standard outliner interchange format for text only. Formatting, images, files are not included.
</label>
</div>
<br/>
<div class="form-check disabled">
<input class="form-check-input" type="radio" name="export-format" id="export-format-markdown"
value="markdown">
<label class="form-check-label" for="export-format-markdown">
Markdown - TAR archive of Markdown formatted notes
</label>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary btn-sm">Export</button>
</div>
</form>
</div>
</div>
</div>

View File

@ -308,6 +308,7 @@
<% include dialogs/attributes.ejs %>
<% include dialogs/branch_prefix.ejs %>
<% include dialogs/event_log.ejs %>
<% include dialogs/export_subtree.ejs %>
<% include dialogs/jump_to_note.ejs %>
<% include dialogs/markdown_import.ejs %>
<% include dialogs/note_revisions.ejs %>