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