mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 00:15:35 +02:00
fix note export/import/branch prefix to use right-clicked note as opposed to current active
This commit is contained in:
@@ -142,10 +142,10 @@ $noteTabContainer.on("click", ".export-note-button", function () {
|
||||
return;
|
||||
}
|
||||
|
||||
exportDialog.showDialog('single');
|
||||
exportDialog.showDialog(treeService.getActiveNode(), 'single');
|
||||
});
|
||||
|
||||
$noteTabContainer.on("click", ".import-files-button", importDialog.showDialog);
|
||||
$noteTabContainer.on("click", ".import-files-button", () => importDialog.showDialog(treeService.getActiveNode()));
|
||||
|
||||
$('[data-toggle="tooltip"]').tooltip({
|
||||
html: true
|
||||
|
||||
@@ -12,21 +12,19 @@ const $noteTitle = $('#branch-prefix-note-title');
|
||||
|
||||
let branchId;
|
||||
|
||||
async function showDialog() {
|
||||
async function showDialog(node) {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
|
||||
$dialog.modal();
|
||||
|
||||
const currentNode = treeService.getActiveNode();
|
||||
|
||||
branchId = currentNode.data.branchId;
|
||||
branchId = node.data.branchId;
|
||||
const branch = await treeCache.getBranch(branchId);
|
||||
|
||||
$treePrefixInput.val(branch.prefix);
|
||||
|
||||
const noteTitle = await treeUtils.getNoteTitle(currentNode.data.noteId);
|
||||
const noteTitle = await treeUtils.getNoteTitle(node.data.noteId);
|
||||
|
||||
$noteTitle.text(" - " + noteTitle);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import treeService from '../services/tree.js';
|
||||
import treeUtils from "../services/tree_utils.js";
|
||||
import utils from "../services/utils.js";
|
||||
import messagingService from "../services/messaging.js";
|
||||
@@ -6,7 +5,7 @@ import infoService from "../services/info.js";
|
||||
|
||||
const $dialog = $("#export-dialog");
|
||||
const $form = $("#export-form");
|
||||
const $noteTitle = $dialog.find(".note-title");
|
||||
const $noteTitle = $dialog.find(".export-note-title");
|
||||
const $subtreeFormats = $("#export-subtree-formats");
|
||||
const $singleFormats = $("#export-single-formats");
|
||||
const $subtreeType = $("#export-type-subtree");
|
||||
@@ -17,8 +16,9 @@ const $exportButton = $("#export-button");
|
||||
const $opmlVersions = $("#opml-versions");
|
||||
|
||||
let exportId = '';
|
||||
let branchId = null;
|
||||
|
||||
async function showDialog(defaultType) {
|
||||
async function showDialog(node, defaultType) {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
// each opening of the dialog resets the exportId so we don't associate it with previous exports anymore
|
||||
@@ -46,8 +46,9 @@ async function showDialog(defaultType) {
|
||||
|
||||
$dialog.modal();
|
||||
|
||||
const currentNode = treeService.getActiveNode();
|
||||
const noteTitle = await treeUtils.getNoteTitle(currentNode.data.noteId);
|
||||
branchId = node.data.branchId;
|
||||
|
||||
const noteTitle = await treeUtils.getNoteTitle(node.data.noteId);
|
||||
|
||||
$noteTitle.html(noteTitle);
|
||||
}
|
||||
@@ -70,9 +71,7 @@ $form.submit(() => {
|
||||
|
||||
const exportVersion = exportFormat === 'opml' ? $dialog.find("input[name='opml-version']:checked").val() : "1.0";
|
||||
|
||||
const currentNode = treeService.getActiveNode();
|
||||
|
||||
exportBranch(currentNode.data.branchId, exportType, exportFormat, exportVersion);
|
||||
exportBranch(branchId, exportType, exportFormat, exportVersion);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -19,8 +19,9 @@ const $codeImportedAsCodeCheckbox = $("#code-imported-as-code-checkbox");
|
||||
const $explodeArchivesCheckbox = $("#explode-archives-checkbox");
|
||||
|
||||
let importId;
|
||||
let importIntoNoteId = null;
|
||||
|
||||
async function showDialog() {
|
||||
async function showDialog(node) {
|
||||
utils.closeActiveDialog();
|
||||
|
||||
// each opening of the dialog resets the importId so we don't associate it with previous imports anymore
|
||||
@@ -37,19 +38,18 @@ async function showDialog() {
|
||||
|
||||
glob.activeDialog = $dialog;
|
||||
|
||||
const currentNode = treeService.getActiveNode();
|
||||
$noteTitle.text(await treeUtils.getNoteTitle(currentNode.data.noteId));
|
||||
importIntoNoteId = node.data.noteId;
|
||||
|
||||
$noteTitle.text(await treeUtils.getNoteTitle(importIntoNoteId));
|
||||
|
||||
$dialog.modal();
|
||||
}
|
||||
|
||||
$form.submit(() => {
|
||||
const currentNode = treeService.getActiveNode();
|
||||
|
||||
// disabling so that import is not triggered again.
|
||||
$importButton.attr("disabled", "disabled");
|
||||
|
||||
importIntoNote(currentNode.data.noteId);
|
||||
importIntoNote(importIntoNoteId);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -132,10 +132,10 @@ class TreeContextMenu {
|
||||
treeChangesService.deleteNodes(treeService.getSelectedOrActiveNodes(this.node));
|
||||
}
|
||||
else if (cmd === "export") {
|
||||
exportDialog.showDialog("subtree");
|
||||
exportDialog.showDialog(this.node,"subtree");
|
||||
}
|
||||
else if (cmd === "importIntoNote") {
|
||||
importDialog.showDialog();
|
||||
importDialog.showDialog(this.node);
|
||||
}
|
||||
else if (cmd === "collapseSubtree") {
|
||||
treeService.collapseTree(this.node);
|
||||
|
||||
@@ -74,8 +74,6 @@ function getMime(fileName) {
|
||||
|
||||
const ext = path.extname(fileName).toLowerCase();
|
||||
|
||||
console.log("EXT", ext);
|
||||
|
||||
if (ext in EXTENSION_TO_MIME) {
|
||||
console.log(EXTENSION_TO_MIME[ext]);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Export note</h5>
|
||||
<h5 class="modal-title">Export note "<span class="export-note-title"></span>"</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user