Vanessa 2025-10-15 20:32:13 +08:00
parent 7545c2517f
commit 214ceb37b1
7 changed files with 352 additions and 1006 deletions

View file

@ -1,8 +1,12 @@
@use "mixin"; @use "mixin";
.fn { .fn {
&__hidescrollbar::-webkit-scrollbar { &__hidescrollbar {
display: none; &::-webkit-scrollbar {
display: none;
}
overflow: auto;
} }
&__ellipsis { &__ellipsis {

View file

@ -150,14 +150,6 @@ export class Backlink extends Model {
this.searchBacklinks(); this.searchBacklinks();
} }
}); });
item.addEventListener("input", (event: KeyboardEvent) => {
const inputElement = event.target as HTMLInputElement;
if (inputElement.value === "") {
inputElement.classList.remove("search__input--block");
} else {
inputElement.classList.add("search__input--block");
}
});
}); });
this.tree = new Tree({ this.tree = new Tree({
element: this.element.querySelector(".backlinkList") as HTMLElement, element: this.element.querySelector(".backlinkList") as HTMLElement,

View file

@ -341,7 +341,6 @@ export class Graph extends Model {
}); });
this.inputElement.addEventListener("compositionend", () => { this.inputElement.addEventListener("compositionend", () => {
this.searchGraph(false); this.searchGraph(false);
this.inputElement.classList.add("search__input--block");
}); });
this.inputElement.addEventListener("blur", (event: InputEvent) => { this.inputElement.addEventListener("blur", (event: InputEvent) => {
const inputElement = event.target as HTMLInputElement; const inputElement = event.target as HTMLInputElement;
@ -351,11 +350,6 @@ export class Graph extends Model {
if (event.isComposing) { if (event.isComposing) {
return; return;
} }
if (this.inputElement.value === "") {
this.inputElement.classList.remove("search__input--block");
} else {
this.inputElement.classList.add("search__input--block");
}
this.searchGraph(false); this.searchGraph(false);
}); });
this.element.querySelectorAll(".b3-slider").forEach((item: HTMLInputElement) => { this.element.querySelectorAll(".b3-slider").forEach((item: HTMLInputElement) => {

File diff suppressed because it is too large Load diff

View file

@ -388,7 +388,7 @@ export const getLocalStorage = (cb: () => void) => {
defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""} defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""}
defaultStorage[Constants.LOCAL_PLUGIN_DOCKS] = {}; // { pluginName: {dockId: IPluginDockTab}} defaultStorage[Constants.LOCAL_PLUGIN_DOCKS] = {}; // { pluginName: {dockId: IPluginDockTab}}
defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = []; defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = [];
defaultStorage[Constants.LOCAL_OUTLINE] = {keepExpand: true, expand: {}}; defaultStorage[Constants.LOCAL_OUTLINE] = {keepCurrentExpand: false};
defaultStorage[Constants.LOCAL_FILEPOSITION] = {}; // {id: IScrollAttr} defaultStorage[Constants.LOCAL_FILEPOSITION] = {}; // {id: IScrollAttr}
defaultStorage[Constants.LOCAL_DIALOGPOSITION] = {}; // {id: IPosition} defaultStorage[Constants.LOCAL_DIALOGPOSITION] = {}; // {id: IPosition}
defaultStorage[Constants.LOCAL_HISTORY] = { defaultStorage[Constants.LOCAL_HISTORY] = {

View file

@ -13,12 +13,11 @@ export class Tree {
private topExtHTML: string; private topExtHTML: string;
public click: (element: Element, event?: MouseEvent) => void; public click: (element: Element, event?: MouseEvent) => void;
private ctrlClick: (element: HTMLElement) => void; private ctrlClick: (element: HTMLElement, event: MouseEvent) => void;
private toggleClick: (element: Element) => void; private toggleClick: (element: Element) => void;
private shiftClick: (element: HTMLElement) => void; private shiftClick: (element: HTMLElement) => void;
private altClick: (element: HTMLElement, event?: MouseEvent) => void; private altClick: (element: HTMLElement, event: MouseEvent) => void;
private rightClick: (element: HTMLElement, event: MouseEvent) => void; private rightClick: (element: HTMLElement, event: MouseEvent) => void;
public onToggleChange: () => void;
constructor(options: { constructor(options: {
element: HTMLElement, element: HTMLElement,
@ -26,12 +25,11 @@ export class Tree {
blockExtHTML?: string, blockExtHTML?: string,
topExtHTML?: string, topExtHTML?: string,
click?(element: HTMLElement, event: MouseEvent): void click?(element: HTMLElement, event: MouseEvent): void
ctrlClick?(element: HTMLElement): void ctrlClick?(element: HTMLElement, event: MouseEvent): void
altClick?(element: HTMLElement, event?: MouseEvent): void altClick?(element: HTMLElement, event: MouseEvent): void
shiftClick?(element: HTMLElement): void shiftClick?(element: HTMLElement): void
toggleClick?(element: HTMLElement): void toggleClick?(element: HTMLElement): void
rightClick?(element: HTMLElement, event: MouseEvent): void rightClick?(element: HTMLElement, event: MouseEvent): void
onToggleChange?: () => void
}) { }) {
this.click = options.click; this.click = options.click;
this.ctrlClick = options.ctrlClick; this.ctrlClick = options.ctrlClick;
@ -39,7 +37,6 @@ export class Tree {
this.shiftClick = options.shiftClick; this.shiftClick = options.shiftClick;
this.rightClick = options.rightClick; this.rightClick = options.rightClick;
this.toggleClick = options.toggleClick; this.toggleClick = options.toggleClick;
this.onToggleChange = options.onToggleChange;
this.element = options.element; this.element = options.element;
this.blockExtHTML = options.blockExtHTML; this.blockExtHTML = options.blockExtHTML;
this.topExtHTML = options.topExtHTML; this.topExtHTML = options.topExtHTML;
@ -207,18 +204,7 @@ data-def-path="${item.defPath}">
this.element.addEventListener("contextmenu", (event) => { this.element.addEventListener("contextmenu", (event) => {
let target = event.target as HTMLElement; let target = event.target as HTMLElement;
while (target && !target.isEqualNode(this.element)) { while (target && !target.isEqualNode(this.element)) {
if (target.classList.contains("b3-list-item__toggle") && !target.classList.contains("fn__hidden")) { if (target.tagName === "LI" && this.rightClick) {
// 右键点击toggle时展开所有子标题
this.expandAllChildren(target.parentElement);
this.setCurrent(target.parentElement);
// 触发折叠状态变化事件
if (this.onToggleChange) {
this.onToggleChange();
}
event.preventDefault();
event.stopPropagation();
break;
} else if (target.tagName === "LI" && this.rightClick) {
this.rightClick(target, event); this.rightClick(target, event);
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
@ -230,13 +216,10 @@ data-def-path="${item.defPath}">
this.element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => { this.element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
let target = event.target as HTMLElement; let target = event.target as HTMLElement;
while (target && !target.isEqualNode(this.element)) { while (target && !target.isEqualNode(this.element)) {
if (target.classList.contains("b3-list-item__toggle") && !target.classList.contains("fn__hidden")) { if (target.classList.contains("b3-list-item__toggle") &&
!target.classList.contains("fn__hidden") && !window.siyuan.ctrlIsPressed && !window.siyuan.altIsPressed) {
this.toggleBlocks(target.parentElement); this.toggleBlocks(target.parentElement);
this.setCurrent(target.parentElement); this.setCurrent(target.parentElement);
// 触发折叠状态变化事件
if (this.onToggleChange) {
this.onToggleChange();
}
event.preventDefault(); event.preventDefault();
break; break;
} }
@ -253,7 +236,7 @@ data-def-path="${item.defPath}">
this.setCurrent(target); this.setCurrent(target);
if (target.getAttribute("data-node-id") || target.getAttribute("data-treetype") === "tag") { if (target.getAttribute("data-node-id") || target.getAttribute("data-treetype") === "tag") {
if (this.ctrlClick && window.siyuan.ctrlIsPressed) { if (this.ctrlClick && window.siyuan.ctrlIsPressed) {
this.ctrlClick(target); this.ctrlClick(target, event);
} else if (this.altClick && window.siyuan.altIsPressed) { } else if (this.altClick && window.siyuan.altIsPressed) {
this.altClick(target, event); this.altClick(target, event);
} else if (this.shiftClick && window.siyuan.shiftIsPressed) { } else if (this.shiftClick && window.siyuan.shiftIsPressed) {
@ -289,86 +272,6 @@ data-def-path="${item.defPath}">
}); });
} }
public expandAllChildren(liElement: Element) {
if (!liElement || !liElement.nextElementSibling) {
return;
}
// 获取当前项的子列表
const nextElement = liElement.nextElementSibling;
if (!nextElement || nextElement.tagName !== "UL") {
return;
}
// 检查子元素的展开状态,如果所有子元素都已展开,则折叠;否则展开所有
const areAllChildrenExpanded = this.areAllChildrenExpanded(nextElement);
// 确保当前元素保持展开状态
const svgElement = liElement.firstElementChild.firstElementChild;
if (!svgElement.classList.contains("b3-list-item__arrow--open")) {
svgElement.classList.add("b3-list-item__arrow--open");
nextElement.classList.remove("fn__none");
if (nextElement.nextElementSibling && nextElement.nextElementSibling.tagName === "UL") {
nextElement.nextElementSibling.classList.remove("fn__none");
}
}
if (areAllChildrenExpanded) {
// 折叠所有子元素,但保持当前元素展开
this.collapseAllChildren(nextElement);
} else {
// 展开所有子元素
this.expandAllChildrenRecursive(nextElement);
}
}
private areAllChildrenExpanded(ulElement: Element): boolean {
const childItems = ulElement.querySelectorAll(":scope > li");
for (const childLi of childItems) {
const arrow = childLi.querySelector(".b3-list-item__arrow");
if (arrow && !arrow.classList.contains("b3-list-item__arrow--open")) {
return false;
}
const childUl = childLi.nextElementSibling;
if (childUl && childUl.tagName === "UL") {
if (!this.areAllChildrenExpanded(childUl)) {
return false;
}
}
}
return true;
}
private expandAllChildrenRecursive(ulElement: Element) {
ulElement.classList.remove("fn__none");
const childItems = ulElement.querySelectorAll(":scope > li");
childItems.forEach(childLi => {
const arrow = childLi.querySelector(".b3-list-item__arrow");
if (arrow) {
arrow.classList.add("b3-list-item__arrow--open");
}
const childUl = childLi.nextElementSibling;
if (childUl && childUl.tagName === "UL") {
this.expandAllChildrenRecursive(childUl);
}
});
}
private collapseAllChildren(ulElement: Element) {
const childItems = ulElement.querySelectorAll(":scope > li");
childItems.forEach(childLi => {
const arrow = childLi.querySelector(".b3-list-item__arrow");
if (arrow) {
arrow.classList.remove("b3-list-item__arrow--open");
}
const childUl = childLi.nextElementSibling;
if (childUl && childUl.tagName === "UL") {
childUl.classList.add("fn__none");
this.collapseAllChildren(childUl);
}
});
}
public expandAll() { public expandAll() {
this.element.querySelectorAll("ul").forEach(item => { this.element.querySelectorAll("ul").forEach(item => {
if (!item.classList.contains("b3-list")) { if (!item.classList.contains("b3-list")) {
@ -400,6 +303,9 @@ data-def-path="${item.defPath}">
} }
public setExpandIds(ids: string[]) { public setExpandIds(ids: string[]) {
if (!ids || ids.length === 0) {
return;
}
this.element.querySelectorAll(".b3-list-item__arrow").forEach(item => { this.element.querySelectorAll(".b3-list-item__arrow").forEach(item => {
if (ids.includes(item.getAttribute("data-id"))) { if (ids.includes(item.getAttribute("data-id"))) {
item.classList.add("b3-list-item__arrow--open"); item.classList.add("b3-list-item__arrow--open");

View file

@ -162,7 +162,7 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
const dialog = new Dialog({ const dialog = new Dialog({
title: `<div style="padding: 8px;"> title: `<div style="padding: 8px;">
${title || window.siyuan.languages.move} ${title || window.siyuan.languages.move}
<div style="max-height: 16px;overflow: auto;line-height: 14px;-webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0) 0, #000 6px);padding-bottom: 4px;margin-bottom: -4px" class="ft__smaller ft__on-surface fn__hidescrollbar"></div> <div style="max-height: 16px;line-height: 14px;-webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0) 0, #000 6px);padding-bottom: 4px;margin-bottom: -4px" class="ft__smaller ft__on-surface fn__hidescrollbar"></div>
</div>`, </div>`,
content: `<div class="b3-form__icon" style="margin: 8px"> content: `<div class="b3-form__icon" style="margin: 8px">
<span data-menu="true" class="b3-form__icon-list fn__a b3-tooltips b3-tooltips__s" aria-label="${updateHotkeyTip("")}"> <span data-menu="true" class="b3-form__icon-list fn__a b3-tooltips b3-tooltips__s" aria-label="${updateHotkeyTip("")}">