diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts index 2595e8c9b..2a9546120 100644 --- a/app/src/protyle/hint/index.ts +++ b/app/src/protyle/hint/index.ts @@ -278,8 +278,16 @@ ${unicode2Emoji(emoji.unicode)}`; this.element.classList.remove("hint--menu"); } this.element.style.width = Math.max(protyle.element.clientWidth / 2, 320) + "px"; - const textareaPosition = getSelectionPosition(protyle.wysiwyg.element); - setPosition(this.element, textareaPosition.left, textareaPosition.top + 26, 30); + if (this.source === "av") { + const blockElement = hasClosestBlock(protyle.toolbar.range.startContainer) + if (blockElement) { + const rowAddRect = blockElement.querySelector(".av__row--add").getBoundingClientRect(); + setPosition(this.element, rowAddRect.left, rowAddRect.bottom, rowAddRect.height); + } + } else { + const textareaPosition = getSelectionPosition(protyle.wysiwyg.element); + setPosition(this.element, textareaPosition.left, textareaPosition.top + 26, 30); + } this.element.scrollTop = 0; this.bindUploadEvent(protyle, this.element); if (this.source !== "hint") { diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index e91e1b5e6..c9a960a45 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -131,7 +131,8 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle const addRowElement = hasClosestByClassName(event.target, "av__row--add"); if (addRowElement) { - (blockElement.querySelector(".av__title") as HTMLInputElement).focus() + protyle.toolbar.range = document.createRange() + protyle.toolbar.range.selectNodeContents(blockElement.querySelector(".av__title")); hintRef("", protyle, "av"); event.preventDefault(); event.stopPropagation();