mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-27 01:14:07 +01:00
This commit is contained in:
parent
1eaa79c999
commit
ce4e2c1dde
2 changed files with 42 additions and 6 deletions
|
|
@ -662,10 +662,30 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
|
|||
} else if (type === "mSelect") {
|
||||
// 不传入为删除
|
||||
if (typeof value === "string") {
|
||||
value = oldValue.mSelect.concat({
|
||||
content: value,
|
||||
color: (oldValue.mSelect.length + 1).toString()
|
||||
});
|
||||
const newMSelectValue: IAVCellSelectValue[] = [];
|
||||
let colorIndex = oldValue.mSelect.length;
|
||||
// 以逗号分隔,去重,去空,去换行后做为选项
|
||||
[...new Set(value.split(",").map(v => v.trim().replace(/\n|\r\n|\r|\u2028|\u2029/g, "")))].forEach((item) => {
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
let hasSameContent = false
|
||||
oldValue.mSelect.find((mSelectItem) => {
|
||||
if (mSelectItem.content === item) {
|
||||
hasSameContent = true
|
||||
return true
|
||||
}
|
||||
})
|
||||
if (hasSameContent) {
|
||||
return;
|
||||
}
|
||||
colorIndex++;
|
||||
newMSelectValue.push({
|
||||
content: item,
|
||||
color: colorIndex.toString()
|
||||
})
|
||||
})
|
||||
value = oldValue.mSelect.concat(newMSelectValue);
|
||||
}
|
||||
}
|
||||
const cellValue = genCellValue(type, value);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue