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: Replace select values when pasting external tables https://github.com/siyuan-note/siyuan/issues/10767
Daniel07bf06ee53eb
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.tsindex c9f30f9af0..2a4ae3fafe 100644--- a/app/src/protyle/render/av/cell.ts+++ b/app/src/protyle/render/av/cell.ts@@ -731,7 +731,7 @@ const updateCellValueByInput = (protyle: IProtyle, type: TAVCol, blockElement: Hexport const updateCellsValue = async (protyle: IProtyle, nodeElement: HTMLElement, value?: any,cElements?: HTMLElement[], columns?: IAVColumn[], html?: string, getOperations = false,- forceOperation = false) => {+ forceOperation = false, replaceSelectValues = false) => {const doOperations: IOperation[] = [];const undoOperations: IOperation[] = [];@@ -846,15 +846,16 @@ export const updateCellsValue = async (protyle: IProtyle, nodeElement: HTMLEleme} else if (type === "mSelect" || type === "select") {// 不传入为删除if (typeof value === "string") {+ const oldSelectValues = replaceSelectValues ? [] : oldValue.mSelect;const newMSelectValue: IAVCellSelectValue[] = [];- let colorIndex = oldValue.mSelect.length;+ let colorIndex = oldSelectValues.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) => {+ oldSelectValues.find((mSelectItem) => {if (mSelectItem.content === item) {hasSameContent = true;return true;@@ -869,7 +870,7 @@ export const updateCellsValue = async (protyle: IProtyle, nodeElement: HTMLElemecolor: colorIndex.toString()});});- newValue = oldValue.mSelect.concat(newMSelectValue);+ newValue = oldSelectValues.concat(newMSelectValue);}} else if (type === "block" && typeof value === "string" && oldValue.block.id) {newValue = {diff --git a/app/src/protyle/util/insertHTML.ts b/app/src/protyle/util/insertHTML.tsindex 2cbea59c6a..0ffe792574 100644--- a/app/src/protyle/util/insertHTML.ts+++ b/app/src/protyle/util/insertHTML.ts@@ -174,7 +174,7 @@ const pasteAVMatrix = async (options: {const operations = await updateCellsValue(options.protyle, options.blockElement, options.values[i][j],[cellElement], options.columns,cellElement.dataset.dtype === "mAsset" ? (options.tempElement.content.children[i * (j + 1) + j]?.outerHTML || "") : options.html,- true, newRowIDSet.has(rowElements[i].dataset.id));+ true, newRowIDSet.has(rowElements[i].dataset.id), true);if (operations.doOperations.length > 0) {doOperations.push(...operations.doOperations);if (newRowIDSet.has(rowElements[i].dataset.id)) {