From 74639a8b719db028ab856f95a80d82553c0d919c Mon Sep 17 00:00:00 2001 From: wpxp123456 <2677556700@qq.com> Date: Fri, 24 Jul 2020 15:41:46 +0800 Subject: [PATCH] fix(bug): bug bug --- src/controllers/conditionformat.js | 8 ++- src/controllers/filter.js | 16 ++--- src/controllers/handler.js | 92 +++++++++++++++++++++----- src/controllers/menuButton.js | 4 +- src/controllers/selection.js | 6 +- src/core.js | 23 +++++++ src/function/functionImplementation.js | 16 ++--- 7 files changed, 122 insertions(+), 43 deletions(-) diff --git a/src/controllers/conditionformat.js b/src/controllers/conditionformat.js index 772cad50b..29ae39901 100644 --- a/src/controllers/conditionformat.js +++ b/src/controllers/conditionformat.js @@ -2064,6 +2064,9 @@ const conditionformat = { $("#luckysheet-editorConditionRule-dialog #isPercent").attr("checked", "checked"); } } + + $("#luckysheet-editorConditionRule-dialog #textcolorshow").spectrum("set", ruleFormat.textColor); + $("#luckysheet-editorConditionRule-dialog #cellcolorshow").spectrum("set", ruleFormat.cellColor); } }, infoDialog: function(title, content){ @@ -3333,8 +3336,9 @@ const conditionformat = { dSmall = genarate(conditionValue0)[2]; } else{ - dBig = genarate(conditionValue0.toString().split("-")[1])[2]; - dSmall = genarate(conditionValue0.toString().split("-")[0])[2]; + let str = conditionValue0.toString().split("-"); + dBig = genarate(str[1].trim())[2]; + dSmall = genarate(str[0].trim())[2]; } //循环应用范围计算 for(let r = cellrange[s].row[0]; r <= cellrange[s].row[1]; r++){ diff --git a/src/controllers/filter.js b/src/controllers/filter.js index 862ab8d81..e667cf5b7 100644 --- a/src/controllers/filter.js +++ b/src/controllers/filter.js @@ -193,14 +193,14 @@ function createFilterOptions(luckysheet_filter_save, filterObj) { $("#luckysheet-filter-selected-sheet" + Store.currentSheetIndex).remove(); $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex).remove(); - if(Store.luckysheet_filter_save == null || JSON.stringify(Store.luckysheet_filter_save) == "{}"){ + if(luckysheet_filter_save == null || JSON.stringify(luckysheet_filter_save) == "{}"){ return; } - let r1 = Store.luckysheet_filter_save.row[0], - r2 = Store.luckysheet_filter_save.row[1]; - let c1 = Store.luckysheet_filter_save.column[0], - c2 = Store.luckysheet_filter_save.column[1]; + let r1 = luckysheet_filter_save.row[0], + r2 = luckysheet_filter_save.row[1]; + let c1 = luckysheet_filter_save.column[0], + c2 = luckysheet_filter_save.column[1]; let row = Store.visibledatarow[r2], row_pre = r1 - 1 == -1 ? 0 : Store.visibledatarow[r1 - 1]; @@ -254,13 +254,13 @@ function createFilterOptions(luckysheet_filter_save, filterObj) { $("#luckysheet-rightclick-menu").hide(); $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide(); - if ($("#luckysheet-cell-main").scrollTop() > Store.luckysheet_filter_save["top_move"]) { - $("#luckysheet-scrollbar-y").scrollTop(Store.luckysheet_filter_save["top_move"]); + if ($("#luckysheet-cell-main").scrollTop() > luckysheet_filter_save["top_move"]) { + $("#luckysheet-scrollbar-y").scrollTop(luckysheet_filter_save["top_move"]); } let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]; - file.filter_select = Store.luckysheet_filter_save; + file.filter_select = luckysheet_filter_save; } export { diff --git a/src/controllers/handler.js b/src/controllers/handler.js index fc4f62731..8233cf8eb 100644 --- a/src/controllers/handler.js +++ b/src/controllers/handler.js @@ -2508,31 +2508,87 @@ export default function luckysheetHandler() { let anchor = $(window.getSelection().anchorNode); let anchorOffset = window.getSelection().anchorOffset; - let dir_n = dir, step = 1; if(dir == 'up'){ - dir_n = 'down'; - step = -1; - } - if(dir == 'left'){ - dir_n = 'right'; - step = -1; + if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); + + event.preventDefault(); + } } + else if(dir == 'down'){ + if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); - if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell(dir_n, step, "rangeOfSelect"); + event.preventDefault(); + } + else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); + + event.preventDefault(); + } } - else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell(dir_n, step, "rangeOfSelect"); + else if(dir == 'left'){ + if(anchor.parent().is("span") && anchor.parent().prev().length == 0 && anchorOffset == 0){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.is("#luckysheet-rich-text-editor") && anchorOffset == 1){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchorOffset == 0){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); + + event.preventDefault(); + } } - else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell(dir_n, step, "rangeOfSelect"); + else if(dir == 'right'){ + if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); + + event.preventDefault(); + } } } - - event.preventDefault(); } } diff --git a/src/controllers/menuButton.js b/src/controllers/menuButton.js index 4a0b4f0a9..13e664ab0 100644 --- a/src/controllers/menuButton.js +++ b/src/controllers/menuButton.js @@ -3540,7 +3540,7 @@ const menuButton = { } } - if(["0", "1", "2"].indexOf(foucsStatus) == -1){ + if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){ foucsStatus = "1"; } } @@ -3555,7 +3555,7 @@ const menuButton = { } } - if(["0", "1", "2"].indexOf(foucsStatus) == -1){ + if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){ foucsStatus = "2"; } } diff --git a/src/controllers/selection.js b/src/controllers/selection.js index c9b76b221..ecef6954c 100644 --- a/src/controllers/selection.js +++ b/src/controllers/selection.js @@ -590,7 +590,7 @@ const selection = { } } - if (getObjType(data) == "object") { + if (typeof data == "object") { if (data.length == 0) { return; }; let cfg = $.extend(true, {}, Store.config); @@ -1679,7 +1679,7 @@ const selection = { }, matchcopy: function (data1, data2) { let data1cache = [], data2cache = [], data1len, data2len; - if (getObjType(data1) == "object") { + if (typeof data1 == "object") { data1cache = data1; } else { @@ -1691,7 +1691,7 @@ const selection = { data1len = data1cache.length; - if (getObjType(data2) == "object") { + if (typeof data2 == "object") { data2cache = data2; } else { diff --git a/src/core.js b/src/core.js index db3bacdf1..2f4613aa2 100644 --- a/src/core.js +++ b/src/core.js @@ -8,9 +8,17 @@ import sheetmanage from './controllers/sheetmanage'; import luckysheetsizeauto from './controllers/resize'; import luckysheetHandler from './controllers/handler'; import {initPlugins} from './controllers/expendPlugins'; +import { + getluckysheetfile, + getluckysheet_select_save, + getconfig, + getvisibledatarow, + getvisibledatacolumn +} from './methods/get'; let luckysheet = {}; +//创建luckysheet表格 luckysheet.create = function (setting) { let extendsetting = common_extend(defaultSetting, setting); @@ -101,6 +109,21 @@ luckysheet.create = function (setting) { } } +//获取所有表格数据 +luckysheet.getluckysheetfile = getluckysheetfile; + +//获取当前表格 选区 +luckysheet.getluckysheet_select_save = getluckysheet_select_save; + +//获取当前表格 config配置 +luckysheet.getconfig = getconfig; + +//获取当前表格 行高数据 +luckysheet.getvisibledatarow = getvisibledatarow; + +//获取当前表格 列宽数据 +luckysheet.getvisibledatacolumn = getvisibledatacolumn; + export { luckysheet } \ No newline at end of file diff --git a/src/function/functionImplementation.js b/src/function/functionImplementation.js index a5fb3a2f6..f9e540a8c 100644 --- a/src/function/functionImplementation.js +++ b/src/function/functionImplementation.js @@ -10301,11 +10301,9 @@ const functionImplementation = { //计算 if(A1){ - var reg = /^(([a-zA-Z]+)|([$][a-zA-Z]+))(([0-9]+)|([$][0-9]+))$/g; - - if(reg.test(ref_text)){ - var row = parseInt(ref_text.replace(/[^0-9]/g, "")) - 1; - var col = ABCatNum(ref_text.replace(/[^A-Za-z]/g, "")); + if(formula.iscelldata(ref_text)){ + let cellrange = formula.getcellrange(ref_text); + let row = cellrange.row[0], col = cellrange.column[0]; if(row < 0 || row >= Store.flowdata.length || col < 0 || col >= Store.flowdata[0].length){ return formula.error.r; @@ -10322,11 +10320,9 @@ const functionImplementation = { } } else{ - var reg = /^[R][0-9]+[C][0-9]+$/g; - - if(reg.test(ref_text)){ - var row = parseInt(ref_text.split("R")[1].split("C")[0]); - var col = parseInt(ref_text.split("R")[1].split("C")[1]); + if(formula.iscelldata(ref_text)){ + let cellrange = formula.getcellrange(ref_text); + let row = cellrange.row[0], col = cellrange.column[0]; if(row < 0 || row >= Store.flowdata.length || col < 0 || col >= Store.flowdata[0].length){ return formula.error.r;