' +
+ '
' +
'
' +
'
' +
'
' +
diff --git a/src/controllers/server.js b/src/controllers/server.js
index d66aea8..0f86499 100644
--- a/src/controllers/server.js
+++ b/src/controllers/server.js
@@ -8,13 +8,15 @@ import menuButton from './menuButton';
import { createFilterOptions } from './filter';
import luckysheetFreezen from './freezen';
import luckysheetPostil from './postil';
+import imageCtrl from './imageCtrl';
+import dataVerificationCtrl from './dataVerificationCtrl';
+import hyperlinkCtrl from './hyperlinkCtrl';
import { getObjType, replaceHtml, getByteLen } from '../utils/util';
import { getSheetIndex } from '../methods/get';
import Store from '../store';
import { collaborativeEditBox } from './select'
import locale from '../locale/locale';
import dayjs from "dayjs";
-import imageCtrl from './imageCtrl';
import json from '../global/json';
const server = {
@@ -169,7 +171,7 @@ const server = {
//客户端接收服务端数据时触发
_this.websocket.onmessage = function(result){
Store.result = result
- let data = eval('(' + result.data + ')');
+ let data = new Function("return " + result.data)();
console.info(data);
let type = data.type;
let {message,id} = data;
@@ -517,12 +519,31 @@ const server = {
}, 1);
}
}
+ else if(k == "images"){ //图片
+ if(index == Store.currentSheetIndex){
+ imageCtrl.images = value;
+ imageCtrl.allImagesShow();
+ imageCtrl.init();
+ }
+ }
+ else if(k == "dataVerification"){ //数据验证
+ if(index == Store.currentSheetIndex){
+ dataVerificationCtrl.dataVerification = value;
+ dataVerificationCtrl.init();
+ }
+ }
+ else if(k == "hyperlink"){ //链接
+ if(index == Store.currentSheetIndex){
+ hyperlinkCtrl.hyperlink = value;
+ hyperlinkCtrl.init();
+ }
+ }
}
else if(type == "fc"){ //函数链calc
let op = item.op, pos = item.pos;
if(getObjType(value) != "object"){
- value = eval('('+ value +')');
+ value = new Function("return " + value)();
}
let r = value.r, c = value.c;
@@ -995,7 +1016,7 @@ const server = {
// console.log("request");
if(_this.updateUrl != ""){
$.post(_this.updateUrl, { compress: iscommpress, gridKey: _this.gridKey, data: params }, function (data) {
- let re = eval('('+ data +')')
+ let re = new Function("return " + data)();
if(re.status){
$("#luckysheet_info_detail_update").html("最近存档时间:"+ dayjs().format("M-D H:m:s"));
$("#luckysheet_info_detail_save").html("同步成功");
@@ -1055,7 +1076,7 @@ const server = {
if(_this.updateImageUrl != ""){
// $.post(_this.updateImageUrl, { compress: true, gridKey: _this.gridKey, data:data1 }, function (data) {
$.post(_this.updateImageUrl, { compress: false, gridKey: _this.gridKey, data:data1 }, function (data) {
- let re = eval('('+ data +')')
+ let re = new Function("return " + data)();
if(re.status){
imageRequestLast = dayjs();
}
diff --git a/src/controllers/sheetBar.js b/src/controllers/sheetBar.js
index 231b1e9..10673a8 100644
--- a/src/controllers/sheetBar.js
+++ b/src/controllers/sheetBar.js
@@ -20,7 +20,7 @@ import luckysheetConfigsetting from './luckysheetConfigsetting';
//表格底部名称栏区域 相关事件(增、删、改、隐藏显示、颜色等等)
-let isInitialSheetConfig = false, luckysheetcurrentSheetitem = null, jfdbclicklagTimeout = null;
+let isInitialSheetConfig = false, luckysheetcurrentSheetitem = null, jfdbclicklagTimeout = null,oldSheetFileName = "";;
function showsheetconfigmenu() {
if (!isInitialSheetConfig) {
isInitialSheetConfig = true;
@@ -225,10 +225,55 @@ export function initialSheetBar(){
luckysheetsheetnameeditor($(this));
});
+ let compositionFlag = true;
+ $("#luckysheet-sheet-area").on("compositionstart", "span.luckysheet-sheets-item-name", ()=> compositionFlag = false);
+ $("#luckysheet-sheet-area").on("compositionend", "span.luckysheet-sheets-item-name", ()=> compositionFlag = true);
+ $("#luckysheet-sheet-area").on("input", "span.luckysheet-sheets-item-name", function () {
+ if(Store.allowEdit===false){
+ return;
+ }
+
+ if(Store.limitSheetNameLength === false){
+ return
+ }
+
+ let maxLength = Store.defaultSheetNameMaxLength;
+ if(maxLength === 0){
+ return
+ }
+
+ setTimeout( ()=> {
+ if (compositionFlag) {
+
+ if ($(this).text().length >= maxLength) { /* 检查:值是否越界 */
+ setTimeout(() => {
+ $(this).text($(this).text().substring(0, maxLength));
+
+ let range = window.getSelection();
+ range.selectAllChildren(this);
+ range.collapseToEnd();
+ }, 0);
+ }
+ }
+ }, 0);
+ });
+
$("#luckysheet-sheet-area").on("blur", "span.luckysheet-sheets-item-name", function (e) {
if(Store.allowEdit===false){
return;
}
+
+ if(0 === $(this).text().length){
+
+ alert(locale_sheetconfig.sheetNamecannotIsEmptyError);
+ setTimeout(()=>{
+ $(this).text(oldSheetFileName);
+ luckysheetsheetnameeditor($(this));
+ $(this).focus();
+ }, 1);
+ return;
+ }
+
let $t = $(this);
let txt = $t.text(), oldtxt = $t.data("oldtxt");
var reg1 = new RegExp("[\\[\\]:\\?*\/'\"]");
@@ -279,6 +324,7 @@ export function initialSheetBar(){
let $t = $(this);
if (kcode == keycode.ENTER) {
let index = getSheetIndex(Store.currentSheetIndex);
+ oldSheetFileName = Store.luckysheetfile[index].name || oldSheetFileName;
Store.luckysheetfile[index].name = $t.text();
$t.attr("contenteditable", "false");
}
diff --git a/src/core.js b/src/core.js
index ebfa392..9ec44a4 100644
--- a/src/core.js
+++ b/src/core.js
@@ -74,6 +74,8 @@ luckysheet.create = function (setting) {
Store.fullscreenmode = extendsetting.fullscreenmode;
Store.lang = extendsetting.lang; //language
Store.allowEdit = extendsetting.allowEdit;
+ Store.limitSheetNameLength = extendsetting.limitSheetNameLength;
+ Store.defaultSheetNameMaxLength = extendsetting.defaultSheetNameMaxLength;
Store.fontList = extendsetting.fontList;
server.gridKey = extendsetting.gridKey;
server.loadUrl = extendsetting.loadUrl;
diff --git a/src/css/luckysheet-core.css b/src/css/luckysheet-core.css
index 7877f3e..5c7ad45 100644
--- a/src/css/luckysheet-core.css
+++ b/src/css/luckysheet-core.css
@@ -2329,8 +2329,14 @@ body:not(.ewa-ipad) .luckysheet-rows-h-cell-sel:hover {
padding-right: 10px;
padding-left: 12px;
}
-
-
+#luckysheet-sheet-list .luckysheet-cols-menuitem .luckysheet-cols-menuitem-content {
+ padding-right: 0px;
+ max-width: 430px;
+ min-width: 100px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
.luckysheet-filter-menu div.luckysheet-cols-menuitem {
padding-top: 0px;
padding-bottom: 0px;
@@ -2978,6 +2984,14 @@ fieldset[disabled] .btn-danger.focus {
#luckysheet-sheet-list .luckysheet-cols-menuitem .luckysheet-cols-menuitem-content {
padding-left: 5px;
}
+/*
+#luckysheet-sheet-list .luckysheet-cols-menuitem .luckysheet-cols-menuitem-content {
+ max-width: 420px;
+ min-width: 190px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+} */
#luckysheet-sheet-list .icon {
diff --git a/src/global/api.js b/src/global/api.js
index cb3728b..36a4901 100644
--- a/src/global/api.js
+++ b/src/global/api.js
@@ -113,7 +113,10 @@ export function setCellValue(row, column, value, options = {}) {
return tooltip.info("The order parameter is invalid.", "");
}
- let data = $.extend(true, [], file.data);
+ let data = file.data;
+ if(isRefresh) {
+ data = $.extend(true, [], file.data);
+ }
if(data.length == 0){
data = sheetmanage.buildGridData(file);
}
@@ -147,6 +150,10 @@ export function setCellValue(row, column, value, options = {}) {
}
else if(value instanceof Object){
let curv = {};
+ let cell = data[row][column];
+ if(isRealNull(cell)){
+ cell = {};
+ }
if(value.f!=null && value.v==null){
curv.f = value.f;
if(value.ct!=null){
@@ -164,6 +171,9 @@ export function setCellValue(row, column, value, options = {}) {
if(value.v!=null){
curv.v = value.v;
}
+ else {
+ curv.v = cell.v;
+ }
if(value.m!=null){
curv.m = value.m;
}
@@ -175,7 +185,11 @@ export function setCellValue(row, column, value, options = {}) {
if(attr in formatList){
menuButton.updateFormatCell(data, attr, v, row, row, column, column);//change range format
}
+ else {
+ cell[attr] = v;
+ }
}
+ data[row][column] = cell;
}
else{
if(value.toString().substr(0,1)=="=" || value.toString().substr(0,5)=="
cellWidth){
- // let strArr = []; //文本截断数组
- // strArr = getCellTextSplitArr(value, strArr, cellWidth, canvas);
-
- // computeRowlen = (oneLineTextHeight+word_space_height) * strArr.length + spaceHeight;
- // }
- // else{
- // computeRowlen = oneLineTextHeight + spaceHeight;
- // }
- // }
- // else if(cell.tr != null){
- // //单元格有旋转标示
- // let tr = cell.tr;
-
- // if(tr == "0"){
- // //无旋转
- // computeRowlen = oneLineTextHeight + spaceHeight;
- // }
- // else if(tr == "1" || tr == "2"){
- // //向下倾斜(45 旋转)----向上倾斜(-45 旋转)
- // computeRowlen = 0.707 * (textMetrics + oneLineTextHeight) + spaceHeight;
- // }
- // else if(tr == "3"){
- // //竖排文字
- // computeRowlen = value.length * oneLineTextHeight + spaceHeight;
- // }
- // else if(tr == "4" || tr == "5"){
- // //向下90(90 旋转)----向上90(-90 旋转)
- // computeRowlen = textMetrics + spaceHeight;
- // }
-
- // computeRowlen = Math.round(computeRowlen);
- // }
- // else{
- // computeRowlen = oneLineTextHeight + spaceHeight;
- // }
-
//比较计算高度和当前高度取最大高度
if(computeRowlen > currentRowLen){
currentRowLen = computeRowlen;
@@ -118,7 +63,7 @@ function rowlenByRange(d, r1, r2, cfg) {
}
currentRowLen = currentRowLen/Store.zoomRatio;
- console.log(currentRowLen);
+
if(currentRowLen != Store.defaultrowlen){
cfg_clone["rowlen"][r] = currentRowLen;
}
diff --git a/src/locale/en.js b/src/locale/en.js
index f5db3f9..1af6071 100644
--- a/src/locale/en.js
+++ b/src/locale/en.js
@@ -9528,6 +9528,7 @@ export default {
noHide:"Can't hide, at least keep one sheet tag",
chartEditNoOpt:"This operation is not allowed in chart editing mode!",
sheetNameSpecCharError:"The name cannot contain:[ ] : \ ? * / ' \"",
+ sheetNamecannotIsEmptyError:"Sheet name cannot be empty"
},
conditionformat: {
conditionformat_greaterThan: 'Conditionformat-GreaterThan',
diff --git a/src/locale/es.js b/src/locale/es.js
index 78c7d07..a7cd0fa 100644
--- a/src/locale/es.js
+++ b/src/locale/es.js
@@ -9526,6 +9526,7 @@ export default {
noHide:"No se puede ocultar, al menos conserva una etiqueta de hoja",
chartEditNoOpt:"¡Esta operación no está permitida en el modo de edición de gráficos!",
sheetNameSpecCharError:"El nombre no puede contener:[ ] : \ ? * / ' \"",
+ sheetNamecannotIsEmptyError:"El nombre de la hoja no puede estar vacío"
},
conditionformat: {
conditionformat_greaterThan: 'Conditionformat-GreaterThan',
diff --git a/src/locale/zh.js b/src/locale/zh.js
index 0e85c01..ba3d4b7 100644
--- a/src/locale/zh.js
+++ b/src/locale/zh.js
@@ -9770,6 +9770,7 @@ export default {
noHide:"不能隐藏, 至少保留一个sheet标签",
chartEditNoOpt:"图表编辑模式下不允许该操作!",
sheetNameSpecCharError:"名称不能包含:[ ] : \ ? * / ' \"",
+ sheetNamecannotIsEmptyError:"名称不能为空"
},
conditionformat: {
conditionformat_greaterThan: '条件格式——大于',