Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: https://github.com/siyuan-note/siyuan/issues/8664

Vanessa5546bb75b84f
diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.ts
index 3df4a65e81..7aa900e525 100644
--- a/app/src/protyle/render/av/select.ts
+++ b/app/src/protyle/render/av/select.ts
@@ -355,7 +355,13 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
}, currentElement: HTMLElement, menuElement: HTMLElement) => {
const rowID = options.cellElement.parentElement.dataset.id;
const colId = options.cellElement.dataset.colId;
- const cellId = options.cellElement.dataset.id;
+ let cellIndex = 0;
+ Array.from(options.cellElement.parentElement.querySelectorAll(".av__cell")).find((item: HTMLElement, index) => {
+ if (item.dataset.id === options.cellElement.dataset.id) {
+ cellIndex = index;
+ return true;
+ }
+ })
let colData: IAVColumn;
data.view.columns.find((item: IAVColumn) => {
if (item.id === colId) {
@@ -369,38 +375,26 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
let cellData: IAVCell;
data.view.rows.find(row => {
if (row.id === rowID) {
- row.cells.find(cell => {
- if (cell.id === cellId) {
- cellData = cell;
- if (!cellData.value.mSelect) {
- cellData.value.mSelect = [];
- }
- return true;
- }
- });
+ cellData = row.cells[cellIndex];
+ // 为空时 cellId 每次请求都不一致
+ cellData.id = options.cellElement.dataset.id;
+ if (!cellData.value) {
+ cellData.value = {mSelect:[]} as IAVCellValue;
+ }
return true;
}
});
- if (!cellData) {
- cellData = {
- color: "",
- bgColor: "",
- id: Lute.NewNodeID(),
- value: genCellValue(colData.type, ""),
- valueType: colData.type
- };
- } else {
- let hasSelected = false;
- cellData.value.mSelect.find((item) => {
- if (item.content === currentElement.dataset.name) {
- hasSelected = true;
- return true;
- }
- });
- if (hasSelected) {
- menuElement.querySelector("input").focus();
- return;
+
+ let hasSelected = false;
+ cellData.value.mSelect.find((item) => {
+ if (item.content === currentElement.dataset.name) {
+ hasSelected = true;
+ return true;
}
+ });
+ if (hasSelected) {
+ menuElement.querySelector("input").focus();
+ return;
}
const oldValue = Object.assign([], cellData.value.mSelect);
@@ -428,7 +422,7 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
data: colData.options
}, {
action: "updateAttrViewCell",
- id: cellId,
+ id: cellData.id,
keyID: colId,
rowID,
avID: data.id,
@@ -442,14 +436,14 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
} else {
transaction(protyle, [{
action: "updateAttrViewCell",
- id: cellId,
+ id: cellData.id,
keyID: colId,
rowID,
avID: data.id,
data: cellData.value
}], [{
action: "updateAttrViewCell",
- id: cellId,
+ id: cellData.id,
keyID: colId,
rowID,
avID: data.id,