mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
chore(client): fix typecheck issues
This commit is contained in:
parent
29b813fa3b
commit
8a587d4d21
@ -266,6 +266,72 @@ export type CommandMappings = {
|
|||||||
jumpToNote: CommandData;
|
jumpToNote: CommandData;
|
||||||
commandPalette: CommandData;
|
commandPalette: CommandData;
|
||||||
|
|
||||||
|
// Keyboard shortcuts
|
||||||
|
backInNoteHistory: CommandData;
|
||||||
|
forwardInNoteHistory: CommandData;
|
||||||
|
forceSaveRevision: CommandData;
|
||||||
|
scrollToActiveNote: CommandData;
|
||||||
|
quickSearch: CommandData;
|
||||||
|
collapseTree: CommandData;
|
||||||
|
createNoteAfter: CommandData;
|
||||||
|
createNoteInto: CommandData;
|
||||||
|
addNoteAboveToSelection: CommandData;
|
||||||
|
addNoteBelowToSelection: CommandData;
|
||||||
|
openNewTab: CommandData;
|
||||||
|
activateNextTab: CommandData;
|
||||||
|
activatePreviousTab: CommandData;
|
||||||
|
openNewWindow: CommandData;
|
||||||
|
toggleTray: CommandData;
|
||||||
|
firstTab: CommandData;
|
||||||
|
secondTab: CommandData;
|
||||||
|
thirdTab: CommandData;
|
||||||
|
fourthTab: CommandData;
|
||||||
|
fifthTab: CommandData;
|
||||||
|
sixthTab: CommandData;
|
||||||
|
seventhTab: CommandData;
|
||||||
|
eigthTab: CommandData;
|
||||||
|
ninthTab: CommandData;
|
||||||
|
lastTab: CommandData;
|
||||||
|
showNoteSource: CommandData;
|
||||||
|
showSQLConsole: CommandData;
|
||||||
|
showBackendLog: CommandData;
|
||||||
|
showCheatsheet: CommandData;
|
||||||
|
showHelp: CommandData;
|
||||||
|
addLinkToText: CommandData;
|
||||||
|
followLinkUnderCursor: CommandData;
|
||||||
|
insertDateTimeToText: CommandData;
|
||||||
|
pasteMarkdownIntoText: CommandData;
|
||||||
|
cutIntoNote: CommandData;
|
||||||
|
addIncludeNoteToText: CommandData;
|
||||||
|
editReadOnlyNote: CommandData;
|
||||||
|
toggleRibbonTabClassicEditor: CommandData;
|
||||||
|
toggleRibbonTabBasicProperties: CommandData;
|
||||||
|
toggleRibbonTabBookProperties: CommandData;
|
||||||
|
toggleRibbonTabFileProperties: CommandData;
|
||||||
|
toggleRibbonTabImageProperties: CommandData;
|
||||||
|
toggleRibbonTabOwnedAttributes: CommandData;
|
||||||
|
toggleRibbonTabInheritedAttributes: CommandData;
|
||||||
|
toggleRibbonTabPromotedAttributes: CommandData;
|
||||||
|
toggleRibbonTabNoteMap: CommandData;
|
||||||
|
toggleRibbonTabNoteInfo: CommandData;
|
||||||
|
toggleRibbonTabNotePaths: CommandData;
|
||||||
|
toggleRibbonTabSimilarNotes: CommandData;
|
||||||
|
toggleRightPane: CommandData;
|
||||||
|
printActiveNote: CommandData;
|
||||||
|
exportAsPdf: CommandData;
|
||||||
|
openNoteExternally: CommandData;
|
||||||
|
renderActiveNote: CommandData;
|
||||||
|
unhoist: CommandData;
|
||||||
|
reloadFrontendApp: CommandData;
|
||||||
|
openDevTools: CommandData;
|
||||||
|
findInText: CommandData;
|
||||||
|
toggleLeftPane: CommandData;
|
||||||
|
toggleFullscreen: CommandData;
|
||||||
|
zoomOut: CommandData;
|
||||||
|
zoomIn: CommandData;
|
||||||
|
zoomReset: CommandData;
|
||||||
|
copyWithoutFormatting: CommandData;
|
||||||
|
|
||||||
// Geomap
|
// Geomap
|
||||||
deleteFromMap: { noteId: string };
|
deleteFromMap: { noteId: string };
|
||||||
|
|
||||||
|
@ -15,10 +15,10 @@ const mockElement = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const mockJQuery = vi.fn(() => [mockElement]);
|
const mockJQuery = vi.fn(() => [mockElement]);
|
||||||
mockJQuery.length = 1;
|
(mockJQuery as any).length = 1;
|
||||||
mockJQuery[0] = mockElement;
|
mockJQuery[0] = mockElement;
|
||||||
|
|
||||||
global.$ = mockJQuery as any;
|
(global as any).$ = mockJQuery as any;
|
||||||
global.document = mockElement as any;
|
global.document = mockElement as any;
|
||||||
|
|
||||||
describe("shortcuts", () => {
|
describe("shortcuts", () => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import utils from "./utils.js";
|
import utils from "./utils.js";
|
||||||
|
|
||||||
type ElementType = HTMLElement | Document;
|
type ElementType = HTMLElement | Document;
|
||||||
type Handler = () => void;
|
type Handler = (e: KeyboardEvent) => void;
|
||||||
|
|
||||||
interface ShortcutBinding {
|
interface ShortcutBinding {
|
||||||
element: HTMLElement | Document;
|
element: HTMLElement | Document;
|
||||||
@ -45,7 +45,7 @@ function bindElShortcut($el: JQuery<ElementType | Element>, keyboardShortcut: st
|
|||||||
if (matchesShortcut(e, keyboardShortcut)) {
|
if (matchesShortcut(e, keyboardShortcut)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
handler();
|
handler(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
import { ActionKeyboardShortcut } from "@triliumnext/commons";
|
||||||
import type { CommandNames } from "../../components/app_context.js";
|
import type { CommandNames } from "../../components/app_context.js";
|
||||||
import keyboardActionsService, { type Action } from "../../services/keyboard_actions.js";
|
import keyboardActionsService from "../../services/keyboard_actions.js";
|
||||||
import AbstractButtonWidget, { type AbstractButtonWidgetSettings } from "./abstract_button.js";
|
import AbstractButtonWidget, { type AbstractButtonWidgetSettings } from "./abstract_button.js";
|
||||||
import type { ButtonNoteIdProvider } from "./button_from_note.js";
|
import type { ButtonNoteIdProvider } from "./button_from_note.js";
|
||||||
|
|
||||||
let actions: Action[];
|
let actions: ActionKeyboardShortcut[];
|
||||||
|
|
||||||
keyboardActionsService.getActions().then((as) => (actions = as));
|
keyboardActionsService.getActions().then((as) => (actions = as));
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ export default class CommandButtonWidget extends AbstractButtonWidget<CommandBut
|
|||||||
|
|
||||||
const action = actions.find((act) => act.actionName === this._command);
|
const action = actions.find((act) => act.actionName === this._command);
|
||||||
|
|
||||||
if (action && action.effectiveShortcuts.length > 0) {
|
if (action?.effectiveShortcuts && action.effectiveShortcuts.length > 0) {
|
||||||
return `${title} (${action.effectiveShortcuts.join(", ")})`;
|
return `${title} (${action.effectiveShortcuts.join(", ")})`;
|
||||||
} else {
|
} else {
|
||||||
return title;
|
return title;
|
||||||
|
@ -268,7 +268,7 @@ export default class RibbonContainer extends NoteContextAwareWidget {
|
|||||||
const action = actions.find((act) => act.actionName === toggleCommandName);
|
const action = actions.find((act) => act.actionName === toggleCommandName);
|
||||||
const title = $(this).attr("data-title");
|
const title = $(this).attr("data-title");
|
||||||
|
|
||||||
if (action && action.effectiveShortcuts.length > 0) {
|
if (action?.effectiveShortcuts && action.effectiveShortcuts.length > 0) {
|
||||||
return `${title} (${action.effectiveShortcuts.join(", ")})`;
|
return `${title} (${action.effectiveShortcuts.join(", ")})`;
|
||||||
} else {
|
} else {
|
||||||
return title ?? "";
|
return title ?? "";
|
||||||
|
@ -187,7 +187,7 @@ export default class JumpToNoteDialog extends BasicWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showInFullText(e: JQuery.TriggeredEvent) {
|
showInFullText(e: JQuery.TriggeredEvent | KeyboardEvent) {
|
||||||
// stop from propagating upwards (dangerous, especially with ctrl+enter executable javascript notes)
|
// stop from propagating upwards (dangerous, especially with ctrl+enter executable javascript notes)
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
@ -1552,7 +1552,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
const hotKeyMap: Record<string, (node: Fancytree.FancytreeNode, e: JQuery.KeyDownEvent) => boolean> = {};
|
const hotKeyMap: Record<string, (node: Fancytree.FancytreeNode, e: JQuery.KeyDownEvent) => boolean> = {};
|
||||||
|
|
||||||
for (const action of actions) {
|
for (const action of actions) {
|
||||||
for (const shortcut of action.effectiveShortcuts) {
|
for (const shortcut of action.effectiveShortcuts ?? []) {
|
||||||
hotKeyMap[shortcutService.normalizeShortcut(shortcut)] = (node) => {
|
hotKeyMap[shortcutService.normalizeShortcut(shortcut)] = (node) => {
|
||||||
const notePath = treeService.getNotePath(node);
|
const notePath = treeService.getNotePath(node);
|
||||||
|
|
||||||
|
@ -52,7 +52,8 @@ export default class DateTimeFormatOptions extends OptionsWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async optionsLoaded(options: OptionMap) {
|
async optionsLoaded(options: OptionMap) {
|
||||||
const shortcutKey = (await keyboardActionsService.getAction("insertDateTimeToText")).effectiveShortcuts.join(", ");
|
const action = await keyboardActionsService.getAction("insertDateTimeToText");
|
||||||
|
const shortcutKey = (action.effectiveShortcuts ?? []).join(", ");
|
||||||
const $link = await linkService.createLink("_hidden/_options/_optionsShortcuts", {
|
const $link = await linkService.createLink("_hidden/_options/_optionsShortcuts", {
|
||||||
"title": shortcutKey,
|
"title": shortcutKey,
|
||||||
"showTooltip": false
|
"showTooltip": false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user