mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
878249a46c
commit
e8a1860920
5 changed files with 12 additions and 1 deletions
|
|
@ -29,6 +29,7 @@ export class BlockPanel {
|
|||
public editors: Protyle[] = [];
|
||||
private observerResize: ResizeObserver;
|
||||
private observerLoad: IntersectionObserver;
|
||||
private originalRefBlockIDs: IObject;
|
||||
|
||||
// x,y 和 targetElement 二选一必传
|
||||
constructor(options: {
|
||||
|
|
@ -38,7 +39,8 @@ export class BlockPanel {
|
|||
defIds?: string[],
|
||||
isBacklink: boolean,
|
||||
x?: number,
|
||||
y?: number
|
||||
y?: number,
|
||||
originalRefBlockIDs?: IObject, // isBacklink 为 true 时有效
|
||||
}) {
|
||||
this.id = genUUID();
|
||||
this.targetElement = options.targetElement;
|
||||
|
|
@ -48,6 +50,7 @@ export class BlockPanel {
|
|||
this.x = options.x;
|
||||
this.y = options.y;
|
||||
this.isBacklink = options.isBacklink;
|
||||
this.originalRefBlockIDs = options.originalRefBlockIDs;
|
||||
|
||||
this.element = document.createElement("div");
|
||||
this.element.classList.add("block__popover");
|
||||
|
|
@ -169,6 +172,7 @@ export class BlockPanel {
|
|||
const editor = new Protyle(this.app, editorElement, {
|
||||
blockId: this.nodeIds[index],
|
||||
defId: this.defIds[index] || this.defIds[0] || "",
|
||||
originalRefBlockIDs: this.isBacklink ? this.originalRefBlockIDs : undefined,
|
||||
action,
|
||||
render: {
|
||||
scroll: true,
|
||||
|
|
|
|||
|
|
@ -336,6 +336,7 @@ export const showPopover = async (app: App, showRef = false) => {
|
|||
}
|
||||
let ids: string[];
|
||||
let defIds: string[];
|
||||
let originalRefBlockIDs: IObject
|
||||
const dataId = popoverTargetElement.getAttribute("data-id");
|
||||
if (dataId) {
|
||||
// backlink/util/hint/正文标题 上的弹层
|
||||
|
|
@ -343,6 +344,7 @@ export const showPopover = async (app: App, showRef = false) => {
|
|||
const postResponse = await fetchSyncPost("/api/block/getRefIDs", {id: dataId});
|
||||
ids = postResponse.data.refIDs;
|
||||
defIds = postResponse.data.defIDs;
|
||||
originalRefBlockIDs = postResponse.data.originalRefBlockIDs;
|
||||
} else {
|
||||
if (dataId.startsWith("[")) {
|
||||
ids = JSON.parse(dataId);
|
||||
|
|
@ -394,6 +396,7 @@ export const showPopover = async (app: App, showRef = false) => {
|
|||
const postResponse = await fetchSyncPost(url, {id: targetId});
|
||||
ids = postResponse.data.refIDs;
|
||||
defIds = postResponse.data.defIDs;
|
||||
originalRefBlockIDs = postResponse.data.originalRefBlockIDs;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -414,6 +417,7 @@ export const showPopover = async (app: App, showRef = false) => {
|
|||
isBacklink: showRef || popoverTargetElement.classList.contains("protyle-attr--refcount") || popoverTargetElement.classList.contains("counter"),
|
||||
nodeIds: ids,
|
||||
defIds,
|
||||
originalRefBlockIDs,
|
||||
}));
|
||||
}
|
||||
// 不能清除,否则ctrl 后 shift 就 无效 popoverTargetElement = undefined;
|
||||
|
|
|
|||
|
|
@ -385,6 +385,7 @@ export class Plugin {
|
|||
y?: number,
|
||||
targetElement?: HTMLElement,
|
||||
isBacklink: boolean,
|
||||
originalRefBlockIDs?: IObject,
|
||||
}) => {
|
||||
window.siyuan.blockPanels.push(new BlockPanel({
|
||||
app: this.app,
|
||||
|
|
|
|||
|
|
@ -290,6 +290,7 @@ export class Protyle {
|
|||
fetchPost("/api/filetree/getDoc", {
|
||||
id: mergedOptions.blockId,
|
||||
isBacklink: mergedOptions.action.includes(Constants.CB_GET_BACKLINK),
|
||||
originalRefBlockIDs: mergedOptions.originalRefBlockIDs,
|
||||
// 0: 仅当前 ID(默认值),1:向上 2:向下,3:上下都加载,4:加载最后
|
||||
mode: (mergedOptions.action && mergedOptions.action.includes(Constants.CB_GET_CONTEXT)) ? 3 : 0,
|
||||
size: mergedOptions.action?.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks,
|
||||
|
|
|
|||
1
app/src/types/protyle.d.ts
vendored
1
app/src/types/protyle.d.ts
vendored
|
|
@ -446,6 +446,7 @@ interface IProtyleOptions {
|
|||
mode?: TEditorMode,
|
||||
blockId?: string
|
||||
rootId?: string
|
||||
originalRefBlockIDs?: IObject
|
||||
key?: string
|
||||
defId?: string
|
||||
render?: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue