From 1c45347de52bd93544f4fa2b0ae1259232da4d48 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 17 May 2024 18:02:15 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/11409 --- app/src/protyle/render/av/cell.ts | 6 ++++++ app/src/protyle/render/av/select.ts | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index d9cec86d4..dbae54645 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -13,6 +13,7 @@ import {genAVValueHTML} from "./blockAttr"; import {Constants} from "../../../constants"; import {hintRef} from "../../hint/extend"; import {pathPosix} from "../../../util/pathName"; +import {mergeAddOption} from "./select"; const renderCellURL = (urlContent: string) => { let host = urlContent; @@ -587,6 +588,11 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va (cellValue.type === "relation" && typeof cellValue.relation === "string")) { return; } + if (type === "select" || type === "mSelect") { + const operations = mergeAddOption(columns.find(e => e.id === colId), cellValue, avID); + doOperations.push(...operations.doOperations); + undoOperations.push(...operations.undoOperations); + } if (objEquals(cellValue, oldValue)) { return; } diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.ts index 0e966b492..269e915c4 100644 --- a/app/src/protyle/render/av/select.ts +++ b/app/src/protyle/render/av/select.ts @@ -566,7 +566,7 @@ export const getSelectHTML = (data: IAVTable, cellElements: HTMLElement[], init `; }; -export const mergeAddOption = (column: IAVColumn, cellValue: IAVCellValue, avID:string) => { +export const mergeAddOption = (column: IAVColumn, cellValue: IAVCellValue, avID: string) => { const doOperations: IOperation[] = []; const undoOperations: IOperation[] = []; cellValue.mSelect.forEach((item: IAVCellSelectValue) => { @@ -580,15 +580,17 @@ export const mergeAddOption = (column: IAVColumn, cellValue: IAVCellValue, avID: } }); if (!needAdd) { + const newColor = ((column.options?.length || 0) % 13 + 1).toString() column.options.push({ name: item.content, - color:(column.options?.length || 0) % 13 + 1 + color: newColor }); + item.color = newColor; doOperations.push({ action: "updateAttrViewColOptions", id: column.id, avID, - data: column.options + data: column.options }) undoOperations.push({ action: "removeAttrViewColOption",