An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Prevent errors when editing database fields in grouped views https://github.com/siyuan-note/siyuan/issues/14975
Daniel3a58d08f4943
diff --git a/app/src/protyle/render/av/batchEdit.ts b/app/src/protyle/render/av/batchEdit.tsindex 53ab66d08e..d1eb469d81 100644--- a/app/src/protyle/render/av/batchEdit.ts+++ b/app/src/protyle/render/av/batchEdit.ts@@ -26,36 +26,39 @@ export const getEditableAVFields = (blockElement: HTMLElement) => {return getFieldsByData(data).filter((field) => EDITABLE_FIELD_TYPES.includes(field.type));};-const getItemCell = (view: IAVView, itemID: string, fieldID: string): IAVCell | undefined => {+const findItemCell = (view: IAVView, viewType: TAVView, itemID: string, fieldIndex: number): IAVCell | undefined => {if (view.groups?.length > 0) {for (const group of view.groups) {- const cell = getItemCell(group, itemID, fieldID);+ const cell = findItemCell(group, viewType, itemID, fieldIndex);if (cell) {return cell;}}return;}- const isTable = view.type === "table";- const fields = isTable ? (view as IAVTable).columns : (view as IAVGallery).fields;- const fieldIndex = fields.findIndex((field) => field.id === fieldID);- if (fieldIndex < 0) {- return;- }+ const isTable = viewType === "table";if (isTable) {- const item = (view as IAVTable).rows.find((currentItem) => currentItem.id === itemID);+ const item = (view as IAVTable).rows?.find((currentItem) => currentItem.id === itemID);return item?.cells[fieldIndex];}- const item = (view as IAVGallery).cards.find((currentItem) => currentItem.id === itemID);+ const item = (view as IAVGallery).cards?.find((currentItem) => currentItem.id === itemID);return item?.values[fieldIndex];};+const getItemCell = (data: IAV, itemID: string, fieldID: string) => {+ const fieldIndex = getFieldsByData(data).findIndex((field) => field.id === fieldID);+ if (fieldIndex < 0) {+ return;+ }+ return findItemCell(data.view, data.viewType, itemID, fieldIndex);+};+const createEditProxy = (options: {data: IAV;field: IAVColumn;itemID: string;}) => {- const cell = getItemCell(options.data.view, options.itemID, options.field.id);+ const cell = getItemCell(options.data, options.itemID, options.field.id);const value = cell?.value ?JSON.parse(JSON.stringify(cell.value)) as IAVCellValue :createEmptyAVValue(options.field.id, options.field.type, options.itemID);@@ -116,7 +119,7 @@ export const openAVFieldEditor = (options: {}destroyed = true;cellElements.forEach((cellElement, index) => {- const cell = getItemCell(data.view, itemIDs[index], options.field.id);+ const cell = getItemCell(data, itemIDs[index], options.field.id);if (!cell || !cellElement.dataset.cellValue) {return;}