mirror of
https://github.com/zadam/trilium.git
synced 2025-11-14 01:05:49 +01:00
Merge branch 'develop' into feat/llm-integration-part2
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
import { t } from "../../services/i18n.js";
|
||||
import options from "../../services/options.js";
|
||||
import CommandButtonWidget from "./command_button.js";
|
||||
|
||||
export default class CreateAiChatButton extends CommandButtonWidget {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.icon("bx bx-bot")
|
||||
.title(t("ai.create_new_ai_chat"))
|
||||
.titlePlacement("bottom")
|
||||
.command("createAiChat")
|
||||
.class("icon-action");
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
return options.get("aiEnabled") === "true";
|
||||
}
|
||||
|
||||
async refreshWithNote() {
|
||||
if (this.isEnabled()) {
|
||||
this.$widget.show();
|
||||
} else {
|
||||
this.$widget.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ export default class NoteActionsWidget extends NoteContextAwareWidget {
|
||||
|
||||
this.$convertNoteIntoAttachmentButton.toggle(note.isEligibleForConversionToAttachment());
|
||||
|
||||
this.toggleDisabled(this.$findInTextButton, ["text", "code", "book"].includes(note.type));
|
||||
this.toggleDisabled(this.$findInTextButton, ["text", "code", "book", "mindMap"].includes(note.type));
|
||||
|
||||
this.toggleDisabled(this.$showAttachmentsButton, !isInOptions);
|
||||
this.toggleDisabled(this.$showSourceButton, ["text", "code", "relationMap", "mermaid", "canvas", "mindMap", "geoMap"].includes(note.type));
|
||||
|
||||
@@ -188,7 +188,7 @@ export default class FindWidget extends NoteContextAwareWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!["text", "code", "render"].includes(this.note?.type ?? "")) {
|
||||
if (!["text", "code", "render", "mindMap"].includes(this.note?.type ?? "")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -250,6 +250,8 @@ export default class FindWidget extends NoteContextAwareWidget {
|
||||
case "text":
|
||||
const readOnly = await this.noteContext?.isReadOnly();
|
||||
return readOnly ? this.htmlHandler : this.textHandler;
|
||||
case "mindMap":
|
||||
return this.htmlHandler;
|
||||
default:
|
||||
console.warn("FindWidget: Unsupported note type for find widget", this.note?.type);
|
||||
}
|
||||
@@ -352,7 +354,7 @@ export default class FindWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
return super.isEnabled() && ["text", "code", "render"].includes(this.note?.type ?? "");
|
||||
return super.isEnabled() && ["text", "code", "render", "mindMap"].includes(this.note?.type ?? "");
|
||||
}
|
||||
|
||||
async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
|
||||
|
||||
@@ -85,7 +85,7 @@ export default class FindInHtml {
|
||||
if (this.$results?.length) {
|
||||
const $current = this.$results.eq(this.currentIndex);
|
||||
this.$results.removeClass(FIND_RESULT_SELECTED_CSS_CLASSNAME);
|
||||
$current[0].scrollIntoView();
|
||||
$current[0].scrollIntoView({ block: 'center', inline: 'center'});
|
||||
$current.addClass(FIND_RESULT_SELECTED_CSS_CLASSNAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ const NOTE_TYPES: NoteTypeMapping[] = [
|
||||
// Misc note types
|
||||
{ type: "render", mime: "", title: t("note_types.render-note"), selectable: true },
|
||||
{ type: "webView", mime: "", title: t("note_types.web-view"), selectable: true },
|
||||
{ type: "aiChat", mime: "application/json", title: t("note_types.ai-chat"), selectable: true },
|
||||
|
||||
// Code notes
|
||||
{ type: "code", mime: "text/plain", title: t("note_types.code"), selectable: true },
|
||||
@@ -50,7 +49,8 @@ const NOTE_TYPES: NoteTypeMapping[] = [
|
||||
{ type: "image", title: t("note_types.image"), selectable: false },
|
||||
{ type: "launcher", mime: "", title: t("note_types.launcher"), selectable: false },
|
||||
{ type: "noteMap", mime: "", title: t("note_types.note-map"), selectable: false },
|
||||
{ type: "search", title: t("note_types.saved-search"), selectable: false }
|
||||
{ type: "search", title: t("note_types.saved-search"), selectable: false },
|
||||
{ type: "aiChat", mime: "application/json", title: t("note_types.ai-chat"), selectable: false }
|
||||
];
|
||||
|
||||
const NOT_SELECTABLE_NOTE_TYPES = NOTE_TYPES.filter((nt) => !nt.selectable).map((nt) => nt.type);
|
||||
|
||||
@@ -378,16 +378,45 @@ export default class TabRowWidget extends BasicWidget {
|
||||
}
|
||||
|
||||
scrollTabContainer(direction: number, behavior: ScrollBehavior = "smooth") {
|
||||
const currentScrollLeft = this.$tabScrollingContainer[0]?.scrollLeft;
|
||||
this.$tabScrollingContainer[0].scrollTo({
|
||||
left: currentScrollLeft + direction,
|
||||
this.$tabScrollingContainer[0].scrollBy({
|
||||
left: direction,
|
||||
behavior
|
||||
});
|
||||
};
|
||||
|
||||
setupScrollEvents() {
|
||||
this.$tabScrollingContainer[0].addEventListener('wheel', (event) => {
|
||||
this.scrollTabContainer(event.deltaY * 1.5);
|
||||
let deltaX = 0;
|
||||
let isScrolling = false;
|
||||
const stepScroll = () => {
|
||||
if (Math.abs(deltaX) > 5) {
|
||||
const step = Math.round(deltaX * 0.2);
|
||||
deltaX -= step;
|
||||
this.scrollTabContainer(step, "instant");
|
||||
requestAnimationFrame(stepScroll);
|
||||
} else {
|
||||
this.scrollTabContainer(deltaX, "instant");
|
||||
deltaX = 0;
|
||||
isScrolling = false;
|
||||
}
|
||||
};
|
||||
this.$tabScrollingContainer[0].addEventListener('wheel', async (event) => {
|
||||
if (!event.shiftKey && event.deltaX === 0) {
|
||||
event.preventDefault();
|
||||
// Clamp deltaX between TAB_CONTAINER_MIN_WIDTH and TAB_CONTAINER_MIN_WIDTH * 3
|
||||
deltaX += Math.sign(event.deltaY) * Math.max(Math.min(Math.abs(event.deltaY), TAB_CONTAINER_MIN_WIDTH * 3), TAB_CONTAINER_MIN_WIDTH);
|
||||
if (!isScrolling) {
|
||||
isScrolling = true;
|
||||
stepScroll();
|
||||
}
|
||||
} else if (event.shiftKey) {
|
||||
event.preventDefault();
|
||||
if (event.deltaY > 0) {
|
||||
await appContext.tabManager.activateNextTabCommand();
|
||||
} else {
|
||||
await appContext.tabManager.activatePreviousTabCommand();
|
||||
}
|
||||
this.activeTabEl.scrollIntoView();
|
||||
}
|
||||
});
|
||||
|
||||
this.$scrollButtonLeft[0].addEventListener('click', () => this.scrollTabContainer(-200));
|
||||
|
||||
@@ -286,4 +286,13 @@ export default class MindMapWidget extends TypeWidget {
|
||||
utils.downloadSvgAsPng(this.note.title, svg);
|
||||
}
|
||||
|
||||
async executeWithContentElementEvent({ resolve, ntxId }: EventData<"executeWithContentElement">) {
|
||||
if (!this.isNoteContext(ntxId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.initialized;
|
||||
|
||||
resolve(this.$content.find('.main-node-container'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user