mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
8b8859bc54
commit
1bb123b74a
15 changed files with 41 additions and 31 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||||
import Protyle from "../protyle";
|
import {Protyle} from "../protyle";
|
||||||
import {genUUID} from "../util/genID";
|
import {genUUID} from "../util/genID";
|
||||||
import {setPadding} from "../protyle/ui/initUI";
|
import {setPadding} from "../protyle/ui/initUI";
|
||||||
import {setPosition} from "../util/setPosition";
|
import {setPosition} from "../util/setPosition";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import {Tab} from "../layout/Tab";
|
import {Tab} from "../layout/Tab";
|
||||||
import Protyle from "../protyle";
|
import {Protyle} from "../protyle";
|
||||||
import {Model} from "../layout/Model";
|
import {Model} from "../layout/Model";
|
||||||
import {disabledProtyle} from "../protyle/util/onGet";
|
import {disabledProtyle} from "../protyle/util/onGet";
|
||||||
import {setPadding} from "../protyle/ui/initUI";
|
import {setPadding} from "../protyle/ui/initUI";
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,12 @@ import {Tab} from "../Tab";
|
||||||
import {Model} from "../Model";
|
import {Model} from "../Model";
|
||||||
import {getDisplayName} from "../../util/pathName";
|
import {getDisplayName} from "../../util/pathName";
|
||||||
import {Tree} from "../../util/Tree";
|
import {Tree} from "../../util/Tree";
|
||||||
import {hasClosestByClassName} from "../../protyle/util/hasClosest";
|
|
||||||
import {getDockByType, setPanelFocus} from "../util";
|
import {getDockByType, setPanelFocus} from "../util";
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {getAllModels} from "../getAll";
|
|
||||||
import {onGet} from "../../protyle/util/onGet";
|
|
||||||
import {updateHotkeyTip} from "../../protyle/util/compatibility";
|
import {updateHotkeyTip} from "../../protyle/util/compatibility";
|
||||||
import {openFileById} from "../../editor/util";
|
import {openFileById} from "../../editor/util";
|
||||||
import {MenuItem} from "../../menus/Menu";
|
import {Protyle} from "../../protyle";
|
||||||
import Protyle from "../../protyle";
|
|
||||||
|
|
||||||
export class Backlink extends Model {
|
export class Backlink extends Model {
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
|
|
@ -306,6 +302,8 @@ export class Backlink extends Model {
|
||||||
}, (response) => {
|
}, (response) => {
|
||||||
const editorElement = document.createElement("div");
|
const editorElement = document.createElement("div");
|
||||||
editorElement.style.minHeight = "auto";
|
editorElement.style.minHeight = "auto";
|
||||||
|
editorElement.setAttribute("data-defid", this.blockId)
|
||||||
|
editorElement.setAttribute("data-ismention", isMention? "true" : "false")
|
||||||
liElement.after(editorElement);
|
liElement.after(editorElement);
|
||||||
const editor = new Protyle(editorElement, {
|
const editor = new Protyle(editorElement, {
|
||||||
blockId: "",
|
blockId: "",
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import {Graph} from "./Graph";
|
||||||
import {Model} from "../Model";
|
import {Model} from "../Model";
|
||||||
import {getDockByType, resizeTabs, setPanelFocus} from "../util";
|
import {getDockByType, resizeTabs, setPanelFocus} from "../util";
|
||||||
import {Inbox} from "./Inbox";
|
import {Inbox} from "./Inbox";
|
||||||
import Protyle from "../../protyle";
|
import {Protyle} from "../../protyle";
|
||||||
import {Backlink} from "./Backlink";
|
import {Backlink} from "./Backlink";
|
||||||
|
|
||||||
export class Dock {
|
export class Dock {
|
||||||
|
|
|
||||||
|
|
@ -383,6 +383,9 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushBack = true, callback?: () => void) => {
|
export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushBack = true, callback?: () => void) => {
|
||||||
|
if (protyle.options.backlinkData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const breadcrumbHLElement = protyle.breadcrumb?.element.querySelector(".protyle-breadcrumb__item--active");
|
const breadcrumbHLElement = protyle.breadcrumb?.element.querySelector(".protyle-breadcrumb__item--active");
|
||||||
if (breadcrumbHLElement && breadcrumbHLElement.getAttribute("data-node-id") === id) {
|
if (breadcrumbHLElement && breadcrumbHLElement.getAttribute("data-node-id") === id) {
|
||||||
if (id === protyle.block.rootID) {
|
if (id === protyle.block.rootID) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import Protyle from "../protyle";
|
import {Protyle} from "../protyle";
|
||||||
import {setEditor} from "./util/setEmpty";
|
import {setEditor} from "./util/setEmpty";
|
||||||
import {closePanel} from "./util/closePanel";
|
import {closePanel} from "./util/closePanel";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
|
|
@ -21,7 +21,7 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) =
|
||||||
setEditMode(window.siyuan.mobileEditor.protyle, "wysiwyg");
|
setEditMode(window.siyuan.mobileEditor.protyle, "wysiwyg");
|
||||||
}
|
}
|
||||||
let blockElement;
|
let blockElement;
|
||||||
Array.from(window.siyuan.mobileEditor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find(item => {
|
Array.from(window.siyuan.mobileEditor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find((item: HTMLElement) => {
|
||||||
if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
|
if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
|
||||||
blockElement = item;
|
blockElement = item;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import {onGet} from "./util/onGet";
|
||||||
import {reloadProtyle} from "./util/reload";
|
import {reloadProtyle} from "./util/reload";
|
||||||
import {renderBacklink} from "./wysiwyg/renderBacklink";
|
import {renderBacklink} from "./wysiwyg/renderBacklink";
|
||||||
|
|
||||||
class Protyle {
|
export class Protyle {
|
||||||
|
|
||||||
public readonly version: string;
|
public readonly version: string;
|
||||||
public protyle: IProtyle;
|
public protyle: IProtyle;
|
||||||
|
|
@ -95,7 +95,7 @@ class Protyle {
|
||||||
case "heading2doc":
|
case "heading2doc":
|
||||||
case "li2doc":
|
case "li2doc":
|
||||||
if (this.protyle.block.rootID === data.data.srcRootBlockID) {
|
if (this.protyle.block.rootID === data.data.srcRootBlockID) {
|
||||||
if (this.protyle.block.showAll && data.cmd === "heading2doc") {
|
if (this.protyle.block.showAll && data.cmd === "heading2doc" && !this.protyle.options.backlinkData) {
|
||||||
fetchPost("/api/filetree/getDoc", {
|
fetchPost("/api/filetree/getDoc", {
|
||||||
id: this.protyle.block.rootID,
|
id: this.protyle.block.rootID,
|
||||||
size: Constants.SIZE_GET,
|
size: Constants.SIZE_GET,
|
||||||
|
|
@ -245,5 +245,3 @@ class Protyle {
|
||||||
destroy(this.protyle);
|
destroy(this.protyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Protyle;
|
|
||||||
|
|
|
||||||
|
|
@ -654,7 +654,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (window.siyuan.dragElement && window.siyuan.dragElement.getAttribute("data-type") === "navigation-file" && targetElement) {
|
} else if (window.siyuan.dragElement && window.siyuan.dragElement.getAttribute("data-type") === "navigation-file"
|
||||||
|
&& targetElement && !protyle.options.backlinkData) {
|
||||||
// 文件树拖拽
|
// 文件树拖拽
|
||||||
fetchPost("/api/filetree/doc2Heading", {
|
fetchPost("/api/filetree/doc2Heading", {
|
||||||
srcID: window.siyuan.dragElement.getAttribute("data-node-id"),
|
srcID: window.siyuan.dragElement.getAttribute("data-node-id"),
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,9 @@ import {fetchPost} from "../../util/fetch";
|
||||||
import {Constants} from "../../constants";
|
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";
|
||||||
|
|
||||||
export const reloadProtyle = (protyle:IProtyle) => {
|
export const reloadProtyle = (protyle:IProtyle) => {
|
||||||
if (protyle.options.backlinkData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (window.siyuan.config.editor.displayBookmarkIcon) {
|
if (window.siyuan.config.editor.displayBookmarkIcon) {
|
||||||
protyle.wysiwyg.element.classList.add("protyle-wysiwyg--attr");
|
protyle.wysiwyg.element.classList.add("protyle-wysiwyg--attr");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -15,11 +13,22 @@ export const reloadProtyle = (protyle:IProtyle) => {
|
||||||
}
|
}
|
||||||
protyle.lute.SetProtyleMarkNetImg(window.siyuan.config.editor.displayNetImgMark);
|
protyle.lute.SetProtyleMarkNetImg(window.siyuan.config.editor.displayNetImgMark);
|
||||||
addLoading(protyle);
|
addLoading(protyle);
|
||||||
fetchPost("/api/filetree/getDoc", {
|
if (protyle.options.backlinkData) {
|
||||||
id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID,
|
const isMention = protyle.element.getAttribute("data-ismention") === "true";
|
||||||
mode: 0,
|
fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {
|
||||||
size: protyle.block.showAll ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,
|
defID: protyle.element.getAttribute("data-defid"),
|
||||||
}, getResponse => {
|
refTreeID: protyle.block.rootID
|
||||||
onGet(getResponse, protyle, protyle.block.showAll ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS], saveScroll(protyle, true), true);
|
}, 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);
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -446,7 +446,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
// ctrl+home 光标移动到顶
|
// ctrl+home 光标移动到顶
|
||||||
if (!event.altKey && !event.shiftKey && isCtrl(event) && event.key === "Home") {
|
if (!event.altKey && !event.shiftKey && isCtrl(event) && event.key === "Home") {
|
||||||
if (protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-index") === "0" ||
|
if (protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-index") === "0" ||
|
||||||
protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "true") {
|
protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "true" ||
|
||||||
|
protyle.options.backlinkData) {
|
||||||
focusBlock(protyle.wysiwyg.element.firstElementChild);
|
focusBlock(protyle.wysiwyg.element.firstElementChild);
|
||||||
protyle.contentElement.scrollTop = 0;
|
protyle.contentElement.scrollTop = 0;
|
||||||
protyle.scroll.lastScrollTop = 1;
|
protyle.scroll.lastScrollTop = 1;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import {Model} from "../layout/Model";
|
import {Model} from "../layout/Model";
|
||||||
import {Tab} from "../layout/Tab";
|
import {Tab} from "../layout/Tab";
|
||||||
import Protyle from "../protyle";
|
import {Protyle} from "../protyle";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {getIconByType} from "../editor/getIcon";
|
import {getIconByType} from "../editor/getIcon";
|
||||||
import {getDisplayName, getNotebookName} from "../util/pathName";
|
import {getDisplayName, getNotebookName} from "../util/pathName";
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import {escapeHtml} from "../util/escape";
|
||||||
import {getIconByType} from "../editor/getIcon";
|
import {getIconByType} from "../editor/getIcon";
|
||||||
import {getDisplayName, getNotebookName, pathPosix} from "../util/pathName";
|
import {getDisplayName, getNotebookName, pathPosix} from "../util/pathName";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import Protyle from "../protyle";
|
import {Protyle} from "../protyle";
|
||||||
import {Dialog} from "../dialog";
|
import {Dialog} from "../dialog";
|
||||||
import {fetchPost, fetchSyncPost} from "../util/fetch";
|
import {fetchPost, fetchSyncPost} from "../util/fetch";
|
||||||
import {onGet} from "../protyle/util/onGet";
|
import {onGet} from "../protyle/util/onGet";
|
||||||
|
|
|
||||||
2
app/src/types/protyle.d.ts
vendored
2
app/src/types/protyle.d.ts
vendored
|
|
@ -401,7 +401,7 @@ interface IOptions {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 编辑器异步渲染完成后的回调方法 */
|
/** 编辑器异步渲染完成后的回调方法 */
|
||||||
after?(protyle: import("../protyle/index").default): void;
|
after?(protyle: import("../protyle").Protyle): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IProtyle {
|
interface IProtyle {
|
||||||
|
|
|
||||||
|
|
@ -771,7 +771,7 @@ const editKeydown = (event: KeyboardEvent) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.wysiwyg.custom, event)) {
|
if (matchHotKey(window.siyuan.config.keymap.editor.general.wysiwyg.custom, event) && !protyle.options.backlinkData) {
|
||||||
setEditMode(protyle, "wysiwyg");
|
setEditMode(protyle, "wysiwyg");
|
||||||
protyle.scroll.lastScrollTop = 0;
|
protyle.scroll.lastScrollTop = 0;
|
||||||
fetchPost("/api/filetree/getDoc", {
|
fetchPost("/api/filetree/getDoc", {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import {escapeHtml} from "./escape";
|
||||||
import {isMobile} from "./functions";
|
import {isMobile} from "./functions";
|
||||||
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||||
import {renderAssetsPreview} from "../asset/renderAssets";
|
import {renderAssetsPreview} from "../asset/renderAssets";
|
||||||
import Protyle from "../protyle";
|
import {Protyle} from "../protyle";
|
||||||
import {onGet} from "../protyle/util/onGet";
|
import {onGet} from "../protyle/util/onGet";
|
||||||
|
|
||||||
let historyEditor: Protyle;
|
let historyEditor: Protyle;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue