mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🚨
This commit is contained in:
parent
0014c8b5f3
commit
d1e67e055b
5 changed files with 36 additions and 36 deletions
|
|
@ -180,7 +180,7 @@ export class Backlink extends Model {
|
|||
refTreeID: liElement.getAttribute("data-node-id")
|
||||
}, (response) => {
|
||||
const editorElement = document.createElement("div");
|
||||
liElement.after(editorElement)
|
||||
liElement.after(editorElement);
|
||||
const editor = new Protyle(editorElement, {
|
||||
blockId: "",
|
||||
backlinkData: response.data.backlinks,
|
||||
|
|
@ -191,9 +191,9 @@ export class Backlink extends Model {
|
|||
scroll: false,
|
||||
breadcrumb: false,
|
||||
}
|
||||
})
|
||||
this.editors.push(editor)
|
||||
})
|
||||
});
|
||||
this.editors.push(editor);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -259,8 +259,8 @@ export class Backlink extends Model {
|
|||
this.tree.element.querySelectorAll(".protyle-wysiwyg--hl").forEach((hlItem) => {
|
||||
hlItem.classList.remove("protyle-wysiwyg--hl");
|
||||
});
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
this.mTree.element.addEventListener("scroll", () => {
|
||||
this.mTree.element.querySelectorAll(".protyle-gutters").forEach(item => {
|
||||
item.classList.add("fn__none");
|
||||
|
|
@ -269,8 +269,8 @@ export class Backlink extends Model {
|
|||
this.mTree.element.querySelectorAll(".protyle-wysiwyg--hl").forEach((hlItem) => {
|
||||
hlItem.classList.remove("protyle-wysiwyg--hl");
|
||||
});
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
// 为了快捷键的 dispatch
|
||||
this.element.querySelector('[data-type="collapse"]').addEventListener("click", () => {
|
||||
this.tree.collapseAll();
|
||||
|
|
@ -406,8 +406,8 @@ export class Backlink extends Model {
|
|||
}
|
||||
|
||||
this.editors.forEach(item => {
|
||||
item.destroy()
|
||||
})
|
||||
item.destroy();
|
||||
});
|
||||
this.editors = [];
|
||||
this.element.querySelector('.block__icon[data-type="refresh"] svg').classList.remove("fn__rotate");
|
||||
this.notebookId = data.box;
|
||||
|
|
@ -415,15 +415,15 @@ export class Backlink extends Model {
|
|||
this.inputsElement[1].value = data.mk;
|
||||
if (data.backlinks) {
|
||||
data.backlinks.forEach((item) => {
|
||||
delete item.blocks
|
||||
delete item.children
|
||||
})
|
||||
delete item.blocks;
|
||||
delete item.children;
|
||||
});
|
||||
}
|
||||
if (data.backmentions) {
|
||||
data.backmentions.forEach((item) => {
|
||||
delete item.blocks
|
||||
delete item.children
|
||||
})
|
||||
delete item.blocks;
|
||||
delete item.children;
|
||||
});
|
||||
}
|
||||
this.tree.updateData(data.backlinks);
|
||||
this.mTree.updateData(data.backmentions);
|
||||
|
|
|
|||
|
|
@ -158,8 +158,8 @@ class Protyle {
|
|||
});
|
||||
setPadding(this.protyle);
|
||||
if (options.backlinkData) {
|
||||
renderBacklink(this.protyle, options.backlinkData)
|
||||
return
|
||||
renderBacklink(this.protyle, options.backlinkData);
|
||||
return;
|
||||
}
|
||||
fetchPost("/api/filetree/getDoc", {
|
||||
id: options.blockId,
|
||||
|
|
|
|||
|
|
@ -1374,10 +1374,10 @@ export class WYSIWYG {
|
|||
let shiftStartElement: HTMLElement;
|
||||
this.element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
|
||||
hideElements(["hint", "util"], protyle);
|
||||
const backlinkBreadcrumbItemElement = hasClosestByClassName(event.target, "protyle-breadcrumb__item")
|
||||
const backlinkBreadcrumbItemElement = hasClosestByClassName(event.target, "protyle-breadcrumb__item");
|
||||
if (backlinkBreadcrumbItemElement) {
|
||||
loadBreadcrumb(backlinkBreadcrumbItemElement);
|
||||
event.stopPropagation()
|
||||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
if (!window.siyuan.shiftIsPressed) {
|
||||
|
|
|
|||
|
|
@ -7,25 +7,25 @@ export const renderBacklink = (protyle: IProtyle, backlinkData: {
|
|||
blockPaths: IBreadcrumb[],
|
||||
dom: string
|
||||
}[]) => {
|
||||
protyle.block.showAll = true
|
||||
let html = ""
|
||||
protyle.block.showAll = true;
|
||||
let html = "";
|
||||
backlinkData.forEach(item => {
|
||||
html += genBreadcrumb(item.blockPaths) + item.dom
|
||||
html += genBreadcrumb(item.blockPaths) + item.dom;
|
||||
});
|
||||
protyle.wysiwyg.element.innerHTML = html
|
||||
protyle.wysiwyg.element.innerHTML = html;
|
||||
removeLoading(protyle);
|
||||
}
|
||||
};
|
||||
|
||||
export const loadBreadcrumb = (element: HTMLElement) => {
|
||||
if (element.classList.contains("protyle-breadcrumb__item--active")) {
|
||||
return;
|
||||
}
|
||||
element.parentElement.querySelector(".protyle-breadcrumb__item--active").classList.remove("protyle-breadcrumb__item--active")
|
||||
element.classList.add("protyle-breadcrumb__item--active")
|
||||
let nextElement = element.parentElement.nextElementSibling
|
||||
element.parentElement.querySelector(".protyle-breadcrumb__item--active").classList.remove("protyle-breadcrumb__item--active");
|
||||
element.classList.add("protyle-breadcrumb__item--active");
|
||||
let nextElement = element.parentElement.nextElementSibling;
|
||||
while (nextElement && !nextElement.classList.contains("protyle-breadcrumb__bar")) {
|
||||
const tempElement = nextElement
|
||||
nextElement = nextElement.nextElementSibling
|
||||
const tempElement = nextElement;
|
||||
nextElement = nextElement.nextElementSibling;
|
||||
tempElement.remove();
|
||||
}
|
||||
fetchPost("/api/filetree/getDoc", {
|
||||
|
|
@ -33,11 +33,11 @@ export const loadBreadcrumb = (element: HTMLElement) => {
|
|||
size: Constants.SIZE_GET_MAX,
|
||||
}, getResponse => {
|
||||
element.parentElement.insertAdjacentHTML("afterend", getResponse.data.content);
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const genBreadcrumb = (blockPaths: IBreadcrumb[]) => {
|
||||
let html = ''
|
||||
let html = "";
|
||||
blockPaths.forEach((item, index) => {
|
||||
if (index === 0) {
|
||||
return;
|
||||
|
|
@ -49,6 +49,6 @@ const genBreadcrumb = (blockPaths: IBreadcrumb[]) => {
|
|||
if (index !== blockPaths.length - 1) {
|
||||
html += '<svg class="protyle-breadcrumb__arrow"><use xlink:href="#iconRight"></use></svg>';
|
||||
}
|
||||
})
|
||||
});
|
||||
return `<div contenteditable="false" class="protyle-breadcrumb__bar protyle-breadcrumb__bar--nowrap">${html}</div>`;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ data-def-path="${item.defPath}">
|
|||
|
||||
private toggleBlocks(liElement: HTMLElement) {
|
||||
if (this.toggleClick) {
|
||||
this.toggleClick(liElement)
|
||||
this.toggleClick(liElement);
|
||||
return;
|
||||
}
|
||||
if (!liElement.nextElementSibling) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue