|
@@ -3,11 +3,9 @@ import {fetchPost} from "../../util/fetch";
|
|
|
import {Constants} from "../../constants";
|
|
|
import {onGet} from "./onGet";
|
|
|
import {saveScroll} from "../scroll/saveScroll";
|
|
|
+import {renderBacklink} from "../wysiwyg/renderBacklink";
|
|
|
|
|
|
export const reloadProtyle = (protyle:IProtyle) => {
|
|
|
- if (protyle.options.backlinkData) {
|
|
|
- return;
|
|
|
- }
|
|
|
if (window.siyuan.config.editor.displayBookmarkIcon) {
|
|
|
protyle.wysiwyg.element.classList.add("protyle-wysiwyg--attr");
|
|
|
} else {
|
|
@@ -15,11 +13,22 @@ export const reloadProtyle = (protyle:IProtyle) => {
|
|
|
}
|
|
|
protyle.lute.SetProtyleMarkNetImg(window.siyuan.config.editor.displayNetImgMark);
|
|
|
addLoading(protyle);
|
|
|
- fetchPost("/api/filetree/getDoc", {
|
|
|
- id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID,
|
|
|
- mode: 0,
|
|
|
- size: protyle.block.showAll ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,
|
|
|
- }, getResponse => {
|
|
|
- onGet(getResponse, protyle, protyle.block.showAll ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS], saveScroll(protyle, true), true);
|
|
|
- });
|
|
|
+ if (protyle.options.backlinkData) {
|
|
|
+ const isMention = protyle.element.getAttribute("data-ismention") === "true";
|
|
|
+ fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {
|
|
|
+ defID: protyle.element.getAttribute("data-defid"),
|
|
|
+ refTreeID: protyle.block.rootID
|
|
|
+ }, response => {
|
|
|
+ protyle.options.backlinkData = isMention ? response.data.backmentions : response.data.backlinks,
|
|
|
+ renderBacklink(protyle, protyle.options.backlinkData);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ fetchPost("/api/filetree/getDoc", {
|
|
|
+ id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID,
|
|
|
+ mode: 0,
|
|
|
+ size: protyle.block.showAll ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,
|
|
|
+ }, getResponse => {
|
|
|
+ onGet(getResponse, protyle, protyle.block.showAll ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS], saveScroll(protyle, true), true);
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|