lrz 5 years ago
parent
commit
68e9b86e76
  1. 14
      docs/zh/guide/api.md
  2. 8
      src/controllers/conditionformat.js
  3. 3
      src/controllers/keyboard.js
  4. 59
      src/controllers/selection.js
  5. 920
      src/global/api.js
  6. 25
      src/global/formula.js

14
docs/zh/guide/api.md

@ -634,8 +634,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### getRangeHtml([setting]) ### getRangeHtml([setting])
[todo]
- **参数** - **参数**
@ -731,7 +729,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### getRangeArray(dimensional [,setting]) ### getRangeArray(dimensional [,setting])
[todo]
- **参数** - **参数**
@ -741,11 +738,8 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
+ `"oneDimensional"`: 一维数组 + `"oneDimensional"`: 一维数组
+ `"twoDimensional"`: 二维数组 + `"twoDimensional"`: 二维数组
+ `"custom"`: 自定义行列数的二维数组
- {PlainObject} [setting]: 可选参数 - {PlainObject} [setting]: 可选参数
+ {Number} [row]: `dimensional`为`custom`的时候设置,多维数组的行数 + {Object | String} [range]: 选区范围,支持选区的格式为`"A1:B2"`、`"sheetName!A1:B2"`或者`{row:[0,1],column:[0,1]}`,只能为单个选区;默认为当前选区
+ {Number} [column]: `dimensional`为`custom`的时候设置,多维数组的列数
+ {Array | Object | String} [range]: 选区范围,支持选区的格式为`"A1:B2"`、`"sheetName!A1:B2"`或者`{row:[0,1],column:[0,1]}`,只能为单个选区;默认为当前选区
+ {Number} [order]: 工作表下标;默认值为当前工作表下标 + {Number} [order]: 工作表下标;默认值为当前工作表下标
- **说明** - **说明**
@ -936,8 +930,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### setRangeShow(range [,setting])<div id='setRangeShow'></div> ### setRangeShow(range [,setting])<div id='setRangeShow'></div>
[todo]
- **参数** - **参数**
@ -1084,8 +1076,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### setRangeFilter(type [,setting]) ### setRangeFilter(type [,setting])
[todo]
- **参数** - **参数**
@ -1096,7 +1086,7 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
+ `"open"`: 打开筛选功能,返回当前筛选的范围对象 + `"open"`: 打开筛选功能,返回当前筛选的范围对象
+ `"close"`: 关闭筛选功能,返回关闭前筛选的范围对象 + `"close"`: 关闭筛选功能,返回关闭前筛选的范围对象
- {PlainObject} [setting]: 可选参数 - {PlainObject} [setting]: 可选参数
+ {Array | Object | String} [range]: 选区范围,支持选区的格式为`"A1:B2"`、`"sheetName!A1:B2"`或者`{row:[0,1],column:[0,1]}`,只能为单个选区;默认为当前选区 + {Object | String} [range]: 选区范围,支持选区的格式为`"A1:B2"`、`"sheetName!A1:B2"`或者`{row:[0,1],column:[0,1]}`,只能为单个选区;默认为当前选区
+ {Number} [order]: 工作表下标;默认值为当前工作表下标 + {Number} [order]: 工作表下标;默认值为当前工作表下标
+ {Function} [success]: 操作结束的回调函数 + {Function} [success]: 操作结束的回调函数

8
src/controllers/conditionformat.js

