diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts index f98306918..cc7abd45b 100644 --- a/app/src/block/popover.ts +++ b/app/src/block/popover.ts @@ -23,7 +23,7 @@ export const initBlockPopover = (app: App) => { if (aElement) { let tip = aElement.getAttribute("aria-label") || aElement.getAttribute("data-inline-memo-content"); if (aElement.classList.contains("av__celltext")) { - if (aElement.offsetWidth > aElement.parentElement.clientWidth - 5) { // 只能减左边 padding,换行时字体会穿透到右侧 padding + if (aElement.offsetWidth > aElement.parentElement.clientWidth - (aElement.classList.contains("fn__flex-shrink") ? 19 : 5)) { // 只能减左边 padding,换行时字体会穿透到右侧 padding if (aElement.querySelector(".av__cellicon")) { tip = `${aElement.firstChild.textContent} → ${aElement.lastChild.textContent}`; } else { diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts index b95212b62..65df6926e 100644 --- a/app/src/protyle/gutter/index.ts +++ b/app/src/protyle/gutter/index.ts @@ -217,6 +217,9 @@ export class Gutter { return; } if (buttonElement.dataset.type === "NodeAttributeViewRow") { + blockElement.querySelectorAll(".av__cell--select").forEach((cellElement: HTMLElement) => { + cellElement.classList.remove("av__cell--select"); + }); const avID = blockElement.getAttribute("data-av-id"); const srcIDs = [Lute.NewNodeID()]; const previousID = event.altKey ? (rowElement.previousElementSibling.getAttribute("data-id") || "") : buttonElement.dataset.rowId; diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts index 03cfe0466..24991bf0e 100644 --- a/app/src/protyle/hint/index.ts +++ b/app/src/protyle/hint/index.ts @@ -399,7 +399,10 @@ ${genHintItemHTML(item)} return; } if (this.source === "av") { - const cellElement = hasClosestByClassName(protyle.toolbar.range.startContainer, "av__cell"); + let cellElement = hasClosestByClassName(protyle.toolbar.range.startContainer, "av__cell"); + if (!cellElement) { + cellElement = nodeElement.querySelector(".av__cell--select") as HTMLElement; + } if (!cellElement) { return; } diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index e30fcd9ad..1f53964a1 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -315,8 +315,15 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type inputElement.addEventListener("input", (event: InputEvent) => { if (Constants.BLOCK_HINT_KEYS.includes(inputElement.value.substring(0, 2))) { protyle.toolbar.range = document.createRange(); + if (!blockElement.contains(cellElements[0])) { + const rowElement = hasClosestByClassName(cellElements[0], "av__row") as HTMLElement; + if (cellElements[0]) { + cellElements[0] = blockElement.querySelector(`.av__row[data-id="${rowElement.dataset.id}"] .av__cell[data-col-id="${cellElements[0].dataset.colId}"]`) as HTMLElement; + } + } protyle.toolbar.range.selectNodeContents(cellElements[0].lastChild); focusByRange(protyle.toolbar.range); + cellElements[0].classList.add("av__cell--select"); hintRef(inputElement.value.substring(2), protyle, "av"); avMaskElement?.remove(); event.preventDefault(); diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts index a61cd9a76..4a8cbfc98 100644 --- a/app/src/protyle/render/av/render.ts +++ b/app/src/protyle/render/av/render.ts @@ -98,7 +98,7 @@ data-icon="${column.icon}" data-dtype="${column.type}" data-wrap="${column.wrap} style="width: ${column.width || "200px"};">