Skip to content

Commit

Permalink
fix: cell data contains "<" sign
Browse files Browse the repository at this point in the history
1. fix edit box and function box shows error data when cell value contains "<" and ">" sign. 2: fix
copy paste data error when cell value contains "<", ">" sign. 3: add .vscode to gitignore

fix dream-num#1060
  • Loading branch information
zhichaoxu committed Jun 20, 2022
1 parent abbbebe commit 2f2e942
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ docs/.vuepress/dist

.idea
.history
.vs
.vs
.vscode
2 changes: 2 additions & 0 deletions src/controllers/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ const selection = {
if(c_value == null){
c_value = "";
}

c_value = formula.ltGtSignDeal(c_value)

column += c_value;
}
Expand Down
1 change: 1 addition & 0 deletions src/controllers/updateCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
$("#luckysheet-rich-text-editor").html("");
}
else{
value = formula.ltGtSignDeal(value);
$("#luckysheet-rich-text-editor").html(value);
if (!isnotfocus) {
luckysheetRangeLast($("#luckysheet-rich-text-editor")[0]);
Expand Down
9 changes: 9 additions & 0 deletions src/global/formula.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ const luckysheetformula = {
if (typeof str !== 'string') return str;
return str.replace(/<script>/g, '&lt;script&gt;').replace(/<\/script>/, '&lt;/script&gt;');
},
ltGtSignDeal: function (str) {
if (typeof str !== 'string') return str;
if (str.substr(0, 5) === "<span" || str.startsWith('=')) {
return str
}
return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
},
fucntionboxshow: function(r, c) {

if (!checkProtectionCellHidden(r, c, Store.currentSheetIndex)) {
Expand Down Expand Up @@ -3407,10 +3414,12 @@ const luckysheetformula = {

}
else {
value = _this.ltGtSignDeal(value);
$copy.html(value);
}
}
else {
value = _this.ltGtSignDeal(value);
$copy.html(value);
}
}
Expand Down

0 comments on commit 2f2e942

Please sign in to comment.