Vanessa 2023-07-29 10:34:26 +08:00
parent fb9856f073
commit 79842fc793
2 changed files with 12 additions and 3 deletions

View file

@ -278,8 +278,16 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
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") {

View file

@ -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();