@ -1434,7 +1434,7 @@ const conditionformat = {
} }
else{ else{
if(formula.iscelldata(txt)){ if(formula.iscelldata(txt)){
range.push(formula.getcellrange(txt.tos)); range.push(formula.getcellrange(txt));
} }
} }
@ -2825,9 +2825,13 @@ const conditionformat = {
return null; return null;
} }
}, },
getComputeMap: function(){ getComputeMap: function(sheetIndex){
let index = getSheetIndex(Store.currentSheetIndex); let index = getSheetIndex(Store.currentSheetIndex);
if(sheetIndex != null){
index = getSheetIndex(sheetIndex);
}
let ruleArr = Store.luckysheetfile[index]["luckysheet_conditionformat_save"]; let ruleArr = Store.luckysheetfile[index]["luckysheet_conditionformat_save"];
let data = Store.luckysheetfile[index]["data"]; let data = Store.luckysheetfile[index]["data"];

3
src/controllers/keyboard.js

@ -856,9 +856,12 @@ export function keyboardInitial(){
formulaMoveEvent("right", ctrlKey, shiftKey,event); formulaMoveEvent("right", ctrlKey, shiftKey,event);
} }
else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40 || kcode == keycode.WIN || kcode == keycode.WIN_R || kcode == keycode.MENU))) || kcode == 8 || kcode == 32 || kcode == 46 || (event.ctrlKey && kcode == 86)) { else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40 || kcode == keycode.WIN || kcode == keycode.WIN_R || kcode == keycode.MENU))) || kcode == 8 || kcode == 32 || kcode == 46 || (event.ctrlKey && kcode == 86)) {
if(event.target.id!="luckysheet-input-box" && event.target.id!="luckysheet-rich-text-editor"){
formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode); formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode);
setCenterInputPosition(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1], Store.flowdata); setCenterInputPosition(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1], Store.flowdata);
} }
}
}).keyup(function (e) { }).keyup(function (e) {
let kcode = e.keyCode; let kcode = e.keyCode;

59
src/controllers/selection.js

@ -100,41 +100,39 @@ const selection = {
Store.luckysheet_selection_range = []; Store.luckysheet_selection_range = [];
//copy范围 //copy范围
let minR = Store.luckysheet_select_save[0].row[0], let rowIndexArr = [], colIndexArr = [];
maxR = Store.luckysheet_select_save[0].row[1];
let minC = Store.luckysheet_select_save[0].column[0],
maxC = Store.luckysheet_select_save[0].column[1];
let copyRange = [], RowlChange = false, HasMC = false; let copyRange = [], RowlChange = false, HasMC = false;
for(let s = 0; s < Store.luckysheet_select_save.length; s++){ for(let s = 0; s < Store.luckysheet_select_save.length; s++){
let range = Store.luckysheet_select_save[s]; let range = Store.luckysheet_select_save[s];
if(range.row[0] < minR){ let r1 = range.row[0],
minR = range.row[0]; r2 = range.row[1];
} let c1 = range.column[0],
c2 = range.column[1];
if(range.row[1] > maxR){ for(let copyR = r1; copyR <= r2; copyR++){
maxR = range.row[1]; if (Store.config["rowhidden"] != null && Store.config["rowhidden"][copyR] != null) {
continue;
} }
if(range.column[0] < minC){ if(!rowIndexArr.includes(copyR)){
minC = range.column[0]; rowIndexArr.push(copyR);
} }
if(range.column[1] > maxC){ if (Store.config["rowlen"] != null && (copyR in Store.config["rowlen"])){
maxC = range.column[1]; RowlChange = true;
} }
for(let copyR = range.row[0]; copyR <= range.row[1]; copyR++){ for(let copyC = c1; copyC <= c2; copyC++){
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][copyR] != null) { if (Store.config["colhidden"] != null && Store.config["colhidden"][copyC] != null) {
continue; continue;
} }
if (Store.config["rowlen"] != null && (copyR in Store.config["rowlen"])){ if(!colIndexArr.includes(copyC)){
RowlChange = true; colIndexArr.push(copyC);
} }
for(let copyC = range.column[0]; copyC <= range.column[1]; copyC++){
let cell = Store.flowdata[copyR][copyC]; let cell = Store.flowdata[copyR][copyC];
if(getObjType(cell) == "object" && ("mc" in cell) && cell.mc.rs != null){ if(getObjType(cell) == "object" && ("mc" in cell) && cell.mc.rs != null){
@ -169,20 +167,31 @@ const selection = {
d = editor.deepCopyFlowData(Store.flowdata); d = editor.deepCopyFlowData(Store.flowdata);
let colgroup = ""; let colgroup = "";
for (let r = minR; r <= maxR; r++) { rowIndexArr = rowIndexArr.sort();
colIndexArr = colIndexArr.sort();
for (let i = 0; i < rowIndexArr.length; i++) {
let r = rowIndexArr[i];
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) { if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) {
continue; continue;
} }
cpdata += '<tr>'; cpdata += '<tr>';
for (let c = minC; c <= maxC; c++) { for (let j = 0; j < colIndexArr.length; j++) {
let c = colIndexArr[j];
if (Store.config["colhidden"] != null && Store.config["colhidden"][c] != null) {
continue;
}
let column = '<td ${span} style="${style}">'; let column = '<td ${span} style="${style}">';
if (d[r] != null && d[r][c] != null) { if (d[r] != null && d[r][c] != null) {
let style = "", span = ""; let style = "", span = "";
if(r == minR){ if(r == rowIndexArr[0]){
if(Store.config == null || Store.config["columnlen"] == null || Store.config["columnlen"][c.toString()] == null){ if(Store.config == null || Store.config["columnlen"] == null || Store.config["columnlen"][c.toString()] == null){
colgroup += '<colgroup width="72px"></colgroup>'; colgroup += '<colgroup width="72px"></colgroup>';
} }
@ -191,7 +200,7 @@ const selection = {
} }
} }
if(c == minC){ if(c == colIndexArr[0]){
if(Store.config == null || Store.config["rowlen"] == null || Store.config["rowlen"][r.toString()] == null){ if(Store.config == null || Store.config["rowlen"] == null || Store.config["rowlen"][r.toString()] == null){
style += 'height:19px;'; style += 'height:19px;';
} }
@ -470,7 +479,7 @@ const selection = {
column += ""; column += "";
if(r == minR){ if(r == rowIndexArr[0]){
if(Store.config == null || Store.config["columnlen"] == null || Store.config["columnlen"][c.toString()] == null){ if(Store.config == null || Store.config["columnlen"] == null || Store.config["columnlen"][c.toString()] == null){
colgroup += '<colgroup width="72px"></colgroup>'; colgroup += '<colgroup width="72px"></colgroup>';
} }
@ -479,7 +488,7 @@ const selection = {
} }
} }
if(c == minC){ if(c == colIndexArr[0]){
if(Store.config == null || Store.config["rowlen"] == null || Store.config["rowlen"][r.toString()] == null){ if(Store.config == null || Store.config["rowlen"] == null || Store.config["rowlen"][r.toString()] == null){
style += 'height:19px;'; style += 'height:19px;';
} }

920
src/global/api.js

File diff suppressed because it is too large

25
src/global/formula.js

@ -3238,7 +3238,7 @@ const luckysheetformula = {
let value = $editer.text(), let value = $editer.text(),
valuetxt = value; valuetxt = value;
if (value.length > 0 && !(value1txt.substr(0, 1) != "=" && value1.indexOf("span")>-1) && (kcode != 229 || value.length == 1)) { if (value.length > 0 && value1txt.substr(0, 1) == "=" && (kcode != 229 || value.length == 1)) {
value = _this.functionHTMLGenerate(value); value = _this.functionHTMLGenerate(value);
value1 = _this.functionHTMLGenerate(value1txt); value1 = _this.functionHTMLGenerate(value1txt);
@ -3266,11 +3266,32 @@ const luckysheetformula = {
} }
$functionbox.html(value); $functionbox.html(value);
} }
else if(value1txt.substr(0, 1) != "=" && value1.indexOf("span")>-1){ else if(value1txt.substr(0, 1) != "=" && (kcode != 229 || value.length == 1)){
//&& value1.indexOf("span")>-1
// $editer.html(value1); // $editer.html(value1);
let w = window.getSelection();
if(w!=null && w.type!="None"){
let range = w.getRangeAt(0);
let c = range.startContainer;
if(c.id=="luckysheet-rich-text-editor" || $(c).closest("#luckysheet-rich-text-editor")){
$functionbox.html(value); $functionbox.html(value);
} }
else if(c.id=="luckysheet-functionbox-cell" || $(c).closest("#luckysheet-functionbox-cell")){
if(value1.indexOf("span")>-1){
}
else{
$editer.html(value);
}
}
}
}
_this.rangestart = false; _this.rangestart = false;
_this.rangedrag_column_start = false; _this.rangedrag_column_start = false;

Loading…
Cancel
Save