diff --git a/docs/zh/guide/api.md b/docs/zh/guide/api.md
index 10bed91..58117f8 100644
--- a/docs/zh/guide/api.md
+++ b/docs/zh/guide/api.md
@@ -1444,9 +1444,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### deleteRangeConditionalFormat(itemIndex [,setting])
-[todo]
-
-
- **参数**:
- {Number} [itemIndex]: 条件格式规则索引
@@ -1469,9 +1466,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### clearRange([setting])
-[todo]
-
-
- **参数**:
- {PlainObject} [setting]: 可选参数
@@ -1481,7 +1475,7 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
- **说明**:
- 清除指定工作表指定单元格区域的内容,返回清除掉的数据,不同于删除选区的功能,不需要设定单元格移动情况
+ 清除指定工作表指定单元格区域的内容,不同于删除选区的功能,不需要设定单元格移动情况
- **示例**:
@@ -1492,9 +1486,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### deleteRange(move [,setting])
-[todo]
-
-
- **参数**:
- {String} [move]: 删除后,右侧还是下方的单元格移动
@@ -1505,13 +1496,13 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
+ `"up"`: 下方单元格上移
- {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]: 工作表下标;默认值为当前工作表下标
+ {Function} [success]: 操作结束的回调函数
- **说明**:
- 删除指定工作表指定单元格区域,返回删除掉的数据,同时,指定是右侧单元格左移还是下方单元格上移
+ 删除指定工作表指定单元格区域,同时,指定是右侧单元格左移还是下方单元格上移
- **示例**:
@@ -1558,9 +1549,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### matrixOperation(type [,setting])
-[todo]
-
-
- **参数**:
- {String} [type]: 矩阵操作的类型
@@ -1603,9 +1591,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### matrixCalculation(type, number [,setting])
-[todo]
-
-
- **参数**:
- {String} [type]: 计算方式
@@ -1678,8 +1663,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### getSheet([setting])
-[todo]
-
- **参数**:
- {PlainObject} [setting]: 可选参数
@@ -1695,9 +1678,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### getSheetData([setting])
-[todo]
-
-
- **参数**:
- {PlainObject} [setting]: 可选参数
@@ -1711,9 +1691,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### getConfig([setting])
-[todo]
-
-
- **参数**:
- {PlainObject} [setting]: 可选参数
@@ -1725,20 +1702,17 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
------------
-### setConfig([setting])
-
-[todo]
-
+### setConfig(cfg, [setting])
- **参数**:
-
+ - {Object} [cfg]: config配置
- {PlainObject} [setting]: 可选参数
+ {Number} [order]: 工作表下标;默认值为当前工作表下标
+ {Function} [success]: 操作结束的回调函数
- **说明**:
- 快捷设置当前工作表config配置
+ 快捷设置指定工作表config配置
------------
diff --git a/src/controllers/inlineString.js b/src/controllers/inlineString.js
index d989f26..84913fa 100644
--- a/src/controllers/inlineString.js
+++ b/src/controllers/inlineString.js
@@ -2,8 +2,10 @@ import {getFontStyleByCell, textTrim} from "../global/getdata";
import {selectTextContent,selectTextContentCross,selectTextContentCollapse} from '../global/cursorPos';
import locale from '../locale/locale';
import Store from '../store';
+import { connect } from "net";
export const inlineStyleAffectAttribute = {"bl":1, "it":1 , "ff":1, "cl":1, "un":1,"fs":1,"fc":1};
+export const inlineStyleAffectCssName = {"font-weight":1, "font-style":1 , "font-family":1, "text-decoration":1, "border-bottom":1,"font-size":1,"color":1};
export function isInlineStringCell(cell){
let isIs = cell && cell.ct!=null && cell.ct.t=="inlineStr" && cell.ct.s!=null && cell.ct.s.length>0;
@@ -68,10 +70,16 @@ export function updateInlineStringFormat(cell, attr, value, $input){
let endOffset = range.endOffset, startOffset = range.startOffset;
if($textEditor.length>0){
- if(startContainer===endContainer){
- let span = startContainer.parentNode, spanIndex;
+ if(startContainer===endContainer){
+ let span = startContainer.parentNode, spanIndex, inherit=false;
let content = span.innerHTML;
+
+ let fullContent = $textEditor.html();
+ if(fullContent.substr(0,5) != "" + left + "";
+ let cssText = span.style.cssText;
+ if(inherit){
+ let box = $(span).closest("#luckysheet-input-box").get(0);
+ if(box!=null){
+ cssText = extendCssText(box.style.cssText, cssText);
+ }
+ }
+ cont += "" + left + "";
}
if(mid!=""){
@@ -94,12 +109,26 @@ export function updateInlineStringFormat(cell, attr, value, $input){
// cssText = removeClassWidthCss(cssText, attr);
let cssText = getCssText(span.style.cssText, attr, value);
+
+ if(inherit){
+ let box = $(span).closest("#luckysheet-input-box").get(0);
+ if(box!=null){
+ cssText = extendCssText(box.style.cssText, cssText);
+ }
+ }
cont += "" + mid + "";
}
if(right!=""){
- cont += "" + right + "";
+ let cssText = span.style.cssText;
+ if(inherit){
+ let box = $(span).closest("#luckysheet-input-box").get(0);
+ if(box!=null){
+ cssText = extendCssText(box.style.cssText, cssText);
+ }
+ }
+ cont += "" + right + "";
}
if(startContainer.parentNode.tagName=="SPAN"){
@@ -121,8 +150,8 @@ export function updateInlineStringFormat(cell, attr, value, $input){
}
selectTextContent($textEditor.find("span").get(seletedNodeIndex));
- }
- else{
+ }
+ else{
if(startContainer.parentNode.tagName=="SPAN" && endContainer.parentNode.tagName=="SPAN"){
let startSpan = startContainer.parentNode, startSpanIndex;
let endSpan = endContainer.parentNode, endSpanIndex;
@@ -195,7 +224,7 @@ export function updateInlineStringFormat(cell, attr, value, $input){
selectTextContentCross(spans.get(startSeletedNodeIndex), spans.get(endSeletedNodeIndex));
}
- }
+ }
}
else if($functionbox.length>0){
@@ -298,7 +327,13 @@ export function enterKeyControll(cell){
}
export function updateInlineStringFormatOutside(cell, key, value){
+ if(cell.ct==null){
+ return;
+ }
let s = cell.ct.s;
+ if(s==null){
+ return;
+ }
for(let i=0;i= 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"){
+ // if(event.target.id!="luckysheet-input-box" && event.target.id!="luckysheet-rich-text-editor"){
formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode);
setCenterInputPosition(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1], Store.flowdata);
- }
+ // }
}
}).keyup(function (e) {
@@ -872,7 +872,9 @@ export function keyboardInitial(){
//输入框中文输入后 shift 和 空格 处理
if(parseInt($("#luckysheet-input-box").css("top")) > 0 && (kcode == 13 || kcode == 16 || kcode == 32)){
- formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode);
+ // if(event.target.id=="luckysheet-input-box" || event.target.id=="luckysheet-rich-text-editor"){
+ // formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode);
+ // }
}
e.preventDefault();
diff --git a/src/controllers/menuButton.js b/src/controllers/menuButton.js
index 610fc9b..29d8dee 100644
--- a/src/controllers/menuButton.js
+++ b/src/controllers/menuButton.js
@@ -2887,7 +2887,7 @@ const menuButton = {
if(value.substr(0,1)!="="){
let cell = d[Store.luckysheetCellUpdate[0]][Store.luckysheetCellUpdate[1]];
updateInlineStringFormat(cell, attr, foucsStatus, luckysheetformula.rangeResizeTo);
- return;
+ // return;
}
}
}
@@ -3014,12 +3014,12 @@ const menuButton = {
let value = d[r][c];
if (getObjType(value) == "object") {
- if(attr in inlineStyleAffectAttribute && isInlineStringCell(value)){
+ // if(attr in inlineStyleAffectAttribute && isInlineStringCell(value)){
updateInlineStringFormatOutside(value, attr, foucsStatus);
- }
- else{
+ // }
+ // else{
d[r][c][attr] = foucsStatus;
- }
+ // }
}
else{
diff --git a/src/controllers/rowColumnOperation.js b/src/controllers/rowColumnOperation.js
index 1b2f34a..d695283 100644
--- a/src/controllers/rowColumnOperation.js
+++ b/src/controllers/rowColumnOperation.js
@@ -1636,6 +1636,10 @@ export function rowColumnOperationInitial(){
delete d[r][c]["spl"];
}
+
+ if(d[r][c]["ct"] != null && d[r][c]["ct"].t == 'inlineStr'){
+ delete d[r][c]["ct"];
+ }
}
else{
d[r][c] = null;
diff --git a/src/controllers/sheetmanage.js b/src/controllers/sheetmanage.js
index bf37f40..5d943da 100644
--- a/src/controllers/sheetmanage.js
+++ b/src/controllers/sheetmanage.js
@@ -972,6 +972,30 @@ const sheetmanage = {
}
},
+ loadOtherFile:function(file){
+ let _this = this;
+ let sheetindexset = _this.checkLoadSheetIndex(file);
+ let sheetindex = [];
+
+ for(let i = 0; i < sheetindexset.length; i++){
+ let item = sheetindexset[i];
+
+ if(item == file["index"]){
+ continue;
+ }
+
+ sheetindex.push(item);
+ }
+
+ for(let i = 0;i {
+ if (success && typeof success === 'function') {
+ success();
+ }
+ }, 1);
+
+ return cdformatItem;
}
+
+/**
+ * 清除指定工作表指定单元格区域的内容,不同于删除选区的功能,不需要设定单元格移动情况
+ * @param {Object} options 可选参数
+ * @param {Array | Object | String} options.range 要清除的选区范围
+ * @param {Number} options.order 工作表下标;默认值为当前工作表下标
+ * @param {Function} options.success 操作结束的回调函数
+ */
+export function clearRange(options = {}) {
+ let {
+ range = Store.luckysheet_select_save,
+ order = getSheetIndex(Store.currentSheetIndex),
+ success
+ } = {...options}
+
+ if(getObjType(range) == 'string'){
+ if(!formula.iscelldata(range)){
+ return tooltip.info("The range parameter is invalid.", "");
+ }
+
+ let cellrange = formula.getcellrange(range);
+ range = [{
+ "row": cellrange.row,
+ "column": cellrange.column
+ }]
+ }
+ else if(getObjType(range) == 'object'){
+ if(range.row == null || range.column == null){
+ return tooltip.info("The range parameter is invalid.", "");
+ }
+
+ range = [{
+ "row": range.row,
+ "column": range.column
+ }];
+ }
+
+ if(getObjType(range) != 'array'){
+ return tooltip.info("The range parameter is invalid.", "");
+ }
+
+ let file = Store.luckysheetfile[order];
+
+ if(file == null){
+ return tooltip.info("The order parameter is invalid.", "");
+ }
+
+ let cfg = $.extend(true, {}, file.config);
+ let has_PartMC = false;
+
+ for(let s = 0; s < range.length; s++){
+ let r1 = range[s].row[0],
+ r2 = range[s].row[1];
+ let c1 = range[s].column[0],
+ c2 = range[s].column[1];
+
+ has_PartMC = hasPartMC(cfg, r1, r2, c1, c2);
+
+ if(has_PartMC){
+ break;
+ }
+ }
+
+ if(has_PartMC){
+ return tooltip.info('Cannot perform this operation on partially merged cells', '');
+ }
+
+ let d = $.extend(true, [], file.data);
+
+ if(d.length == 0){
+ d = $.extend(true, [], sheetmanage.buildGridData(file));
+ }
+
+ for(let s = 0; s < range.length; s++){
+ let r1 = range[s].row[0],
+ r2 = range[s].row[1];
+ let c1 = range[s].column[0],
+ c2 = range[s].column[1];
+
+ for(let r = r1; r <= r2; r++){
+ for(let c = c1; c <= c2; c++){
+ let cell = d[r][c];
+
+ if(getObjType(cell) == "object"){
+ delete cell["m"];
+ delete cell["v"];
+
+ if(cell["f"] != null){
+ delete cell["f"];
+ formula.delFunctionGroup(r, c, file.index);
+
+ delete cell["spl"];
+ }
+
+ if(cell["ct"] != null && cell["ct"].t == 'inlineStr'){
+ delete cell["ct"];
+ }
+ }
+ else{
+ d[r][c] = null;
+ }
+ }
+ }
+ }
+
+ if(file.index == Store.currentSheetIndex){
+ jfrefreshgrid(d, range);
+ }
+ else{
+ file.data = d;
+ }
+
+ if (success && typeof success === 'function') {
+ success();
+ }
+}
+
+
+/**
+ * 删除指定工作表指定单元格区域,返回删除掉的数据,同时,指定是右侧单元格左移还是下方单元格上移
+ * @param {String} move 删除后,单元格左移/上移
+ * @param {Object} options 可选参数
+ * @param {Object | String} options.range 要删除的选区范围
+ * @param {Number} options.order 工作表下标;默认值为当前工作表下标
+ * @param {Function} options.success 操作结束的回调函数
+ */
+export function deleteRange(move, options = {}) {
+ let moveList = ['left', 'up'];
+
+ if(!moveList.includes(move)){
+ return tooltip.info("The move parameter is invalid.", "");
+ }
+
+ let {
+ range = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1],
+ order = getSheetIndex(Store.currentSheetIndex),
+ success
+ } = {...options}
+
+ if(getObjType(range) == 'string'){
+ if(!formula.iscelldata(range)){
+ return tooltip.info("The range parameter is invalid.", "");
+ }
+
+ let cellrange = formula.getcellrange(range);
+ range = {
+ "row": cellrange.row,
+ "column": cellrange.column
+ };
+ }
+
+ if(getObjType(range) != 'object' || range.row == null || range.column == null){
+ return tooltip.info("The range parameter is invalid.", "");
+ }
+
+ let file = Store.luckysheetfile[order];
+
+ if(file == null){
+ return tooltip.info("The order parameter is invalid.", "");
+ }
+
+ let str = range.row[0],
+ edr = range.row[1],
+ stc = range.column[0],
+ edc = range.column[1];
+
+ if(move == 'left'){
+ luckysheetDeleteCell('moveLeft', str, edr, stc, edc, order);
+ }
+ else if(move == 'up'){
+ luckysheetDeleteCell('moveUp', str, edr, stc, edc, order);
+ }
+
+ if (success && typeof success === 'function') {
+ success();
+ }
+}
+
+
/**
* 指定工作表指定单元格区域的数据进行矩阵操作,返回操作成功后的结果数据
* @param {String} type 矩阵操作的类型
@@ -4033,6 +4278,93 @@ export function getSheet(options = {}){
}
+/**
+ * 快捷返回指定工作表的数据
+ * @param {Object} options 可选参数
+ * @param {Number} options.order 工作表下标;默认值为当前工作表下标
+ */
+export function getSheetData(options = {}) {
+ let {
+ order = getSheetIndex(Store.currentSheetIndex)
+ } = {...options};
+
+ let file = Store.luckysheetfile[order];
+
+ if(file == null){
+ return tooltip.info("The order parameter is invalid.", "");
+ }
+
+ let data = $.extend(true, [], file.data);
+
+ if(data == null || data.length == 0){
+ data = $.extend(true, [], sheetmanage.buildGridData(file));
+ }
+
+ return data;
+}
+
+/**
+ * 快捷返回指定工作表的config配置
+ * @param {Object} options 可选参数
+ * @param {Number} options.order 工作表下标;默认值为当前工作表下标
+ */
+export function getConfig(options = {}) {
+ let {
+ order = getSheetIndex(Store.currentSheetIndex)
+ } = {...options};
+
+ let file = Store.luckysheetfile[order];
+
+ if(file == null){
+ return tooltip.info("The order parameter is invalid.", "");
+ }
+
+ let config = $.extend(true, {}, file.config);
+
+ return config;
+}
+
+/**
+ * 快捷设置指定工作表config配置
+ * @param {Object} options 可选参数
+ * @param {Number} options.order 工作表下标;默认值为当前工作表下标
+ * @param {Function} options.success 操作结束的回调函数
+ */
+export function setConfig(cfg, options = {}) {
+ if(getObjType(cfg) != 'object'){
+ return tooltip.info("The cfg parameter is invalid.", "");
+ }
+
+ let {
+ order = getSheetIndex(Store.currentSheetIndex),
+ success
+ } = {...options};
+
+ let file = Store.luckysheetfile[order];
+
+ if(file == null){
+ return tooltip.info("The order parameter is invalid.", "");
+ }
+
+ file.config = cfg;
+
+ if(file.index == Store.currentSheetIndex){
+ Store.config = cfg;
+
+ if("rowhidden" in cfg || "colhidden" in cfg || "rowlen" in cfg || "columnlen" in cfg){
+ jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
+ }
+
+ setTimeout(function () {
+ luckysheetrefreshgrid();
+ }, 1);
+ }
+
+ if (success && typeof success === 'function') {
+ success();
+ }
+}
+
/**
* 返回所有表格数据结构的一维数组luckysheetfile
*/
diff --git a/src/global/extend.js b/src/global/extend.js
index 960ea37..70b8aea 100644
--- a/src/global/extend.js
+++ b/src/global/extend.js
@@ -1612,6 +1612,13 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, order) {
else if(str <= r && edr >= r + rs - 1 && edc < c){
merge_new[r + "_" + (c - clen)] = { "r": r, "c": c - clen, "rs": rs, "cs": cs };
}
+ else{
+ for(let r_i = r; r_i <= r + rs - 1; r_i++){
+ for(let c_i = c; c_i <= c + cs - 1; c_i++){
+ delete d[r_i][c_i].mc;
+ }
+ }
+ }
}
else if(type == "moveUp"){
if(stc > c + cs - 1 || edc < c || str > r + rs - 1){
@@ -1620,6 +1627,13 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, order) {
else if(stc <= c && edc >= c + cs - 1 && edr < r){
merge_new[(r - rlen) + "_" + c] = { "r": r - rlen, "c": c, "rs": rs, "cs": cs };
}
+ else{
+ for(let r_i = r; r_i <= r + rs - 1; r_i++){
+ for(let c_i = c; c_i <= c + cs - 1; c_i++){
+ delete d[r_i][c_i].mc;
+ }
+ }
+ }
}
}
cfg["merge"] = merge_new;
@@ -1905,19 +1919,9 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, order) {
CFr2 = cf_range[j].row[1],
CFc1 = cf_range[j].column[0],
CFc2 = cf_range[j].column[1];
-
- if(!(str > CFr2 || edr < CFr1) || !(stc > CFc2 || edc < CFc1)){
- let range = conditionformat.CFSplitRange(
- cf_range[j],
- { "row": [str, edr], "column": [stc, edc] },
- { "row": [str, edr], "column": [stc, edc] },
- "restPart"
- );
-
- cf_new_range.concat(range);
- }
- else{
- cf_new_range.push(cf_range[j]);
+
+ if(!(str <= CFr1 && edr >= CFr2 && stc <= CFc1 && edc >= CFc2)){
+ cf_new_range = getMoveRange(type, str, edr, stc, edc, CFr1, CFr2, CFc1, CFc2, rlen, clen);
}
}
@@ -1978,18 +1982,8 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, order) {
bd_c1 = borderRange[j].column[0],
bd_c2 = borderRange[j].column[1];
- if(!(str > bd_r2 || edr < bd_r1) || !(stc > bd_c2 || edc < bd_c1)){
- let range = conditionformat.CFSplitRange(
- borderRange[j],
- { "row": [str, edr], "column": [stc, edc] },
- { "row": [str, edr], "column": [stc, edc] },
- "restPart"
- );
-
- emptyRange.concat(range);
- }
- else{
- emptyRange.push(borderRange[j]);
+ if(!(str <= bd_r1 && edr >= bd_r2 && stc <= bd_c1 && edc >= bd_c2)){
+ emptyRange = getMoveRange(type, str, edr, stc, edc, bd_r1, bd_r2, bd_c1, bd_c2, rlen, clen);
}
}
@@ -2095,6 +2089,315 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, order) {
}
}
+function getMoveRange(type, str, edr, stc, edc, r1, r2, c1, c2, rlen, clen) {
+ let newRange = [];
+
+ if(type == "moveLeft"){
+ if(str > r2 || edr < r1 || stc > c2){
+ newRange.push({
+ "row": [r1, r2],
+ "column": [c1, c2]
+ });
+ }
+ else if(edc < c1){
+ if(str <= r1 && edr >= r2){
+ newRange.push({
+ "row": [r1, r2],
+ "column": [c1 - clen, c2 - clen]
+ });
+ }
+ else if(str > r1 && edr < r2){
+ let range= [
+ { "row": [r1, str - 1], "column": [c1, c2] },
+ { "row": [edr + 1, r2], "column": [c1, c2] },
+ { "row": [str, edr], "column": [c1 - clen, c2 - clen] }
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(str > r1){
+ let range= [
+ { "row": [r1, str - 1], "column": [c1, c2] },
+ { "row": [str, r2], "column": [c1 - clen, c2 - clen] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(edr < r2){
+ let range= [
+ { "row": [r1, edr], "column": [c1 - clen, c2 - clen] },
+ { "row": [edr + 1, r2], "column": [c1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ }
+ else if(edc >= c1){
+ if(stc <= c1 && edc >= c2){
+ if(str > r1 && edr < r2){
+ let range= [
+ { "row": [r1, str - 1], "column": [c1, c2] },
+ { "row": [edr + 1, r2], "column": [c1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(str > r1){
+ let range= [
+ { "row": [r1, str - 1], "column": [c1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(edr < r2){
+ let range= [
+ { "row": [edr + 1, r2], "column": [c1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ }
+ else if(stc > c1 && edc < c2){
+ if(str <= r1 && edr >= r2){
+ newRange.push({
+ "row": [r1, r2],
+ "column": [c1, c2 - clen]
+ });
+ }
+ else if(str > r1 && edr < r2){
+ let range= [
+ { "row": [r1, str - 1], "column": [c1, c2] },
+ { "row": [edr + 1, r2], "column": [c1, c2] },
+ { "row": [str, edr], "column": [c1, c2 - clen] }
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(str > r1){
+ let range= [
+ { "row": [r1, str - 1], "column": [c1, c2] },
+ { "row": [str, r2], "column": [c1, c2 - clen] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(edr < r2){
+ let range= [
+ { "row": [r1, edr], "column": [c1, c2 - clen] },
+ { "row": [edr + 1, r2], "column": [c1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ }
+ else if(stc > c1){
+ if(str <= r1 && edr >= r2){
+ newRange.push({
+ "row": [r1, r2],
+ "column": [c1, stc - 1]
+ });
+ }
+ else if(str > r1 && edr < r2){
+ let range= [
+ { "row": [r1, str - 1], "column": [c1, c2] },
+ { "row": [edr + 1, r2], "column": [c1, c2] },
+ { "row": [str, edr], "column": [c1, stc - 1] }
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(str > r1){
+ let range= [
+ { "row": [r1, str - 1], "column": [c1, c2] },
+ { "row": [str, r2], "column": [c1, stc - 1] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(edr < r2){
+ let range= [
+ { "row": [r1, edr], "column": [c1, stc - 1] },
+ { "row": [edr + 1, r2], "column": [c1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ }
+ else if(edc < c2){
+ if(str <= r1 && edr >= r2){
+ newRange.push({
+ "row": [r1, r2],
+ "column": [c1 - clen, c2 - clen]
+ });
+ }
+ else if(str > r1 && edr < r2){
+ let range= [
+ { "row": [r1, str - 1], "column": [c1, c2] },
+ { "row": [edr + 1, r2], "column": [c1, c2] },
+ { "row": [str, edr], "column": [c1 - clen, c2 - clen] }
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(str > r1){
+ let range= [
+ { "row": [r1, str - 1], "column": [c1, c2] },
+ { "row": [str, r2], "column": [c1 - clen, c2 - clen] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(edr < r2){
+ let range= [
+ { "row": [r1, edr], "column": [c1 - clen, c2 - clen] },
+ { "row": [edr + 1, r2], "column": [c1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ }
+ }
+ }
+ else if(type == "moveUp"){
+ if(stc > c2 || edc < c1 || str > r2){
+ newRange.push({
+ "row": [r1, r2],
+ "column": [c1, c2]
+ });
+ }
+ else if(edr < r1){
+ if(stc <= c1 && edc >= c2){
+ newRange.push({
+ "row": [r1 - rlen, r2 - rlen],
+ "column": [c1, c2]
+ });
+ }
+ else if(stc > c1 && edc < c2){
+ let range= [
+ { "row": [r1, r2], "column": [c1, stc - 1] },
+ { "row": [r1, r2], "column": [edc + 1, c2] },
+ { "row": [r1 - rlen, r2 - rlen], "column": [stc, edc] }
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(stc > c1){
+ let range= [
+ { "row": [r1, r2], "column": [c1, stc - 1] },
+ { "row": [r1 - rlen, r2 - rlen], "column": [stc, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(edc < c2){
+ let range= [
+ { "row": [r1 - rlen, r2 - rlen], "column": [c1, edc] },
+ { "row": [r1, r2], "column": [edc + 1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ }
+ else if(edr >= r1){
+ if(str <= r1 && edr >= r2){
+ if(stc > c1 && edc < c2){
+ let range= [
+ { "row": [r1, r2], "column": [c1, stc - 1] },
+ { "row": [r1, r2], "column": [edc + 1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(stc > c1){
+ let range= [
+ { "row": [r1, r2], "column": [c1, stc - 1] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(edc < c2){
+ let range= [
+ { "row": [r1, r2], "column": [edc + 1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ }
+ else if(str > r1 && edr < r2){
+ if(stc <= c1 && edc >= c2){
+ newRange.push({
+ "row": [r1, r2 - rlen],
+ "column": [c1, c2]
+ });
+ }
+ else if(stc > c1 && edc < c2){
+ let range= [
+ { "row": [r1, r2], "column": [c1, stc - 1] },
+ { "row": [r1, r2], "column": [edc + 1, c2] },
+ { "row": [r1, r2 - rlen], "column": [stc, edc] }
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(stc > c1){
+ let range= [
+ { "row": [r1, r2], "column": [c1, stc - 1] },
+ { "row": [r1, r2 - rlen], "column": [stc, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(edc < c2){
+ let range= [
+ { "row": [r1, r2 - rlen], "column": [c1, edc] },
+ { "row": [r1, r2], "column": [edc + 1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ }
+ else if(str > r1){
+ if(stc <= c1 && edc >= c2){
+ newRange.push({
+ "row": [r1, str - 1],
+ "column": [c1, c2]
+ });
+ }
+ else if(stc > c1 && edc < c2){
+ let range= [
+ { "row": [r1, r2], "column": [c1, stc - 1] },
+ { "row": [r1, r2], "column": [edc + 1, c2] },
+ { "row": [r1, str - 1], "column": [stc, edc] }
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(stc > c1){
+ let range= [
+ { "row": [r1, r2], "column": [c1, stc - 1] },
+ { "row": [r1, str - 1], "column": [stc, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(edc < c2){
+ let range= [
+ { "row": [r1, str - 1], "column": [c1, edc] },
+ { "row": [r1, r2], "column": [edc + 1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ }
+ else if(edr < r2){
+ if(stc <= c1 && edc >= c2){
+ newRange.push({
+ "row": [r1 - rlen, r2 - rlen],
+ "column": [c1, c2]
+ });
+ }
+ else if(stc > c1 && edc < c2){
+ let range= [
+ { "row": [r1, r2], "column": [c1, stc - 1] },
+ { "row": [r1, r2], "column": [edc + 1, c2] },
+ { "row": [r1 - rlen, r2 - rlen], "column": [stc, edc] }
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(stc > c1){
+ let range= [
+ { "row": [r1, r2], "column": [c1, stc - 1] },
+ { "row": [r1 - rlen, r2 - rlen], "column": [stc, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ else if(edc < c2){
+ let range= [
+ { "row": [r1 - rlen, r2 - rlen], "column": [c1, edc] },
+ { "row": [r1, r2], "column": [edc + 1, c2] },
+ ];
+ newRange = newRange.concat(range);
+ }
+ }
+ }
+ }
+
+ return newRange;
+}
+
export {
luckysheetextendtable,
luckysheetextendData,
diff --git a/src/global/formula.js b/src/global/formula.js
index 5f3ce09..b8fe635 100644
--- a/src/global/formula.js
+++ b/src/global/formula.js
@@ -1220,11 +1220,12 @@ const luckysheetformula = {
let curv = Store.flowdata[r][c];
let isPrevInline = isInlineStringCell(curv);
- let isCurInline = (inputText.slice(0, 1) != "=" && inputHtml.indexOf("span")>-1);
+ let isCurInline = (inputText.slice(0, 1) != "=" && inputHtml.substr(0,5) == "-1
// $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);
- }
- else if(c.id=="luckysheet-functionbox-cell" || $(c).closest("#luckysheet-functionbox-cell")){
- if(value1.indexOf("span")>-1){
+ // let w = window.getSelection();
+ // if(w!=null && w.type!="None"){
+ // let range = w.getRangeAt(0);
+ // let c = range.startContainer;
- }
- else{
- $editer.html(value);
- }
- }
+ // if(c.id=="luckysheet-rich-text-editor" || $(c).closest("#luckysheet-rich-text-editor")){
+ // $functionbox.html(value);
+ // }
+ // else if(c.id=="luckysheet-functionbox-cell" || $(c).closest("#luckysheet-functionbox-cell")){
+ // if(value1.indexOf("span")>-1){
+
+ // }
+ // else{
+ // $editer.html(value);
+ // }
+ // }
+ // }
+ // console.trace();
+ // console.log(value, $copy.attr("id"));
+
+ if($copy.attr("id")=="luckysheet-rich-text-editor"){
+ if($copy.html().substr(0,5) == " 0 && startContainer.parentNode.tagName=="SPAN" && !range.collapsed) {
- let span = startContainer.parentNode;
- let styleList = convertCssToStyleList(span.style.cssText);
- foucsStatus = styleList[a];
- isInlineEdit = true;
- }
- }
+ // var w = window.getSelection(), isInlineEdit=false;
+ // if(w.type!="None"){
+ // var range = w.getRangeAt(0);
+ // let startContainer = range.startContainer;
+ // if (parseInt($("#luckysheet-input-box").css("top")) > 0 && startContainer.parentNode.tagName=="SPAN" && !range.collapsed) {
+ // let span = startContainer.parentNode;
+ // let styleList = convertCssToStyleList(span.style.cssText);
+ // foucsStatus = styleList[a];
+ // isInlineEdit = true;
+ // }
+ // }
+
+ // if(!isInlineEdit){
+ // if(isInlineStringCell(cell)){
+ // foucsStatus = cell.ct.s[0][a];
+ // }
+ // else{
+ // foucsStatus = foucsStatus[a];
+ // }
+ // }
- if(!isInlineEdit){
- if(isInlineStringCell(cell)){
- foucsStatus = cell.ct.s[0][a];
- }
- else{
- foucsStatus = foucsStatus[a];
- }
- }
+ foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";