From a7c7174e67cc92893cddfd71cf9aa1b23b2ffe35 Mon Sep 17 00:00:00 2001 From: takeuchi kazuto Date: Thu, 25 Aug 2022 21:53:32 +0900 Subject: [PATCH] fix: clearing cell removes hyperlink --- src/controllers/controlHistory.js | 6 ++++-- src/controllers/rowColumnOperation.js | 12 ++++++++---- src/global/refresh.js | 9 +++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/controllers/controlHistory.js b/src/controllers/controlHistory.js index 71bc6af..7b3aa0f 100644 --- a/src/controllers/controlHistory.js +++ b/src/controllers/controlHistory.js @@ -83,7 +83,8 @@ const controlHistory = { "RowlChange": ctr.RowlChange, "cdformat": ctr.cdformat, "dataVerification": ctr.dataVerification, - "dynamicArray": ctr.dynamicArray + "dynamicArray": ctr.dynamicArray, + "hyperlink": ctr.hyperlink, } // jfrefreshgrid(ctr.data, ctr.range, allParam); @@ -459,7 +460,8 @@ const controlHistory = { "RowlChange": ctr.RowlChange, "cdformat": ctr.curCdformat, "dataVerification": ctr.curDataVerification, - "dynamicArray": ctr.curDynamicArray + "dynamicArray": ctr.curDynamicArray, + "hyperlink": ctr.curHyperlink, } formulaHistoryHanddler(ctr, "undo"); diff --git a/src/controllers/rowColumnOperation.js b/src/controllers/rowColumnOperation.js index 59c4af5..0e21da5 100644 --- a/src/controllers/rowColumnOperation.js +++ b/src/controllers/rowColumnOperation.js @@ -2068,7 +2068,10 @@ export function rowColumnOperationInitial(){ return; } - const hyperlinkMap = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].hyperlink; + + const file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]; + const hyperlink = file.hyperlink && $.extend(true, {}, file.hyperlink); + let hyperlinkUpdated; for(let s = 0; s < Store.luckysheet_select_save.length; s++){ let r1 = Store.luckysheet_select_save[s].row[0], @@ -2101,14 +2104,15 @@ export function rowColumnOperationInitial(){ d[r][c] = null; } // 同步清除 hyperlink - if (hyperlinkMap && hyperlinkMap[`${r}_${c}`]) { - delete hyperlinkMap[`${r}_${c}`]; + if (hyperlink?.[`${r}_${c}`]) { + delete hyperlink[`${r}_${c}`]; + hyperlinkUpdated = true; } } } } - jfrefreshgrid(d, Store.luckysheet_select_save); + jfrefreshgrid(d, Store.luckysheet_select_save, hyperlinkUpdated && { hyperlink }); // 清空编辑框的内容 // 备注:在functionInputHanddler方法中会把该标签的内容拷贝到 #luckysheet-functionbox-cell diff --git a/src/global/refresh.js b/src/global/refresh.js index b03ff1a..3e8a45f 100644 --- a/src/global/refresh.js +++ b/src/global/refresh.js @@ -58,6 +58,7 @@ function jfrefreshgrid(data, range, allParam, isRunExecFunction = true, isRefres let cdformat = allParam["cdformat"]; //条件格式 let dataVerification = allParam["dataVerification"]; //数据验证 let dynamicArray = allParam["dynamicArray"]; //动态数组 + let hyperlink = allParam["hyperlink"]; let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]; @@ -110,6 +111,8 @@ function jfrefreshgrid(data, range, allParam, isRunExecFunction = true, isRefres "curDataVerification": curDataVerification, "dynamicArray": $.extend(true, [], file["dynamicArray"]), "curDynamicArray": curDynamicArray, + "hyperlink": hyperlink && $.extend(true, {}, file.hyperlink), + "curHyperlink": hyperlink, "range": range, "dataRange": [...file.luckysheet_select_save]// 保留操作时的选区 }); @@ -153,6 +156,12 @@ function jfrefreshgrid(data, range, allParam, isRunExecFunction = true, isRefres server.saveParam("all", Store.currentSheetIndex, dynamicArray, { "k": "dynamicArray" }); } + if(hyperlink != null){ + file["hyperlink"] = hyperlink; + hyperlinkCtrl.hyperlink = hyperlink; + server.saveParam("all", Store.currentSheetIndex, hyperlink, { "k": "hyperlink" }); + } + //更新数据的范围 for(let s = 0; s < range.length; s++){ let r1 = range[s].row[0];