From 2735e16d69d88ed2a549ec533ee671759155a7ee Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 16 Nov 2024 12:03:08 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/13131 --- app/src/layout/dock/Backlink.ts | 3 --- app/src/protyle/index.ts | 28 +++++++++++++++-------- app/src/protyle/util/editorCommonEvent.ts | 7 ++++++ app/src/protyle/wysiwyg/getBlock.ts | 2 +- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/app/src/layout/dock/Backlink.ts b/app/src/layout/dock/Backlink.ts index 08f316b7f..025b81383 100644 --- a/app/src/layout/dock/Backlink.ts +++ b/app/src/layout/dock/Backlink.ts @@ -465,9 +465,6 @@ export class Backlink extends Model { if (!this.blockId) { return; } - this.editors.forEach(item => { - item.destroy(); - }); const element = this.element.querySelector('.block__icon[data-type="refresh"] svg'); element.classList.add("fn__rotate"); fetchPost("/api/ref/refreshBacklink", { diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts index 24bfe15a0..730ced09f 100644 --- a/app/src/protyle/index.ts +++ b/app/src/protyle/index.ts @@ -41,6 +41,7 @@ import {focusBlock, getEditorRange} from "./util/selection"; import {hasClosestBlock} from "./util/hasClosest"; import {setStorageVal} from "./util/compatibility"; import {merge} from "./util/merge"; +import {getAllModels} from "../layout/getAll"; export class Protyle { @@ -125,15 +126,24 @@ export class Protyle { } break; case "transactions": - data.data[0].doOperations.forEach((item: IOperation) => { - if (!this.protyle.preview.element.classList.contains("fn__none") && - item.action !== "updateAttrs" // 预览模式下点击只读 - ) { - this.protyle.preview.render(this.protyle); - } else { - onTransaction(this.protyle, item, false); - } - }); + if (options.backlinkData) { + getAllModels().backlink.find(item => { + if (item.element.contains(this.protyle.element)) { + item.refresh(); + return true; + } + }); + } else { + data.data[0].doOperations.forEach((item: IOperation) => { + if (!this.protyle.preview.element.classList.contains("fn__none") && + item.action !== "updateAttrs" // 预览模式下点击只读 + ) { + this.protyle.preview.render(this.protyle); + } else { + onTransaction(this.protyle, item, false); + } + }); + } break; case "readonly": window.siyuan.config.editor.readOnly = data.data; diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 6d2689e8c..f989db579 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -61,6 +61,13 @@ const moveToNew = (protyle: IProtyle, sourceElements: Element[], targetElement: topSourceElement = getTopAloneElement(item); if (topSourceElement.isSameNode(item)) { topSourceElement = undefined; + // 单个缩放或反链面板中的列表项拖拽到包含该列表的编辑器中会导致残留的 list + Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${item.getAttribute("data-node-id")}"]`)).find((targetItem: HTMLElement) => { + if (!isInEmbedBlock(targetItem) && targetItem.parentElement.querySelectorAll(".li").length === 1) { + topSourceElement = targetItem.parentElement; + return true; + } + }); } } const copyId = Lute.NewNodeID(); diff --git a/app/src/protyle/wysiwyg/getBlock.ts b/app/src/protyle/wysiwyg/getBlock.ts index 76d636436..3c9dbabb2 100644 --- a/app/src/protyle/wysiwyg/getBlock.ts +++ b/app/src/protyle/wysiwyg/getBlock.ts @@ -74,7 +74,7 @@ export const getContenteditableElement = (element: Element) => { if (editableElement && !hasClosestByAttribute(editableElement, "data-type", "NodeBlockQueryEmbed")) { return editableElement; } - return false; + return undefined; }; export const isNotEditBlock = (element: Element) => {