mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
7545c2517f
commit
214ceb37b1
7 changed files with 352 additions and 1006 deletions
|
|
@ -1,10 +1,14 @@
|
|||
@use "mixin";
|
||||
|
||||
.fn {
|
||||
&__hidescrollbar::-webkit-scrollbar {
|
||||
&__hidescrollbar {
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
&__ellipsis {
|
||||
@include mixin.text-clamp(1);
|
||||
display: block; // 集市挂件名称过长遮挡星标 https://github.com/siyuan-note/siyuan/issues/4782
|
||||
|
|
|
|||
|
|
@ -150,14 +150,6 @@ export class Backlink extends Model {
|
|||
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({
|
||||
element: this.element.querySelector(".backlinkList") as HTMLElement,
|
||||
|
|
|
|||
|
|
@ -341,7 +341,6 @@ export class Graph extends Model {
|
|||
});
|
||||
this.inputElement.addEventListener("compositionend", () => {
|
||||
this.searchGraph(false);
|
||||
this.inputElement.classList.add("search__input--block");
|
||||
});
|
||||
this.inputElement.addEventListener("blur", (event: InputEvent) => {
|
||||
const inputElement = event.target as HTMLInputElement;
|
||||
|
|
@ -351,11 +350,6 @@ export class Graph extends Model {
|
|||
if (event.isComposing) {
|
||||
return;
|
||||
}
|
||||
if (this.inputElement.value === "") {
|
||||
this.inputElement.classList.remove("search__input--block");
|
||||
} else {
|
||||
this.inputElement.classList.add("search__input--block");
|
||||
}
|
||||
this.searchGraph(false);
|
||||
});
|
||||
this.element.querySelectorAll(".b3-slider").forEach((item: HTMLInputElement) => {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -388,7 +388,7 @@ export const getLocalStorage = (cb: () => void) => {
|
|||
defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""}
|
||||
defaultStorage[Constants.LOCAL_PLUGIN_DOCKS] = {}; // { pluginName: {dockId: IPluginDockTab}}
|
||||
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_DIALOGPOSITION] = {}; // {id: IPosition}
|
||||
defaultStorage[Constants.LOCAL_HISTORY] = {
|
||||
|
|
|
|||
|
|
@ -13,12 +13,11 @@ export class Tree {
|
|||
private topExtHTML: string;
|
||||
|
||||
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 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;
|
||||
public onToggleChange: () => void;
|
||||
|
||||
constructor(options: {
|
||||
element: HTMLElement,
|
||||
|
|
@ -26,12 +25,11 @@ export class Tree {
|
|||
blockExtHTML?: string,
|
||||
topExtHTML?: string,
|
||||
click?(element: HTMLElement, event: MouseEvent): void
|
||||
ctrlClick?(element: HTMLElement): void
|
||||
altClick?(element: HTMLElement, event?: MouseEvent): void
|
||||
ctrlClick?(element: HTMLElement, event: MouseEvent): void
|
||||
altClick?(element: HTMLElement, event: MouseEvent): void
|
||||
shiftClick?(element: HTMLElement): void
|
||||
toggleClick?(element: HTMLElement): void
|
||||
rightClick?(element: HTMLElement, event: MouseEvent): void
|
||||
onToggleChange?: () => void
|
||||
}) {
|
||||
this.click = options.click;
|
||||
this.ctrlClick = options.ctrlClick;
|
||||
|
|
@ -39,7 +37,6 @@ export class Tree {
|
|||
this.shiftClick = options.shiftClick;
|
||||
this.rightClick = options.rightClick;
|
||||
this.toggleClick = options.toggleClick;
|
||||
this.onToggleChange = options.onToggleChange;
|
||||
this.element = options.element;
|
||||
this.blockExtHTML = options.blockExtHTML;
|
||||
this.topExtHTML = options.topExtHTML;
|
||||
|
|
@ -207,18 +204,7 @@ data-def-path="${item.defPath}">
|
|||
this.element.addEventListener("contextmenu", (event) => {
|
||||
let target = event.target as HTMLElement;
|
||||
while (target && !target.isEqualNode(this.element)) {
|
||||
if (target.classList.contains("b3-list-item__toggle") && !target.classList.contains("fn__hidden")) {
|
||||
// 右键点击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) {
|
||||
if (target.tagName === "LI" && this.rightClick) {
|
||||
this.rightClick(target, event);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
|
@ -230,13 +216,10 @@ data-def-path="${item.defPath}">
|
|||
this.element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
|
||||
let target = event.target as HTMLElement;
|
||||
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.setCurrent(target.parentElement);
|
||||
// 触发折叠状态变化事件
|
||||
if (this.onToggleChange) {
|
||||
this.onToggleChange();
|
||||
}
|
||||
event.preventDefault();
|
||||
break;
|
||||
}
|
||||
|
|
@ -253,7 +236,7 @@ data-def-path="${item.defPath}">
|
|||
this.setCurrent(target);
|
||||
if (target.getAttribute("data-node-id") || target.getAttribute("data-treetype") === "tag") {
|
||||
if (this.ctrlClick && window.siyuan.ctrlIsPressed) {
|
||||
this.ctrlClick(target);
|
||||
this.ctrlClick(target, event);
|
||||
} else if (this.altClick && window.siyuan.altIsPressed) {
|
||||
this.altClick(target, event);
|
||||
} 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() {
|
||||
this.element.querySelectorAll("ul").forEach(item => {
|
||||
if (!item.classList.contains("b3-list")) {
|
||||
|
|
@ -400,6 +303,9 @@ data-def-path="${item.defPath}">
|
|||
}
|
||||
|
||||
public setExpandIds(ids: string[]) {
|
||||
if (!ids || ids.length === 0) {
|
||||
return;
|
||||
}
|
||||
this.element.querySelectorAll(".b3-list-item__arrow").forEach(item => {
|
||||
if (ids.includes(item.getAttribute("data-id"))) {
|
||||
item.classList.add("b3-list-item__arrow--open");
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
|
|||
const dialog = new Dialog({
|
||||
title: `<div style="padding: 8px;">
|
||||
${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>`,
|
||||
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("⌥↓")}">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue