import Draggabilly from "draggabilly"; import { t } from "../services/i18n.js"; import BasicWidget from "./basic_widget.js"; import contextMenu from "../menus/context_menu.js"; import utils from "../services/utils.js"; import keyboardActionService from "../services/keyboard_actions.js"; import appContext from "../components/app_context.js"; import froca from "../services/froca.js"; import attributeService from "../services/attributes.js"; const TAB_CONTAINER_MIN_WIDTH = 24; const TAB_CONTAINER_MAX_WIDTH = 240; const TAB_CONTAINER_LEFT_PADDING = 5; const NEW_TAB_WIDTH = 32; const MIN_FILLER_WIDTH = 50; const MARGIN_WIDTH = 5; const TAB_SIZE_SMALL = 84; const TAB_SIZE_SMALLER = 60; const TAB_SIZE_MINI = 48; const TAB_TPL = `
`; const NEW_TAB_BUTTON_TPL = `
+
`; const FILLER_TPL = `
`; const TAB_ROW_TPL = `
`; export default class TabRowWidget extends BasicWidget { doRender() { this.$widget = $(TAB_ROW_TPL); const documentStyle = window.getComputedStyle(document.documentElement); this.showNoteIcons = documentStyle.getPropertyValue("--tab-note-icons") === "true"; this.draggabillies = []; this.setupStyle(); this.setupEvents(); this.setupDraggabilly(); this.setupNewButton(); this.setupFiller(); this.layoutTabs(); this.setVisibility(); this.$widget.on("contextmenu", ".note-tab", (e) => { e.preventDefault(); const ntxId = $(e.target).closest(".note-tab").attr("data-ntx-id"); contextMenu.show({ x: e.pageX, y: e.pageY, items: [ { title: t("tab_row.close"), command: "closeTab", uiIcon: "bx bx-x" }, { title: t("tab_row.close_other_tabs"), command: "closeOtherTabs", uiIcon: "bx bx-empty", enabled: appContext.tabManager.noteContexts.length !== 1 }, { title: t("tab_row.close_right_tabs"), command: "closeRightTabs", uiIcon: "bx bx-empty", enabled: appContext.tabManager.noteContexts.at(-1).ntxId !== ntxId }, { title: t("tab_row.close_all_tabs"), command: "closeAllTabs", uiIcon: "bx bx-empty" }, { title: "----" }, { title: t("tab_row.reopen_last_tab"), command: "reopenLastTab", uiIcon: "bx bx-undo", enabled: appContext.tabManager.recentlyClosedTabs.length !== 0 }, { title: "----" }, { title: t("tab_row.move_tab_to_new_window"), command: "moveTabToNewWindow", uiIcon: "bx bx-window-open" }, { title: t("tab_row.copy_tab_to_new_window"), command: "copyTabToNewWindow", uiIcon: "bx bx-empty" } ], selectMenuItemHandler: ({ command }) => { this.triggerCommand(command, { ntxId }); } }); }); } setupStyle() { this.$style = $("