🎨 已选中的文件再次选中时,不会在文件树中跳转 (#6820)

This commit is contained in:
meteor 2022-12-08 21:41:35 +08:00 committed by GitHub
parent 44f1e43e26
commit 2e15fbf098
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -345,7 +345,7 @@ export const updatePanelByEditor = (protyle?: IProtyle, focus = true, pushBackSt
}
if (window.siyuan.config.fileTree.alwaysSelectOpenedFile && protyle) {
const fileModel = getDockByType("file")?.data.file;
if (fileModel instanceof Files) {
if (fileModel instanceof Files && !fileModel.isSelected(protyle.path)) {
fileModel.selectItem(protyle.notebookId, protyle.path);
}
}

View file

@ -852,6 +852,21 @@ export class Files extends Model {
liElement.insertAdjacentHTML("afterend", `<ul>${fileHTML}</ul>`);
this.setCurrent(this.element.querySelector(`ul[data-url="${data.box}"] li[data-path="${filePath}"]`));
}
/**
*
* @param filePath
* @returns
*/
public isSelected(filePath: string): boolean {
if(!filePath) {
return false;
}
const target = this.element.querySelector(`li[data-path="${filePath}"]`);
if(target) {
return target.classList.contains("b3-list-item--focus");
}
return false;
}
private setCurrent(target: HTMLElement, isScroll = true) {
if (!target) {