mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-10 22:23:28 +08:00
This commit is contained in:
parent
7f097f3b99
commit
5546bb75b8
@ -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,27 +375,16 @@ 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 = [];
|
||||
cellData = row.cells[cellIndex];
|
||||
// 为空时 cellId 每次请求都不一致
|
||||
cellData.id = options.cellElement.dataset.id;
|
||||
if (!cellData.value) {
|
||||
cellData.value = {mSelect:[]} as IAVCellValue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
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) {
|
||||
@ -401,7 +396,6 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
|
||||
menuElement.querySelector("input").focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const oldValue = Object.assign([], cellData.value.mSelect);
|
||||
if (colData.type === "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,
|
||||
|
Loading…
Reference in New Issue
Block a user