mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
2e15fbf098
commit
28957d3ba6
3 changed files with 9 additions and 21 deletions
|
|
@ -345,11 +345,14 @@ export const updatePanelByEditor = (protyle?: IProtyle, focus = true, pushBackSt
|
||||||
}
|
}
|
||||||
if (window.siyuan.config.fileTree.alwaysSelectOpenedFile && protyle) {
|
if (window.siyuan.config.fileTree.alwaysSelectOpenedFile && protyle) {
|
||||||
const fileModel = getDockByType("file")?.data.file;
|
const fileModel = getDockByType("file")?.data.file;
|
||||||
if (fileModel instanceof Files && !fileModel.isSelected(protyle.path)) {
|
if (fileModel instanceof Files) {
|
||||||
|
const target = fileModel.element.querySelector(`li[data-path="${protyle.path}"]`);
|
||||||
|
if (!target || (target && !target.classList.contains("b3-list-item--focus"))) {
|
||||||
fileModel.selectItem(protyle.notebookId, protyle.path);
|
fileModel.selectItem(protyle.notebookId, protyle.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 切换页签或关闭所有页签时,需更新对应的面板
|
// 切换页签或关闭所有页签时,需更新对应的面板
|
||||||
const models = getAllModels();
|
const models = getAllModels();
|
||||||
updateOutline(models, protyle, reload);
|
updateOutline(models, protyle, reload);
|
||||||
|
|
|
||||||
|
|
@ -852,21 +852,6 @@ export class Files extends Model {
|
||||||
liElement.insertAdjacentHTML("afterend", `<ul>${fileHTML}</ul>`);
|
liElement.insertAdjacentHTML("afterend", `<ul>${fileHTML}</ul>`);
|
||||||
this.setCurrent(this.element.querySelector(`ul[data-url="${data.box}"] li[data-path="${filePath}"]`));
|
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) {
|
private setCurrent(target: HTMLElement, isScroll = true) {
|
||||||
if (!target) {
|
if (!target) {
|
||||||
|
|
|
||||||
|
|
@ -432,7 +432,7 @@ export const globalShortcut = () => {
|
||||||
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general[item.hotkeyLangId].custom)}</span>
|
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general[item.hotkeyLangId].custom)}</span>
|
||||||
</li>`;
|
</li>`;
|
||||||
});
|
});
|
||||||
let range: Range
|
let range: Range;
|
||||||
if (getSelection().rangeCount > 0) {
|
if (getSelection().rangeCount > 0) {
|
||||||
range = getSelection().getRangeAt(0).cloneRange();
|
range = getSelection().getRangeAt(0).cloneRange();
|
||||||
}
|
}
|
||||||
|
|
@ -450,7 +450,7 @@ export const globalShortcut = () => {
|
||||||
transparent: true,
|
transparent: true,
|
||||||
destroyCallback: () => {
|
destroyCallback: () => {
|
||||||
if (range && range.getBoundingClientRect().height !== 0) {
|
if (range && range.getBoundingClientRect().height !== 0) {
|
||||||
focusByRange(range)
|
focusByRange(range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -1260,7 +1260,7 @@ const panelTreeKeydown = (event: KeyboardEvent) => {
|
||||||
if (nextElement.nextElementSibling.tagName === "UL") {
|
if (nextElement.nextElementSibling.tagName === "UL") {
|
||||||
if (nextElement.nextElementSibling.classList.contains("fn__none")) { // 遇到折叠内容
|
if (nextElement.nextElementSibling.classList.contains("fn__none")) { // 遇到折叠内容
|
||||||
if (nextElement.nextElementSibling.nextElementSibling) {
|
if (nextElement.nextElementSibling.nextElementSibling) {
|
||||||
nextElement = nextElement.nextElementSibling.nextElementSibling
|
nextElement = nextElement.nextElementSibling.nextElementSibling;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nextElement = nextElement.nextElementSibling.firstElementChild;
|
nextElement = nextElement.nextElementSibling.firstElementChild;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue