Added tab highlighting and scroll into view logic
This commit is contained in:
@@ -158,6 +158,11 @@ export class CodeViewComponent extends CodeViewBase {
|
|||||||
this.lspManagerService.sendMessage(message);
|
this.lspManagerService.sendMessage(message);
|
||||||
this.markdownPreviewService.sendMessage(message);
|
this.markdownPreviewService.sendMessage(message);
|
||||||
|
|
||||||
|
message = new ServiceMessage();
|
||||||
|
message.action = "highlight-active-tab";
|
||||||
|
message.filePath = this.activeFile?.path;
|
||||||
|
this.tabsService.sendMessage(message);
|
||||||
|
|
||||||
this.updateInfoBar();
|
this.updateInfoBar();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -226,7 +231,6 @@ export class CodeViewComponent extends CodeViewBase {
|
|||||||
message.action = "file-changed";
|
message.action = "file-changed";
|
||||||
message.filePath = this.activeFile.path;
|
message.filePath = this.activeFile.path;
|
||||||
this.tabsService.sendMessage(message);
|
this.tabsService.sendMessage(message);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.editor.on("changeSession", (session) => {
|
this.editor.on("changeSession", (session) => {
|
||||||
@@ -236,6 +240,11 @@ export class CodeViewComponent extends CodeViewBase {
|
|||||||
|
|
||||||
this.lspManagerService.sendMessage(message);
|
this.lspManagerService.sendMessage(message);
|
||||||
|
|
||||||
|
message = new ServiceMessage();
|
||||||
|
message.action = "highlight-active-tab";
|
||||||
|
message.filePath = this.activeFile?.path;
|
||||||
|
this.tabsService.sendMessage(message);
|
||||||
|
|
||||||
this.updateInfoBar();
|
this.updateInfoBar();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export class TabsComponent {
|
|||||||
|
|
||||||
tabs: any[] = this.tabsService.tabs;
|
tabs: any[] = this.tabsService.tabs;
|
||||||
targetEvent!: any;
|
targetEvent!: any;
|
||||||
|
activeTab!: any;
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -54,7 +55,7 @@ export class TabsComponent {
|
|||||||
this.tabsService.getMessage$().pipe(
|
this.tabsService.getMessage$().pipe(
|
||||||
takeUntilDestroyed(this.#destroyRef)
|
takeUntilDestroyed(this.#destroyRef)
|
||||||
).subscribe((message: ServiceMessage) => {
|
).subscribe((message: ServiceMessage) => {
|
||||||
let elm = document.querySelectorAll(`[title="${message.filePath}"]`)[1];
|
let elm = document.querySelector(`[title="${message.filePath}"]`);
|
||||||
|
|
||||||
switch ( message.action ) {
|
switch ( message.action ) {
|
||||||
case "create-tab":
|
case "create-tab":
|
||||||
@@ -71,6 +72,42 @@ export class TabsComponent {
|
|||||||
case "file-saved":
|
case "file-saved":
|
||||||
elm.classList.remove("file-deleted");
|
elm.classList.remove("file-deleted");
|
||||||
elm.classList.remove("file-changed");
|
elm.classList.remove("file-changed");
|
||||||
|
break;
|
||||||
|
case "highlight-active-tab":
|
||||||
|
console.log("\n\n")
|
||||||
|
console.log(message)
|
||||||
|
console.log(elm)
|
||||||
|
console.log(this.activeTab)
|
||||||
|
|
||||||
|
if (!elm) {
|
||||||
|
if (this.activeTab) {
|
||||||
|
this.activeTab.classList.remove("active-tab")
|
||||||
|
this.activeTab = elm;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.activeTab) {
|
||||||
|
if (
|
||||||
|
this.activeTab.getAttribute("title") == elm.getAttribute("title")
|
||||||
|
) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.activeTab.classList.remove("active-tab")
|
||||||
|
}
|
||||||
|
|
||||||
|
this.activeTab = elm;
|
||||||
|
elm.classList.add("active-tab");
|
||||||
|
elm.scrollIntoView(
|
||||||
|
{
|
||||||
|
behavior: "smooth",
|
||||||
|
block: "center",
|
||||||
|
inline: "center"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -208,16 +245,14 @@ export class TabsComponent {
|
|||||||
let target = event.target;
|
let target = event.target;
|
||||||
|
|
||||||
if ( target.classList.contains("tab") ) {
|
if ( target.classList.contains("tab") ) {
|
||||||
this.tabsService.sendEditorsServiceAMessage(
|
let fpath = event.srcElement.getAttribute("title")
|
||||||
"set-tab-to-editor",
|
this.tabsService.sendEditorsServiceAMessage("set-tab-to-editor", fpath);
|
||||||
event.srcElement.getAttribute("title")
|
|
||||||
);
|
|
||||||
|
|
||||||
|
// this.updateActiveTabHighlight(fpath);
|
||||||
} else if ( target.classList.contains("title") ) {
|
} else if ( target.classList.contains("title") ) {
|
||||||
this.tabsService.sendEditorsServiceAMessage(
|
let fpath = event.srcElement.parentElement.getAttribute("title")
|
||||||
"set-tab-to-editor",
|
this.tabsService.sendEditorsServiceAMessage("set-tab-to-editor", fpath);
|
||||||
event.srcElement.parentElement.getAttribute("title")
|
// this.updateActiveTabHighlight(fpath);
|
||||||
);
|
|
||||||
} else if ( target.classList.contains("close-button") ) {
|
} else if ( target.classList.contains("close-button") ) {
|
||||||
this.tabsService.closeTab(
|
this.tabsService.closeTab(
|
||||||
event.srcElement.parentElement.getAttribute("title")
|
event.srcElement.parentElement.getAttribute("title")
|
||||||
@@ -225,4 +260,11 @@ export class TabsComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private updateActiveTabHighlight(fpath: string): void {
|
||||||
|
let message = new ServiceMessage();
|
||||||
|
message.action = "highlight-active-tab";
|
||||||
|
message.filePath = fpath;
|
||||||
|
this.tabsService.sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user