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