mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
a2fb0071e7
commit
d5931778cf
6 changed files with 34 additions and 30 deletions
|
|
@ -306,7 +306,7 @@ export class Backlink extends Model {
|
|||
const clickEvent = (currentSort: string) => {
|
||||
(type === "sort" ? this.tree : this.mTree).element.previousElementSibling.querySelector(`[data-type="${type}"]`).setAttribute("data-sort", currentSort);
|
||||
this.searchBacklinks();
|
||||
}
|
||||
};
|
||||
window.siyuan.menus.menu.remove();
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: sort === "0" ? "iconSelect" : undefined,
|
||||
|
|
@ -314,57 +314,57 @@ export class Backlink extends Model {
|
|||
click: () => {
|
||||
clickEvent("0");
|
||||
}
|
||||
}).element)
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: sort === "1" ? "iconSelect" : undefined,
|
||||
label: window.siyuan.languages.fileNameDESC,
|
||||
click: () => {
|
||||
clickEvent("1");
|
||||
}
|
||||
}).element)
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: sort === "4" ? "iconSelect" : undefined,
|
||||
label: window.siyuan.languages.fileNameNatASC,
|
||||
click: () => {
|
||||
clickEvent("4");
|
||||
}
|
||||
}).element)
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: sort === "5" ? "iconSelect" : undefined,
|
||||
label: window.siyuan.languages.fileNameNatDESC,
|
||||
click: () => {
|
||||
clickEvent("5");
|
||||
}
|
||||
}).element)
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element)
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: sort === "9" ? "iconSelect" : undefined,
|
||||
label: window.siyuan.languages.createdASC,
|
||||
click: () => {
|
||||
clickEvent("9");
|
||||
}
|
||||
}).element)
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: sort === "10" ? "iconSelect" : undefined,
|
||||
label: window.siyuan.languages.createdDESC,
|
||||
click: () => {
|
||||
clickEvent("10");
|
||||
}
|
||||
}).element)
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: sort === "2" ? "iconSelect" : undefined,
|
||||
label: window.siyuan.languages.modifiedASC,
|
||||
click: () => {
|
||||
clickEvent("2");
|
||||
}
|
||||
}).element)
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: sort === "3" ? "iconSelect" : undefined,
|
||||
label: window.siyuan.languages.modifiedDESC,
|
||||
click: () => {
|
||||
clickEvent("3");
|
||||
}
|
||||
}).element)
|
||||
}).element);
|
||||
}
|
||||
|
||||
private toggleItem(liElement: HTMLElement, isMention: boolean) {
|
||||
|
|
@ -443,13 +443,13 @@ export class Backlink extends Model {
|
|||
backlinkOpenIds: [],
|
||||
backlinkMOpenIds: [],
|
||||
backlinkMStatus: 3 // 0 全展开,1 展开一半箭头向下,2 展开一半箭头向上,3 全收起
|
||||
}
|
||||
};
|
||||
this.tree.element.querySelectorAll(".b3-list-item__arrow--open").forEach(item => {
|
||||
this.status[this.blockId].backlinkOpenIds.push(item.parentElement.parentElement.getAttribute("data-node-id"))
|
||||
})
|
||||
this.status[this.blockId].backlinkOpenIds.push(item.parentElement.parentElement.getAttribute("data-node-id"));
|
||||
});
|
||||
this.mTree.element.querySelectorAll(".b3-list-item__arrow--open").forEach(item => {
|
||||
this.status[this.blockId].backlinkMOpenIds.push(item.parentElement.parentElement.getAttribute("data-node-id"))
|
||||
})
|
||||
this.status[this.blockId].backlinkMOpenIds.push(item.parentElement.parentElement.getAttribute("data-node-id"));
|
||||
});
|
||||
if (this.mTree.element.style.flex) {
|
||||
if (this.mTree.element.style.height === "0px") {
|
||||
this.status[this.blockId].backlinkMStatus = 3;
|
||||
|
|
@ -513,15 +513,15 @@ export class Backlink extends Model {
|
|||
backlinkOpenIds: [],
|
||||
backlinkMOpenIds: [],
|
||||
backlinkMStatus: 3
|
||||
}
|
||||
};
|
||||
if (data.mentionsCount === 0) {
|
||||
this.status[this.blockId].backlinkMStatus = 3;
|
||||
} else {
|
||||
this.status[this.blockId].backlinkMOpenIds = [data.backmentions[0].id]
|
||||
this.status[this.blockId].backlinkMOpenIds = [data.backmentions[0].id];
|
||||
if (data.linkRefsCount === 0) {
|
||||
this.status[this.blockId].backlinkMStatus = 0;
|
||||
} else {
|
||||
this.status[this.blockId].backlinkOpenIds = [data.backlinks[0].id]
|
||||
this.status[this.blockId].backlinkOpenIds = [data.backlinks[0].id];
|
||||
this.status[this.blockId].backlinkMStatus = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -529,17 +529,17 @@ export class Backlink extends Model {
|
|||
|
||||
// restore status
|
||||
this.status[this.blockId].backlinkOpenIds.forEach(item => {
|
||||
const liElement = this.tree.element.querySelector(`.b3-list-item[data-node-id="${item}"]`) as HTMLElement
|
||||
const liElement = this.tree.element.querySelector(`.b3-list-item[data-node-id="${item}"]`) as HTMLElement;
|
||||
if (liElement) {
|
||||
this.toggleItem(liElement, false);
|
||||
}
|
||||
})
|
||||
});
|
||||
this.status[this.blockId].backlinkMOpenIds.forEach(item => {
|
||||
const liElement = this.mTree.element.querySelector(`.b3-list-item[data-node-id="${item}"]`) as HTMLElement
|
||||
const liElement = this.mTree.element.querySelector(`.b3-list-item[data-node-id="${item}"]`) as HTMLElement;
|
||||
if (liElement) {
|
||||
this.toggleItem(liElement, true);
|
||||
}
|
||||
})
|
||||
});
|
||||
// 0 全展开,1 展开一半箭头向下,2 展开一半箭头向上,3 全收起
|
||||
const layoutElement = this.mTree.element.previousElementSibling.querySelector('[data-type="layout"]');
|
||||
if (this.status[this.blockId].backlinkMStatus === 2 || this.status[this.blockId].backlinkMStatus === 1) {
|
||||
|
|
@ -563,8 +563,8 @@ export class Backlink extends Model {
|
|||
layoutElement.setAttribute("aria-label", window.siyuan.languages.down);
|
||||
layoutElement.querySelector("use").setAttribute("xlink:href", "#iconDown");
|
||||
}
|
||||
this.tree.element.previousElementSibling.querySelector('[data-type="sort"]').setAttribute("data-sort", this.status[this.blockId].sort)
|
||||
this.mTree.element.previousElementSibling.querySelector('[data-type="mSort"]').setAttribute("data-sort", this.status[this.blockId].mSort)
|
||||
this.tree.element.previousElementSibling.querySelector('[data-type="sort"]').setAttribute("data-sort", this.status[this.blockId].sort);
|
||||
this.mTree.element.previousElementSibling.querySelector('[data-type="mSort"]').setAttribute("data-sort", this.status[this.blockId].mSort);
|
||||
|
||||
setTimeout(() => {
|
||||
this.tree.element.scrollTop = this.status[this.blockId].scrollTop;
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ export const countBlockWord = (ids: string[], rootID?: string) => {
|
|||
|
||||
export const clearCounter = () => {
|
||||
document.querySelector("#status .status__counter").innerHTML = "";
|
||||
}
|
||||
};
|
||||
|
||||
export const renderStatusbarCounter = (stat: { runeCount: number, wordCount: number, linkCount: number, imageCount: number, refCount: number }) => {
|
||||
let html = `<span class="ft__on-surface">${window.siyuan.languages.runeCount}</span> ${stat.runeCount}<span class="fn__space"></span>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export const openByMobile = (uri: string) => {
|
|||
};
|
||||
|
||||
export const writeText = async (text: string) => {
|
||||
let range: Range
|
||||
let range: Range;
|
||||
if (getSelection().rangeCount > 0) {
|
||||
range = getSelection().getRangeAt(0).cloneRange();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1101,8 +1101,8 @@ export class WYSIWYG {
|
|||
this.element.addEventListener("contextmenu", (event: MouseEvent & { detail: any }) => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
const x = event.clientX || event.detail.x
|
||||
const y = event.clientY || event.detail.y
|
||||
const x = event.clientX || event.detail.x;
|
||||
const y = event.clientY || event.detail.y;
|
||||
const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");
|
||||
if (selectElements.length > 1) {
|
||||
// 多选块
|
||||
|
|
@ -1111,7 +1111,7 @@ export class WYSIWYG {
|
|||
window.siyuan.menus.menu.popup({x, y});
|
||||
return;
|
||||
}
|
||||
const target = event.detail.target || event.target as HTMLElement
|
||||
const target = event.detail.target || event.target as HTMLElement;
|
||||
const embedElement = hasClosestByAttribute(target, "data-type", "NodeBlockQueryEmbed");
|
||||
if (embedElement) {
|
||||
if (getSelection().rangeCount === 0) {
|
||||
|
|
|
|||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -446,6 +446,7 @@ declare interface IFile {
|
|||
|
||||
declare interface IBlockTree {
|
||||
nodeType: string,
|
||||
hPath: string,
|
||||
subType: string,
|
||||
name: string,
|
||||
type: string,
|
||||
|
|
|
|||
|
|
@ -57,14 +57,17 @@ export class Tree {
|
|||
private genHTML(data: IBlockTree[]) {
|
||||
let html = `<ul${data[0].depth === 0 ? " class='b3-list b3-list--background'" : ""}>`;
|
||||
data.forEach((item) => {
|
||||
let titleTip = "";
|
||||
let iconHTML = '<svg class="b3-list-item__graphic"><use xlink:href="#iconFolder"></use></svg>';
|
||||
if (item.type === "bookmark") {
|
||||
iconHTML = '<svg class="b3-list-item__graphic"><use xlink:href="#iconBookmark"></use></svg>';
|
||||
} else if (item.type === "tag") {
|
||||
iconHTML = '<svg class="b3-list-item__graphic"><use xlink:href="#iconTags"></use></svg>';
|
||||
} else if (item.type === "backlink") {
|
||||
titleTip= ` title="${item.hPath}"`;
|
||||
iconHTML = `<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.nodeType, item.subType)}"></use></svg>`;
|
||||
} else if (item.type === "outline") {
|
||||
titleTip= ` title="${Lute.EscapeHTMLStr(Lute.BlockDOM2Content(item.name))}"`;
|
||||
iconHTML = `<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.nodeType, item.subType)}"></use></svg>`;
|
||||
}
|
||||
let countHTML = "";
|
||||
|
|
@ -82,7 +85,7 @@ ${item.label ? "data-label='" + item.label + "'" : ""}>
|
|||
<svg data-id="${encodeURIComponent(item.name + item.depth)}" class="b3-list-item__arrow ${((item.children && item.children.length > 0) || (item.blocks && item.blocks.length > 0)) ? "b3-list-item__arrow--open" : (item.type === "backlink" ? "" : "fn__hidden")}"><use xlink:href="#iconRight"></use></svg>
|
||||
</span>
|
||||
${iconHTML}
|
||||
<span class="b3-list-item__text"${item.type === "outline" ? ' title="' + Lute.EscapeHTMLStr(Lute.BlockDOM2Content(item.name)) + '"' : ""}>${item.name}</span>
|
||||
<span class="b3-list-item__text"${titleTip}>${item.name}</span>
|
||||
${countHTML}
|
||||
${this.topExtHTML || ""}
|
||||
</li>`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue