From 803fb6def861f77754b6b059d56e6264e3e64c67 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 27 Sep 2023 23:13:32 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/9294 --- app/src/protyle/render/av/action.ts | 23 +++++++++++++++-------- app/src/protyle/wysiwyg/index.ts | 9 +-------- app/src/types/index.d.ts | 1 + 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index 229fef82f..aace4e0a3 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -171,14 +171,21 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle const addRowElement = hasClosestByClassName(event.target, "av__row--add"); if (addRowElement) { - if (protyle.hint.element.classList.contains("fn__none")) { - protyle.toolbar.range = document.createRange(); - protyle.toolbar.range.selectNodeContents(blockElement.querySelector(".av__title")); - focusByRange(protyle.toolbar.range); - hintRef("", protyle, "av"); - } else { - hideElements(["hint"], protyle); - } + const avID = blockElement.getAttribute("data-av-id"); + const srcIDs = [Lute.NewNodeID()] + const previousID = addRowElement.getAttribute("data-id") || "", ; + transaction(protyle, [{ + action: "insertAttrViewBlock", + avID, + previousID, + srcIDs, + isDetached: true, + }], [{ + action: "removeAttrViewBlock", + srcIDs, + avID, + }]); + insertAttrViewBlockAnimation(blockElement, 1, previousID); event.preventDefault(); event.stopPropagation(); return true; diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index b2be5d445..e27bd035b 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1605,14 +1605,7 @@ export class WYSIWYG { event }); }); - - const addRowElement = hasClosestByClassName(event.target, "av__row--add"); - if (addRowElement) { - hideElements(["util"], protyle); - } else { - hideElements(["hint", "util"], protyle); - } - + hideElements(["hint", "util"], protyle); const ctrlIsPressed = event.metaKey || event.ctrlKey; /// #if !MOBILE const backlinkBreadcrumbItemElement = hasClosestByClassName(event.target, "protyle-breadcrumb__item"); diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index dffa9ebcf..7f45ba3a2 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -373,6 +373,7 @@ interface IOperation { previousID?: string retData?: any nextID?: string // insert 专享 + isDetached?: boolean // insertAttrViewBlock 专享 srcIDs?: string[] // insertAttrViewBlock 专享 name?: string // addAttrViewCol 专享 type?: TAVCol // addAttrViewCol 专享