Vanessa 2025-02-09 13:30:18 +08:00
parent 9b2f439675
commit 2c951ab6da

View file

@ -85,8 +85,14 @@ export class Files extends Model {
case "removeDoc":
this.onRemove(data);
break;
case "createdailynote":
case "create":
if (data.data.listDocTree) {
this.selectItem(data.data.box.id, data.data.path);
} else {
this.updateItemArrow(data.data.box.id, data.data.path);
}
break;
case "createdailynote":
case "heading2doc":
case "li2doc":
this.selectItem(data.data.box.id, data.data.path);
@ -754,6 +760,29 @@ export class Files extends Model {
}
}
private updateItemArrow(notebookId: string, filePath: string) {
const treeElement = this.element.querySelector(`[data-url="${notebookId}"]`);
if (!treeElement) {
return;
}
let currentPath = filePath;
let liElement
while (!liElement) {
liElement = treeElement.querySelector(`[data-path="${currentPath}"]`);
if (!liElement) {
const dirname = pathPosix().dirname(currentPath);
if (dirname === "/") {
currentPath = dirname;
} else {
currentPath = dirname + ".sy";
}
} else {
liElement.querySelector("fn__hidden").classList.remove("fn__hidden");
break;
}
}
}
private genNotebook(item: INotebook) {
const emojiHTML = `<span class="b3-list-item__icon b3-tooltips b3-tooltips__e" aria-label="${window.siyuan.languages.changeIcon}">${unicode2Emoji(item.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].note)}</span>`;
if (item.closed) {