Vanessa 2022-11-17 23:23:47 +08:00
parent a1c74e4d90
commit c2c0794e48
2 changed files with 15 additions and 8 deletions

View File

@ -385,7 +385,8 @@ export class Backlink extends Model {
} else { } else {
fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", { fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {
defID: this.blockId, defID: this.blockId,
refTreeID: docId refTreeID: docId,
keyword: isMention ? this.inputsElement[1].value : this.inputsElement[0].value
}, (response) => { }, (response) => {
svgElement.removeAttribute("disabled"); svgElement.removeAttribute("disabled");
svgElement.classList.add("b3-list-item__arrow--open"); svgElement.classList.add("b3-list-item__arrow--open");

View File

@ -4,6 +4,7 @@ import {Constants} from "../../constants";
import {onGet} from "./onGet"; import {onGet} from "./onGet";
import {saveScroll} from "../scroll/saveScroll"; import {saveScroll} from "../scroll/saveScroll";
import {renderBacklink} from "../wysiwyg/renderBacklink"; import {renderBacklink} from "../wysiwyg/renderBacklink";
import {hasClosestByClassName} from "./hasClosest";
export const reloadProtyle = (protyle: IProtyle) => { export const reloadProtyle = (protyle: IProtyle) => {
if (window.siyuan.config.editor.displayBookmarkIcon) { if (window.siyuan.config.editor.displayBookmarkIcon) {
@ -17,13 +18,18 @@ export const reloadProtyle = (protyle: IProtyle) => {
addLoading(protyle); addLoading(protyle);
if (protyle.options.backlinkData) { if (protyle.options.backlinkData) {
const isMention = protyle.element.getAttribute("data-ismention") === "true"; const isMention = protyle.element.getAttribute("data-ismention") === "true";
fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", { const tabElement = hasClosestByClassName(protyle.element, "sy__backlink")
defID: protyle.element.getAttribute("data-defid"), if (tabElement) {
refTreeID: protyle.block.rootID const inputsElement = tabElement.querySelectorAll(".b3-form__icon-input") as NodeListOf<HTMLInputElement>
}, response => { fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {
protyle.options.backlinkData = isMention ? response.data.backmentions : response.data.backlinks, defID: protyle.element.getAttribute("data-defid"),
renderBacklink(protyle, protyle.options.backlinkData); refTreeID: protyle.block.rootID,
}); keyword: isMention ? inputsElement[1].value : inputsElement[0].value
}, response => {
protyle.options.backlinkData = isMention ? response.data.backmentions : response.data.backlinks,
renderBacklink(protyle, protyle.options.backlinkData);
});
}
} else { } else {
fetchPost("/api/filetree/getDoc", { fetchPost("/api/filetree/getDoc", {
id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID, id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID,