Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(bug): bug
Browse files Browse the repository at this point in the history
bug

fix #361, fix #364, fix #365
  • Loading branch information
wpxp123456 committed Dec 18, 2020
1 parent f6d625d commit 0f257e8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/controllers/inlineString.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ export function convertSpanToShareString($dom){
let styleList = convertCssToStyleList(span.style.cssText);

let curStyleListString = JSON.stringify(styleList);
let v = span.innerHTML;
// let v = span.innerHTML;
let v = span.innerText;
v = v.replace(/\n/g, "\r\n");

if(curStyleListString==preStyleListString){
Expand Down
19 changes: 15 additions & 4 deletions src/controllers/sheetBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ function showsheetconfigmenu() {
}

let luckysheetsheetrightclick = function ($t, $cur, e) {
//保存正在编辑的单元格内容
if (parseInt($("#luckysheet-input-box").css("top")) > 0) {
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
}

clearTimeout(jfdbclicklagTimeout);
if ($cur.hasClass("luckysheet-sheets-item-name") && $cur.attr("contenteditable") == "true") {
return;
Expand All @@ -136,10 +141,6 @@ let luckysheetsheetrightclick = function ($t, $cur, e) {
}, 1);
}
else {
//保存正在编辑的单元格内容
if (parseInt($("#luckysheet-input-box").css("top")) > 0) {
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
}
$("#luckysheet-input-box").removeAttr("style");
$("#luckysheet-formula-functionrange .luckysheet-formula-functionrange-highlight").remove();
}
Expand Down Expand Up @@ -410,6 +411,11 @@ export function initialSheetBar(){
});

$("#luckysheet-sheets-add").click(function (e) {
//保存正在编辑的单元格内容
if (parseInt($("#luckysheet-input-box").css("top")) > 0) {
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
}

sheetmanage.addNewSheet(e);
sheetmanage.locationSheet();
$("#luckysheet-input-box").removeAttr("style");
Expand Down Expand Up @@ -458,6 +464,11 @@ export function initialSheetBar(){

let initialOpenSheet = true;
$("#luckysheet-sheets-m").click(function (e) {
//保存正在编辑的单元格内容
if (parseInt($("#luckysheet-input-box").css("top")) > 0) {
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
}

$("#luckysheet-sheet-list").html("");

let item = "";
Expand Down
26 changes: 22 additions & 4 deletions src/global/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,27 @@ export function setCellFormat(row, column, attr, value, options = {}) {
order = curSheetOrder,
success
} = { ...options };
let targetSheetData = $.extend(true, [], Store.luckysheetfile[order].data);

let file = Store.luckysheetfile[order];

if(file == null){
return tooltip.info("The order parameter is invalid.", "");
}

let targetSheetData = $.extend(true, [], file.data);
if(targetSheetData.length == 0){
targetSheetData = sheetmanage.buildGridData(file);
}

let cellData = targetSheetData[row][column] || {};
let cfg = $.extend(true, {}, file.config);

// 特殊格式
if (attr == 'ct' && (!value || !value.hasOwnProperty('fa') || !value.hasOwnProperty('t'))) {
return new TypeError('While set attribute \'ct\' to cell, the value must have property \'fa\' and \'t\'')
}

if (attr == 'bd') {
let cfg = $.extend(true, {}, Store.config);
if(cfg["borderInfo"] == null){
cfg["borderInfo"] = [];
}
Expand All @@ -360,15 +371,22 @@ export function setCellFormat(row, column, attr, value, options = {}) {
}

cfg["borderInfo"].push(borderInfo);
Store.config = cfg;
} else {
cellData[attr] = value;
}

targetSheetData[row][column] = cellData;

// refresh
jfrefreshgrid(targetSheetData, [{ "row": [row, row], "column": [column, column] }]);
if(file.index == Store.currentSheetIndex){
file.config = cfg;
Store.config = cfg;
jfrefreshgrid(targetSheetData, [{ "row": [row, row], "column": [column, column] }]);
}
else {
file.config = cfg;
file.data = targetSheetData;
}

if (success && typeof success === 'function') {
success(cellData);
Expand Down

0 comments on commit 0f257e8

Please sign in to comment.