Vanessa 2025-09-26 18:52:21 +08:00
parent b29a487366
commit c8831f8119
3 changed files with 10 additions and 5 deletions

View file

@ -573,3 +573,7 @@ const openEdit = (protyle: IProtyle, element: HTMLElement, event: MouseEvent) =>
target = target.parentElement;
}
};
export const isCustomAttr = (cellElement: Element) => {
return !!cellElement.getAttribute("data-av-id");
};

View file

@ -14,9 +14,10 @@ import * as dayjs from "dayjs";
import {Constants} from "../../../constants";
import {insertGalleryItemAnimation} from "./gallery/item";
import {clearSelect} from "../../util/clearSelect";
import {isCustomAttr} from "./blockAttr";
export const getFieldIdByCellElement = (cellElement: Element, viewType: TAVView): string => {
if (hasClosestByClassName(cellElement, "custom-attr")) {
if (isCustomAttr(cellElement)) {
return cellElement.getAttribute("data-row-id");
}
return (hasClosestByClassName(cellElement, viewType === "table" ? "av__row" : "av__gallery-item") as HTMLElement).dataset.id;

View file

@ -5,7 +5,7 @@ import {confirmDialog} from "../../../dialog/confirmDialog";
import {upDownHint} from "../../../util/upDownHint";
import {bindEditEvent, getColId, getEditHTML} from "./col";
import {updateAttrViewCellAnimation} from "./action";
import {genAVValueHTML} from "./blockAttr";
import {genAVValueHTML, isCustomAttr} from "./blockAttr";
import {escapeAriaLabel, escapeAttr, escapeHtml} from "../../../util/escape";
import {genCellValueByElement, getTypeByCellElement} from "./cell";
import * as dayjs from "dayjs";
@ -213,7 +213,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,
} else {
cellElements.forEach((cellElement: HTMLElement, index) => {
const rowID = getFieldIdByCellElement(cellElement, viewType);
if (viewType === "table") {
if (viewType === "table" || isCustomAttr) {
cellElement = cellElements[index] = (blockElement.querySelector(`.av__row[data-id="${rowID}"] .av__cell[data-col-id="${cellElement.dataset.colId}"]`) ||
blockElement.querySelector(`.fn__flex-1[data-col-id="${cellElement.dataset.colId}"]`)) as HTMLElement;
} else {
@ -331,7 +331,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,
} else {
cellElements.forEach((cellElement: HTMLElement, index) => {
const rowID = getFieldIdByCellElement(cellElement, viewType);
if (viewType === "table") {
if (viewType === "table" || isCustomAttr) {
cellElement = cellElements[index] = (blockElement.querySelector(`.av__row[data-id="${rowID}"] .av__cell[data-col-id="${cellElement.dataset.colId}"]`) ||
blockElement.querySelector(`.fn__flex-1[data-col-id="${cellElement.dataset.colId}"]`)) as HTMLElement;
} else {
@ -523,7 +523,7 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: H
if (!nodeElement) {
cellElements.forEach((item, index) => {
const rowID = getFieldIdByCellElement(item, data.viewType);
if (data.viewType === "table") {
if (data.viewType === "table" || isCustomAttr(item)) {
cellElements[index] = (blockElement.querySelector(`.av__row[data-id="${rowID}"] .av__cell[data-col-id="${item.dataset.colId}"]`) ||
blockElement.querySelector(`.fn__flex-1[data-col-id="${item.dataset.colId}"]`)) as HTMLElement;
} else {