mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
refactor: 💡 fix note_tree.ts lint
This commit is contained in:
parent
14a3b2811d
commit
e555a3354f
2
src/public/app/types-fancytree.d.ts
vendored
2
src/public/app/types-fancytree.d.ts
vendored
@ -969,7 +969,7 @@ declare namespace Fancytree {
|
|||||||
/**
|
/**
|
||||||
* Callback(targetNode, data), return true, to enable dnd drop
|
* Callback(targetNode, data), return true, to enable dnd drop
|
||||||
*/
|
*/
|
||||||
dragEnter?: ((targetNode: FancytreeNode, data: any) => void) | undefined;
|
dragEnter?: ((targetNode: FancytreeNode) => void) | undefined;
|
||||||
/**
|
/**
|
||||||
* Events (drag over)
|
* Events (drag over)
|
||||||
*/
|
*/
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
import hoistedNoteService from "../services/hoisted_note.js";
|
|
||||||
import treeService from "../services/tree.js";
|
|
||||||
import utils from "../services/utils.js";
|
|
||||||
import contextMenu from "../menus/context_menu.js";
|
|
||||||
import froca from "../services/froca.js";
|
|
||||||
import branchService from "../services/branches.js";
|
|
||||||
import ws from "../services/ws.js";
|
|
||||||
import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
|
||||||
import server from "../services/server.js";
|
|
||||||
import noteCreateService from "../services/note_create.js";
|
|
||||||
import toastService from "../services/toast.js";
|
|
||||||
import appContext, { type CommandListenerData, type EventData } from "../components/app_context.js";
|
import appContext, { type CommandListenerData, type EventData } from "../components/app_context.js";
|
||||||
import keyboardActionsService from "../services/keyboard_actions.js";
|
import type { SetNoteOpts } from "../components/note_context.js";
|
||||||
import clipboard from "../services/clipboard.js";
|
|
||||||
import protectedSessionService from "../services/protected_session.js";
|
|
||||||
import linkService from "../services/link.js";
|
|
||||||
import options from "../services/options.js";
|
|
||||||
import protectedSessionHolder from "../services/protected_session_holder.js";
|
|
||||||
import dialogService from "../services/dialog.js";
|
|
||||||
import shortcutService from "../services/shortcuts.js";
|
|
||||||
import { t } from "../services/i18n.js";
|
|
||||||
import type FBranch from "../entities/fbranch.js";
|
import type FBranch from "../entities/fbranch.js";
|
||||||
import type LoadResults from "../services/load_results.js";
|
|
||||||
import type FNote from "../entities/fnote.js";
|
import type FNote from "../entities/fnote.js";
|
||||||
import type { NoteType } from "../entities/fnote.js";
|
import type { NoteType } from "../entities/fnote.js";
|
||||||
|
import contextMenu from "../menus/context_menu.js";
|
||||||
|
import branchService from "../services/branches.js";
|
||||||
|
import clipboard from "../services/clipboard.js";
|
||||||
|
import dialogService from "../services/dialog.js";
|
||||||
|
import froca from "../services/froca.js";
|
||||||
|
import hoistedNoteService from "../services/hoisted_note.js";
|
||||||
|
import { t } from "../services/i18n.js";
|
||||||
|
import keyboardActionsService from "../services/keyboard_actions.js";
|
||||||
|
import linkService from "../services/link.js";
|
||||||
|
import type LoadResults from "../services/load_results.js";
|
||||||
import type { AttributeRow, BranchRow } from "../services/load_results.js";
|
import type { AttributeRow, BranchRow } from "../services/load_results.js";
|
||||||
import type { SetNoteOpts } from "../components/note_context.js";
|
import noteCreateService from "../services/note_create.js";
|
||||||
|
import options from "../services/options.js";
|
||||||
|
import protectedSessionService from "../services/protected_session.js";
|
||||||
|
import protectedSessionHolder from "../services/protected_session_holder.js";
|
||||||
|
import server from "../services/server.js";
|
||||||
|
import shortcutService from "../services/shortcuts.js";
|
||||||
|
import toastService from "../services/toast.js";
|
||||||
|
import treeService from "../services/tree.js";
|
||||||
|
import utils from "../services/utils.js";
|
||||||
|
import ws from "../services/ws.js";
|
||||||
|
import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
||||||
|
|
||||||
const TPL = /*html*/`
|
const TPL = /*html*/`
|
||||||
<div class="tree-wrapper">
|
<div class="tree-wrapper">
|
||||||
@ -241,7 +241,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
this.$autoCollapseNoteTree = this.$treeSettingsPopup.find(".auto-collapse-note-tree");
|
this.$autoCollapseNoteTree = this.$treeSettingsPopup.find(".auto-collapse-note-tree");
|
||||||
|
|
||||||
this.$treeSettingsButton = this.$widget.find(".tree-settings-button");
|
this.$treeSettingsButton = this.$widget.find(".tree-settings-button");
|
||||||
this.$treeSettingsButton.on("click", (e) => {
|
this.$treeSettingsButton.on("click", () => {
|
||||||
if (this.$treeSettingsPopup.is(":visible")) {
|
if (this.$treeSettingsPopup.is(":visible")) {
|
||||||
this.$treeSettingsPopup.hide();
|
this.$treeSettingsPopup.hide();
|
||||||
return;
|
return;
|
||||||
@ -466,7 +466,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
data.dataTransfer.setData("text", JSON.stringify(notes));
|
data.dataTransfer.setData("text", JSON.stringify(notes));
|
||||||
return true; // allow dragging to start
|
return true; // allow dragging to start
|
||||||
},
|
},
|
||||||
dragEnter: (node, data) => {
|
dragEnter: (node) => {
|
||||||
if (node.data.noteType === "search") {
|
if (node.data.noteType === "search") {
|
||||||
return false;
|
return false;
|
||||||
} else if (node.data.noteId === "_lbRoot") {
|
} else if (node.data.noteId === "_lbRoot") {
|
||||||
@ -512,8 +512,12 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
notes = JSON.parse(jsonStr);
|
notes = JSON.parse(jsonStr);
|
||||||
} catch (e) {
|
} catch (error: unknown) {
|
||||||
logError(`Cannot parse JSON '${jsonStr}' into notes for drop`);
|
if (error instanceof Error) {
|
||||||
|
logError(`Cannot parse JSON '${jsonStr}' into notes for drop: ${error.message}`);
|
||||||
|
} else {
|
||||||
|
logError(`Cannot parse JSON '${jsonStr}' into notes for drop: Unknown error`);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,17 +675,16 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
let showTimeout: Timeout;
|
let showTimeout: Timeout;
|
||||||
|
|
||||||
this.$tree.on("touchstart", ".fancytree-node", (e) => {
|
this.$tree.on("touchstart", ".fancytree-node", (e) => {
|
||||||
touchStart = new Date().getTime();
|
|
||||||
showTimeout = setTimeout(() => {
|
showTimeout = setTimeout(() => {
|
||||||
this.showContextMenu(e);
|
this.showContextMenu(e);
|
||||||
}, 300);
|
}, 300);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$tree.on("touchmove", ".fancytree-node", (e) => {
|
this.$tree.on("touchmove", ".fancytree-node", () => {
|
||||||
clearTimeout(showTimeout);
|
clearTimeout(showTimeout);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$tree.on("touchend", ".fancytree-node", (e) => {
|
this.$tree.on("touchend", ".fancytree-node", () => {
|
||||||
clearTimeout(showTimeout);
|
clearTimeout(showTimeout);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -703,8 +706,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let touchStart;
|
|
||||||
|
|
||||||
this.tree = $.ui.fancytree.getTree(this.$tree);
|
this.tree = $.ui.fancytree.getTree(this.$tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1251,7 +1252,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
// activeNode is supposed to be moved when we find out activeNode is deleted but not all branches are deleted. save it for fixing activeNodePath after all nodes loaded.
|
// activeNode is supposed to be moved when we find out activeNode is deleted but not all branches are deleted. save it for fixing activeNodePath after all nodes loaded.
|
||||||
let movedActiveNode = null;
|
let movedActiveNode = null;
|
||||||
let parentsOfAddedNodes = [];
|
const parentsOfAddedNodes = [];
|
||||||
|
|
||||||
for (const branchRow of branchRows) {
|
for (const branchRow of branchRows) {
|
||||||
if (branchRow.noteId) {
|
if (branchRow.noteId) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user