Browse Source

style(icon): icon

menu button
master
lrz 5 years ago
parent
commit
07d2aba864
  1. 33
      src/controllers/constant.js
  2. 121
      src/controllers/controlHistory.js
  3. 1438
      src/controllers/dataVerificationCtrl.js
  4. 28
      src/controllers/dropCell.js
  5. 17
      src/controllers/filter.js
  6. 8
      src/controllers/formulaBar.js
  7. 277
      src/controllers/freezen.js
  8. 296
      src/controllers/handler.js
  9. 494
      src/controllers/inlineString.js
  10. 2
      src/controllers/insertFormula.js
  11. 9
      src/controllers/keyboard.js
  12. 563
      src/controllers/menuButton.js
  13. 11
      src/controllers/orderBy.js
  14. 2
      src/controllers/pivotTable.js
  15. 9
      src/controllers/postil.js
  16. 2
      src/controllers/resize.js
  17. 66
      src/controllers/rowColumnOperation.js
  18. 10
      src/controllers/searchReplace.js
  19. 19
      src/controllers/select.js
  20. 278
      src/controllers/selection.js
  21. 13
      src/controllers/server.js
  22. 13
      src/controllers/sheetBar.js
  23. 38
      src/controllers/sheetmanage.js
  24. 19
      src/controllers/updateCell.js
  25. 175
      src/css/luckysheet-core.css
  26. 2
      src/function/functionImplementation.js
  27. 724
      src/global/api.js
  28. 72
      src/global/cursorPos.js
  29. 153
      src/global/draw.js
  30. 2
      src/global/editor.js
  31. 169
      src/global/extend.js
  32. 359
      src/global/formula.js
  33. 771
      src/global/getRowlen.js
  34. 307
      src/global/getdata.js
  35. 109
      src/global/refresh.js
  36. 22
      src/global/sort.js
  37. 41
      src/index.html
  38. 52
      src/locale/en.js
  39. 51
      src/locale/zh.js
  40. 2
      src/store/index.js

33
src/controllers/constant.js

@ -181,6 +181,9 @@ const gridHTML = function(){
</div>
<div class="img-list"></div>
</div>
<div id="luckysheet-dataVerification-dropdown-btn"></div>
<div id="luckysheet-dataVerification-dropdown-List" class="luckysheet-mousedown-cancel"></div>
<div id="luckysheet-dataVerification-showHintBox" class="luckysheet-mousedown-cancel"></div>
<div class="luckysheet-cell-copy"></div>
<div class="luckysheet-grdblkflowpush"></div> \${flow}
</div>
@ -243,7 +246,9 @@ const columeHeader_word = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'
//右键菜单dom
function rightclickHTML(){
const rightclick = locale().rightclick;
const _locale = locale();
const rightclick = _locale.rightclick;
const toolbar = _locale.toolbar;
return `<div id="luckysheet-rightclick-menu" class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-mousedown-cancel">
<div id="luckysheet-copy-btn" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel luckysheet-copy-btn" data-clipboard-action="copy" data-clipboard-target="#luckysheet-copy-content">
@ -346,6 +351,12 @@ function rightclickHTML(){
<div id="luckysheetdatavisual" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${rightclick.chartGeneration}</div>
</div>
<div id="luckysheetInsertImage" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${toolbar.insertImage}</div>
</div>
<div id="luckysheetDataVerification" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${toolbar.dataVerification}</div>
</div>
</div>
</div>
<div id="luckysheetcopyfor_sub" class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-rightgclick-menu-sub luckysheet-mousedown-cancel">
@ -1331,6 +1342,24 @@ function menuToolBar (){
</div>
</div>
<div class="luckysheet-toolbar-button-split-left luckysheet-toolbar-button luckysheet-inline-block"
data-tips="${toolbar.dataVerification}" id="luckysheet-dataVerification-btn-title" role="button" style="user-select: none;">
<div class="luckysheet-toolbar-button-outer-box luckysheet-inline-block"
style="user-select: none;">
<div class="luckysheet-toolbar-menu-button-inner-box luckysheet-inline-block"
style="user-select: none;">
<div class="luckysheet-toolbar-menu-button-caption luckysheet-inline-block"
style="user-select: none;">
<div class="luckysheet-icon luckysheet-inline-block " style="user-select: none;">
<div aria-hidden="true" class="luckysheet-icon-img-container luckysheet-icon-img luckysheet-icon-rotation-none iconfont icon-shujuyanzheng"
style="user-select: none;">
<input id="luckysheet-imgUpload" type="file" accept="image/*" style="display:none;"></input>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="luckysheet-toolbar-button-split-left luckysheet-toolbar-button luckysheet-inline-block"
data-tips="${toolbar.splitColumn}" id="luckysheet-splitColumn-btn-title" role="button" style="user-select: none;">
<div class="luckysheet-toolbar-button-outer-box luckysheet-inline-block"
style="user-select: none;">
@ -1384,7 +1413,7 @@ function menuToolBar (){
</div>
</div>
</div>
`;
`;
}
const luckysheetlodingHTML = function(){

121
src/controllers/controlHistory.js

@ -4,6 +4,7 @@ import pivotTable from './pivotTable';
import conditionformat from './conditionformat';
import luckysheetPostil from './postil';
import imageCtrl from './imageCtrl';
import dataVerificationCtrl from './dataVerificationCtrl';
import {zoomRefreshView,zoomNumberDomBind} from './zoom';
import { createFilter, createFilterOptions, labelFilterOptionState } from './filter';
import formula from '../global/formula';
@ -58,7 +59,15 @@ const controlHistory = {
}
formula.execFunctionGroup(null, null, null, null, ctr.data);//取之前的数据
jfrefreshgrid(ctr.data, ctr.range, ctr.config, ctr.cdformat, ctr.RowlChange);
let allParam = {
"cfg": ctr.config,
"RowlChange": ctr.RowlChange,
"cdformat": ctr.cdformat,
"dataVerification": ctr.dataVerification,
"dynamicArray": ctr.dynamicArray
}
jfrefreshgrid(ctr.data, ctr.range, allParam);
}
else if (ctr.type == "pasteCut") {
let s = {
@ -69,6 +78,8 @@ const controlHistory = {
"curConfig": ctr.source["config"],
"cdformat": ctr.source["curCdformat"],
"curCdformat": ctr.source["cdformat"],
"dataVerification": ctr.source["curDataVerification"],
"curDataVerification": ctr.source["dataVerification"],
"range": ctr.source["range"]
}
let t = {
@ -79,6 +90,8 @@ const controlHistory = {
"curConfig": ctr.target["config"],
"cdformat": ctr.target["curCdformat"],
"curCdformat": ctr.target["cdformat"],
"dataVerification": ctr.target["curDataVerification"],
"curDataVerification": ctr.target["dataVerification"],
"range": ctr.target["range"]
}
jfrefreshgrid_pastcut(s, t, ctr.RowlChange);
@ -139,17 +152,47 @@ const controlHistory = {
ctrlValue.index = ctrlValue.index + 1;
}
jfrefreshgrid_adRC(ctr.data, ctr.config, "delRC", ctrlValue, ctr.calc, ctr.filterObj, ctr.cf, ctr.af, ctr.freezen);
jfrefreshgrid_adRC(
ctr.data,
ctr.config,
"delRC",
ctrlValue,
ctr.calc,
ctr.filterObj,
ctr.cf,
ctr.af,
ctr.freezen,
ctr.dataVerification
);
}
else if (ctr.type == "delRC") { //删除行列撤销操作
let ctrlValue = $.extend(true, {}, ctr.ctrlValue);
ctrlValue.restore = true;
ctrlValue.direction = "lefttop";
jfrefreshgrid_adRC(ctr.data, ctr.config, "addRC", ctrlValue, ctr.calc, ctr.filterObj, ctr.cf, ctr.af, ctr.freezen);
jfrefreshgrid_adRC(
ctr.data,
ctr.config,
"addRC",
ctrlValue,
ctr.calc,
ctr.filterObj,
ctr.cf,
ctr.af,
ctr.freezen,
ctr.dataVerification
);
}
else if (ctr.type == "deleteCell") { //删除单元格撤销操作
jfrefreshgrid_deleteCell(ctr.data, ctr.config, ctr.ctrl, ctr.calc, ctr.filterObj, ctr.cf);
jfrefreshgrid_deleteCell(
ctr.data,
ctr.config,
ctr.ctrl,
ctr.calc,
ctr.filterObj,
ctr.cf,
ctr.dataVerification
);
}
else if (ctr.type == "showHidRows") { // 隐藏、显示行 撤销操作
//config
@ -285,7 +328,17 @@ const controlHistory = {
server.saveParam("all", ctr.sheetIndex, ctr.oldcolor, { "k": "color" });
}
else if (ctr.type == "mergeChange") {
jfrefreshgrid(ctr.data, ctr.range, ctr.config);
let allParam = {
"cfg": ctr.config,
}
jfrefreshgrid(ctr.data, ctr.range, allParam);
}
else if (ctr.type == "updateDataVerification"){
dataVerificationCtrl.ref(ctr.currentDataVerification, ctr.historyDataVerification, ctr.sheetIndex);
}
else if (ctr.type == "updateDataVerificationOfCheckbox"){
dataVerificationCtrl.refOfCheckbox(ctr.currentDataVerification, ctr.historyDataVerification, ctr.sheetIndex, ctr.data, ctr.range);
}
else if (ctr.type == "updateCF"){
let historyRules = ctr["data"]["historyRules"];
@ -375,7 +428,15 @@ const controlHistory = {
if (ctr.type == "datachange") {
formula.execFunctionGroup();
jfrefreshgrid(ctr.curdata, ctr.range, ctr.curConfig, ctr.curCdformat, ctr.RowlChange);
let allParam = {
"cfg": ctr.curConfig,
"RowlChange": ctr.RowlChange,
"cdformat": ctr.curCdformat,
"dataVerification": ctr.curDataVerification,
"dynamicArray": ctr.curDynamicArray
}
jfrefreshgrid(ctr.curdata, ctr.range, allParam);
}
else if (ctr.type == "pasteCut") {
jfrefreshgrid_pastcut(ctr.source, ctr.target, ctr.RowlChange);
@ -415,13 +476,43 @@ const controlHistory = {
jfrefreshgridall(ctr.curdata[0].length, ctr.curdata.length, ctr.curdata, ctr.curconfig, ctr.currange, ctr.ctrlType, ctr.ctrlValue);
}
else if (ctr.type == "addRC") { //增加行列重做操作
jfrefreshgrid_adRC(ctr.curData, ctr.curConfig, "addRC", ctr.ctrlValue, ctr.curCalc, ctr.curFilterObj, ctr.curCf, ctr.curAf, ctr.curFreezen);
jfrefreshgrid_adRC(
ctr.curData,
ctr.curConfig,
"addRC",
ctr.ctrlValue,
ctr.curCalc,
ctr.curFilterObj,
ctr.curCf,
ctr.curAf,
ctr.curFreezen,
ctr.curDataVerification
);
}
else if (ctr.type == "delRC") { //删除行列重做操作
jfrefreshgrid_adRC(ctr.curData, ctr.curConfig, "delRC", ctr.ctrlValue, ctr.curCalc, ctr.curFilterObj, ctr.curCf, ctr.curAf, ctr.curFreezen);
jfrefreshgrid_adRC(
ctr.curData,
ctr.curConfig,
"delRC",
ctr.ctrlValue,
ctr.curCalc,
ctr.curFilterObj,
ctr.curCf,
ctr.curAf,
ctr.curFreezen,
ctr.curDataVerification
);
}
else if (ctr.type == "deleteCell") { //删除单元格重做操作
jfrefreshgrid_deleteCell(ctr.curData, ctr.curConfig, ctr.ctrl, ctr.curCalc, ctr.curFilterObj, ctr.curCf);
jfrefreshgrid_deleteCell(
ctr.curData,
ctr.curConfig,
ctr.ctrl,
ctr.curCalc,
ctr.curFilterObj,
ctr.curCf,
ctr.curDataVerification
);
}
else if (ctr.type == "showHidRows") { // 隐藏、显示行 重做操作
//config
@ -540,7 +631,17 @@ const controlHistory = {
server.saveParam("all", ctr.sheetIndex, ctr.color, { "k": "color" });
}
else if (ctr.type == "mergeChange") {
jfrefreshgrid(ctr.curData, ctr.range, ctr.curConfig);
let allParam = {
"cfg": ctr.curConfig,
}
jfrefreshgrid(ctr.curData, ctr.range, allParam);
}
else if (ctr.type == "updateDataVerification"){
dataVerificationCtrl.ref(ctr.historyDataVerification, ctr.currentDataVerification, ctr.sheetIndex);
}
else if (ctr.type == "updateDataVerificationOfCheckbox"){
dataVerificationCtrl.refOfCheckbox(ctr.historyDataVerification, ctr.currentDataVerification, ctr.sheetIndex, ctr.curData, ctr.range);
}
else if (ctr.type == "updateCF"){
let currentRules = ctr["data"]["currentRules"];

1438
src/controllers/dataVerificationCtrl.js

File diff suppressed because it is too large

28
src/controllers/dropCell.js

@ -450,6 +450,7 @@ const luckysheetDropCell = {
let cfg = $.extend(true, {}, Store.config);
let borderInfoCompute = getBorderInfoCompute();
let dataVerification = $.extend(true, {}, file["dataVerification"]);
let direction = _this.direction;
let type = _this.applyType;
@ -563,6 +564,11 @@ const luckysheetDropCell = {
cfg["borderInfo"].push(bd_obj);
}
//数据验证
if(dataVerification[bd_r + "_" + bd_c]){
dataVerification[j + "_" + i] = dataVerification[bd_r + "_" + bd_c];
}
}
}
if(direction == "up"){
@ -647,6 +653,11 @@ const luckysheetDropCell = {
cfg["borderInfo"].push(bd_obj);
}
//数据验证
if(dataVerification[bd_r + "_" + bd_c]){
dataVerification[j + "_" + i] = dataVerification[bd_r + "_" + bd_c];
}
}
}
}
@ -741,6 +752,11 @@ const luckysheetDropCell = {
cfg["borderInfo"].push(bd_obj);
}
//数据验证
if(dataVerification[bd_r + "_" + bd_c]){
dataVerification[i + "_" + j] = dataVerification[bd_r + "_" + bd_c];
}
}
}
if(direction == "left"){
@ -825,6 +841,11 @@ const luckysheetDropCell = {
cfg["borderInfo"].push(bd_obj);
}
//数据验证
if(dataVerification[bd_r + "_" + bd_c]){
dataVerification[i + "_" + j] = dataVerification[bd_r + "_" + bd_c];
}
}
}
}
@ -852,7 +873,12 @@ const luckysheetDropCell = {
}
//刷新一次表格
jfrefreshgrid(d, Store.luckysheet_select_save, cfg, cdformat);
let allParam = {
"cfg": cfg,
"cdformat": cdformat,
"dataVerification": dataVerification
}
jfrefreshgrid(d, Store.luckysheet_select_save, allParam);
selectHightlightShow();
},

17
src/controllers/filter.js

@ -120,15 +120,18 @@ function orderbydatafiler(str, stc, edr, edc, index, asc) {
}
}
let allParam = {};
if(Store.config["rowlen"] != null){
let cfg = $.extend(true, {}, Store.config);
cfg = rowlenByRange(d, str, edr, cfg);
jfrefreshgrid(d, [{ "row": [str, edr], "column": [stc, edc] }], cfg, null, true);
}
else{
jfrefreshgrid(d, [{ "row": [str, edr], "column": [stc, edc] }]);
allParam = {
"cfg": cfg,
"RowlChange": true
}
}
jfrefreshgrid(d, [{ "row": [str, edr], "column": [stc, edc] }], allParam);
}
//创建筛选按钮
@ -1250,9 +1253,6 @@ function initialFilterHandler(){
$("#luckysheet-filter-menu .luckysheet-filter-selected-input").hide().find("input").val();
$("#luckysheet-filter-selected span").data("type", "0").data("type", null).text(locale_filter.conditionNone);
$('#luckysheet-filter-selected-sheet' + Store.currentSheetIndex + ', #luckysheet-filter-options-sheet' + Store.currentSheetIndex).remove();
$("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide();
let redo = {};
redo["type"] = "datachangeAll_filter_clear";
redo["sheetIndex"] = Store.currentSheetIndex;
@ -1287,6 +1287,9 @@ function initialFilterHandler(){
Store.jfundo = [];
Store.jfredo.push(redo);
$('#luckysheet-filter-selected-sheet' + Store.currentSheetIndex + ', #luckysheet-filter-options-sheet' + Store.currentSheetIndex).remove();
$("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide();
//清除筛选发送给后台
Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].filter = null;
Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].filter_select = null;

8
src/controllers/formulaBar.js

@ -33,10 +33,10 @@ export function formulaBarInitial(){
let row_index = last["row_focus"], col_index = last["column_focus"];
let $input = $("#luckysheet-rich-text-editor"),value = $input.text();
if(value) {
formula.updatecell(row_index, col_index);
}
// let $input = $("#luckysheet-rich-text-editor"),value = $input.text();
// if(value) {
// formula.updatecell(row_index, col_index);
// }
luckysheetupdateCell(row_index, col_index, Store.flowdata, null, true);
formula.rangeResizeTo = $("#luckysheet-functionbox-cell");
}

277
src/controllers/freezen.js

@ -1624,186 +1624,183 @@ const luckysheetFreezen = {
Store.luckysheetfile[order]["frozen"] = frozen[operate];
},
frozenTofreezen: function() {
// get frozen type
const frozen = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["frozen"];
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
const frozen = file["frozen"];
if(frozen == null){
return;
}
let freezen = null;
// transform to freezen
if(frozen.type === 'row'){
let scrollTop = $("#luckysheet-cell-main").scrollTop();
let row_st = luckysheet_searcharray(Store.visibledatarow, scrollTop);
if(row_st == -1){
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
freezen = {
horizontal:{
freezenhorizontaldata: freezenhorizontaldata,
top: top
}
}
}
else if(frozen.type === 'column'){
let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);
if(col_st == -1){
col_st = 0;
}
let left = Store.visibledatacolumn[col_st] - 2 - scrollLeft + Store.rowHeaderWidth;
let freezenverticaldata = [Store.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_st + 1), left];
if(file["freezen"] == null){
let freezen = null;
freezen = {
vertical:{
freezenverticaldata: freezenverticaldata,
left: left
// transform to freezen
if(frozen.type === 'row'){
let scrollTop = 0;
let row_st = luckysheet_searcharray(Store.visibledatarow, scrollTop);
if(row_st == -1){
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
freezen = {
horizontal:{
freezenhorizontaldata: freezenhorizontaldata,
top: top
}
}
}
}
else if(frozen.type === 'both'){
let scrollTop = $("#luckysheet-cell-main").scrollTop();
let row_st = luckysheet_searcharray(Store.visibledatarow, scrollTop);
if(row_st == -1){
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
freezen = {
}
let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);
if(col_st == -1){
col_st = 0;
}
let left = Store.visibledatacolumn[col_st] - 2 - scrollLeft + Store.rowHeaderWidth;
let freezenverticaldata = [Store.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_st + 1), left];
freezen = {
horizontal:{
freezenhorizontaldata: freezenhorizontaldata,
top: top
},
vertical:{
freezenverticaldata: freezenverticaldata,
left: left
else if(frozen.type === 'column'){
let scrollLeft = 0;
let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);
if(col_st == -1){
col_st = 0;
}
let left = Store.visibledatacolumn[col_st] - 2 - scrollLeft + Store.rowHeaderWidth;
let freezenverticaldata = [Store.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_st + 1), left];
freezen = {
vertical:{
freezenverticaldata: freezenverticaldata,
left: left
}
}
}
else if(frozen.type === 'both'){
let scrollTop = 0;
let row_st = luckysheet_searcharray(Store.visibledatarow, scrollTop);
if(row_st == -1){
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
let scrollLeft = 0;
let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);
if(col_st == -1){
col_st = 0;
}
let left = Store.visibledatacolumn[col_st] - 2 - scrollLeft + Store.rowHeaderWidth;
let freezenverticaldata = [Store.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_st + 1), left];
freezen = {
horizontal:{
freezenhorizontaldata: freezenhorizontaldata,
top: top
},
vertical:{
freezenverticaldata: freezenverticaldata,
left: left
}
}
}
else if(frozen.type === 'rangeRow'){
let scrollTop = $("#luckysheet-cell-main").scrollTop();
let row_st = luckysheet_searcharray(Store.visibledatarow, scrollTop);
let row_focus = frozen.range["row_focus"];
if(row_focus > row_st){
row_st = row_focus;
}
if(row_st == -1){
row_st = 0;
}
else if(frozen.type === 'rangeRow'){
let scrollTop = 0;
let row_st = luckysheet_searcharray(Store.visibledatarow, scrollTop);
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
let row_focus = frozen.range["row_focus"];
freezen = {
horizontal:{
freezenhorizontaldata: freezenhorizontaldata,
top: top
if(row_focus > row_st){
row_st = row_focus;
}
if(row_st == -1){
row_st = 0;
}
}
}
else if(frozen.type === 'rangeColumn'){
let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
let column_focus = frozen.range["column_focus"];
freezen = {
horizontal:{
freezenhorizontaldata: freezenhorizontaldata,
top: top
}
}
if(column_focus > col_st){
col_st = column_focus;
}
else if(frozen.type === 'rangeColumn'){
let scrollLeft = 0;
let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);
if(col_st == -1){
col_st = 0;
}
let column_focus = frozen.range["column_focus"];
let left = Store.visibledatacolumn[col_st] - 2 - scrollLeft + Store.rowHeaderWidth;
let freezenverticaldata = [Store.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_st + 1), left];
if(column_focus > col_st){
col_st = column_focus;
}
freezen = {
vertical:{
freezenverticaldata: freezenverticaldata,
left: left
if(col_st == -1){
col_st = 0;
}
}
}
else if(frozen.type === 'rangeBoth'){
let scrollTop = $("#luckysheet-cell-main").scrollTop();
let row_st = luckysheet_searcharray(Store.visibledatarow, scrollTop);
let left = Store.visibledatacolumn[col_st] - 2 - scrollLeft + Store.rowHeaderWidth;
let freezenverticaldata = [Store.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_st + 1), left];
let row_focus = frozen.range["row_focus"];
freezen = {
vertical:{
freezenverticaldata: freezenverticaldata,
left: left
}
}
if(row_focus > row_st){
row_st = row_focus;
}
if(row_st == -1){
row_st = 0;
}
else if(frozen.type === 'rangeBoth'){
let scrollTop = 0;
let row_st = luckysheet_searcharray(Store.visibledatarow, scrollTop);
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
let row_focus = frozen.range["row_focus"];
let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);
if(row_focus > row_st){
row_st = row_focus;
}
if(row_st == -1){
row_st = 0;
}
let column_focus = frozen.range["column_focus"];
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
if(column_focus > col_st){
col_st = column_focus;
}
let scrollLeft = 0;
let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);
if(col_st == -1){
col_st = 0;
}
let column_focus = frozen.range["column_focus"];
if(column_focus > col_st){
col_st = column_focus;
}
let left = Store.visibledatacolumn[col_st] - 2 - scrollLeft + Store.rowHeaderWidth;
let freezenverticaldata = [Store.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_st + 1), left];
if(col_st == -1){
col_st = 0;
}
let left = Store.visibledatacolumn[col_st] - 2 - scrollLeft + Store.rowHeaderWidth;
let freezenverticaldata = [Store.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_st + 1), left];
freezen = {
horizontal:{
freezenhorizontaldata: freezenhorizontaldata,
top: top
},
vertical:{
freezenverticaldata: freezenverticaldata,
left: left
freezen = {
horizontal:{
freezenhorizontaldata: freezenhorizontaldata,
top: top
},
vertical:{
freezenverticaldata: freezenverticaldata,
left: left
}
}
}
}
else if(frozen.type === 'cancel'){
freezen = {
horizontal: null,
vertical: null
else if(frozen.type === 'cancel'){
freezen = {
horizontal: null,
vertical: null
}
}
}
Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["freezen"] = freezen;
file["freezen"] = freezen;
}
}
}

296
src/controllers/handler.js

@ -5,6 +5,7 @@ import pivotTable from './pivotTable';
import luckysheetDropCell from './dropCell';
import luckysheetPostil from './postil';
import imageCtrl from './imageCtrl';
import dataVerificationCtrl from './dataVerificationCtrl';
import menuButton from './menuButton';
import conditionformat from './conditionformat';
import alternateformat from './alternateformat';
@ -21,6 +22,7 @@ import { selectHightlightShow, selectIsOverlap, selectionCopyShow, luckysheet_co
import selection from './selection';
import controlHistory from './controlHistory';
import splitColumn from './splitColumn';
import {hideMenuByCancel} from '../global/cursorPos';
import { luckysheetdefaultstyle } from './constant';
import {
@ -231,8 +233,16 @@ export default function luckysheetHandler() {
}
});
$("#luckysheet-rich-text-editor").mouseup(function(e){
menuButton.inputMenuButtonFocus(e.target);
});
//表格mousedown
$("#luckysheet-cell-main, #luckysheetTableContent").mousedown(function (event) {
if($(event.target).hasClass('luckysheet-mousedown-cancel')){
return;
}
$("#luckysheet-cell-selected").find(".luckysheet-cs-fillhandle")
.css("cursor","default")
.end()
@ -289,6 +299,9 @@ export default function luckysheetHandler() {
col_index_ed = margeset.column[3];
}
//数据验证 单元格聚焦
dataVerificationCtrl.cellFocus(row_index, col_index, true);
//若点击单元格部分不在视图内
if (col_pre < $("#luckysheet-cell-main").scrollLeft()) {
$("#luckysheet-scrollbar-x").scrollLeft(col_pre);
@ -300,6 +313,8 @@ export default function luckysheetHandler() {
//mousedown是右键
if (event.which == "3") {
$("#luckysheet-dataVerification-showHintBox").hide();
let isright = false;
for (let s = 0; s < Store.luckysheet_select_save.length; s++) {
@ -669,6 +684,134 @@ export default function luckysheetHandler() {
return;
}
//数据验证 单元格范围选择
if($("#luckysheet-dataVerificationRange-dialog").is(":visible")){
dataVerificationCtrl.selectStatus = true;
Store.luckysheet_select_status = false;
if (event.shiftKey) {
let last = dataVerificationCtrl.selectRange[dataVerificationCtrl.selectRange.length - 1];
let top = 0, height = 0, rowseleted = [];
if (last.top > row_pre) {
top = row_pre;
height = last.top + last.height - row_pre;
if (last.row[1] > last.row_focus) {
last.row[1] = last.row_focus;
}
rowseleted = [row_index, last.row[1]];
}
else if (last.top == row_pre) {
top = row_pre;
height = last.top + last.height - row_pre;
rowseleted = [row_index, last.row[0]];
}
else {
top = last.top;
height = row - last.top - 1;
if (last.row[0] < last.row_focus) {
last.row[0] = last.row_focus;
}
rowseleted = [last.row[0], row_index];
}
let left = 0, width = 0, columnseleted = [];
if (last.left > col_pre) {
left = col_pre;
width = last.left + last.width - col_pre;
if (last.column[1] > last.column_focus) {
last.column[1] = last.column_focus;
}
columnseleted = [col_index, last.column[1]];
}
else if (last.left == col_pre) {
left = col_pre;
width = last.left + last.width - col_pre;
columnseleted = [col_index, last.column[0]];
}
else {
left = last.left;
width = col - last.left - 1;
if (last.column[0] < last.column_focus) {
last.column[0] = last.column_focus;
}
columnseleted = [last.column[0], col_index];
}
let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
if (changeparam != null) {
columnseleted = changeparam[0];
rowseleted = changeparam[1];
top = changeparam[2];
height = changeparam[3];
left = changeparam[4];
width = changeparam[5];
}
last["row"] = rowseleted;
last["column"] = columnseleted;
last["left_move"] = left;
last["width_move"] = width;
last["top_move"] = top;
last["height_move"] = height;
dataVerificationCtrl.selectRange[dataVerificationCtrl.selectRange.length - 1] = last;
}
else if (event.ctrlKey) {
dataVerificationCtrl.selectRange.push({
"left": col_pre,
"width": col - col_pre - 1,
"top": row_pre,
"height": row - row_pre - 1,
"left_move": col_pre,
"width_move": col - col_pre - 1,
"top_move": row_pre,
"height_move": row - row_pre - 1,
"row": [row_index, row_index_ed],
"column": [col_index, col_index_ed],
"row_focus": row_index,
"column_focus": col_index
});
}
else {
dataVerificationCtrl.selectRange = [];
dataVerificationCtrl.selectRange.push({
"left": col_pre,
"width": col - col_pre - 1,
"top": row_pre,
"height": row - row_pre - 1,
"left_move": col_pre,
"width_move": col - col_pre - 1,
"top_move": row_pre,
"height_move": row - row_pre - 1,
"row": [row_index, row_index_ed],
"column": [col_index, col_index_ed],
"row_focus": row_index,
"column_focus": col_index
});
}
selectionCopyShow(dataVerificationCtrl.selectRange);
let range = dataVerificationCtrl.getTxtByRange(dataVerificationCtrl.selectRange);
$("#luckysheet-dataVerificationRange-dialog input").val(range);
return;
}
else{
dataVerificationCtrl.selectStatus = false;
dataVerificationCtrl.selectRange = [];
}
//if公式生成器
if (ifFormulaGenerator.singleRangeFocus) {
$("#luckysheet-ifFormulaGenerator-dialog .singRange").click();
@ -1023,6 +1166,10 @@ export default function luckysheetHandler() {
showrightclickmenu($("#luckysheet-rightclick-menu"), x, y);
}
}).dblclick(function (event) {
if($(event.target).hasClass('luckysheet-mousedown-cancel')){
return;
}
//禁止前台编辑(只可 框选单元格、滚动查看表格)
if (!Store.allowEdit) {
return;
@ -1569,6 +1716,101 @@ export default function luckysheetHandler() {
let range = conditionformat.getTxtByRange(conditionformat.selectRange);
$("#luckysheet-multiRange-dialog input").val(range);
}
else if (dataVerificationCtrl.selectStatus) {
let mouse = mouseposition(event.pageX, event.pageY);
let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
let row_location = rowLocation(y),
row = row_location[1],
row_pre = row_location[0],
row_index = row_location[2];
let col_location = colLocation(x),
col = col_location[1],
col_pre = col_location[0],
col_index = col_location[2];
let last = dataVerificationCtrl.selectRange[dataVerificationCtrl.selectRange.length - 1];
let top = 0, height = 0, rowseleted = [];
if (last.top > row_pre) {
top = row_pre;
height = last.top + last.height - row_pre;
if (last.row[1] > last.row_focus) {
last.row[1] = last.row_focus;
}
rowseleted = [row_index, last.row[1]];
}
else if (last.top == row_pre) {
top = row_pre;
height = last.top + last.height - row_pre;
rowseleted = [row_index, last.row[0]];
}
else {
top = last.top;
height = row - last.top - 1;
if (last.row[0] < last.row_focus) {
last.row[0] = last.row_focus;
}
rowseleted = [last.row[0], row_index];
}
let left = 0, width = 0, columnseleted = [];
if (last.left > col_pre) {
left = col_pre;
width = last.left + last.width - col_pre;
if (last.column[1] > last.column_focus) {
last.column[1] = last.column_focus;
}
columnseleted = [col_index, last.column[1]];
}
else if (last.left == col_pre) {
left = col_pre;
width = last.left + last.width - col_pre;
columnseleted = [col_index, last.column[0]];
}
else {
left = last.left;
width = col - last.left - 1;
if (last.column[0] < last.column_focus) {
last.column[0] = last.column_focus;
}
columnseleted = [last.column[0], col_index];
}
let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
if (changeparam != null) {
columnseleted = changeparam[0];
rowseleted = changeparam[1];
top = changeparam[2];
height = changeparam[3];
left = changeparam[4];
width = changeparam[5];
}
last["row"] = rowseleted;
last["column"] = columnseleted;
last["left_move"] = left;
last["width_move"] = width;
last["top_move"] = top;
last["height_move"] = height;
dataVerificationCtrl.selectRange[dataVerificationCtrl.selectRange.length - 1] = last;
selectionCopyShow(dataVerificationCtrl.selectRange);
let range = dataVerificationCtrl.getTxtByRange(dataVerificationCtrl.selectRange);
$("#luckysheet-dataVerificationRange-dialog input").val(range);
}
else if (formula.rangestart) {
formula.rangedrag(event);
}
@ -2909,6 +3151,12 @@ export default function luckysheetHandler() {
cfg["rowlen"] = {};
}
if (cfg["customHeight"] == null) {
cfg["customHeight"] = {};
}
cfg["customHeight"][Store.luckysheet_rows_change_size_start[1]] = 1;
cfg["rowlen"][Store.luckysheet_rows_change_size_start[1]] = Math.ceil(size/Store.zoomRatio);
let images = imageCtrl.moveChangeSize("row", Store.luckysheet_rows_change_size_start[1], size);
@ -2985,6 +3233,12 @@ export default function luckysheetHandler() {
cfg["columnlen"] = {};
}
if (cfg["customWidth"] == null) {
cfg["customWidth"] = {};
}
cfg["customWidth"][Store.luckysheet_cols_change_size_start[1]] = 1;
cfg["columnlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size/Store.zoomRatio);
let images = imageCtrl.moveChangeSize("column", Store.luckysheet_cols_change_size_start[1], size);
@ -3257,7 +3511,13 @@ export default function luckysheetHandler() {
last["row_focus"] = rf;
last["column_focus"] = cf;
jfrefreshgrid(d, range, cfg, cdformat, RowlChange);
let allParam = {
"cfg": cfg,
"RowlChange": RowlChange,
"cdformat": cdformat
}
jfrefreshgrid(d, range, allParam);
selectHightlightShow();
@ -4040,6 +4300,10 @@ export default function luckysheetHandler() {
$("#luckysheet-insertImg-btn-title").click(function () {
$("#luckysheet-imgUpload").click();
});
$("#luckysheetInsertImage").click(function () {
$("#luckysheet-imgUpload").click();
$("#luckysheet-rightclick-menu").hide();
})
$("#luckysheet-imgUpload").click(function (e) {
e.stopPropagation();
});
@ -4055,6 +4319,20 @@ export default function luckysheetHandler() {
}
});
//菜单栏 数据验证按钮
$("#luckysheet-dataVerification-btn-title").click(function () {
if (Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0) {
return;
}
dataVerificationCtrl.createDialog();
dataVerificationCtrl.init();
})
$("#luckysheetDataVerification").click(function () {
$("#luckysheet-dataVerification-btn-title").click();
$("#luckysheet-rightclick-menu").hide();
})
//冻结行列
$("#luckysheet-freezen-btn-horizontal").click(function () {
if ($.trim($(this).text()) == locale().freezen.freezenCancel) {
@ -4130,19 +4408,11 @@ export default function luckysheetHandler() {
//有批注在编辑时
luckysheetPostil.removeActivePs();
if (!$(event.target).hasClass("luckysheet-mousedown-cancel") && $(event.target).filter("[class*='sp-palette']").length == 0 && $(event.target).filter("[class*='sp-thumb']").length == 0 && $(event.target).filter("[class*='sp-']").length == 0) {
$("#luckysheet-rightclick-menu").hide();
$("#luckysheet-cols-h-hover").hide();
$("#luckysheet-cols-menu-btn").hide();
$("#luckysheet-rightclick-menu").hide();
$("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu, #luckysheet-user-menu").hide();
$("body > .luckysheet-filter-menu, body > .luckysheet-filter-submenu, body > .luckysheet-cols-menu").hide();
//$("body > luckysheet-menuButton").hide();
Store.luckysheet_cols_menu_status = false;
}
hideMenuByCancel(event);
//点击功能栏时 如果是单元格编辑模式 则退出编辑模式
if ($(event.target).closest("#luckysheet-wa-editor").length > 0 && parseInt($("#luckysheet-input-box").css("top")) > 0) {
console.log(event);
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
luckysheetMoveHighlightCell("down", 0, "rangeOfSelect");
}
@ -4397,8 +4667,6 @@ export default function luckysheetHandler() {
clipboardData = e.originalEvent.clipboardData;
}
let txtdata = clipboardData.getData("text/html");
//如果标示是qksheet复制的内容,判断剪贴板内容是否是当前页面复制的内容
@ -4480,7 +4748,6 @@ export default function luckysheetHandler() {
}
}
const locale_fontjson = locale().fontjson;
if (txtdata.indexOf("luckysheet_copy_action_table") > - 1 && Store.luckysheet_copy_save["copyRange"] != null && Store.luckysheet_copy_save["copyRange"].length > 0 && isEqual) {
@ -4720,7 +4987,6 @@ export default function luckysheetHandler() {
else if(clipboardData.files.length == 1 && clipboardData.files[0].type.indexOf('image') > -1){
let render = new FileReader();
render.readAsDataURL(clipboardData.files[0]);
render.onload = function(event){
let src = event.target.result;
imageCtrl.inserImg(src);

494
src/controllers/inlineString.js

@ -0,0 +1,494 @@
import {getFontStyleByCell, textTrim} from "../global/getdata";
import {selectTextContent,selectTextContentCross,selectTextContentCollapse} from '../global/cursorPos';
import locale from '../locale/locale';
import Store from '../store';
export const inlineStyleAffectAttribute = {"bl":1, "it":1 , "ff":1, "cl":1, "un":1,"fs":1,"fc":1};
export function isInlineStringCell(cell){
let isIs = cell && cell.ct!=null && cell.ct.t=="inlineStr" && cell.ct.s!=null && cell.ct.s.length>0;
return isIs;
}
export function isInlineStringCT(ct){
let isIs = ct!=null && ct.t=="inlineStr" && ct.s!=null && ct.s.length>0;
return isIs;
}
export function updateInlineStringFormat(cell, attr, value, $input){
// let s = Store.inlineStringEditCache;
var w = window.getSelection();
var range;
if(w.type=="None"){
range = Store.inlineStringEditRange;
}
else{
range = w.getRangeAt(0);
}
// if(isInlineStringCell(cell)){
// if(Store.inlineStringEditCache==null){
// Store.inlineStringEditCache = JSON.parse(JSON.stringify(cell.ct.s));
// }
// }
// else{
// Store.inlineStringEditCache = [{
// v:cell.v
// }];
// }
let cac = range.commonAncestorContainer;
let $textEditor;
if(cac.id=="luckysheet-rich-text-editor"){
$textEditor = $(cac);
}
else{
$textEditor = $(cac).closest("#luckysheet-rich-text-editor");
}
let $functionbox = $(cac).closest("#luckysheet-functionbox-cell");
if($textEditor.length==0 && $functionbox.length==0 && Store.inlineStringEditRange!=null){
range = Store.inlineStringEditRange;
cac = range.commonAncestorContainer;
if(cac.id=="luckysheet-rich-text-editor"){
$textEditor = $(cac);
}
else{
$textEditor = $(cac).closest("#luckysheet-rich-text-editor");
}
$functionbox = $(cac).closest("#luckysheet-functionbox-cell");
}
if(range.collapsed===true){
return;
}
let endContainer = range.endContainer, startContainer = range.startContainer;
let endOffset = range.endOffset, startOffset = range.startOffset;
if($textEditor.length>0){
if(startContainer===endContainer){
let span = startContainer.parentNode, spanIndex;
let content = span.innerHTML;
let left="" , mid="" , right="";
let s1=0, s2=startOffset, s3 = endOffset, s4=content.length;
left = content.substring(s1, s2);
mid = content.substring(s2, s3);
right = content.substring(s3, s4);
let cont = "";
if(left!=""){
cont += "<span style='"+ span.style.cssText +"'>" + left + "</span>";
}
if(mid!=""){
// let styleObj = {};
// styleObj[attr] = value;
// let s = getFontStyleByCell(styleObj, undefined, undefined, false);
// let ukey = textTrim(s.substr(0, s.indexOf(':')));
// let uvalue = textTrim(s.substr(s.indexOf(':')+1));
// uvalue = uvalue.substr(0, uvalue.length-1);
// let cssText = span.style.cssText;
// cssText = removeClassWidthCss(cssText, attr);
let cssText = getCssText(span.style.cssText, attr, value);
cont += "<span style='"+ cssText +"'>" + mid + "</span>";
}
if(right!=""){
cont += "<span style='"+ span.style.cssText +"'>" + right + "</span>";
}
if(startContainer.parentNode.tagName=="SPAN"){
spanIndex = $textEditor.find("span").index(span);
$(span).replaceWith(cont);
}
else{
spanIndex = 0;
$(span).html(cont);
}
let seletedNodeIndex = 0;
if(s1==s2){
seletedNodeIndex = spanIndex;
}
else{
seletedNodeIndex = spanIndex+1;
}
selectTextContent($textEditor.find("span").get(seletedNodeIndex));
}
else{
if(startContainer.parentNode.tagName=="SPAN" && endContainer.parentNode.tagName=="SPAN"){
let startSpan = startContainer.parentNode, startSpanIndex;
let endSpan = endContainer.parentNode, endSpanIndex;
startSpanIndex = $textEditor.find("span").index(startSpan);
endSpanIndex = $textEditor.find("span").index(endSpan);
let startContent = startSpan.innerHTML, endContent = endSpan.innerHTML;
let sleft="" , sright="", eleft="" , eright="";
let s1=0, s2=startOffset, s3 = endOffset, s4=endContent.length;
sleft = startContent.substring(s1, s2);
sright = startContent.substring(s2, startContent.length);
eleft = endContent.substring(0, s3);
eright = endContent.substring(s3, s4);
let spans = $textEditor.find("span");
let replaceSpans = spans.slice(startSpanIndex, endSpanIndex+1);
let cont = "";
for(let i=0;i<startSpanIndex;i++){
let span = spans.get(i), content = span.innerHTML;
cont += "<span style='"+ span.style.cssText +"'>" + content + "</span>";
}
if(sleft!=""){
cont += "<span style='"+ startSpan.style.cssText +"'>" + sleft + "</span>";
}
if(sright!=""){
let cssText = getCssText(startSpan.style.cssText, attr, value);
cont += "<span style='"+ cssText +"'>" + sright + "</span>";
}
if(startSpanIndex<endSpanIndex){
for(let i=startSpanIndex+1;i<endSpanIndex;i++){
let span = spans.get(i), content = span.innerHTML;
cont += "<span style='"+ span.style.cssText +"'>" + content + "</span>";
}
}
if(eleft!=""){
let cssText = getCssText(endSpan.style.cssText, attr, value);
cont += "<span style='"+ cssText +"'>" + eleft + "</span>";
}
if(eright!=""){
cont += "<span style='"+ endSpan.style.cssText +"'>" + eright + "</span>";
}
for(let i=endSpanIndex+1;i<spans.length;i++){
let span = spans.get(i), content = span.innerHTML;
cont += "<span style='"+ span.style.cssText +"'>" + content + "</span>";
}
$textEditor.html(cont);
// console.log(replaceSpans, cont);
// replaceSpans.replaceWith(cont);
let startSeletedNodeIndex, endSeletedNodeIndex;
if(s1==s2){
startSeletedNodeIndex = startSpanIndex;
endSeletedNodeIndex = endSpanIndex;
}
else{
startSeletedNodeIndex = startSpanIndex+1;
endSeletedNodeIndex = endSpanIndex+1;
}
spans = $textEditor.find("span");
selectTextContentCross(spans.get(startSeletedNodeIndex), spans.get(endSeletedNodeIndex));
}
}
}
else if($functionbox.length>0){
}
}
export function enterKeyControll(){
var w = window.getSelection();
if(w.type=="None"){
return
}
var range = w.getRangeAt(0);
let cac = range.commonAncestorContainer;
let $textEditor;
if(cac.id=="luckysheet-rich-text-editor"){
$textEditor = $(cac);
}
else{
$textEditor = $(cac).closest("#luckysheet-rich-text-editor");
}
let $functionbox = $(cac).closest("#luckysheet-functionbox-cell");
// if(range.collapsed===true){
// return;
// }
let endContainer = range.endContainer, startContainer = range.startContainer;
let endOffset = range.endOffset, startOffset = range.startOffset;
if($textEditor.length>0){
let startSpan = startContainer.parentNode;
let startSpanIndex = $textEditor.find("span").index(startSpan);
if(range.collapsed===false){
range.deleteContents();
}
let startContent = startSpan.innerHTML;
let sleft="" , sright="";
let s1=0, s2=startOffset;
sleft = startContent.substring(s1, s2);
sright = startContent.substring(s2, startContent.length);
let cont = "<span style='"+ startSpan.style.cssText +"'>" + sleft + "\n" + sright + "</span>";
let spanIndex;
if(startContainer.parentNode.tagName=="SPAN"){
spanIndex = $textEditor.find("span").index(startSpan);
$(startSpan).replaceWith(cont);
}
else{
spanIndex = 0;
$(startSpan).html(cont);
}
selectTextContentCollapse($textEditor.find("span").get(spanIndex), startOffset+1);
}
else if($functionbox.length>0){
}
}
export function updateInlineStringFormatOutside(cell, key, value){
let s = cell.ct.s;
for(let i=0;i<s.length;i++){
let item = s[i];
item[key] = value;
}
}
export function convertSpanToShareString($dom){
let styles = [], preStyleList, preStyleListString=null;
for(let i=0;i<$dom.length;i++){
let span = $dom.get(i);
let styleList = convertCssToStyleList(span.style.cssText);
let curStyleListString = JSON.stringify(styleList);
let v = span.innerHTML;
v = v.replace(/\n/g, "\r\n");
if(curStyleListString==preStyleListString){
preStyleList.v += v;
}
else{
styleList.v = v;
styles.push(styleList);
preStyleListString = curStyleListString;
preStyleList = styleList;
}
}
return styles;
}
export function convertCssToStyleList(cssText){
if(cssText==null || cssText.length==0){
return {};
}
let cssTextArray = cssText.split(";");
let styleList = {
"ff":"Arial", //font family
"fc":"#000000",//font color
"fs":12,//font size
"cl":0,//strike
"un":0,//underline
"bl":0,//blod
"it":0,//italic
};
const _locale = locale();
const locale_fontarray = _locale.fontarray;
const locale_fontjson = _locale.fontjson;
cssTextArray.forEach(s => {
s = s.toLowerCase();
let key = textTrim(s.substr(0, s.indexOf(':')));
let value = textTrim(s.substr(s.indexOf(':') + 1));
if(key=="font-weight"){
if(value=="bold"){
styleList["bl"] = 1;
}
else{
styleList["bl"] = 0;
}
}
if(key=="font-style"){
if(value=="italic"){
styleList["it"] = 1;
}
else{
styleList["it"] = 0;
}
}
if(key=="font-family"){
let ff = locale_fontjson[value];
if(ff==null){
styleList["ff"] = value;
}
else{
styleList["ff"] = ff;
}
}
if(key=="font-size"){
styleList["fs"] = parseInt(value);
}
if(key=="color"){
styleList["fc"] = value;
}
if(key=="text-decoration"){
styleList["cl"] = 1;
}
if(key=="border-bottom"){
styleList["un"] = 1;
}
if(key=="lucky-strike"){
styleList["cl"] = value;
}
if(key=="lucky-underline"){
styleList["un"] = value;
}
});
return styleList;
}
const luckyToCssName = {
"bl":"font-weight",
"it":"font-style",
"ff":"font-family",
"fs":"font-size",
"fc":"color",
"cl":"text-decoration",
"un":"border-bottom",
}
function getClassWithcss(cssText, ukey){
let cssTextArray = cssText.split(";");
if(ukey==null || ukey.length==0){
return cssText;
}
if(cssText.indexOf(ukey)>-1){
for(let i=0;i<cssTextArray.length;i++){
let s = cssTextArray[i];
s = s.toLowerCase();
let key = textTrim(s.substr(0, s.indexOf(':')));
let value = textTrim(s.substr(s.indexOf(':') + 1));
if(key==ukey){
return value;
}
}
}
return "";
}
function upsetClassWithCss(cssText, ukey, uvalue){
let cssTextArray = cssText.split(";");
let newCss = "";
if(ukey==null || ukey.length==0){
return cssText;
}
if(cssText.indexOf(ukey)>-1){
for(let i=0;i<cssTextArray.length;i++){
let s = cssTextArray[i];
s = s.toLowerCase();
let key = textTrim(s.substr(0, s.indexOf(':')));
let value = textTrim(s.substr(s.indexOf(':') + 1));
if(key==ukey){
newCss += key + ":" + uvalue + ";";
}
else if(key.length>0){
newCss += key + ":" + value + ";";
}
}
}
else if(ukey.length>0){
cssText += ukey + ":" + uvalue + ";";
newCss = cssText;
}
return newCss;
}
function removeClassWidthCss(cssText, ukey){
let cssTextArray = cssText.split(";");
let newCss = "";
let oUkey = ukey;
if(ukey==null || ukey.length==0){
return cssText;
}
if(ukey in luckyToCssName){
ukey = luckyToCssName[ukey];
}
if(cssText.indexOf(ukey)>-1){
for(let i=0;i<cssTextArray.length;i++){
let s = cssTextArray[i];
s = s.toLowerCase();
let key = textTrim(s.substr(0, s.indexOf(':')));
let value = textTrim(s.substr(s.indexOf(':') + 1));
if(key==ukey || (oUkey=="cl" && key=="lucky-strike") || (oUkey=="un" && key=="lucky-underline") ){
continue;
}
else if(key.length>0){
newCss += key + ":" + value + ";";
}
}
}
else{
newCss = cssText;
}
return newCss;
}
function getCssText(cssText, attr, value){
let styleObj = {};
styleObj[attr] = value;
if(attr=="un"){
let fontColor = getClassWithcss(cssText,"color");
if(fontColor==""){
fontColor = "#000000";
}
let fs = getClassWithcss(cssText,"font-size");
if(fs==""){
fs = 11;
}
fs = parseInt(fs);
styleObj["_fontSize"] = fs;
styleObj["_color"] = fontColor;
}
let s = getFontStyleByCell(styleObj, undefined, undefined, false);
let ukey = textTrim(s.substr(0, s.indexOf(':')));
let uvalue = textTrim(s.substr(s.indexOf(':')+1));
uvalue = uvalue.substr(0, uvalue.length-1);
// let cssText = span.style.cssText;
cssText = removeClassWidthCss(cssText, attr);
cssText = upsetClassWithCss(cssText, ukey, uvalue);
return cssText;
}

2
src/controllers/insertFormula.js

@ -15,7 +15,7 @@ const insertFormula = {
let _this = this;
let _locale = locale();
let locale_formulaMore = _locale.formulaMore;
let locale_button = _locale.button
let locale_button = _locale.button;
$(document).off("keyup.fxSFLI").on("keyup.fxSFLI", "#searchFormulaListInput", function(){
$("#formulaTypeList").empty();

9
src/controllers/keyboard.js

@ -25,6 +25,7 @@ import formula from '../global/formula';
import cleargridelement from '../global/cleargridelement';
import tooltip from '../global/tooltip';
import locale from '../locale/locale';
import {enterKeyControll} from './inlineString';
import Store from '../store';
@ -300,10 +301,16 @@ export function keyboardInitial(){
return;
}
let $inputbox = $("#luckysheet-input-box");
if (kcode == keycode.ENTER && parseInt($inputbox.css("top")) > 0) {
if((altKey || event.metaKey) && kcode == keycode.ENTER && parseInt($inputbox.css("top")) > 0){
enterKeyControll();
event.preventDefault();
}
else if (kcode == keycode.ENTER && parseInt($inputbox.css("top")) > 0) {
if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) {
formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active"));
}

563
src/controllers/menuButton.js

@ -26,9 +26,12 @@ import { rowLocationByIndex, colLocationByIndex } from '../global/location';
import { isdatatypemulti } from '../global/datecontroll';
import { rowlenByRange, getCellTextSplitArr } from '../global/getRowlen';
import { setcellvalue } from '../global/setdata';
import { getFontStyleByCell, checkstatusByCell} from '../global/getdata';
import { countfunc } from '../global/count';
import { hideMenuByCancel } from '../global/cursorPos';
import { getSheetIndex, getRangetxt, getluckysheetfile } from '../methods/get';
import { setluckysheetfile } from '../methods/set';
import {isInlineStringCell,updateInlineStringFormat,convertCssToStyleList,inlineStyleAffectAttribute,updateInlineStringFormatOutside} from './inlineString';
import { replaceHtml, getObjType, rgbTohex, mouseclickposition, luckysheetfontformat,luckysheetContainerFocus } from '../utils/util';
import Store from '../store';
import locale from '../locale/locale';
@ -455,7 +458,10 @@ const menuButton = {
});
//字体设置
$("#luckysheet-icon-font-family").click(function(){
$("#luckysheet-icon-font-family").mousedown(function(e){
hideMenuByCancel(e);
e.stopPropagation();
}).click(function(){
let menuButtonId = $(this).attr("id")+"-menuButton";
let $menuButton = $("#"+menuButtonId);
if($menuButton.length == 0){
@ -504,7 +510,10 @@ const menuButton = {
});
//字体颜色
$("#luckysheet-icon-text-color").click(function(){
$("#luckysheet-icon-text-color").mousedown(function(e){
hideMenuByCancel(e);
e.stopPropagation();
}).click(function(){
let d = editor.deepCopyFlowData(Store.flowdata);
let color = $(this).attr("color");
if(color == null){
@ -513,7 +522,10 @@ const menuButton = {
_this.updateFormat(d, "fc", color);
});
$("#luckysheet-icon-text-color-menu").click(function(){
$("#luckysheet-icon-text-color-menu").mousedown(function(e){
hideMenuByCancel(e);
e.stopPropagation();
}).click(function(){
let menuButtonId = $(this).attr("id") + "-menuButton";
let $menuButton = $("#"+menuButtonId);
@ -785,7 +797,19 @@ const menuButton = {
//字体大小
let luckysheet_fs_setTimeout = null;
$("#luckysheet-icon-font-size").click(function(e){
$("#luckysheet-icon-font-size").mousedown(function(e){
if (parseInt($("#luckysheet-input-box").css("top")) > 0){
let w = window.getSelection();
if(w.type!="None"){
let range = w.getRangeAt(0);
if(!range.collapsed){
Store.inlineStringEditRange = range.cloneRange();
}
}
}
hideMenuByCancel(e);
e.stopPropagation();
}).click(function(){
let menuButtonId = $(this).attr("id") + "-menuButton";
let $menuButton = $("#" + menuButtonId);
@ -846,8 +870,13 @@ const menuButton = {
menuleft = menuleft - tlen + userlen;
}
mouseclickposition($menuButton, menuleft, $(this).offset().top + 25, "lefttop");
})
.find("input.luckysheet-toolbar-textinput").keyup(function(e){
.find("input.luckysheet-toolbar-textinput").keydown(function(e){
hideMenuByCancel(e);
e.stopPropagation();
}).keyup(function(e){
if(e.keyCode != 13){//Enter
return;
}
@ -2096,7 +2125,10 @@ const menuButton = {
});
//加粗
$("#luckysheet-icon-bold").click(function(){
$("#luckysheet-icon-bold").mousedown(function(e){
hideMenuByCancel(e);
e.stopPropagation();
}).click(function(e){
let d = editor.deepCopyFlowData(Store.flowdata);
let row_index = Store.luckysheet_select_save[0]["row_focus"],
col_index = Store.luckysheet_select_save[0]["column_focus"];
@ -2114,7 +2146,10 @@ const menuButton = {
});
//斜体
$("#luckysheet-icon-italic").click(function(){
$("#luckysheet-icon-italic").mousedown(function(e){
hideMenuByCancel(e);
e.stopPropagation();
}).click(function(){
let d = editor.deepCopyFlowData(Store.flowdata);
let row_index = Store.luckysheet_select_save[0]["row_focus"],
col_index = Store.luckysheet_select_save[0]["column_focus"];
@ -2132,7 +2167,10 @@ const menuButton = {
});
//删除线
$("#luckysheet-icon-strikethrough").click(function(){
$("#luckysheet-icon-strikethrough").mousedown(function(e){
hideMenuByCancel(e);
e.stopPropagation();
}).click(function(){
let d = editor.deepCopyFlowData(Store.flowdata);
let row_index = Store.luckysheet_select_save[0]["row_focus"],
col_index = Store.luckysheet_select_save[0]["column_focus"];
@ -2836,6 +2874,17 @@ const menuButton = {
let canvasElement = document.createElement('canvas');
let canvas = canvasElement.getContext("2d");
if(attr in inlineStyleAffectAttribute ){
if (parseInt($("#luckysheet-input-box").css("top")) > 0 ) {
let value = $("#luckysheet-input-box").text();
if(value.substr(0,1)!="="){
let cell = d[Store.luckysheetCellUpdate[0]][Store.luckysheetCellUpdate[1]];
updateInlineStringFormat(cell, attr, foucsStatus, luckysheetformula.rangeResizeTo);
return;
}
}
}
let cfg = $.extend(true, {}, Store.config);
if(cfg["rowlen"] == null){
cfg["rowlen"] = {};
@ -2958,7 +3007,13 @@ const menuButton = {
let value = d[r][c];
if (getObjType(value) == "object") {
d[r][c][attr] = foucsStatus;
if(attr in inlineStyleAffectAttribute && isInlineStringCell(value)){
updateInlineStringFormatOutside(value, attr, foucsStatus);
}
else{
d[r][c][attr] = foucsStatus;
}
}
else{
d[r][c] = { v: value };
@ -2972,15 +3027,20 @@ const menuButton = {
}
}
cfg = rowlenByRange(d, row_st, row_ed, cfg);
if(attr == "tb" || attr == "tr" || attr == "fs"){
cfg = rowlenByRange(d, row_st, row_ed, cfg);
}
}
let allParam = {};
if(attr == "tb" || attr == "tr" || attr == "fs"){
jfrefreshgrid(d, Store.luckysheet_select_save, cfg, null, true, false);
}
else{
jfrefreshgrid(d, Store.luckysheet_select_save, undefined, undefined,undefined,false);
allParam = {
"cfg": cfg,
"RowlChange": true
}
}
jfrefreshgrid(d, Store.luckysheet_select_save, allParam, false);
},
updateFormat_mc: function(d, foucsStatus){
let cfg = $.extend(true, {}, Store.config);
@ -3181,7 +3241,7 @@ const menuButton = {
}
Store.clearjfundo = false;
jfrefreshgrid(d, Store.luckysheet_select_save, cfg);
jfrefreshgrid(d, Store.luckysheet_select_save, {"cfg": cfg});
Store.clearjfundo = true;
},
borderfix: function(d, r, c){
@ -3201,316 +3261,183 @@ const menuButton = {
//return [-2, -2, 1, 0];
}
},
menuButtonFocus: function(d, r, c){
changeMenuButtonDom:function(attr, foucsStatus, _locale){
let _this = this;
let foucsList = ["bl", "it", "cl", "ff", "ht", "vt", "fs", "tb", "tr"];
const _locale = locale();
if(_locale==null){
_locale = locale();
}
const locale_fontarray = _locale.fontarray;
const locale_fontjson = _locale.fontjson;
for(let i = 0; i < foucsList.length; i++){
let attr = foucsList[i];
let foucsStatus = _this.checkstatus(d, r, c, attr);
if(attr == "bl"){
if(foucsStatus != "0"){
$("#luckysheet-icon-bold").addClass("luckysheet-toolbar-button-hover");
}
else{
$("#luckysheet-icon-bold").removeClass("luckysheet-toolbar-button-hover");
}
}
else if(attr == "it"){
if(foucsStatus != "0"){
$("#luckysheet-icon-italic").addClass("luckysheet-toolbar-button-hover");
}
else{
$("#luckysheet-icon-italic").removeClass("luckysheet-toolbar-button-hover");
}
}
else if(attr == "cl"){
if(foucsStatus != "0"){
$("#luckysheet-icon-strikethrough").addClass("luckysheet-toolbar-button-hover");
}
else{
$("#luckysheet-icon-strikethrough").removeClass("luckysheet-toolbar-button-hover");
}
}
else if(attr == "ff"){
let menuButtonId = "luckysheet-icon-font-family-menuButton";
let $menuButton = $("#" + menuButtonId);
// const locale_fontarray = locale().fontarray;
let itemname = locale_fontarray[0], itemvalue = 0;
if(foucsStatus != null){
if(isdatatypemulti(foucsStatus)["num"]){
itemvalue = parseInt(foucsStatus);
itemname = locale_fontarray[itemvalue];
}
else{
itemvalue = locale_fontjson[foucsStatus];
itemname = locale_fontarray[itemvalue];
}
}
_this.focus($menuButton, itemvalue);
$("#luckysheet-icon-font-family").find(".luckysheet-toolbar-menu-button-caption").html(" "+ itemname +" ");
}
else if(attr == "fs"){
let $menuButton = $("#luckysheet-icon-font-size-menuButton");
let itemvalue = foucsStatus, $input = $("#luckysheet-icon-font-size input");
_this.focus($menuButton, itemvalue);
$("#luckysheet-icon-font-size").attr("itemvalue", itemvalue);
$input.val(itemvalue);
}
else if(attr == "ht"){
let $menuButton = $("#luckysheet-icon-align-menu-menuButton");
let $t = $("luckysheet-icon-align"), itemvalue = "left";
if(foucsStatus == "0"){
itemvalue = "center";
}
else if(foucsStatus == "2"){
itemvalue = "right";
}
_this.focus($menuButton, itemvalue);
// add iconfont
const iconfontObject = iconfontObjects.align;
let $icon = $("#luckysheet-icon-align").attr("type", itemvalue).find(".luckysheet-icon-img-container");
$icon.removeAttr("class").addClass("luckysheet-icon-img-container luckysheet-icon-img luckysheet-icon-align-" + itemvalue + iconfontObject[itemvalue]);
$menuButton.hide();
}
else if(attr == "vt"){
let $menuButton = $("#luckysheet-icon-valign-menu-menuButton");
let $t = $("luckysheet-icon-valign"), itemvalue = "bottom";
if(foucsStatus == "1"){
itemvalue = "top";
}
else if(foucsStatus == "0"){
itemvalue = "middle";
}
_this.focus($menuButton, itemvalue);
// add iconfont
const iconfontObject = iconfontObjects.align;
let $icon = $("#luckysheet-icon-valign").attr("type", itemvalue).find(".luckysheet-icon-img-container");
$icon.removeAttr("class").addClass("luckysheet-icon-img-container luckysheet-icon-img luckysheet-icon-valign-" + itemvalue + iconfontObject[itemvalue]);
$menuButton.hide();
}
else if(attr == "tb"){
let $menuButton = $("#luckysheet-icon-textwrap-menu-menuButton");
let $t = $("luckysheet-icon-textwrap"), itemvalue = "clip";
if(foucsStatus == "1"){
itemvalue = "overflow";
}
else if(foucsStatus == "2"){
itemvalue = "wrap";
}
_this.focus($menuButton, itemvalue);
// add iconfont
const iconfontObject = iconfontObjects.textWrap;
let $icon = $("#luckysheet-icon-textwrap").attr("type", itemvalue).find(".luckysheet-icon-img-container");
$icon.removeAttr("class").addClass("luckysheet-icon-img-container luckysheet-icon-img luckysheet-icon-textwrap-" + itemvalue + iconfontObject[itemvalue]);
$menuButton.hide();
}
else if(attr == "tr"){
let $menuButton = $("#luckysheet-icon-rotation-menu-menuButton");
let $t = $("luckysheet-icon-rotation"), itemvalue = "none";
if(foucsStatus == "1"){
itemvalue = "angleup";
}
else if(foucsStatus == "2"){
itemvalue = "angledown";
}
else if(foucsStatus == "3"){
itemvalue = "vertical";
}
else if(foucsStatus == "4"){
itemvalue = "rotation-up";
}
else if(foucsStatus == "5"){
itemvalue = "rotation-down";
}
_this.focus($menuButton, itemvalue);
// add iconfont
const iconfontObject = iconfontObjects.rotation;
let $icon = $("#luckysheet-icon-rotation").attr("type", itemvalue).find(".luckysheet-icon-img-container");
$icon.removeAttr("class").addClass("luckysheet-icon-img-container luckysheet-icon-img luckysheet-icon-rotation-" + itemvalue + iconfontObject[itemvalue]);
$menuButton.hide();
}
}
},
checkstatusByCell:function(cell, a){
let foucsStatus =cell;
let tf = {"bl":1, "it":1 , "ff":1, "cl":1, "un":1};
if(a in tf){
if(foucsStatus == null){
foucsStatus = "0";
if(attr == "bl"){
if(foucsStatus != "0"){
$("#luckysheet-icon-bold").addClass("luckysheet-toolbar-button-hover");
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
$("#luckysheet-icon-bold").removeClass("luckysheet-toolbar-button-hover");
}
}
else if(a == "fc"){
if(foucsStatus == null){
foucsStatus = "#000000";
else if(attr == "it"){
if(foucsStatus != "0"){
$("#luckysheet-icon-italic").addClass("luckysheet-toolbar-button-hover");
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "#000000";
}
if(foucsStatus.indexOf("rgba") > -1){
foucsStatus = rgbTohex(foucsStatus);
}
$("#luckysheet-icon-italic").removeClass("luckysheet-toolbar-button-hover");
}
}
else if(a == "bg"){
if(foucsStatus == null){
foucsStatus = null;
else if(attr == "cl"){
if(foucsStatus != "0"){
$("#luckysheet-icon-strikethrough").addClass("luckysheet-toolbar-button-hover");
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
else if(foucsStatus.toString().indexOf("rgba") > -1){
foucsStatus = rgbTohex(foucsStatus);
}
$("#luckysheet-icon-strikethrough").removeClass("luckysheet-toolbar-button-hover");
}
}
else if(a.substr(0, 2) == "bs"){
if(foucsStatus == null){
foucsStatus = "none";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "none";
else if(attr == "ff"){
let menuButtonId = "luckysheet-icon-font-family-menuButton";
let $menuButton = $("#" + menuButtonId);
// const locale_fontarray = locale().fontarray;
let itemname = locale_fontarray[0], itemvalue = 0;
if(foucsStatus != null){
if(isdatatypemulti(foucsStatus)["num"]){
itemvalue = parseInt(foucsStatus);
itemname = locale_fontarray[itemvalue];
}
else{
itemvalue = locale_fontjson[foucsStatus];
itemname = locale_fontarray[itemvalue];
}
}
_this.focus($menuButton, itemvalue);
$("#luckysheet-icon-font-family").find(".luckysheet-toolbar-menu-button-caption").html(" "+ itemname +" ");
}
else if(a.substr(0, 2) == "bc"){
if(foucsStatus == null){
foucsStatus = "#000000";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "#000000";
}
}
else if(attr == "fs"){
let $menuButton = $("#luckysheet-icon-font-size-menuButton");
let itemvalue = foucsStatus, $input = $("#luckysheet-icon-font-size input");
_this.focus($menuButton, itemvalue);
$("#luckysheet-icon-font-size").attr("itemvalue", itemvalue);
$input.val(itemvalue);
}
else if(a == "ht"){
if(foucsStatus == null){
foucsStatus = "1";
else if(attr == "ht"){
let $menuButton = $("#luckysheet-icon-align-menu-menuButton");
let $t = $("luckysheet-icon-align"), itemvalue = "left";
if(foucsStatus == "0"){
itemvalue = "center";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "1";
}
else if(foucsStatus == "2"){
itemvalue = "right";
}
if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
foucsStatus = "1";
}
_this.focus($menuButton, itemvalue);
// add iconfont
const iconfontObject = iconfontObjects.align;
let $icon = $("#luckysheet-icon-align").attr("type", itemvalue).find(".luckysheet-icon-img-container");
$icon.removeAttr("class").addClass("luckysheet-icon-img-container luckysheet-icon-img luckysheet-icon-align-" + itemvalue + iconfontObject[itemvalue]);
$menuButton.hide();
}
else if(a == "vt"){
if(foucsStatus == null){
foucsStatus = "2";
else if(attr == "vt"){
let $menuButton = $("#luckysheet-icon-valign-menu-menuButton");
let $t = $("luckysheet-icon-valign"), itemvalue = "bottom";
if(foucsStatus == "1"){
itemvalue = "top";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "2";
}
else if(foucsStatus == "0"){
itemvalue = "middle";
}
if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
foucsStatus = "2";
}
_this.focus($menuButton, itemvalue);
// add iconfont
const iconfontObject = iconfontObjects.align;
let $icon = $("#luckysheet-icon-valign").attr("type", itemvalue).find(".luckysheet-icon-img-container");
$icon.removeAttr("class").addClass("luckysheet-icon-img-container luckysheet-icon-img luckysheet-icon-valign-" + itemvalue+ iconfontObject[itemvalue]);
$menuButton.hide();
}
else if(a == "ct"){
if(foucsStatus == null){
foucsStatus = null;
else if(attr == "tb"){
let $menuButton = $("#luckysheet-icon-textwrap-menu-menuButton");
let $t = $("luckysheet-icon-textwrap"), itemvalue = "clip";
if(foucsStatus == "1"){
itemvalue = "overflow";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
else if(foucsStatus == "2"){
itemvalue = "wrap";
}
_this.focus($menuButton, itemvalue);
// add iconfont
const iconfontObject = iconfontObjects.textWrap;
let $icon = $("#luckysheet-icon-textwrap").attr("type", itemvalue).find(".luckysheet-icon-img-container");
$icon.removeAttr("class").addClass("luckysheet-icon-img-container luckysheet-icon-img luckysheet-icon-textwrap-" + itemvalue + iconfontObject[itemvalue]);
$menuButton.hide();
}
else if(a == "fs"){
if(foucsStatus == null){
foucsStatus = "10";
else if(attr == "tr"){
let $menuButton = $("#luckysheet-icon-rotation-menu-menuButton");
let $t = $("luckysheet-icon-rotation"), itemvalue = "none";
if(foucsStatus == "1"){
itemvalue = "angleup";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "10";
}
else if(foucsStatus == "2"){
itemvalue = "angledown";
}
}
else if(a == "tb"){
if(foucsStatus == null){
foucsStatus = "0";
else if(foucsStatus == "3"){
itemvalue = "vertical";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "tr"){
if(foucsStatus == null){
foucsStatus = "0";
else if(foucsStatus == "4"){
itemvalue = "rotation-up";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
else if(foucsStatus == "5"){
itemvalue = "rotation-down";
}
_this.focus($menuButton, itemvalue);
// add iconfont
const iconfontObject = iconfontObjects.rotation;
let $icon = $("#luckysheet-icon-rotation").attr("type", itemvalue).find(".luckysheet-icon-img-container");
$icon.removeAttr("class").addClass("luckysheet-icon-img-container luckysheet-icon-img luckysheet-icon-rotation-" + itemvalue + iconfontObject[itemvalue]);
$menuButton.hide();
}
else if(a == "rt"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
},
inputMenuButtonFocus:function(focusTarget){
var w = window.getSelection();
var range = w.getRangeAt(0);
let startContainer = range.startContainer;
Store.inlineStringEditRange = null;
const _locale = locale();
if(startContainer.parentNode.tagName=="SPAN"){
let cssText = startContainer.parentNode.style.cssText;
let stylelist = convertCssToStyleList(cssText);
for(let key in stylelist){
this.changeMenuButtonDom(key, stylelist[key], _locale);
}
}
},
menuButtonFocus: function(d, r, c){
let _this = this;
let foucsList = ["bl", "it", "cl", "ff", "ht", "vt", "fs", "tb", "tr"];
const _locale = locale();
for(let i = 0; i < foucsList.length; i++){
let attr = foucsList[i];
let foucsStatus = _this.checkstatus(d, r, c, attr);
return foucsStatus;
this.changeMenuButtonDom(attr, foucsStatus, _locale);
}
},
checkstatus: function(d, r, c, a){
let foucsStatus = d[r][c];
return this.checkstatusByCell(foucsStatus, a);
return checkstatusByCell(foucsStatus, a);
},
setLineDash: function(canvasborder, type, hv, m_st, m_ed, line_st, line_ed){
let borderType = {
@ -4272,6 +4199,10 @@ const menuButton = {
const locale_fontarray = locale().fontarray;
let cell = d[r][c];
let ct = cell.ct, isInline=false;
if(isInlineStringCell(cell)){
isInline = true;
}
for(let key in cell){
let value = _this.checkstatus(d, r, c , key);
@ -4300,37 +4231,39 @@ const menuButton = {
}
}
if(key == "bl" && value != "0"){
style += "font-weight: bold;";
}
if(key == "it" && value != "0"){
style += "font-style:italic;";
}
if(key == "ff" && value != "0"){
let f = value;
if(!isNaN(parseInt(value))){
f = locale_fontarray[parseInt(value)];
}
style += "font-family: " + f + ";";
}
if(key == "fs" && value != "10"){
style += "font-size: "+ value + "pt;";
}
if((key == "fc" && value != "#000000") || checksAF != null || (checksCF != null && checksCF["textColor"] != null)){
if(checksCF != null && checksCF["textColor"] != null){
style += "color: " + checksCF["textColor"] + ";";
}
else if(checksAF != null){
style += "color: " + checksAF[0] + ";";
}
else{
style += "color: " + value + ";";
}
}
// if(!isInline){
// if(key == "bl" && value != "0"){
// style += "font-weight: bold;";
// }
// if(key == "it" && value != "0"){
// style += "font-style:italic;";
// }
// if(key == "ff" && value != "0"){
// let f = value;
// if(!isNaN(parseInt(value))){
// f = locale_fontarray[parseInt(value)];
// }
// style += "font-family: " + f + ";";
// }
// if(key == "fs" && value != "10"){
// style += "font-size: "+ value + "pt;";
// }
// if((key == "fc" && value != "#000000") || checksAF != null || (checksCF != null && checksCF["textColor"] != null)){
// if(checksCF != null && checksCF["textColor"] != null){
// style += "color: " + checksCF["textColor"] + ";";
// }
// else if(checksAF != null){
// style += "color: " + checksAF[0] + ";";
// }
// else{
// style += "color: " + value + ";";
// }
// }
// }
if(key == "ht" && value != "1"){
if(value == "0"){
@ -4351,6 +4284,10 @@ const menuButton = {
}
}
if(!isInline){
style += getFontStyleByCell(cell,checksAF,checksCF);
}
return style;
}
}

11
src/controllers/orderBy.js

@ -212,16 +212,19 @@ export function orderByInitial(){
}
}
let allParam = {};
if(Store.config["rowlen"] != null){
let cfg = $.extend(true, {}, Store.config);
cfg = rowlenByRange(d, str, r2, cfg);
jfrefreshgrid(d, [{ "row": [str, r2], "column": [c1, c2] }], cfg, null, true);
}
else{
jfrefreshgrid(d, [{ "row": [str, r2], "column": [c1, c2] }]);
allParam = {
"cfg": cfg,
"RowlChange": true
}
}
jfrefreshgrid(d, [{ "row": [str, r2], "column": [c1, c2] }], allParam);
$("#luckysheet-sort-dialog").hide();
$("#luckysheet-modal-dialog-mask").hide();
});

2
src/controllers/pivotTable.js

@ -733,7 +733,7 @@ const pivotTable = {
jfrefreshgridall(data[0].length, data.length, data, null, Store.luckysheet_select_save, "datachangeAll", undefined, undefined,isRefreshCanvas);
}
else {
jfrefreshgrid(data, Store.luckysheet_select_save, undefined, undefined, undefined, undefined,isRefreshCanvas);
jfrefreshgrid(data, Store.luckysheet_select_save, {}, null, isRefreshCanvas);
selectHightlightShow();
}

9
src/controllers/postil.js

@ -825,7 +825,14 @@ const luckysheetPostil = {
let r = id.split("luckysheet-postil-show_")[1].split("_")[0];
let c = id.split("luckysheet-postil-show_")[1].split("_")[1];
_this.buildPs(r, c, Store.flowdata[r][c].ps);
let cell = Store.flowdata[r][c];
if(cell != null && cell.ps != null){
_this.buildPs(r, c, cell.ps);
}
else{
$("#" + id).hide();
}
});
}
}

2
src/controllers/resize.js

@ -306,6 +306,7 @@ export function menuToolBarWidth() {
$('#luckysheet-freezen-btn-horizontal').offset().left,
$('#luckysheet-icon-autofilter').offset().left,
$('#luckysheet-icon-conditionformat').offset().left,
$('#luckysheet-dataVerification-btn-title').offset().left,
$('#luckysheet-splitColumn-btn-title').offset().left,
$('#luckysheet-chart-btn-screenshot').offset().left,
$('#luckysheet-icon-seachmore').offset().left,
@ -341,6 +342,7 @@ export function menuToolBarWidth() {
['#luckysheet-freezen-btn-horizontal','#luckysheet-icon-freezen-menu'],
'#luckysheet-icon-autofilter',
'#luckysheet-icon-conditionformat',
'#luckysheet-dataVerification-btn-title',
'#luckysheet-splitColumn-btn-title',
'#luckysheet-chart-btn-screenshot',
'#luckysheet-icon-seachmore'

66
src/controllers/rowColumnOperation.js

@ -32,8 +32,9 @@ import { getcellvalue } from '../global/getdata';
import tooltip from '../global/tooltip';
import editor from '../global/editor';
import locale from '../locale/locale';
import {getMeasureText} from '../global/getRowlen';
import {getMeasureText,getCellTextInfo} from '../global/getRowlen';
import { luckysheet_searcharray } from '../controllers/sheetSearch';
import {isInlineStringCell} from './inlineString';
import Store from '../store';
export function rowColumnOperationInitial(){
@ -1711,24 +1712,39 @@ function luckysheetcolsdbclick() {
for(let r = dataset_row_st; r <= dataset_row_ed; r++){
let cell = d[r][colIndex];
if(cell == null || isRealNull(cell.v)){
if(cell == null || (isRealNull(cell.v) && !isInlineStringCell(cell)) ){
continue;
}
let fontset = luckysheetfontformat(cell);
canvas.font = fontset;
// let fontset = luckysheetfontformat(cell);
// canvas.font = fontset;
let value = getcellvalue(r, colIndex, d, "m").toString(); //单元格文本
let textMetrics = getMeasureText(value, canvas).width; //文本宽度
// let value = getcellvalue(r, colIndex, d, "m").toString(); //单元格文本
// let textMetrics = getMeasureText(value, canvas).width; //文本宽度
let cellWidth = colLocationByIndex(colIndex)[1] - colLocationByIndex(colIndex)[0] - 2;
let textInfo = getCellTextInfo(cell, canvas,{
r:r,
c:colIndex,
cellWidth:cellWidth
});
let computeRowlen = 0;
// console.log("rowlen", textInfo);
if(textInfo!=null){
computeRowlen = textInfo.textWidthAll;
}
if(textMetrics + 6 > currentColLen){
currentColLen = textMetrics + 6;
if(computeRowlen + 6 > currentColLen){
currentColLen = computeRowlen + 6;
}
}
if(currentColLen != Store.defaultcollen){
cfg["columnlen"][colIndex] = currentColLen;
if(cfg["customWidth"]){
delete cfg["customWidth"][colIndex];
}
}
matchColumn[colIndex] = 1;
@ -1744,24 +1760,44 @@ function luckysheetcolsdbclick() {
for(let r = dataset_row_st; r <= dataset_row_ed; r++){
let cell = d[r][c];
if(cell == null || isRealNull(cell.v)){
if(cell == null || (isRealNull(cell.v) && !isInlineStringCell(cell)) ){
continue;
}
let fontset = luckysheetfontformat(cell);
canvas.font = fontset;
// let fontset = luckysheetfontformat(cell);
// canvas.font = fontset;
// let value = getcellvalue(r, c, d, "m").toString(); //单元格文本
// let textMetrics = getMeasureText(value, canvas).width; //文本宽度
let value = getcellvalue(r, c, d, "m").toString(); //单元格文本
let textMetrics = getMeasureText(value, canvas).width; //文本宽度
// if(textMetrics + 6 > currentColLen){
// currentColLen = textMetrics + 6;
// }
if(textMetrics + 6 > currentColLen){
currentColLen = textMetrics + 6;
let cellWidth = colLocationByIndex(c)[1] - colLocationByIndex(c)[0] - 2;
let textInfo = getCellTextInfo(cell, canvas,{
r:r,
c:c,
cellWidth:cellWidth
});
let computeRowlen = 0;
// console.log("rowlen", textInfo);
if(textInfo!=null){
computeRowlen = textInfo.textWidthAll;
}
if(computeRowlen + 6 > currentColLen){
currentColLen = computeRowlen + 6;
}
}
if(currentColLen != Store.defaultcollen){
cfg["columnlen"][c] = currentColLen;
if(cfg["customWidth"]){
delete cfg["customWidth"][c];
}
}
matchColumn[c] = 1;

10
src/controllers/searchReplace.js

@ -476,6 +476,11 @@ const luckysheetSearchReplace = {
const _locale = locale();
const locale_findAndReplace = _locale.findAndReplace;
if(!Store.allowEdit){
tooltip.info(locale_findAndReplace.modeTip, "");
return;
}
let searchText = $("#luckysheet-search-replace #searchInput input").val();
if(searchText == "" || searchText == null){
if(isEditMode()){
@ -628,6 +633,11 @@ const luckysheetSearchReplace = {
const _locale = locale();
const locale_findAndReplace = _locale.findAndReplace;
if(!Store.allowEdit){
tooltip.info(locale_findAndReplace.modeTip, "");
return;
}
let searchText = $("#luckysheet-search-replace #searchInput input").val();
if(searchText == "" || searchText == null){
if(isEditMode()){

19
src/controllers/select.js

@ -3,6 +3,7 @@ import formula from '../global/formula';
import { dynamicArrayHightShow } from '../global/dynamicArray';
import { rowLocationByIndex, colLocationByIndex } from '../global/location';
import browser from '../global/browser';
import dataVerificationCtrl from './dataVerificationCtrl';
import { getSheetIndex, getRangetxt } from '../methods/get';
import Store from '../store';
import locale from '../locale/locale';
@ -163,6 +164,8 @@ function selectHightlightShow() {
);
//左上角选择区域框
formula.fucntionboxshow(rf, cf);
//focus单元格数据验证
dataVerificationCtrl.cellFocus(rf, cf);
}
}
@ -283,15 +286,19 @@ function selectTitlesRange(map) {
}
//选区是否重叠
function selectIsOverlap() {
function selectIsOverlap(range) {
if(range == null){
range = Store.luckysheet_select_save;
}
let overlap = false;
let map = {};
for(let s = 0; s < Store.luckysheet_select_save.length; s++){
let str_r = Store.luckysheet_select_save[s].row[0],
end_r = Store.luckysheet_select_save[s].row[1];
let str_c = Store.luckysheet_select_save[s].column[0],
end_c = Store.luckysheet_select_save[s].column[1];
for(let s = 0; s < range.length; s++){
let str_r = range[s].row[0],
end_r = range[s].row[1];
let str_c = range[s].column[0],
end_c = range[s].column[1];
for(let r = str_r; r <= end_r; r++){
for(let c = str_c; c <= end_c; c++){

278
src/controllers/selection.js

@ -26,7 +26,7 @@ const selection = {
Store.luckysheet_selection_range = [];
selectionCopyShow();
Store.luckysheet_copy_save = {};
// Store.luckysheet_copy_save = {};
if (!clipboardData) {
let textarea = $("#luckysheet-copy-content").css("visibility", "hidden");
@ -721,11 +721,19 @@ const selection = {
Store.luckysheet_select_save = [{ "row": [minh, maxh], "column": [minc, maxc] }];
if(addr > 0 || addc > 0 || RowlChange){
jfrefreshgrid(d, Store.luckysheet_select_save, cfg, null, true);
let allParam = {
"cfg": cfg,
"RowlChange": true
}
jfrefreshgrid(d, Store.luckysheet_select_save, allParam);
}
else{
jfrefreshgrid(d, Store.luckysheet_select_save, cfg);
let allParam = {
"cfg": cfg
}
jfrefreshgrid(d, Store.luckysheet_select_save, allParam);
selectHightlightShow();
}
}
@ -790,7 +798,10 @@ const selection = {
last["column"] = [curC, curC + clen - 1];
if (addr > 0 || addc > 0) {
jfrefreshgrid(d, Store.luckysheet_select_save, null, null, true);
let allParam = {
"RowlChange": true
}
jfrefreshgrid(d, Store.luckysheet_select_save, allParam);
}
else {
jfrefreshgrid(d, Store.luckysheet_select_save);
@ -799,9 +810,10 @@ const selection = {
}
},
pasteHandlerOfCutPaste: function(copyRange){
if(Store.allowEdit===false){
if(Store.allowEdit === false){
return;
}
let cfg = $.extend(true, {}, Store.config);
if(cfg["merge"] == null){
cfg["merge"] = {};
@ -810,9 +822,14 @@ const selection = {
//复制范围
let copyHasMC = copyRange["HasMC"];
let copyRowlChange = copyRange["RowlChange"];
let copySheetIndex = copyRange["dataSheetIndex"];
let copyData = $.extend(true, [], getdatabyselection({"row": copyRange["copyRange"][0].row, "column": copyRange["copyRange"][0].column}, copySheetIndex));
let c_r1 = copyRange["copyRange"][0].row[0],
c_r2 = copyRange["copyRange"][0].row[1],
c_c1 = copyRange["copyRange"][0].column[0],
c_c2 = copyRange["copyRange"][0].column[1];
let copyData = $.extend(true, [], getdatabyselection({"row": [c_r1, c_r2], "column": [c_c1, c_c2]}, copySheetIndex));
let copyh = copyData.length, copyc = copyData[0].length;
@ -847,11 +864,13 @@ const selection = {
}
let borderInfoCompute = getBorderInfoCompute(copySheetIndex);
let c_dataVerification = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(copySheetIndex)]["dataVerification"]);
let dataVerification = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dataVerification"]);
//剪切粘贴在当前表操作,删除剪切范围内数据和合并单元格
//剪切粘贴在当前表操作,删除剪切范围内数据、合并单元格和数据验证
if(Store.currentSheetIndex == copySheetIndex){
for(let i = copyRange["copyRange"][0].row[0]; i <= copyRange["copyRange"][0].row[1]; i++){
for(let j = copyRange["copyRange"][0].column[0]; j <= copyRange["copyRange"][0].column[1]; j++){
for(let i = c_r1; i <= c_r2; i++){
for(let j = c_c1; j <= c_c2; j++){
let cell = d[i][j];
if(getObjType(cell) == "object" && ("mc" in cell)){
@ -862,6 +881,8 @@ const selection = {
}
d[i][j] = null;
delete dataVerification[i + "_" + j];
}
}
@ -877,7 +898,12 @@ const selection = {
let bd_emptyRange = [];
for(let j = 0; j < bd_range.length; j++){
bd_emptyRange = bd_emptyRange.concat(conditionformat.CFSplitRange(bd_range[j], {"row": copyRange["copyRange"][0].row, "column": copyRange["copyRange"][0].column}, {"row": [minh, maxh], "column": [minc, maxc]}, "restPart"));
bd_emptyRange = bd_emptyRange.concat(conditionformat.CFSplitRange(
bd_range[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]},
{"row": [minh, maxh], "column": [minc, maxc]},
"restPart"
));
}
cfg["borderInfo"][i].range = bd_emptyRange;
@ -888,7 +914,7 @@ const selection = {
let bd_r = cfg["borderInfo"][i].value.row_index;
let bd_c = cfg["borderInfo"][i].value.col_index;
if(!(bd_r >= copyRange["copyRange"][0].row[0] && bd_r <= copyRange["copyRange"][0].row[1] && bd_c >= copyRange["copyRange"][0].column[0] && bd_c <= copyRange["copyRange"][0].column[1])){
if(!(bd_r >= c_r1 && bd_r <= c_r2 && bd_c >= c_c1 && bd_c <= c_c2)){
source_borderInfo.push(cfg["borderInfo"][i]);
}
}
@ -903,16 +929,16 @@ const selection = {
let x = [].concat(d[h]);
for (let c = minc; c <= maxc; c++) {
if(borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - minh) + "_" + (copyRange["copyRange"][0].column[0] + c - minc)]){
if(borderInfoCompute[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)]){
let bd_obj = {
"rangeType": "cell",
"value": {
"row_index": h,
"col_index": c,
"l": borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - minh) + "_" + (copyRange["copyRange"][0].column[0] + c - minc)].l,
"r": borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - minh) + "_" + (copyRange["copyRange"][0].column[0] + c - minc)].r,
"t": borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - minh) + "_" + (copyRange["copyRange"][0].column[0] + c - minc)].t,
"b": borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - minh) + "_" + (copyRange["copyRange"][0].column[0] + c - minc)].b
"l": borderInfoCompute[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)].l,
"r": borderInfoCompute[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)].r,
"t": borderInfoCompute[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)].t,
"b": borderInfoCompute[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)].b
}
}
@ -942,6 +968,11 @@ const selection = {
cfg["borderInfo"].push(bd_obj);
}
//数据验证 剪切
if(c_dataVerification[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)]){
dataVerification[h + "_" + c] = c_dataVerification[(c_r1 + h - minh) + "_" + (c_c1 + c - minc)];
}
if(getObjType(x[c]) == "object" && ("mc" in x[c])){
if("rs" in x[c].mc){
delete cfg["merge"][x[c]["mc"].r + "_" + x[c]["mc"].c];
@ -983,7 +1014,7 @@ const selection = {
cfg = rowlenByRange(d, minh, maxh, cfg);
}
else{
cfg = rowlenByRange(d, copyRange["copyRange"][0].row[0], copyRange["copyRange"][0].row[1], cfg);
cfg = rowlenByRange(d, c_r1, c_r2, cfg);
cfg = rowlenByRange(d, minh, maxh, cfg);
}
}
@ -1000,13 +1031,8 @@ const selection = {
sourceCurConfig["merge"] = {};
}
let source_r1 = copyRange["copyRange"][0].row[0],
source_r2 = copyRange["copyRange"][0].row[1];
let source_c1 = copyRange["copyRange"][0].column[0],
source_c2 = copyRange["copyRange"][0].column[1];
for(let source_r = source_r1; source_r <= source_r2; source_r++){
for(let source_c = source_c1; source_c <= source_c2; source_c++){
for(let source_r = c_r1; source_r <= c_r2; source_r++){
for(let source_c = c_c1; source_c <= c_c2; source_c++){
let cell = sourceCurData[source_r][source_c];
if(getObjType(cell) == "object" && ("mc" in cell)){
@ -1020,7 +1046,7 @@ const selection = {
}
if(copyRowlChange){
sourceCurConfig = rowlenByRange(sourceCurData, source_r1, source_r2, sourceCurConfig);
sourceCurConfig = rowlenByRange(sourceCurData, c_r1, c_r2, sourceCurConfig);
}
//边框
@ -1035,7 +1061,12 @@ const selection = {
let bd_emptyRange = [];
for(let j = 0; j < bd_range.length; j++){
bd_emptyRange = bd_emptyRange.concat(conditionformat.CFSplitRange(bd_range[j], {"row": copyRange["copyRange"][0].row, "column": copyRange["copyRange"][0].column}, {"row": [minh, maxh], "column": [minc, maxc]}, "restPart"));
bd_emptyRange = bd_emptyRange.concat(conditionformat.CFSplitRange(
bd_range[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]},
{"row": [minh, maxh], "column": [minc, maxc]},
"restPart"
));
}
sourceCurConfig["borderInfo"][i].range = bd_emptyRange;
@ -1046,7 +1077,7 @@ const selection = {
let bd_r = sourceCurConfig["borderInfo"][i].value.row_index;
let bd_c = sourceCurConfig["borderInfo"][i].value.col_index;
if(!(bd_r >= copyRange["copyRange"][0].row[0] && bd_r <= copyRange["copyRange"][0].row[1] && bd_c >= copyRange["copyRange"][0].column[0] && bd_c <= copyRange["copyRange"][0].column[1])){
if(!(bd_r >= c_r1 && bd_r <= c_r2 && bd_c >= c_c1 && bd_c <= c_c2)){
source_borderInfo.push(sourceCurConfig["borderInfo"][i]);
}
}
@ -1066,10 +1097,22 @@ const selection = {
let emptyRange2 = [];
for(let j = 0; j < source_curCdformat_cellrange.length; j++){
let range = conditionformat.CFSplitRange(source_curCdformat_cellrange[j], {"row": copyRange["copyRange"][0].row, "column": copyRange["copyRange"][0].column}, {"row": [minh, maxh], "column": [minc, maxc]}, "restPart");
let range = conditionformat.CFSplitRange(
source_curCdformat_cellrange[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]},
{"row": [minh, maxh], "column": [minc, maxc]},
"restPart"
);
emptyRange = emptyRange.concat(range);
let range2 = conditionformat.CFSplitRange(source_curCdformat_cellrange[j], {"row": copyRange["copyRange"][0].row, "column": copyRange["copyRange"][0].column}, {"row": [minh, maxh], "column": [minc, maxc]}, "operatePart");
let range2 = conditionformat.CFSplitRange(
source_curCdformat_cellrange[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]},
{"row": [minh, maxh], "column": [minc, maxc]},
"operatePart"
);
if(range2.length > 0){
emptyRange2 = emptyRange2.concat(range2);
}
@ -1091,6 +1134,13 @@ const selection = {
target_curCdformat = target_curCdformat.concat(ruleArr);
}
//数据验证
for(let i = c_r1; i <= c_r2; i++){
for(let j = c_c1; j <= c_c2; j++){
delete c_dataVerification[i + "_" + j];
}
}
source = {
"sheetIndex": copySheetIndex,
"data": sourceData,
@ -1099,9 +1149,11 @@ const selection = {
"curConfig": sourceCurConfig,
"cdformat": source_cdformat,
"curCdformat": source_curCdformat,
"dataVerification": $.extend(true, {}, Store.luckysheetfile[getSheetIndex(copySheetIndex)]["dataVerification"]),
"curDataVerification": c_dataVerification,
"range": {
"row": copyRange["copyRange"][0].row,
"column": copyRange["copyRange"][0].column
"row": [c_r1, c_r2],
"column": [c_c1, c_c2]
}
}
target = {
@ -1112,6 +1164,8 @@ const selection = {
"curConfig": cfg,
"cdformat": target_cdformat,
"curCdformat": target_curCdformat,
"dataVerification": $.extend(true, {}, Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dataVerification"]),
"curDataVerification": dataVerification,
"range": {
"row": [minh, maxh],
"column": [minc, maxc]
@ -1128,7 +1182,13 @@ const selection = {
let emptyRange = [];
for(let j = 0; j < cellrange.length; j++){
let range = conditionformat.CFSplitRange(cellrange[j], {"row": copyRange["copyRange"][0].row, "column": copyRange["copyRange"][0].column}, {"row": [minh, maxh], "column": [minc, maxc]}, "allPart");
let range = conditionformat.CFSplitRange(
cellrange[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]},
{"row": [minh, maxh], "column": [minc, maxc]},
"allPart"
);
emptyRange = emptyRange.concat(range);
}
@ -1145,9 +1205,11 @@ const selection = {
"curConfig": cfg,
"cdformat": cdformat,
"curCdformat": curCdformat,
"dataVerification": $.extend(true, {}, Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dataVerification"]),
"curDataVerification": dataVerification,
"range": {
"row": copyRange["copyRange"][0].row,
"column": copyRange["copyRange"][0].column
"row": [c_r1, c_r2],
"column": [c_c1, c_c2]
}
}
target = {
@ -1158,6 +1220,8 @@ const selection = {
"curConfig": cfg,
"cdformat": cdformat,
"curCdformat": curCdformat,
"dataVerification": $.extend(true, {}, Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dataVerification"]),
"curDataVerification": dataVerification,
"range": {
"row": [minh, maxh],
"column": [minc, maxc]
@ -1183,11 +1247,16 @@ const selection = {
let copyRowlChange = copyRange["RowlChange"];
let copySheetIndex = copyRange["dataSheetIndex"];
let c_r1 = copyRange["copyRange"][0].row[0],
c_r2 = copyRange["copyRange"][0].row[1],
c_c1 = copyRange["copyRange"][0].column[0],
c_c2 = copyRange["copyRange"][0].column[1];
let arr = [], isSameRow = false;
for(let i = 0; i < copyRange["copyRange"].length; i++){
let arrData = getdatabyselection({"row": copyRange["copyRange"][i].row, "column": copyRange["copyRange"][i].column}, copySheetIndex);
if(copyRange["copyRange"].length > 1){
if(copyRange["copyRange"][0].row[0] == copyRange["copyRange"][1].row[0] && copyRange["copyRange"][0].row[1] == copyRange["copyRange"][1].row[1]){
if(c_r1 == copyRange["copyRange"][1].row[0] && c_r2 == copyRange["copyRange"][1].row[1]){
arrData = arrData[0].map(function(col, a){
return arrData.map(function(row){
return row[a];
@ -1198,7 +1267,7 @@ const selection = {
isSameRow = true;
}
else if(copyRange["copyRange"][0].column[0] == copyRange["copyRange"][1].column[0] && copyRange["copyRange"][0].column[1] == copyRange["copyRange"][1].column[1]){
else if(c_c1 == copyRange["copyRange"][1].column[0] && c_c2 == copyRange["copyRange"][1].column[1]){
arr = arr.concat(arrData);
}
}
@ -1274,6 +1343,8 @@ const selection = {
}
let borderInfoCompute = getBorderInfoCompute(copySheetIndex);
let c_dataVerification = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(copySheetIndex)].dataVerification);
let dataVerification = null;
let mth = 0, mtc = 0, maxcellCahe = 0, maxrowCache = 0;
for(let th = 1; th <= timesH; th++){
@ -1284,24 +1355,24 @@ const selection = {
maxcellCahe = minc + tc * copyc;
//行列位移值 用于单元格有函数
let offsetRow = mth - copyRange["copyRange"][0].row[0];
let offsetCol = mtc - copyRange["copyRange"][0].column[0];
let offsetRow = mth - c_r1;
let offsetCol = mtc - c_c1;
let offsetMC = {};
for (let h = mth; h < maxrowCache; h++) {
let x = [].concat(d[h]);
for (let c = mtc; c < maxcellCahe; c++) {
if(borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - mth) + "_" + (copyRange["copyRange"][0].column[0] + c - mtc)]){
if(borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]){
let bd_obj = {
"rangeType": "cell",
"value": {
"row_index": h,
"col_index": c,
"l": borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - mth) + "_" + (copyRange["copyRange"][0].column[0] + c - mtc)].l,
"r": borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - mth) + "_" + (copyRange["copyRange"][0].column[0] + c - mtc)].r,
"t": borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - mth) + "_" + (copyRange["copyRange"][0].column[0] + c - mtc)].t,
"b": borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - mth) + "_" + (copyRange["copyRange"][0].column[0] + c - mtc)].b
"l": borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)].l,
"r": borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)].r,
"t": borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)].t,
"b": borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)].b
}
}
@ -1331,6 +1402,15 @@ const selection = {
cfg["borderInfo"].push(bd_obj);
}
//数据验证 复制
if(c_dataVerification[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]){
if(dataVerification == null){
dataVerification = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].dataVerification)
}
dataVerification[h + "_" + c] = c_dataVerification[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)];
}
if(getObjType(x[c]) == "object" && "mc" in x[c]){
if("rs" in x[c].mc){
delete cfg["merge"][x[c]["mc"].r + "_" + x[c]["mc"].c];
@ -1401,21 +1481,17 @@ const selection = {
}
}
//复制范围 是否有 条件格式
let ruleArr_cf = [], cdformat = [];
//复制范围 是否有 条件格式和数据验证
let cdformat = null;
if(copyRange["copyRange"].length == 1){
let c_file = Store.luckysheetfile[getSheetIndex(copySheetIndex)];
let a_file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
let c_r1 = copyRange["copyRange"][0].row[0],
c_r2 = copyRange["copyRange"][0].row[1],
c_c1 = copyRange["copyRange"][0].column[0],
c_c2 = copyRange["copyRange"][0].column[1];
ruleArr_cf = $.extend(true, [], c_file["luckysheet_conditionformat_save"]);
cdformat = $.extend(true, [], a_file["luckysheet_conditionformat_save"]);
let ruleArr_cf = $.extend(true, [], c_file["luckysheet_conditionformat_save"]);
if(ruleArr_cf != null && ruleArr_cf.length > 0){
cdformat = $.extend(true, [], a_file["luckysheet_conditionformat_save"]);
for(let i = 0; i < ruleArr_cf.length; i++){
let cf_range = ruleArr_cf[i].cellrange;
@ -1429,7 +1505,13 @@ const selection = {
maxcellCahe = minc + tc * copyc;
for(let j = 0; j < cf_range.length; j++){
let range = conditionformat.CFSplitRange(cf_range[j], {"row": [c_r1, c_r2], "column": [c_c1, c_c2]}, {"row": [mth, maxrowCache - 1], "column": [mtc, maxcellCahe - 1]}, "operatePart");
let range = conditionformat.CFSplitRange(
cf_range[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]},
{"row": [mth, maxrowCache - 1], "column": [mtc, maxcellCahe - 1]},
"operatePart"
);
if(range.length > 0){
emptyRange = emptyRange.concat(range);
}
@ -1451,21 +1533,22 @@ const selection = {
if(copyRowlChange || addr > 0 || addc > 0){
cfg = rowlenByRange(d, minh, maxh, cfg);
if(copyRange["copyRange"].length == 1 && ruleArr_cf != null && ruleArr_cf.length > 0){
jfrefreshgrid(d, Store.luckysheet_select_save, cfg, cdformat, true);
}
else{
jfrefreshgrid(d, Store.luckysheet_select_save, cfg, null, true);
let allParam = {
"cfg": cfg,
"RowlChange": true,
"cdformat": cdformat,
"dataVerification": dataVerification
}
jfrefreshgrid(d, Store.luckysheet_select_save, allParam);
}
else{
if(copyRange["copyRange"].length == 1 && ruleArr_cf != null && ruleArr_cf.length > 0){
jfrefreshgrid(d, Store.luckysheet_select_save, cfg, cdformat);
}
else{
jfrefreshgrid(d, Store.luckysheet_select_save, cfg);
let allParam = {
"cfg": cfg,
"cdformat": cdformat,
"dataVerification": dataVerification
}
jfrefreshgrid(d, Store.luckysheet_select_save, allParam);
selectHightlightShow();
}
},
@ -1478,9 +1561,14 @@ const selection = {
//复制范围
let copyHasMC = copyRange["HasMC"];
let copyRowlChange = copyRange["RowlChange"];
let copySheetIndex = copyRange["dataSheetIndex"];
let copyData = $.extend(true, [], getdatabyselection({"row": copyRange["copyRange"][0].row, "column": copyRange["copyRange"][0].column}, copySheetIndex));
let c_r1 = copyRange["copyRange"][0].row[0],
c_r2 = copyRange["copyRange"][0].row[1],
c_c1 = copyRange["copyRange"][0].column[0],
c_c2 = copyRange["copyRange"][0].column[1];
let copyData = $.extend(true, [], getdatabyselection({"row": [c_r1, c_r2], "column": [c_c1, c_c2]}, copySheetIndex));
//应用范围
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
@ -1518,6 +1606,8 @@ const selection = {
let rowMaxLength = d.length;
let borderInfoCompute = getBorderInfoCompute(copySheetIndex);
let c_dataVerification = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(copySheetIndex)].dataVerification);
let dataVerification = null;
let mth = 0, mtc = 0, maxcellCahe = 0, maxrowCache = 0;
for (let th = 1; th <= timesH; th++) {
@ -1540,16 +1630,16 @@ const selection = {
let x = [].concat(d[h]);
for (let c = mtc; c < maxcellCahe; c++) {
if(borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - mth) + "_" + (copyRange["copyRange"][0].column[0] + c - mtc)]){
if(borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]){
let bd_obj = {
"rangeType": "cell",
"value": {
"row_index": h,
"col_index": c,
"l": borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - mth) + "_" + (copyRange["copyRange"][0].column[0] + c - mtc)].l,
"r": borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - mth) + "_" + (copyRange["copyRange"][0].column[0] + c - mtc)].r,
"t": borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - mth) + "_" + (copyRange["copyRange"][0].column[0] + c - mtc)].t,
"b": borderInfoCompute[(copyRange["copyRange"][0].row[0] + h - mth) + "_" + (copyRange["copyRange"][0].column[0] + c - mtc)].b
"l": borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)].l,
"r": borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)].r,
"t": borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)].t,
"b": borderInfoCompute[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)].b
}
}
@ -1579,6 +1669,15 @@ const selection = {
cfg["borderInfo"].push(bd_obj);
}
//数据验证 复制
if(c_dataVerification[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)]){
if(dataVerification == null){
dataVerification = $.extend(true, {}, Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].dataVerification)
}
dataVerification[h + "_" + c] = c_dataVerification[(c_r1 + h - mth) + "_" + (c_c1 + c - mtc)];
}
if(getObjType(x[c]) == "object" && ("mc" in x[c])){
if("rs" in x[c].mc){
delete cfg["merge"][x[c]["mc"].r + "_" + x[c]["mc"].c];
@ -1642,16 +1741,24 @@ const selection = {
}
//复制范围 是否有 条件格式
let cdformat = null;
let ruleArr = $.extend(true, [], Store.luckysheetfile[getSheetIndex(copySheetIndex)]["luckysheet_conditionformat_save"]);
let cdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]);
if(ruleArr != null && ruleArr.length > 0){
cdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]);
for(let i = 0; i < ruleArr.length; i++){
let cdformat_cellrange = ruleArr[i].cellrange;
let emptyRange = [];
for(let j = 0; j < cdformat_cellrange.length; j++){
let range = conditionformat.CFSplitRange(cdformat_cellrange[j], {"row": copyRange["copyRange"][0]["row"], "column": copyRange["copyRange"][0]["column"]}, {"row": [minh, maxh], "column": [minc, maxc]}, "operatePart");
let range = conditionformat.CFSplitRange(
cdformat_cellrange[j],
{"row": [c_r1, c_r2], "column": [c_c1, c_c2]},
{"row": [minh, maxh], "column": [minc, maxc]},
"operatePart"
);
if(range.length > 0){
emptyRange = emptyRange.concat(range);
}
@ -1670,21 +1777,22 @@ const selection = {
if(copyRowlChange){
cfg = rowlenByRange(d, minh, maxh, cfg);
if(ruleArr != null && ruleArr.length > 0){
jfrefreshgrid(d, Store.luckysheet_select_save, cfg, cdformat, true);
}
else{
jfrefreshgrid(d, Store.luckysheet_select_save, cfg, null, true);
let allParam = {
"cfg": cfg,
"RowlChange": true,
"cdformat": cdformat,
"dataVerification": dataVerification
}
jfrefreshgrid(d, Store.luckysheet_select_save, allParam);
}
else{
if(ruleArr != null && ruleArr.length > 0){
jfrefreshgrid(d, Store.luckysheet_select_save, cfg, cdformat);
}
else{
jfrefreshgrid(d, Store.luckysheet_select_save, cfg);
let allParam = {
"cfg": cfg,
"cdformat": cdformat,
"dataVerification": dataVerification
}
jfrefreshgrid(d, Store.luckysheet_select_save, allParam);
selectHightlightShow();
}
},

13
src/controllers/server.js

@ -714,15 +714,12 @@ const server = {
multipleRangeShow: function(id, name, r, c) {
let _this = this;
let r1 = r2 = r;
let c1 = c2 = c;
let row = Store.visibledatarow[r],
row_pre = r - 1 == -1 ? 0 : Store.visibledatarow[r - 1],
col = Store.visibledatacolumn[c],
col_pre = c - 1 == -1 ? 0 : Store.visibledatacolumn[c - 1];
let row = visibledatarow[r2],
row_pre = r1 - 1 == -1 ? 0 : visibledatarow[r1 - 1],
col = visibledatacolumn[c2],
col_pre = c1 - 1 == -1 ? 0 : visibledatacolumn[c1 - 1];
let margeset = menuButton.mergeborer(Store.flowdata, r1, c1);
let margeset = menuButton.mergeborer(Store.flowdata, r, c);
if(!!margeset){
row = margeset.row[1];
row_pre = margeset.row[0];

13
src/controllers/sheetBar.js

@ -11,6 +11,8 @@ import { isEditMode } from '../global/validate';
import formula from '../global/formula';
import cleargridelement from '../global/cleargridelement';
import tooltip from '../global/tooltip';
selectTextDom
import {selectTextDom} from '../global/cursorPos';
import locale from '../locale/locale';
import Store from '../store';
@ -206,16 +208,7 @@ export function initialSheetBar(){
$t.attr("contenteditable", "true").addClass("luckysheet-mousedown-cancel").data("oldtxt", $t.text());
setTimeout(function () {
if (document.selection) {
let range = document.body.createTextRange();
range.moveToElementText($t.get(0));
range.select();
} else if (window.getSelection) {
let range = document.createRange();
range.selectNodeContents($t.get(0));
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
}
selectTextDom($t.get(0));
}, 1);
}

38
src/controllers/sheetmanage.js

@ -18,6 +18,7 @@ import pivotTable from './pivotTable';
import luckysheetsizeauto from './resize';
import luckysheetPostil from './postil';
import imageCtrl from './imageCtrl';
import dataVerificationCtrl from './dataVerificationCtrl';
import luckysheetFreezen from './freezen';
import { createFilterOptions, labelFilterOptionState } from './filter';
import { selectHightlightShow, selectionCopyShow } from './select';
@ -864,13 +865,6 @@ const sheetmanage = {
formula.execFunctionGroupData = null;
window.luckysheet_getcelldata_cache = null;
//批注
luckysheetPostil.buildAllPs(Store.flowdata);
//图片
imageCtrl.images = file.images;
imageCtrl.allImagesShow();
this.sheetParamRestore(file, Store.flowdata);
if(file["freezen"] == null){
@ -883,10 +877,18 @@ const sheetmanage = {
}
rhchInit(Store.flowdata.length, Store.flowdata[0].length);
//批注
luckysheetPostil.buildAllPs(Store.flowdata);
//图片
imageCtrl.images = file.images;
imageCtrl.allImagesShow();
//数据验证
dataVerificationCtrl.dataVerification = file.dataVerification;
createFilterOptions(file["filter_select"], file["filter"]);
},
restoreselect: function() {
let index = this.getSheetIndex(Store.currentSheetIndex);
@ -1424,18 +1426,18 @@ const sheetmanage = {
let index = this.getSheetIndex(sheetIndex);
let file = Store.luckysheetfile[index];
if($('#luckysheet-filter-selected-sheet' + sheetIndex).length > 0 || file.filter_select == null || JSON.stringify(file.filter_select) == "{}"){
if(file.config != null && file.config.rowhidden != null){
file.config.rowhidden = {};
Store.config = file.config;
// if($('#luckysheet-filter-selected-sheet' + sheetIndex).length > 0 || file.filter_select == null || JSON.stringify(file.filter_select) == "{}"){
// if(file.config != null && file.config.rowhidden != null){
// file.config.rowhidden = {};
// Store.config = file.config;
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length,false);
}
// jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length,false);
// }
return;
}
// return;
// }
if(getObjType(file.filter_select) != "object"){
if(getObjType(file.filter_select) == "string"){
file.filter_select = JSON.parse(file.filter_select);
}

19
src/controllers/updateCell.js

@ -3,13 +3,15 @@ import luckysheetFreezen from './freezen';
import menuButton from './menuButton';
import conditionformat from './conditionformat';
import alternateformat from './alternateformat';
import dataVerificationCtrl from './dataVerificationCtrl';
import { chatatABC } from '../utils/util';
import { isEditMode } from '../global/validate';
import { getcellvalue } from '../global/getdata';
import { getcellvalue,getInlineStringStyle } from '../global/getdata';
import { valueShowEs } from '../global/format';
import formula from '../global/formula';
import { luckysheetRangeLast } from '../global/cursorPos';
import cleargridelement from '../global/cleargridelement';
import {isInlineStringCell} from './inlineString';
import Store from '../store';
export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocus) {
@ -17,6 +19,16 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
return;
}
if(dataVerificationCtrl.dataVerification != null && dataVerificationCtrl.dataVerification[row_index1 + '_' + col_index1] != null){
let dataVerificationItem = dataVerificationCtrl.dataVerification[row_index1 + '_' + col_index1];
if(dataVerificationItem.type == 'dropdown'){
dataVerificationCtrl.dropdownListShow();
}
else if(dataVerificationItem.type == 'checkbox'){
return;
}
}
let size = getColumnAndRowSize(row_index1, col_index1, d);
let row = size.row, row_pre = size.row_pre, col = size.col, col_pre = size.col_pre, row_index = size.row_index, col_index = size.col_index;
@ -124,7 +136,10 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
if (!cover) {
if(cell.f!=null){
if(isInlineStringCell(cell)){
value = getInlineStringStyle(row_index, col_index, d);
}
else if(cell.f!=null){
value = getcellvalue(row_index, col_index, d, "f");
}
else{

175
src/css/luckysheet-core.css

@ -7049,4 +7049,177 @@ fieldset[disabled] .btn-danger.focus {
margin-left: 5px;
margin-bottom: -5px;
cursor: pointer;
}
}
/* 数据验证 */
#luckysheet-dataVerification-dialog{
user-select: none;
}
#luckysheet-dataVerification-dialog .box{
font-size: 12px;
}
#luckysheet-dataVerification-dialog .box select{
width: 100%;
height: 30px;
border-color: #d4d4d4;
outline-style: none;
}
#luckysheet-dataVerification-dialog .box input::-webkit-input-placeholder {
color: #d4d4d4;
}
#luckysheet-dataVerification-dialog .box input:-moz-placeholder {
color: #d4d4d4;
}
#luckysheet-dataVerification-dialog .box input::-moz-placeholder {
color: #d4d4d4;
}
#luckysheet-dataVerification-dialog .box input:-ms-input-placeholder {
color: #d4d4d4;
}
#luckysheet-dataVerification-dialog .box-item{
padding: 10px;
border-bottom: 1px solid #E1E4E8;
}
#luckysheet-dataVerification-dialog .box-item .box-item-title{
font-size: 14px;
font-weight: 600;
margin-bottom: 10px;
}
#luckysheet-dataVerification-dialog .box-item .range{
width: 100%;
height: 30px;
border: 1px solid #d4d4d4;
}
#luckysheet-dataVerification-dialog .box-item .range input{
width: calc(100% - 30px);
height: 30px;
padding: 0 10px;
float: left;
border: none;
outline-style: none;
box-sizing: border-box;
}
#luckysheet-dataVerification-dialog .box-item .range i.fa-table{
float: right;
margin-top: 9px;
margin-right: 5px;
cursor: pointer;
color: #6598F3;
}
#luckysheet-dataVerification-dialog .box-item .show-box{
margin-top: 10px;
}
#luckysheet-dataVerification-dialog .box-item .check-box{
height: 30px;
line-height: 30px;
margin-bottom: 10px;
}
#luckysheet-dataVerification-dialog .box-item .check-box:last-child{
margin-bottom: 0;
}
#luckysheet-dataVerification-dialog .box-item .check-box input{
height: 30px;
padding: 0 10px;
border: 1px solid #d4d4d4;
box-sizing: border-box;
}
#luckysheet-dataVerification-dialog .box-item .check{
line-height: 30px;
}
#luckysheet-dataVerification-dialog .box-item .check input{
vertical-align: text-top;
}
#luckysheet-dataVerification-dialog .box-item .input{
height: 30px;
line-height: 30px;
margin-top: 10px;
}
#luckysheet-dataVerification-dialog .box-item .input input{
height: 30px;
padding: 4px 10px 4px 10px;
border: 1px solid #d4d4d4;
box-sizing: border-box;
}
#luckysheet-dataVerification-dialog .box-item .input1 input{
width: 150px;
}
#luckysheet-dataVerification-dialog .box-item .input2 input{
width: 100%;
}
#luckysheet-dataVerification-dialog .box-item .input span{
display: inline-block;
width: 30px;
text-align: center;
}
#luckysheet-dataVerification-dialog .data-verification-hint-text{
width: 100%;
height: 30px;
border: 1px solid #d4d4d4;
margin-top: 10px;
}
#luckysheet-dataVerification-dialog .data-verification-hint-text input{
display: block;
width: 100%;
height: 100%;
padding: 0 10px;
border: none;
outline-style: none;
box-sizing: border-box;
}
#luckysheet-dataVerification-dialog .show-box .show-box-item{
display: none;
}
#luckysheet-dataVerificationRange-dialog input{
height: 30px;
padding: 0 10px;
border: 1px solid #d4d4d4;
outline-style: none;
}
#luckysheet-dataVerification-dropdown-btn{
display: none;
width: 20px;
height: 20px;
background-color: #fff;
position: absolute;
z-index: 10;
overflow: hidden;
}
#luckysheet-dataVerification-dropdown-btn::after{
content: '';
width: 10px;
height: 10px;
background: url(arrow-down.png) center no-repeat;
position: absolute;
left: 50%;
top: 50%;
margin-left: -5px;
margin-top: -5px;
}
#luckysheet-dataVerification-dropdown-List{
display: none;
background-color: #fff;
border: 1px solid #ccc;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
position: absolute;
z-index: 1000;
box-sizing: border-box;
}
#luckysheet-dataVerification-dropdown-List .dropdown-List-item{
padding: 5px 10px;
box-sizing: border-box;
cursor: pointer;
}
#luckysheet-dataVerification-dropdown-List .dropdown-List-item:hover{
background-color: #E1E1E1;
}
#luckysheet-dataVerification-showHintBox{
display: none;
padding: 10px;
background-color: #fff;
border: 1px solid #ccc;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
position: absolute;
z-index: 1000;
user-select: none;
cursor: default;
white-space: nowrap;
}

2
src/function/functionImplementation.js

@ -15806,7 +15806,7 @@ const functionImplementation = {
values = values.concat(func_methods.getDataArr(data_values, false));
}
else if(getObjType(data_values) == "object" && data_values.startCell != null){
values = values.concat(func_methods.getCellDataArr(data_values, "number", false));
values = values.concat(func_methods.getCellDataArr(data_values, "number", true));
}
else{
values.push(data_values);

724
src/global/api.js

File diff suppressed because it is too large

72
src/global/cursorPos.js

@ -1,3 +1,5 @@
import Store from '../store';
function luckysheetRangeLast(obj) {
let range;
@ -45,7 +47,77 @@ function getCursortPosition(textDom){
return cursorPos;
}
function hideMenuByCancel(event){
if (!$(event.target).hasClass("luckysheet-mousedown-cancel") && $(event.target).filter("[class*='sp-palette']").length == 0 && $(event.target).filter("[class*='sp-thumb']").length == 0 && $(event.target).filter("[class*='sp-']").length == 0) {
$("#luckysheet-rightclick-menu").hide();
$("#luckysheet-cols-h-hover").hide();
$("#luckysheet-cols-menu-btn").hide();
$("#luckysheet-rightclick-menu").hide();
$("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu, #luckysheet-user-menu").hide();
$("body > .luckysheet-filter-menu, body > .luckysheet-filter-submenu, body > .luckysheet-cols-menu").hide();
//$("body > luckysheet-menuButton").hide();
Store.luckysheet_cols_menu_status = false;
}
}
function selectTextDom(ele){
if (window.getSelection) {
let range = document.createRange();
range.selectNodeContents(ele);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
}
else if (document.selection) {
let range = document.body.createTextRange();
range.moveToElementText(ele);
range.select();
}
}
function selectTextContent(ele){
if (window.getSelection) {
let range = document.createRange();
var content=ele.firstChild;
range.setStart(content,0);
range.setEnd(content,content.length);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
}
else if (document.selection) {
let range = document.body.createTextRange();
range.moveToElementText(ele);
range.select();
}
}
function selectTextContentCross(sEle, eEle){
if (window.getSelection) {
let range = document.createRange();
var sContent=sEle.firstChild, eContent=eEle.firstChild;
range.setStart(sContent,0);
range.setEnd(eContent,eContent.length);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
}
}
function selectTextContentCollapse(sEle, index){
if (window.getSelection) {
let range = document.createRange();
var sContent=sEle.firstChild;
range.setStart(sContent,index);
range.collapse(true);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
}
}
export {
luckysheetRangeLast,
getCursortPosition,
hideMenuByCancel,
selectTextContent,
selectTextDom,
selectTextContentCross,
selectTextContentCollapse
}

153
src/global/draw.js

@ -3,16 +3,18 @@ import conditionformat from '../controllers/conditionformat';
import alternateformat from '../controllers/alternateformat';
import luckysheetSparkline from '../controllers/sparkline';
import menuButton from '../controllers/menuButton';
import dataVerificationCtrl from '../controllers/dataVerificationCtrl';
import { luckysheetdefaultstyle, luckysheet_CFiconsImg,luckysheetdefaultFont } from '../controllers/constant';
import { luckysheet_searcharray } from '../controllers/sheetSearch';
import { dynamicArrayCompute } from './dynamicArray';
import browser from './browser';
import { isRealNull, isRealNum } from './validate';
import { getCellTextSplitArr,getMeasureText,getCellTextInfo } from './getRowlen';
import { getcellvalue } from './getdata';
import { getcellvalue,getRealCellValue } from './getdata';
import { getBorderInfoCompute } from './border';
import { getSheetIndex } from '../methods/get';
import { getObjType, chatatABC, luckysheetfontformat } from '../utils/util';
import { isInlineStringCell } from '../controllers/inlineString';
import Store from '../store';
import locale from '../locale/locale';
@ -674,10 +676,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
// continue;
}
else{
value = getcellvalue(r, c, null, "m");
if(value == null){
value = getcellvalue(r, c);
}
value = getRealCellValue(r,c);
}
if(value == null || value.toString().length == 0){
@ -718,11 +717,13 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
let value = null;
let margeMaindata = cell["mc"];
value = getcellvalue(margeMaindata.r, margeMaindata.c, null, "m");
// value = getcellvalue(margeMaindata.r, margeMaindata.c, null, "m");
if(value == null){
value = getcellvalue(margeMaindata.r, margeMaindata.c);
}
// if(value == null){
// value = getcellvalue(margeMaindata.r, margeMaindata.c);
// }
value = getRealCellValue(margeMaindata.r,margeMaindata.c);
r = margeMaindata.r;
c = margeMaindata.c;
@ -1180,7 +1181,6 @@ let nullCellRender = function(r, c, start_r, start_c, end_r, end_c,luckysheetTab
let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckysheetTableContent,af_compute, cf_compute,offsetLeft,offsetTop,dynamicArray_compute,cellOverflowMap, dataset_col_st, dataset_col_ed,scrollHeight,scrollWidth,bodrder05,isMerge){
let cell = Store.flowdata[r][c];
let cellWidth = end_c - start_c - 2;
let cellHeight = end_r - start_r - 2;
@ -1219,8 +1219,32 @@ let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckyshee
(start_r + offsetTop + borderfix[1]),
(end_c - start_c + borderfix[2]-(!!isMerge?1:0)),
(end_r - start_r + borderfix[3])
];
luckysheetTableContent.fillRect(cellsize[0], cellsize[1], cellsize[2], cellsize[3]);
];
luckysheetTableContent.fillRect(cellsize[0], cellsize[1], cellsize[2], cellsize[3]);
let dataVerification = dataVerificationCtrl.dataVerification;
if(dataVerification != null && dataVerification[r + '_' + c] != null && !dataVerificationCtrl.validateCellData(value, dataVerification[r + '_' + c])){
//单元格左上角红色小三角标示
let dv_w = 5 * Store.zoomRatio, dv_h = 5 * Store.zoomRatio; //红色小三角宽高
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
(start_c + offsetLeft),
(start_r + offsetTop)
);
luckysheetTableContent.lineTo(
(start_c + offsetLeft + dv_w),
(start_r + offsetTop)
);
luckysheetTableContent.lineTo(
(start_c + offsetLeft),
(start_r + offsetTop + dv_h)
);
luckysheetTableContent.fillStyle = "#FC6666";
luckysheetTableContent.fill();
luckysheetTableContent.closePath();
}
//若单元格有批注(单元格右上角红色小三角标示)
if(cell.ps != null){
@ -1266,7 +1290,6 @@ let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckyshee
luckysheetTableContent.closePath();
}
//溢出单元格
let cellOverflow_bd_r_render = true; //溢出单元格右边框是否需要绘制
let cellOverflow_colInObj = cellOverflow_colIn(cellOverflowMap, r, c, dataset_col_st, dataset_col_ed);
@ -1288,6 +1311,79 @@ let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckyshee
cellOverflow_bd_r_render = false;
}
}
//数据验证 复选框
else if(dataVerification != null && dataVerification[r + '_' + c] != null && dataVerification[r + '_' + c].type == 'checkbox'){
let pos_x = start_c + offsetLeft;
let pos_y = start_r + offsetTop + 1;
luckysheetTableContent.save();
luckysheetTableContent.beginPath();
luckysheetTableContent.rect(pos_x, pos_y, cellWidth, cellHeight);
luckysheetTableContent.clip();
luckysheetTableContent.scale(Store.zoomRatio,Store.zoomRatio);
let measureText = getMeasureText(value, luckysheetTableContent);
let textMetrics = measureText.width + 14;
let oneLineTextHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;
let horizonAlignPos = (pos_x + space_width) ; //默认为1,左对齐
if(horizonAlign == "0"){ //居中对齐
horizonAlignPos = (pos_x + cellWidth / 2) - (textMetrics / 2);
}
else if(horizonAlign == "2"){ //右对齐
horizonAlignPos = (pos_x + cellWidth - space_width) - textMetrics;
}
let verticalCellHeight = cellHeight > oneLineTextHeight ? cellHeight : oneLineTextHeight;
let verticalAlignPos_text = (pos_y + verticalCellHeight - space_height) ; //文本垂直方向基准线
luckysheetTableContent.textBaseline = "bottom";
let verticalAlignPos_checkbox = verticalAlignPos_text - 13;
if(verticalAlign == "0"){ //居中对齐
verticalAlignPos_text = (pos_y + verticalCellHeight / 2);
luckysheetTableContent.textBaseline = "middle";
verticalAlignPos_checkbox = verticalAlignPos_text - 6;
}
else if(verticalAlign == "1"){ //上对齐
verticalAlignPos_text = (pos_y + space_height);
luckysheetTableContent.textBaseline = "top";
verticalAlignPos_checkbox = verticalAlignPos_text + 1;
}
horizonAlignPos = horizonAlignPos / Store.zoomRatio;
verticalAlignPos_text = verticalAlignPos_text / Store.zoomRatio;
verticalAlignPos_checkbox = verticalAlignPos_checkbox / Store.zoomRatio;
//复选框
luckysheetTableContent.lineWidth = 1;
luckysheetTableContent.strokeStyle = "#000";
luckysheetTableContent.strokeRect(horizonAlignPos, verticalAlignPos_checkbox, 10, 10);
if(dataVerification[r + '_' + c].checked){
luckysheetTableContent.beginPath();
luckysheetTableContent.lineTo(
horizonAlignPos + 1,
verticalAlignPos_checkbox + 6
);
luckysheetTableContent.lineTo(
horizonAlignPos + 4,
verticalAlignPos_checkbox + 9
);
luckysheetTableContent.lineTo(
horizonAlignPos + 9,
verticalAlignPos_checkbox + 2
);
luckysheetTableContent.stroke();
luckysheetTableContent.closePath();
}
//文本
luckysheetTableContent.fillStyle = menuButton.checkstatus(Store.flowdata, r, c , "fc");
luckysheetTableContent.fillText(value == null ? "" : value, horizonAlignPos + 14, verticalAlignPos_text);
luckysheetTableContent.restore();
}
else{
//若单元格有条件格式数据条
if(checksCF != null && checksCF["dataBar"] != null){
@ -1802,7 +1898,7 @@ function getCellOverflowMap(canvas, col_st, col_ed, row_st, row_end){
continue
}
if(cell != null && !isRealNull(cell.v) && cell.mc == null && cell.tb == '1'){
if(cell != null && (!isRealNull(cell.v) || isInlineStringCell(cell) ) && cell.mc == null && cell.tb == '1'){
// let fontset = luckysheetfontformat(cell);
// canvas.font = fontset;
@ -2052,21 +2148,28 @@ function cellTextRender(textInfo, ctx, option){
// ctx.fillStyle = "rgb(0,0,0)";
for(let i=0;i<values.length;i++){
let word = values[i];
ctx.font = word.style;
if(word.inline===true && word.style!=null){
ctx.font = word.style.fontset;
ctx.fillStyle = word.style.fc;
}
else{
ctx.font = word.style;
}
ctx.fillText(word.content, (pos_x + word.left)/Store.zoomRatio, (pos_y+word.top)/Store.zoomRatio);
if(word.cancelLine!=null){
let c = word.cancelLine;
ctx.beginPath();
ctx.moveTo(
(pos_x +c.startX)/Store.zoomRatio ,
(pos_y+c.startY)/Store.zoomRatio
Math.floor((pos_x +c.startX)/Store.zoomRatio)+0.5 ,
Math.floor((pos_y+c.startY)/Store.zoomRatio)+0.5 ,
);
ctx.lineTo(
(pos_x +c.endX)/Store.zoomRatio,
(pos_y+c.endY)/Store.zoomRatio
Math.floor((pos_x +c.endX)/Store.zoomRatio)+0.5 ,
Math.floor((pos_y+c.endY)/Store.zoomRatio)+0.5 ,
);
ctx.lineWidth = 1;
ctx.lineWidth = Math.floor(c.fs/9);
ctx.strokeStyle = ctx.fillStyle;
ctx.stroke();
ctx.closePath();
@ -2078,14 +2181,14 @@ function cellTextRender(textInfo, ctx, option){
let item = underLines[a];
ctx.beginPath();
ctx.moveTo(
(pos_x +item.startX)/Store.zoomRatio ,
(pos_y+item.startY)/Store.zoomRatio
Math.floor((pos_x +item.startX)/Store.zoomRatio)+0.5 ,
Math.floor((pos_y+item.startY)/Store.zoomRatio)
);
ctx.lineTo(
(pos_x +item.endX)/Store.zoomRatio,
(pos_y+ item.endY)/Store.zoomRatio
Math.floor((pos_x +item.endX)/Store.zoomRatio)+0.5,
Math.floor((pos_y+ item.endY)/Store.zoomRatio)+0.5
);
ctx.lineWidth = 1;
ctx.lineWidth = Math.floor(item.fs/9);
ctx.strokeStyle = ctx.fillStyle;
ctx.stroke();
ctx.closePath();

2
src/global/editor.js

@ -120,7 +120,7 @@ const editor = {
clen = ed_c - st_c + 1;
if (rlen > 5000) {
jfrefreshgrid(d, st_r, ed_r, st_c, ed_c);
jfrefreshgrid(d, [{ "row": [st_r, ed_r], "column": [st_c, ed_c] }]);
}
else {
jfrefreshrange(d, { "row": [st_r, ed_r], "column": [st_c, ed_c] });

169
src/global/extend.js

@ -14,7 +14,7 @@ import Store from '../store';
function luckysheetextendtable(type, index, value, direction, order) {
let curOrder = order || getSheetIndex(Store.currentSheetIndex);
let file = Store.luckysheetfile[curOrder];
let d = file.data;
let d = $.extend(true, [], file.data);
value = Math.floor(value);
let cfg = $.extend(true, {}, file.config);
@ -457,6 +457,50 @@ function luckysheetextendtable(type, index, value, direction, order) {
newFreezen.freezenverticaldata = luckysheetFreezen.freezenverticaldata;
}
//数据验证配置变动
let dataVerification = file.dataVerification;
let newDataVerification = {};
if(dataVerification != null){
for(let key in dataVerification){
let r = Number(key.split('_')[0]),
c = Number(key.split('_')[1]);
let item = dataVerification[key];
if(type == "row"){
if(index < r){
newDataVerification[(r + value) + "_" + c] = item;
}
else if(index == r){
if(direction == "lefttop"){
newDataVerification[(r + value) + "_" + c] = item;
}
else{
newDataVerification[r + "_" + c] = item;
}
}
else{
newDataVerification[r + "_" + c] = item;
}
}
else if(type == "column"){
if(index < c){
newDataVerification[r + "_" + (c + value)] = item;
}
else if(index == c){
if(direction == "lefttop"){
newDataVerification[r + "_" + (c + value)] = item;
}
else{
newDataVerification[r + "_" + c] = item;
}
}
else{
newDataVerification[r + "_" + c] = item;
}
}
}
}
let type1;
if (type == "row") {
type1 = "r";
@ -713,7 +757,7 @@ function luckysheetextendtable(type, index, value, direction, order) {
}
// 修改当前sheet页时刷新
if (curOrder == Store.currentSheetIndex) {
if (file.index == Store.currentSheetIndex) {
jfrefreshgrid_adRC(
d,
cfg,
@ -723,9 +767,20 @@ function luckysheetextendtable(type, index, value, direction, order) {
newFilterObj,
newCFarr,
newAFarr,
newFreezen
newFreezen,
newDataVerification
);
}
else{
file.data = d;
file.config = cfg;
file.calcChain = newCalcChain;
file.filter = newFilterObj.filter;
file.filter_select = newFilterObj.filter_select;
file.luckysheet_conditionformat_save = newCFarr;
file.luckysheet_alternateformat_save = newAFarr;
file.dataVerification = newDataVerification;
}
let range = null;
if(type == "row"){
@ -746,7 +801,7 @@ function luckysheetextendtable(type, index, value, direction, order) {
}
file.luckysheet_select_save = range;
if (curOrder == Store.currentSheetIndex) {
if (file.index == Store.currentSheetIndex) {
Store.luckysheet_select_save = range;
selectHightlightShow();
}
@ -816,7 +871,7 @@ function luckysheetextendData(rowlen, newData) {
function luckysheetdeletetable(type, st, ed, order) {
let curOrder = order || getSheetIndex(Store.currentSheetIndex);
let file = Store.luckysheetfile[curOrder];
let d = file.data;
let d = $.extend(true, [], file.data);
let slen = ed - st + 1;
let cfg = $.extend(true, {}, file.config);
@ -1280,6 +1335,34 @@ function luckysheetdeletetable(type, st, ed, order) {
newFreezen.freezenverticaldata = luckysheetFreezen.freezenverticaldata;
}
//数据验证配置变动
let dataVerification = file.dataVerification;
let newDataVerification = {};
if(dataVerification != null){
for(let key in dataVerification){
let r = Number(key.split('_')[0]),
c = Number(key.split('_')[1]);
let item = dataVerification[key];
if(type == "row"){
if(r < st){
newDataVerification[r + "_" + c] = item;
}
else if(r > ed){
newDataVerification[(r - slen) + "_" + c] = item;
}
}
else if(type == "column"){
if(c < st){
newDataVerification[r + "_" + c] = item;
}
else if(c > ed){
newDataVerification[r + "_" + (c - slen)] = item;
}
}
}
}
//主逻辑
let type1;
if (type == "row") {
@ -1471,7 +1554,7 @@ function luckysheetdeletetable(type, st, ed, order) {
}
// 修改当前sheet页时刷新
if (curOrder == Store.currentSheetIndex) {
if (file.index == Store.currentSheetIndex) {
jfrefreshgrid_adRC(
d,
cfg,
@ -1481,17 +1564,29 @@ function luckysheetdeletetable(type, st, ed, order) {
newFilterObj,
newCFarr,
newAFarr,
newFreezen
newFreezen,
newDataVerification
);
}
else{
file.data = d;
file.config = cfg;
file.calcChain = newCalcChain;
file.filter = newFilterObj.filter;
file.filter_select = newFilterObj.filter_select;
file.luckysheet_conditionformat_save = newCFarr;
file.luckysheet_alternateformat_save = newAFarr;
file.dataVerification = newDataVerification;
}
}
//删除单元格
function luckysheetDeleteCell(type, str, edr, stc, edc, order) {
let d = editor.deepCopyFlowData(Store.flowdata);
let curOrder = order || getSheetIndex(Store.currentSheetIndex);
let file = Store.luckysheetfile[curOrder];
let d = $.extend(true, [], file.data);
let rlen = edr - str + 1;
let clen = edc - stc + 1;
let cfg = $.extend(true, {}, Store.config);
@ -1835,6 +1930,36 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, order) {
}
}
//数据验证配置变动
let dataVerification = file.dataVerification;
let newDataVerification = {};
if(dataVerification != null){
for(let key in dataVerification){
let r = Number(key.split('_')[0]),
c = Number(key.split('_')[1]);
let item = dataVerification[key];
if(r < str || r > edr || c < stc || c > edc){
if(type == "moveLeft"){
if(c > edc && r >= str && r <= edr){
newDataVerification[r + "_" + (c - clen)] = item;
}
else{
newDataVerification[r + "_" + c] = item;
}
}
else if(type == "moveUp"){
if(r > edr && c >= stc && c <= edc){
newDataVerification[(r - rlen) + "_" + c] = item;
}
else{
newDataVerification[r + "_" + c] = item;
}
}
}
}
}
//边框配置变动
if(cfg["borderInfo"] && cfg["borderInfo"].length > 0){
let borderInfo = [];
@ -1948,14 +2073,26 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, order) {
}
}
jfrefreshgrid_deleteCell(
d,
cfg,
{ type: type, 'str': str, 'edr': edr, 'stc': stc, 'edc': edc },
newCalcChain,
newFilterObj,
newCFarr
);
if(file.index == Store.currentSheetIndex){
jfrefreshgrid_deleteCell(
d,
cfg,
{ type: type, 'str': str, 'edr': edr, 'stc': stc, 'edc': edc },
newCalcChain,
newFilterObj,
newCFarr,
newDataVerification
);
}
else{
file.data = d;
file.config = cfg;
file.calcChain = newCalcChain;
file.filter = newFilterObj.filter;
file.filter_select = newFilterObj.filter_select;
file.luckysheet_conditionformat_save = newCFarr;
file.dataVerification = newDataVerification;
}
}
export {

359
src/global/formula.js

@ -9,8 +9,8 @@ import luckysheetFreezen from '../controllers/freezen';
import { seletedHighlistByindex, luckysheet_count_show } from '../controllers/select';
import { isRealNum, isRealNull, valueIsError, isEditMode } from './validate';
import { isdatetime, isdatatype } from './datecontroll';
import { getCellTextSplitArr } from '../global/getRowlen';
import { getcellvalue,getcellFormula } from './getdata';
import { getCellTextSplitArr,getCellTextInfo } from '../global/getRowlen';
import { getcellvalue,getcellFormula,getInlineStringNoStyle } from './getdata';
import { setcellvalue } from './setdata';
import { genarate, valueShowEs } from './format';
import editor from './editor';
@ -18,6 +18,7 @@ import tooltip from './tooltip';
import { rowLocation, colLocation, colLocationByIndex, mouseposition } from './location';
import { luckysheetRangeLast } from './cursorPos';
import { jfrefreshgrid } from './refresh';
import { isInlineStringCell,convertSpanToShareString } from '../controllers/inlineString';
// import luckysheet_function from '../function/luckysheet_function';
// import functionlist from '../function/functionlist';
import { luckysheet_compareWith, luckysheet_getarraydata, luckysheet_getcelldata, luckysheet_parseData, luckysheet_getValue, luckysheet_indirect_check, luckysheet_indirect_check_return, luckysheet_offset_check } from '../function/func';
@ -325,7 +326,10 @@ const luckysheetformula = {
if (d[r] != null && d[r][c] != null) {
let cell = d[r][c];
if(cell.f != null){
if(isInlineStringCell(cell)){
value = getInlineStringNoStyle(r, c);
}
else if(cell.f != null){
value = getcellvalue(r, c, d, "f");
}
else{
@ -1193,41 +1197,70 @@ const luckysheetformula = {
let _this = this;
let $input = $("#luckysheet-rich-text-editor");
// API, we get value from user
value = value || $input.text();
let inputText = $input.text(), inputHtml = $input.html();
if (_this.rangetosheet != null && _this.rangetosheet != Store.currentSheetIndex) {
sheetmanage.changeSheetExec(_this.rangetosheet);
}
let curv = Store.flowdata[r][c];
if(isRealNull(value)){
if(curv == null || (isRealNull(curv.v) && curv.spl == null)){
_this.cancelNormalSelected();
return;
}
let isPrevInline = isInlineStringCell(curv);
let isCurInline = (inputText.slice(0, 1) != "=" && inputHtml.indexOf("span")>-1);
if(!value && !isCurInline && isPrevInline){
delete curv.ct.s;
curv.ct.t = "g";
curv.ct.fa = "General";
}
else if(curv!=null && curv.qp != 1){
if (getObjType(curv) == "object" && (value == curv.f || value == curv.v || value == curv.m)) {
_this.cancelNormalSelected();
return;
}
else if (value == curv) {
_this.cancelNormalSelected();
return;
else if(isCurInline){
if (getObjType(curv) != "object") {
curv = {};
}
}
delete curv.f;
delete curv.v;
delete curv.m;
if (getObjType(value) == "string" && value.slice(0, 1) == "=" && value.length > 1) {
if(curv.ct==null){
curv.ct = {};
curv.ct.fa = "General";
}
curv.ct.t = "inlineStr";
curv.ct.s = convertSpanToShareString($input.find("span"));
}
else if(getObjType(curv) == "object" && curv.ct != null && curv.ct.fa != null && curv.ct.fa != "@" && !isRealNull(value)){
delete curv.m;//更新时间m处理 , 会实际删除单元格数据的参数(flowdata时已删除)
if(curv.f != null){ //如果原来是公式,而更新的数据不是公式,则把公式删除
delete curv.f;
delete curv.spl; //删除单元格的sparklines的配置串
// API, we get value from user
value = value || $input.text();
if(!isCurInline){
if(isRealNull(value)){
if(curv == null || (isRealNull(curv.v) && curv.spl == null)){
_this.cancelNormalSelected();
return;
}
}
else if(curv!=null && curv.qp != 1){
if (getObjType(curv) == "object" && (value == curv.f || value == curv.v || value == curv.m)) {
_this.cancelNormalSelected();
return;
}
else if (value == curv) {
_this.cancelNormalSelected();
return;
}
}
if (getObjType(value) == "string" && value.slice(0, 1) == "=" && value.length > 1) {
}
else if(getObjType(curv) == "object" && curv.ct != null && curv.ct.fa != null && curv.ct.fa != "@" && !isRealNull(value)){
delete curv.m;//更新时间m处理 , 会实际删除单元格数据的参数(flowdata时已删除)
if(curv.f != null){ //如果原来是公式,而更新的数据不是公式,则把公式删除
delete curv.f;
delete curv.spl; //删除单元格的sparklines的配置串
}
}
}
@ -1236,48 +1269,18 @@ const luckysheetformula = {
let isRunExecFunction = true;
let d = editor.deepCopyFlowData(Store.flowdata);
let dynamicArrayItem = null; //动态数组
if (getObjType(curv) == "object") {
if(getObjType(value) == "string" && value.slice(0, 1) == "=" && value.length > 1){
let v = _this.execfunction(value, r, c, true);
curv = _this.execFunctionGroupData[r][c];
curv.f = v[2];
//打进单元格的sparklines的配置串, 报错需要单独处理。
if(v.length == 4 && v[3].type == "sparklines"){
delete curv.m;
delete curv.v;
let curCalv = v[3].data;
if(getObjType(curCalv) == "array" && getObjType(curCalv[0]) != "object"){
curv.v = curCalv[0];
}
else{
curv.spl = v[3].data;
}
}
}
// from API setCellValue,luckysheet.setCellValue(0, 0, {f: "=sum(D1)", bg:"#0188fb"}),value is an object, so get attribute f as value
else if(getObjType(value) == "object"){
let valueFunction = value.f;
if(!isCurInline){
if(getObjType(valueFunction) == "string" && valueFunction.slice(0, 1) == "=" && valueFunction.length > 1){
let v = _this.execfunction(valueFunction, r, c, true);
if(getObjType(value) == "string" && value.slice(0, 1) == "=" && value.length > 1){
let v = _this.execfunction(value, r, c, true);
// get v/m/ct
curv = _this.execFunctionGroupData[r][c];
// get f
curv.f = v[2];
// get other cell style attribute
delete value.v;
delete value.m;
delete value.f;
Object.assign(curv,value);
//打进单元格的sparklines的配置串, 报错需要单独处理。
if(v.length == 4 && v[3].type == "sparklines"){
delete curv.m;
@ -1292,27 +1295,96 @@ const luckysheetformula = {
curv.spl = v[3].data;
}
}
else if(v.length == 4 && v[3].type == "dynamicArrayItem"){
dynamicArrayItem = v[3].data;
}
}
}
else{
_this.delFunctionGroup(r, c);
_this.execFunctionGroup(r, c, value);
isRunExecFunction = false;
curv = _this.execFunctionGroupData[r][c];
// from API setCellValue,luckysheet.setCellValue(0, 0, {f: "=sum(D1)", bg:"#0188fb"}),value is an object, so get attribute f as value
else if(getObjType(value) == "object"){
let valueFunction = value.f;
if(getObjType(valueFunction) == "string" && valueFunction.slice(0, 1) == "=" && valueFunction.length > 1){
let v = _this.execfunction(valueFunction, r, c, true);
delete curv.f;
delete curv.spl;
// get v/m/ct
if(curv.qp == 1 && ('' + value).substr(0,1)!="'"){//if quotePrefix is 1, cell is force string, cell clear quotePrefix when it is updated
curv.qp = 0;
if(curv.ct!=null){
curv.ct.fa = "General";
curv.ct.t = "n";
curv = _this.execFunctionGroupData[r][c];
curv.f = v[2];
//打进单元格的sparklines的配置串, 报错需要单独处理。
if(v.length == 4 && v[3].type == "sparklines"){
delete curv.m;
delete curv.v;
let curCalv = v[3].data;
if(getObjType(curCalv) == "array" && getObjType(curCalv[0]) != "object"){
curv.v = curCalv[0];
}
else{
curv.spl = v[3].data;
}
}
else if(v.length == 4 && v[3].type == "dynamicArrayItem"){
dynamicArrayItem = v[3].data;
}
}
// from API setCellValue,luckysheet.setCellValue(0, 0, {f: "=sum(D1)", bg:"#0188fb"}),value is an object, so get attribute f as value
else if(getObjType(value) == "object"){
let valueFunction = value.f;
if(getObjType(valueFunction) == "string" && valueFunction.slice(0, 1) == "=" && valueFunction.length > 1){
let v = _this.execfunction(valueFunction, r, c, true);
// get v/m/ct
curv = _this.execFunctionGroupData[r][c];
// get f
curv.f = v[2];
// get other cell style attribute
delete value.v;
delete value.m;
delete value.f;
Object.assign(curv,value);
//打进单元格的sparklines的配置串, 报错需要单独处理。
if(v.length == 4 && v[3].type == "sparklines"){
delete curv.m;
delete curv.v;
let curCalv = v[3].data;
if(getObjType(curCalv) == "array" && getObjType(curCalv[0]) != "object"){
curv.v = curCalv[0];
}
else{
curv.spl = v[3].data;
}
}
}
}
}
else {
_this.delFunctionGroup(r, c);
_this.execFunctionGroup(r, c, value);
isRunExecFunction = false;
curv = _this.execFunctionGroupData[r][c];
delete curv.f;
delete curv.spl;
if(curv.qp == 1 && ('' + value).substr(0,1)!="'"){//if quotePrefix is 1, cell is force string, cell clear quotePrefix when it is updated
curv.qp = 0;
if(curv.ct!=null){
curv.ct.fa = "General";
curv.ct.t = "n";
}
}
}
}
value = curv;
}
else {
@ -1335,6 +1407,9 @@ const luckysheetformula = {
value.spl = v[3].data;
}
}
else if(v.length == 4 && v[3].type == "dynamicArrayItem"){
dynamicArrayItem = v[3].data;
}
}
// from API setCellValue,luckysheet.setCellValue(0, 0, {f: "=sum(D1)", bg:"#0188fb"}),value is an object, so get attribute f as value
else if(getObjType(value) == "object"){
@ -1363,6 +1438,9 @@ const luckysheetformula = {
value.spl = v[3].data;
}
}
else if(v.length == 4 && v[3].type == "dynamicArrayItem"){
dynamicArrayItem = v[3].data;
}
}
}
@ -1383,51 +1461,86 @@ const luckysheetformula = {
cfg["rowlen"] = {};
}
if(d[r][c].tb == "2" && d[r][c].v != null){//自动换行
let defaultrowlen = 19;
let offlinecanvas = $("#luckysheetTableContentF").get(0).getContext("2d");
offlinecanvas.textBaseline = 'top'; //textBaseline以top计算
let fontset = luckysheetfontformat(d[r][c]);
offlinecanvas.font = fontset;
let currentRowLen = defaultrowlen;
if(cfg["rowlen"][r] != null){
currentRowLen = cfg["rowlen"][r];
}
let strValue = getcellvalue(r, c, d).toString();
let measureText = offlinecanvas.measureText(strValue);
if((d[r][c].tb == "2" && d[r][c].v != null) || isInlineStringCell(d[r][c])){//自动换行
let defaultrowlen = Store.defaultrowlen;;
let textMetrics = measureText.width;
let cellWidth = colLocationByIndex(c)[1] - colLocationByIndex(c)[0] - 4;
let oneLineTextHeight = measureText.actualBoundingBoxDescent - measureText.actualBoundingBoxAscent;
let canvas = $("#luckysheetTableContent").get(0).getContext("2d");
// offlinecanvas.textBaseline = 'top'; //textBaseline以top计算
if(textMetrics > cellWidth){
let strArr = [];//文本截断数组
strArr = getCellTextSplitArr(strValue, strArr, cellWidth, offlinecanvas);
// let fontset = luckysheetfontformat(d[r][c]);
// offlinecanvas.font = fontset;
let computeRowlen = oneLineTextHeight * strArr.length + 4;
//比较计算高度和当前高度取最大高度
if(computeRowlen > currentRowLen){
currentRowLen = computeRowlen;
}
}
if(currentRowLen != defaultrowlen){
cfg["rowlen"][r] = currentRowLen;
RowlChange = true;
if(cfg["customHeight"] && cfg["customHeight"][r]==1){
}
else{
// let currentRowLen = defaultrowlen;
// if(cfg["rowlen"][r] != null){
// currentRowLen = cfg["rowlen"][r];
// }
let cellWidth = colLocationByIndex(c)[1] - colLocationByIndex(c)[0] - 2;
let textInfo = getCellTextInfo(d[r][c], canvas,{
r:r,
c:c,
cellWidth:cellWidth
});
let currentRowLen = defaultrowlen;
// console.log("rowlen", textInfo);
if(textInfo!=null){
currentRowLen = textInfo.textHeightAll+2;
}
// let strValue = getcellvalue(r, c, d).toString();
// let measureText = offlinecanvas.measureText(strValue);
// let textMetrics = measureText.width;
// let cellWidth = colLocationByIndex(c)[1] - colLocationByIndex(c)[0] - 4;
// let oneLineTextHeight = measureText.actualBoundingBoxDescent - measureText.actualBoundingBoxAscent;
// if(textMetrics > cellWidth){
// let strArr = [];//文本截断数组
// strArr = getCellTextSplitArr(strValue, strArr, cellWidth, offlinecanvas);
// let computeRowlen = oneLineTextHeight * strArr.length + 4;
// //比较计算高度和当前高度取最大高度
// if(computeRowlen > currentRowLen){
// currentRowLen = computeRowlen;
// }
// }
if(currentRowLen > defaultrowlen){
cfg["rowlen"][r] = currentRowLen;
RowlChange = true;
}
}
}
//动态数组
let dynamicArray = null;
if(!!dynamicArrayItem){
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
dynamicArray = $.extend(true, [], file["dynamicArray"]);
dynamicArray.push(dynamicArrayItem);
}
let allParam = {
"dynamicArray": dynamicArray
}
if(RowlChange){
jfrefreshgrid(d, [{ "row": [r, r], "column": [c, c] }], cfg, null, RowlChange, isRunExecFunction);
}
else {
jfrefreshgrid(d, [{ "row": [r, r], "column": [c, c] }], undefined, undefined, undefined, isRunExecFunction);
allParam = {
"cfg": cfg,
"dynamicArray": dynamicArray,
"RowlChange": RowlChange
}
}
jfrefreshgrid(d, [{ "row": [r, r], "column": [c, c] }], allParam, isRunExecFunction);
// Store.luckysheetCellUpdate.length = 0; //clear array
_this.execFunctionGroupData = null; //销毁
},
@ -3139,13 +3252,14 @@ const luckysheetformula = {
if(kcode != 46){//delete不执行此函数
_this.createRangeHightlight();
}
$functionbox.html(value);
}
_this.rangestart = false;
_this.rangedrag_column_start = false;
_this.rangedrag_row_start = false;
$functionbox.html(value);
_this.rangeHightlightselected($editer, kcode);
}, 1);
},
@ -4879,7 +4993,7 @@ const luckysheetformula = {
let _locale = locale();
let locale_formulaMore = _locale.formulaMore;
console.log(txt,r,c)
if(txt.indexOf(_this.error.r) > -1){
return [false, _this.error.r, txt];
}
@ -4964,6 +5078,8 @@ const luckysheetformula = {
}
//公式结果是数组,分错误值 和 动态数组 两种情况
let dynamicArrayItem = null;
if(getObjType(result) == "array"){
let isErr = false;
@ -4976,14 +5092,7 @@ const luckysheetformula = {
result = result[0][0];
}
else{
let luckysheetfile = getluckysheetfile();
let file = luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
let dynamicArray = file["dynamicArray"] == null ? [] : file["dynamicArray"];
dynamicArray.push({"r": r, "c": c, "f": txt, "data": result});
file["dynamicArray"] = dynamicArray;
setluckysheetfile(luckysheetfile);
dynamicArrayItem = {"r": r, "c": c, "f": txt, "data": result};
result = "";
}
}
@ -5010,6 +5119,10 @@ const luckysheetformula = {
return [true, result, txt, {type: "sparklines", data: sparklines}];
}
if(!!dynamicArrayItem){
return [true, result, txt, {type: "dynamicArrayItem", data: dynamicArrayItem}];
}
return [true, result, txt];
},
testFunction: function(txt, fp) {

771
src/global/getRowlen.js

@ -1,8 +1,9 @@
import { luckysheetfontformat } from '../utils/util';
import menuButton from '../controllers/menuButton';
import { getcellvalue } from './getdata';
import { getcellvalue,checkstatusByCell } from './getdata';
import { colLocationByIndex } from './location';
import { hasChinaword, isRealNull } from './validate';
import { isInlineStringCell } from '../controllers/inlineString';
import Store from '../store';
//计算范围行高
@ -12,6 +13,10 @@ function rowlenByRange(d, r1, r2, cfg) {
cfg_clone["rowlen"] = {};
}
if(cfg_clone["customHeight"] == null){
cfg_clone["customHeight"] = {};
}
let canvas = $("#luckysheetTableContent").get(0).getContext("2d");
canvas.textBaseline = 'top'; //textBaseline以top计算
@ -25,6 +30,10 @@ function rowlenByRange(d, r1, r2, cfg) {
// currentRowLen = cfg_clone["rowlen"][r];
// }
if(cfg_clone["customHeight"][r]==1){
continue;
}
delete cfg_clone["rowlen"][r];
for(let c = 0; c < d[r].length; c++){
@ -34,7 +43,7 @@ function rowlenByRange(d, r1, r2, cfg) {
continue;
}
if(cell != null && cell.v != null){
if(cell != null && (cell.v != null || isInlineStringCell(cell)) ){
let cellWidth = colLocationByIndex(c)[1] - colLocationByIndex(c)[0] - 2;
let textInfo = getCellTextInfo(cell, canvas,{
@ -46,7 +55,7 @@ function rowlenByRange(d, r1, r2, cfg) {
let computeRowlen = 0;
// console.log("rowlen", textInfo);
if(textInfo!=null){
computeRowlen = textInfo.textHeightAll;
computeRowlen = textInfo.textHeightAll+2;
}
// let fontset = luckysheetfontformat(cell);
@ -196,7 +205,7 @@ function getMeasureText(value, ctx, fontset){
}
if(fontset!=null){
ctx.font = preFont;
ctx.font = fontset;
}
cache.actualBoundingBoxDescent = measureText.actualBoundingBoxDescent;
@ -269,13 +278,13 @@ function getCellTextInfo(cell , ctx, option){
}
//水平对齐
let horizonAlign = menuButton.checkstatusByCell(cell, "ht");
let horizonAlign = checkstatusByCell(cell, "ht");
//垂直对齐
let verticalAlign = menuButton.checkstatusByCell(cell, "vt");
let verticalAlign = checkstatusByCell(cell, "vt");
let tb = menuButton.checkstatusByCell(cell ,"tb");//wrap overflow
let tr = menuButton.checkstatusByCell(cell ,"tr");//rotate
let rt = menuButton.checkstatusByCell(cell ,"rt");//rotate angle
let tb = checkstatusByCell(cell ,"tb");//wrap overflow
let tr = checkstatusByCell(cell ,"tr");//rotate
let rt = checkstatusByCell(cell ,"rt");//rotate angle
let isRotateUp = 1, isRotateDown=0;
@ -317,12 +326,65 @@ function getCellTextInfo(cell , ctx, option){
let textContent = {};
textContent.values = [];
let fontset, cancelLine="0", underLine="0", isInline=false, value;
if(cell.ct!=null && cell.ct.t=="inlineStr" && cell.ct.sharedStrings!=null && cell.ct.sharedStrings.length>0){
let strArr = [];
let sharedStrings = cell.ct.s;
for(let i=0;i<cell.ct.sharedStrings.length;i++){
let s = cell.ct.sharedStrings[i];
let fontset, cancelLine="0", underLine="0", fontSize=11, isInline=false, value, inlineStringArr=[];
if(isInlineStringCell(cell)){
let sharedStrings = cell.ct.s, similarIndex = 0;
for(let i=0;i<sharedStrings.length;i++){
let shareCell = sharedStrings[i];
let scfontset = luckysheetfontformat(shareCell);
let fc = shareCell.fc, cl=shareCell.cl,un = shareCell.un, v = shareCell.v, fs=shareCell.fs;
v = v.replace(/\r\n/g, "_x000D_").replace(/&#13;&#10;/g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_");
let splitArr = v.split("_x000D_"), preNewValue=null;
for(let x=0;x<splitArr.length;x++){
let newValue = splitArr[x];
if(newValue==""){
inlineStringArr.push({
fontset:scfontset,
fc:fc==null?"#000":fc,
cl:cl==null?0:cl,
un:un==null?0:un,
wrap:true,
fs:fs==null?11:fs,
});
similarIndex++;
}
else{
let newValueArray = newValue.split("");
for(let n=0;n<newValueArray.length;n++){
let nv = newValueArray[n];
inlineStringArr.push({
fontset:scfontset,
fc:fc==null?"#000":fc,
cl:cl==null?0:cl,
un:un==null?0:un,
v: nv,
si:similarIndex,
fs:fs==null?11:fs,
});
}
if(x!=splitArr.length-1 && !(preNewValue=="" && newValue=="") ){
inlineStringArr.push({
fontset:scfontset,
fc:fc==null?"#000":fc,
cl:cl==null?0:cl,
un:un==null?0:un,
wrap:true,
fs:fs==null?11:fs,
});
similarIndex++;
}
}
preNewValue = newValue;
}
similarIndex++;
}
isInline = true;
}
@ -330,8 +392,9 @@ function getCellTextInfo(cell , ctx, option){
fontset = luckysheetfontformat(cell);
ctx.font = fontset;
cancelLine = menuButton.checkstatusByCell(cell ,"cl");//cancelLine
underLine = menuButton.checkstatusByCell(cell ,"un");//underLine
cancelLine = checkstatusByCell(cell ,"cl");//cancelLine
underLine = checkstatusByCell(cell ,"un");//underLine
fontSize = checkstatusByCell(cell ,"fs");
if(cell instanceof Object){
value = cell.m;
@ -358,63 +421,137 @@ function getCellTextInfo(cell , ctx, option){
if(tr=="3"){//vertical text
ctx.textBaseline = 'top';
let measureText = getMeasureText(value, ctx);
let textHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;
value = value.toString();
let vArr = [];
if(value.length > 1){
vArr = value.split("");
}
else{
vArr.push(value);
}
let textW_all = 0; //拆分后宽高度合计
let textH_all = 0;
let oneWordWidth = getMeasureText(vArr[0], ctx).width;
let colIndex=0, textH_all_cache=0, textH_all_Column = {}, textH_all_ColumnHeight=[];
if(isInline){
let preShareCell = null;
for(let i = 0; i < inlineStringArr.length; i++){
let shareCell = inlineStringArr[i];
let value = shareCell.v, showValue=shareCell.v;
if(shareCell.wrap===true){
value = "M";
showValue = "";
if( preShareCell!=null && preShareCell.wrap!==true && (i<inlineStringArr.length-1)){
// console.log("wrap",i,colIndex,preShareCell.wrap);
textH_all_ColumnHeight.push(textH_all_cache);
textH_all_cache = 0;
colIndex +=1;
for(let i = 0; i < vArr.length; i++){
let textW = oneWordWidth + space_width;
let textH = textHeight + space_height;
// textW_all += textW;
textH_all_cache += textH;
preShareCell = shareCell;
continue;
}
}
let measureText = getMeasureText(value, ctx, shareCell.fontset);
if(tb=="2"){
if(textH_all_cache>cellHeight && textH_all_Column[colIndex]!=null){
// textW_all += textW;
// textH_all = Math.max(textH_all,textH_all_cache);
textH_all_ColumnHeight.push(textH_all_cache-textH);
textH_all_cache = textH;
colIndex +=1;
let textW = measureText.width + space_width;
let textH = measureText.actualBoundingBoxAscent + measureText.actualBoundingBoxDescent + space_height;
// textW_all += textW;
textH_all_cache += textH;
if(tb=="2" && !shareCell.wrap){
if(textH_all_cache>cellHeight && textH_all_Column[colIndex]!=null){
// textW_all += textW;
// textH_all = Math.max(textH_all,textH_all_cache);
// console.log(">",i,colIndex);
textH_all_ColumnHeight.push(textH_all_cache-textH);
textH_all_cache = textH;
colIndex +=1;
}
}
if(i== inlineStringArr.length-1){
textH_all_ColumnHeight.push(textH_all_cache);
}
if(textH_all_Column[colIndex]==null){
textH_all_Column[colIndex]= [];
}
}
if(i== vArr.length-1){
textH_all_ColumnHeight.push(textH_all_cache);
}
let item = {
content:showValue,
style:shareCell,
width:textW,
height:textH,
left:0,
top:0,
colIndex:colIndex,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent,
inline:true,
}
if(textH_all_Column[colIndex]==null){
textH_all_Column[colIndex]= [];
if(shareCell.wrap===true){
item.wrap=true;
}
textH_all_Column[colIndex].push(item);
console.log("normal",i,colIndex,shareCell, preShareCell, textH_all_Column);
preShareCell = shareCell;
}
}
else{
let measureText = getMeasureText(value, ctx);
let textHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;
textH_all_Column[colIndex].push({
content:vArr[i],
style:fontset,
width:textW,
height:textH,
left:0,
top:0,
colIndex:colIndex,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent
});
value = value.toString();
let vArr = [];
if(value.length > 1){
vArr = value.split("");
}
else{
vArr.push(value);
}
let oneWordWidth = getMeasureText(vArr[0], ctx).width;
for(let i = 0; i < vArr.length; i++){
let textW = oneWordWidth + space_width;
let textH = textHeight + space_height;
// textW_all += textW;
textH_all_cache += textH;
if(tb=="2"){
if(textH_all_cache>cellHeight && textH_all_Column[colIndex]!=null){
// textW_all += textW;
// textH_all = Math.max(textH_all,textH_all_cache);
textH_all_ColumnHeight.push(textH_all_cache-textH);
textH_all_cache = textH;
colIndex +=1;
}
}
if(i== vArr.length-1){
textH_all_ColumnHeight.push(textH_all_cache);
}
if(textH_all_Column[colIndex]==null){
textH_all_Column[colIndex]= [];
}
textH_all_Column[colIndex].push({
content:vArr[i],
style:fontset,
width:textW,
height:textH,
left:0,
top:0,
colIndex:colIndex,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent
});
}
}
let textH_all_ColumWidth = [];
@ -474,9 +611,10 @@ function getCellTextInfo(cell , ctx, option){
width:columnWidth,
height:word.height,
left:left,
top:top+word.height/2,
asc:word.asc,
desc:word.desc
top:top+word.height-space_height,
asc:word.height,
desc:0,
fs:fontSize
});
textContent.values.push(word);
@ -496,7 +634,6 @@ function getCellTextInfo(cell , ctx, option){
}
if(tb=="2" || isInline){//wrap
value = value.toString();
let textW_all = 0; //拆分后宽高度合计
let textH_all = 0;
@ -508,119 +645,313 @@ function getCellTextInfo(cell , ctx, option){
textContent.rotate = rt;
rt = Math.abs(rt);
let anchor = 0, preHeight = 0, preWidth=0, preStr, preTextHeight, preTextWidth, i=0;
while(i <= value.length){
let str = value.substring(anchor, i);
let measureText = getMeasureText(str, ctx);
let textWidth = measureText.width;
let textHeight = measureText.actualBoundingBoxAscent+measureText.actualBoundingBoxDescent;
let anchor = 0, preHeight = 0, preWidth=0, preStr, preTextHeight, preTextWidth, i=1, wrapStyle={};
if(isInline){
while(i <= inlineStringArr.length){
let shareCells = inlineStringArr.slice(anchor, i);
if(shareCells[shareCells.length-1].wrap===true){
let width = textWidth * Math.cos(rt*Math.PI/180) + textHeight * Math.sin(rt*Math.PI/180);//consider text box wdith and line height
anchor = i;
if(shareCells.length>1){
for(let s=0;s<shareCells.length-1;s++){
let sc = shareCells[s];
let item = {
content:sc.v,
style:sc,
width:sc.measureText.width,
height:sc.measureText.actualBoundingBoxAscent+sc.measureText.actualBoundingBoxDescent,
left:0,
top:0,
splitIndex:splitIndex,
asc:sc.measureText.actualBoundingBoxAscent,
desc:sc.measureText.actualBoundingBoxDescent,
inline:true,
fs:sc.fs
}
// if(rt!=0){//rotate
// item.textHeight = sc.textHeight;
// item.textWidth = sc.textWidth;
// }
text_all_split[splitIndex].push(item);
}
}
if(shareCells.length==1 || i==inlineStringArr.length){
let sc = shareCells[0];
let measureText = getMeasureText("M", ctx, sc.fontset);
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex] = [];
}
text_all_split[splitIndex].push({
content:"",
style:sc,
width:measureText.width,
height:measureText.actualBoundingBoxAscent+measureText.actualBoundingBoxDescent,
left:0,
top:0,
splitIndex:splitIndex,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent,
inline:true,
wrap:true,
fs:sc.fs
});
}
let height = textWidth * Math.sin(rt*Math.PI/180) + textHeight * Math.cos(rt*Math.PI/180);//consider text box wdith and line height
// textW_all += textW;
if(rt!=0){//rotate
// console.log("all",anchor, i , str);
if((height+space_height)>cellHeight && text_all_split[splitIndex]!=null){
// console.log("cut",anchor, i , str);
anchor = i-1;
text_all_split[splitIndex].push({
content:preStr,
style:fontset,
width:preWidth,
height:preHeight,
left:0,
top:0,
splitIndex:splitIndex,
textHeight:preTextHeight,
textWidth:preTextWidth,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent
});
splitIndex +=1;
i++;
continue;
}
else if(i== value.length){
// console.log("last",anchor, i , str);
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
let textWidth=0, textHeight=0;
for(let s=0;s<shareCells.length;s++){
let sc = shareCells[s];
if(sc.measureText==null){
sc.measureText = getMeasureText(sc.v, ctx, sc.fontset);
}
text_all_split[splitIndex].push({
content:str,
style:fontset,
width:width,
height:height,
left:0,
top:0,
splitIndex:splitIndex,
textHeight:textHeight,
textWidth:textWidth,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent
});
break;
textWidth += sc.measureText.width;
textHeight += sc.measureText.actualBoundingBoxAscent+sc.measureText.actualBoundingBoxDescent;
}
else{
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
let width = textWidth * Math.cos(rt*Math.PI/180) + textHeight * Math.sin(rt*Math.PI/180);//consider text box wdith and line height
let height = textWidth * Math.sin(rt*Math.PI/180) + textHeight * Math.cos(rt*Math.PI/180);//consider text box wdith and line height
// textW_all += textW;
if(rt!=0){//rotate
// console.log("all",anchor, i , str);
if((height+space_height)>cellHeight && text_all_split[splitIndex]!=null && tb=="2"){
// console.log("cut",anchor, i , str);
anchor = i-1;
for(let s=0;s<shareCells.length-1;s++){
let sc = shareCells[s];
text_all_split[splitIndex].push({
content:sc.v,
style:sc,
width:sc.measureText.width,
height:sc.measureText.actualBoundingBoxAscent+sc.measureText.actualBoundingBoxDescent,
left:0,
top:0,
splitIndex:splitIndex,
asc:sc.measureText.actualBoundingBoxAscent,
desc:sc.measureText.actualBoundingBoxDescent,
inline:true,
fs:sc.fs
});
}
splitIndex +=1;
}
else if(i== inlineStringArr.length){
// console.log("last",anchor, i , str);
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
}
for(let s=0;s<shareCells.length;s++){
let sc = shareCells[s];
text_all_split[splitIndex].push({
content:sc.v,
style:sc,
width:sc.measureText.width,
height:sc.measureText.actualBoundingBoxAscent+sc.measureText.actualBoundingBoxDescent,
left:0,
top:0,
splitIndex:splitIndex,
asc:sc.measureText.actualBoundingBoxAscent,
desc:sc.measureText.actualBoundingBoxDescent,
inline:true,
fs:sc.fs
});
}
break;
}
else{
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
}
i++;
}
i++;
}
}
else{//plain
if((width+space_width)>cellWidth && text_all_split[splitIndex]!=null){
anchor = i-1;
text_all_split[splitIndex].push({
content:preStr,
style:fontset,
width:preWidth,
height:preHeight,
left:0,
top:0,
splitIndex:splitIndex,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent
});
else{//plain
if((width+space_width)>cellWidth && text_all_split[splitIndex]!=null && tb=="2"){
anchor = i-1;
for(let s=0;s<shareCells.length-1;s++){
let sc = shareCells[s];
text_all_split[splitIndex].push({
content:sc.v,
style:sc,
width:sc.measureText.width,
height:sc.measureText.actualBoundingBoxAscent+sc.measureText.actualBoundingBoxDescent,
left:0,
top:0,
splitIndex:splitIndex,
asc:sc.measureText.actualBoundingBoxAscent,
desc:sc.measureText.actualBoundingBoxDescent,
inline:true,
fs:sc.fs
});
}
splitIndex +=1;
}
else if(i== inlineStringArr.length){
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
}
splitIndex +=1;
}
else if(i== value.length){
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
for(let s=0;s<shareCells.length;s++){
let sc = shareCells[s];
text_all_split[splitIndex].push({
content:sc.v,
style:sc,
width:sc.measureText.width,
height:sc.measureText.actualBoundingBoxAscent+sc.measureText.actualBoundingBoxDescent,
left:0,
top:0,
splitIndex:splitIndex,
asc:sc.measureText.actualBoundingBoxAscent,
desc:sc.measureText.actualBoundingBoxDescent,
inline:true,
fs:sc.fs
});
}
break;
}
text_all_split[splitIndex].push({
content:str,
style:fontset,
width:width,
height:height,
left:0,
top:0,
splitIndex:splitIndex,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent
});
else{
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
}
i++;
}
}
break;
}
}
else{
value = value.toString();
while(i <= value.length){
let str = value.substring(anchor, i);
let measureText = getMeasureText(str, ctx);
let textWidth = measureText.width;
let textHeight = measureText.actualBoundingBoxAscent+measureText.actualBoundingBoxDescent;
let width = textWidth * Math.cos(rt*Math.PI/180) + textHeight * Math.sin(rt*Math.PI/180);//consider text box wdith and line height
let height = textWidth * Math.sin(rt*Math.PI/180) + textHeight * Math.cos(rt*Math.PI/180);//consider text box wdith and line height
// textW_all += textW;
if(rt!=0){//rotate
// console.log("all",anchor, i , str);
if((height+space_height)>cellHeight && text_all_split[splitIndex]!=null){
// console.log("cut",anchor, i , str);
anchor = i-1;
text_all_split[splitIndex].push({
content:preStr,
style:fontset,
left:0,
top:0,
splitIndex:splitIndex,
height:preTextHeight,
width:preTextWidth,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent,
fs:fontSize,
});
splitIndex +=1;
}
else if(i== value.length){
// console.log("last",anchor, i , str);
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
}
text_all_split[splitIndex].push({
content:str,
style:fontset,
left:0,
top:0,
splitIndex:splitIndex,
height:textHeight,
width:textWidth,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent,
fs:fontSize,
});
break;
}
else{
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
}
i++;
}
}
else{
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
else{//plain
if((width+space_width)>cellWidth && text_all_split[splitIndex]!=null){
anchor = i-1;
text_all_split[splitIndex].push({
content:preStr,
style:fontset,
width:preTextWidth,
height:preTextHeight,
left:0,
top:0,
splitIndex:splitIndex,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent,
fs:fontSize,
});
splitIndex +=1;
}
else if(i== value.length){
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
}
text_all_split[splitIndex].push({
content:str,
style:fontset,
width:textWidth,
height:textHeight,
left:0,
top:0,
splitIndex:splitIndex,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent,
fs:fontSize,
});
break;
}
else{
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
}
i++;
}
i++;
}
preStr = str;
preTextHeight = textHeight;
preTextWidth = textWidth;
}
preWidth = width;
preHeight = height;
preStr = str;
preTextHeight = textHeight;
preTextWidth = textWidth;
}
let split_all_size = [], oneLinemaxWordCount=0;
@ -635,8 +966,8 @@ function getCellTextInfo(cell , ctx, option){
for(let s=0;s<splitLists.length;s++){
let sp = splitLists[s];
if(rt!=0){//rotate
sWidth += sp.textWidth;
sHeight = Math.max(sHeight, sp.textHeight-(supportBoundBox?sp.desc:0));
sWidth += sp.width;
sHeight = Math.max(sHeight, sp.height-(supportBoundBox?sp.desc:0));
}
else{//plain
sWidth += sp.width;
@ -672,7 +1003,7 @@ function getCellTextInfo(cell , ctx, option){
wordCount: maxWordCount
});
}
// console.log(textH_all,textW_all,textW_all_inner);
// let cumColumnWidth = 0;
let cumWordHeight = 0,cumColumnWidth = 0;
let rtPI = rt*Math.PI/180;
@ -771,16 +1102,21 @@ function getCellTextInfo(cell , ctx, option){
wordGroup.left = left;
wordGroup.top = top;
console.log(left, top, cumWordHeight, size.height);
drawLineInfo(wordGroup, cancelLine, underLine,{
width:wordGroup.textWidth,
height:wordGroup.textHeight,
left:left-wordGroup.textWidth,
width:wordGroup.width,
height:wordGroup.height,
left:left-wordGroup.width,
top:top,
asc:size.asc,
desc:size.desc
desc:size.desc,
fs:wordGroup.fs
});
textContent.values.push(wordGroup);
cumColumnWidth += wordGroup.width;
}
@ -853,76 +1189,15 @@ function getCellTextInfo(cell , ctx, option){
}
drawLineInfo(wordGroup, cancelLine, underLine,{
width:wordGroup.textWidth,
height:wordGroup.textHeight,
width:wordGroup.width,
height:wordGroup.height,
left:left,
top:top,
asc:size.asc,
desc:size.desc
desc:size.desc,
fs:wordGroup.fs
});
// let x, y = cumWordHeight; //+ wordGroup.textHeight / Math.sin(rt*Math.PI/180)*isRotateDown;
// if(isRotateUp=="1"){
// if(horizonAlign=="2"){
// x = (cumWordHeight)/Math.tan(rt*Math.PI/180) + cumColumnWidth;
// }
// else if(horizonAlign=="0"){
// x = (cumWordHeight)/Math.tan(rt*Math.PI/180) + cumColumnWidth;
// }
// else{
// x = (cumWordHeight)/Math.tan(rt*Math.PI/180) + cumColumnWidth;
// }
// }
// else{
// if(horizonAlign=="2"){
// x = (textH_all-cumWordHeight)/Math.tan(rt*Math.PI/180) + cumColumnWidth;
// }
// else if(horizonAlign=="0"){
// x = (textH_all-cumWordHeight)/Math.tan(rt*Math.PI/180) + cumColumnWidth;
// }
// else{
// x = (textH_all-cumWordHeight)/Math.tan(rt*Math.PI/180) + cumColumnWidth;
// }
// }
// // x -= wordGroup.textHeight / Math.sin(rt*Math.PI/180)*isRotateDown;
// // x -= size.textHeight*2;
// //textH_all/Math.sin(rt*Math.PI/180) - textH_all/Math.tan(rt*Math.PI/180);
// let leftOffset = 0;
// left = x + leftOffset;
// if(horizonAlign == "0"){
// //+ space_width*textH_all_ColumnHeight.length
// left = x + cellWidth / 2 + leftOffset - textW_all/2;
// }
// else if(horizonAlign == "2"){
// left = x + cellWidth + leftOffset - textW_all;
// }
// //( textH_all/2 - rh/2 )
// let topOffset = 0;
// top = y + cellHeight - topOffset - textH_all + wordGroup.asc +wordGroup.desc +(splitLen>1?(wordGroup.textHeight/1.5):0);
// if(verticalAlign == "0"){
// top = y + cellHeight/2 - topOffset - textH_all/2 + wordGroup.asc+(splitLen>1?(wordGroup.textHeight/3):0);
// }
// else if(verticalAlign == "1"){
// top = y - topOffset + wordGroup.asc;
// }
// cumColumnWidth += wordGroup.textWidth;
// if(c==0 && i==0 && isRotateUp=="1"){
// textContent.textLeftAll = left;
// textContent.textTopAll = top-wordGroup.asc;
// }
// else if(c==0 && i==(splitLen-1) && isRotateUp=="0"){
// textContent.textLeftAll = left;
// textContent.textTopAll = top+wordGroup.desc;
// }
// console.log("plainWrap" ,left , top);
}
else{//plain
left = space_width + cumColumnWidth;
@ -942,7 +1217,7 @@ function getCellTextInfo(cell , ctx, option){
top = space_height + cumWordHeight+ size.asc;
}
cumColumnWidth += wordGroup.width;
drawLineInfo(wordGroup, cancelLine, underLine,{
width:wordGroup.width,
@ -950,7 +1225,8 @@ function getCellTextInfo(cell , ctx, option){
left:left,
top:top,
asc:size.asc,
desc:size.desc
desc:size.desc,
fs:wordGroup.fs
});
}
@ -959,6 +1235,8 @@ function getCellTextInfo(cell , ctx, option){
wordGroup.top = top;
textContent.values.push(wordGroup);
cumColumnWidth += wordGroup.width;
}
@ -1096,7 +1374,8 @@ function getCellTextInfo(cell , ctx, option){
left:left,
top:top,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent
desc:measureText.actualBoundingBoxDescent,
fs:fontSize,
});
textContent.values.push(wordGroup);
@ -1116,7 +1395,17 @@ function getCellTextInfo(cell , ctx, option){
function drawLineInfo(wordGroup, cancelLine,underLine,option){
let left = option.left, top = option.top, width=option.width, height = option.height, asc = option.asc,desc = option.desc;
let left = option.left, top = option.top, width=option.width, height = option.height, asc = option.asc,desc = option.desc,fs = option.fs;
if(wordGroup.wrap===true){
return;
}
if(wordGroup.inline==true && wordGroup.style!=null){
cancelLine = wordGroup.style.cl;
underLine = wordGroup.style.un;
}
if(cancelLine!="0"){
wordGroup.cancelLine = {};
wordGroup.cancelLine.startX = left;
@ -1125,6 +1414,8 @@ function drawLineInfo(wordGroup, cancelLine,underLine,option){
wordGroup.cancelLine.endX = left + width;
wordGroup.cancelLine.endY = top-asc/2+1;
wordGroup.cancelLine.fs = fs;
}
if(underLine!="0"){
@ -1137,6 +1428,8 @@ function drawLineInfo(wordGroup, cancelLine,underLine,option){
item.endX = left + width;
item.endY = top;
item.fs = fs;
wordGroup.underLine.push(item);
}
@ -1148,6 +1441,8 @@ function drawLineInfo(wordGroup, cancelLine,underLine,option){
item.endX = left + width;
item.endY = top+desc;
item.fs = fs;
wordGroup.underLine.push(item);
}
@ -1159,6 +1454,8 @@ function drawLineInfo(wordGroup, cancelLine,underLine,option){
item.endX = left + width;
item.endY = top+desc;
item.fs = fs;
wordGroup.underLine.push(item);
}
@ -1170,6 +1467,8 @@ function drawLineInfo(wordGroup, cancelLine,underLine,option){
item.endX = left + width;
item.endY = top+desc+2;
item.fs = fs;
wordGroup.underLine.push(item);
}
}

307
src/global/getdata.js

@ -1,10 +1,12 @@
import { getObjType } from '../utils/util';
import { getObjType,rgbTohex } from '../utils/util';
import { getSheetIndex } from '../methods/get';
import server from '../controllers/server';
import formula from './formula';
import editor from './editor';
import { dynamicArrayCompute } from './dynamicArray';
import sheetmanage from '../controllers/sheetmanage';
import { isInlineStringCT,isInlineStringCell,convertCssToStyleList } from '../controllers/inlineString';
import locale from '../locale/locale';
import Store from '../store';
//Get selection range value
@ -261,4 +263,307 @@ export function getOrigincell(r, c, i) {
return data[r][c];
}
export function getRealCellValue(r, c){
let value = getcellvalue(r, c, null, "m");
if(value == null){
value = getcellvalue(r, c);
if(value==null){
let ct = getcellvalue(r, c, null, "ct");
if(isInlineStringCT(ct)){
value = ct.s;
}
}
}
return value;
}
export function getInlineStringNoStyle(r, c){
let ct = getcellvalue(r, c, null, "ct");
if(isInlineStringCT(ct)){
let strings = ct.s, value="";
for(let i=0;i<strings.length;i++){
let strObj = strings[i];
if(strObj.v!=null){
value += strObj.v;
}
}
return value;
}
return "";
}
export function getInlineStringStyle(r, c, data){
let ct = getcellvalue(r, c, data, "ct");
if (data == null) {
data = Store.flowdata;
}
let cell = data[r][c];
if(isInlineStringCT(ct)){
let strings = ct.s, value="";
for(let i=0;i<strings.length;i++){
let strObj = strings[i];
if(strObj.v!=null){
let style = getFontStyleByCell(strObj);
value += "<span index='"+ i +"' style='"+ style +"'>" + strObj.v + "</span>";
}
}
return value;
}
return "";
}
export function getFontStyleByCell(cell,checksAF,checksCF, isCheck=true){
if(cell==null){
return;
}
let style = "";
const _locale = locale();
const locale_fontarray = _locale.fontarray;
for(let key in cell){
let value = cell[key];
if(isCheck){
value = checkstatusByCell(cell, key);
}
if(key == "bl" && value != "0"){
style += "font-weight: bold;";
}
if(key == "it" && value != "0"){
style += "font-style:italic;";
}
if(key == "ff"){
let f = value;
if(!isNaN(parseInt(value))){
f = locale_fontarray[parseInt(value)];
}
else{
f = value;
}
style += "font-family: " + f + ";";
}
if(key == "fs" && value != "10"){
style += "font-size: "+ value + "pt;";
}
if((key == "fc" && value != "#000000") || checksAF != null || (checksCF != null && checksCF["textColor"] != null)){
if(checksCF != null && checksCF["textColor"] != null){
style += "color: " + checksCF["textColor"] + ";";
}
else if(checksAF != null){
style += "color: " + checksAF[0] + ";";
}
else{
style += "color: " + value + ";";
}
}
if(key == "cl" && value != "0"){
style += "text-decoration: line-through;";
}
if(key == "un" && (value == "1" || value == "3")){
let color = cell["_color"];
if(color==null){
color = cell["fc"];
}
let fs = cell["_fontSize"];
if(fs==null){
fs = cell["fs"];
}
style += "border-bottom: "+ Math.floor(fs/9) +"px solid "+ color +";";
}
}
return style;
}
export function checkstatusByCell(cell, a){
let foucsStatus =cell;
let tf = {"bl":1, "it":1 , "ff":1, "cl":1, "un":1};
if(a in tf || (a=="fs" && isInlineStringCell(cell)) ){
if(foucsStatus == null){
foucsStatus = "0";
}
else{
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(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "fc"){
if(foucsStatus == null){
foucsStatus = "#000000";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "#000000";
}
if(foucsStatus.indexOf("rgba") > -1){
foucsStatus = rgbTohex(foucsStatus);
}
}
}
else if(a == "bg"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
else if(foucsStatus.toString().indexOf("rgba") > -1){
foucsStatus = rgbTohex(foucsStatus);
}
}
}
else if(a.substr(0, 2) == "bs"){
if(foucsStatus == null){
foucsStatus = "none";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "none";
}
}
}
else if(a.substr(0, 2) == "bc"){
if(foucsStatus == null){
foucsStatus = "#000000";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "#000000";
}
}
}
else if(a == "ht"){
if(foucsStatus == null){
foucsStatus = "1";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "1";
}
}
if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
foucsStatus = "1";
}
}
else if(a == "vt"){
if(foucsStatus == null){
foucsStatus = "2";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "2";
}
}
if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
foucsStatus = "2";
}
}
else if(a == "ct"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
}
}
else if(a == "fs"){
if(foucsStatus == null){
foucsStatus = "10";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "10";
}
}
}
else if(a == "tb"){
if(foucsStatus == null){
foucsStatus = "0";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "tr"){
if(foucsStatus == null){
foucsStatus = "0";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "rt"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
}
}
return foucsStatus;
}
export function textTrim(x) {
if(x==null || x.length==0){
return x;
}
return x.replace(/^\s+|\s+$/gm,'');
}

109
src/global/refresh.js

@ -13,18 +13,21 @@ import luckysheetFreezen from '../controllers/freezen';
import server from '../controllers/server';
import sheetmanage from '../controllers/sheetmanage';
import luckysheetPostil from '../controllers/postil';
import dataVerificationCtrl from '../controllers/dataVerificationCtrl';
import { selectHightlightShow, selectionCopyShow } from '../controllers/select';
import { createFilterOptions } from '../controllers/filter';
import { getSheetIndex } from '../methods/get';
import Store from '../store';
function jfrefreshgrid(data, range, cfg, cdformat, RowlChange, isRunExecFunction=true, isRefreshCanvas=true) {
function jfrefreshgrid(data, range, allParam, isRunExecFunction = true, isRefreshCanvas = true) {
if(data == null){
data = Store.flowdata;
}
if(range == null){
range = Store.luckysheet_select_save;
}
//单元格数据更新联动
if (isRunExecFunction) {
formula.execFunctionExist = [];
@ -40,6 +43,19 @@ function jfrefreshgrid(data, range, cfg, cdformat, RowlChange, isRunExecFunction
formula.execFunctionGroupData = null;
}
//关联参数
if(allParam == null){
allParam = {};
}
let cfg = allParam["cfg"]; //config
let RowlChange = allParam["RowlChange"]; //行高改变
let cdformat = allParam["cdformat"]; //条件格式
let dataVerification = allParam["dataVerification"]; //数据验证
let dynamicArray = allParam["dynamicArray"]; //动态数组
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
if (Store.clearjfundo) {
Store.jfundo = [];
@ -53,11 +69,27 @@ function jfrefreshgrid(data, range, cfg, cdformat, RowlChange, isRunExecFunction
let curCdformat;
if(cdformat == null){
curCdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]);
curCdformat = $.extend(true, [], file["luckysheet_conditionformat_save"]);
}
else{
curCdformat = cdformat;
}
let curDataVerification;
if(dataVerification == null){
curDataVerification = $.extend(true, {}, file["dataVerification"])
}
else{
curDataVerification = dataVerification;
}
let curDynamicArray;
if(dynamicArray == null){
curDynamicArray = $.extend(true, [], file["dynamicArray"]);
}
else{
curDynamicArray = dynamicArray;
}
Store.jfredo.push({
"type": "datachange",
@ -67,21 +99,25 @@ function jfrefreshgrid(data, range, cfg, cdformat, RowlChange, isRunExecFunction
"range": range,
"config": $.extend(true, {}, Store.config),
"curConfig": curConfig,
"cdformat": $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]),
"cdformat": $.extend(true, [], file["luckysheet_conditionformat_save"]),
"curCdformat": curCdformat,
"RowlChange": RowlChange
"RowlChange": RowlChange,
"dataVerification": $.extend(true, [], file["dataVerification"]),
"curDataVerification": curDataVerification,
"dynamicArray": $.extend(true, [], file["dynamicArray"]),
"curDynamicArray": curDynamicArray
});
}
//Store.flowdata
Store.flowdata = data;
editor.webWorkerFlowDataCache(Store.flowdata);//worker存数据
Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].data = Store.flowdata;
file.data = Store.flowdata;
//config
if(cfg != null){
Store.config = cfg;
Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config;
file.config = Store.config;
server.saveParam("all", Store.currentSheetIndex, cfg, { "k": "config" });
@ -92,11 +128,25 @@ function jfrefreshgrid(data, range, cfg, cdformat, RowlChange, isRunExecFunction
//条件格式
if(cdformat != null){
Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"] = cdformat;
file["luckysheet_conditionformat_save"] = cdformat;
server.saveParam("all", Store.currentSheetIndex, cdformat, { "k": "luckysheet_conditionformat_save" });
}
//数据验证
if(dataVerification != null){
dataVerificationCtrl.dataVerification = dataVerification;
file["dataVerification"] = dataVerification;
server.saveParam("all", Store.currentSheetIndex, dataVerification, { "k": "dataVerification" });
}
//动态数组
if(dynamicArray != null){
file["dynamicArray"] = dynamicArray;
server.saveParam("all", Store.currentSheetIndex, dynamicArray, { "k": "dynamicArray" });
}
//更新数据的范围
for(let s = 0; s < range.length; s++){
let r1 = range[s].row[0];
@ -127,7 +177,6 @@ function jfrefreshgrid(data, range, cfg, cdformat, RowlChange, isRunExecFunction
luckysheetrefreshgrid();
}, 1);
}
window.luckysheet_getcelldata_cache = null;
}
@ -331,7 +380,7 @@ function jfrefreshrange(data, range, cdformat) {
}
//删除、增加行列 刷新表格
function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf, af, freezen){
function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf, af, freezen, dataVerification){
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
//merge改变对应的单元格值改变
@ -364,7 +413,7 @@ function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf,
for(let i = 0; i < calc.length; i++){
let clc = calc[i];
let clc_r = clc.r, clc_c = clc.c, clc_i = clc.index, clc_funcStr = getcellFormula(clc_r, clc_c, clc_i);
let clc_r = clc.r, clc_c = clc.c, clc_i = clc.index, clc_funcStr = getcellFormula(clc_r, clc_c, clc_i, data);
let clc_result = formula.execfunction(clc_funcStr, clc_r, clc_c, null, true);
clc.func = clc_result;
@ -397,7 +446,9 @@ function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf,
"af": $.extend(true, [], file.luckysheet_alternateformat_save),
"curAf": af,
"freezen": { "freezenhorizontaldata": luckysheetFreezen.freezenhorizontaldata, "freezenverticaldata": luckysheetFreezen.freezenverticaldata },
"curFreezen": freezen
"curFreezen": freezen,
"dataVerification": $.extend(true, {}, file.dataVerification),
"curDataVerification": dataVerification
});
}
@ -516,12 +567,17 @@ function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf,
luckysheetFreezen.freezenverticaldata = null;
}
//数据验证
dataVerificationCtrl.dataVerification = dataVerification;
file.dataVerification = dataVerification;
server.saveParam("all", Store.currentSheetIndex, file.dataVerification, { "k": "dataVerification" });
//行高、列宽刷新
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
}
//删除单元格 刷新表格
function jfrefreshgrid_deleteCell(data, cfg, ctrl, calc, filterObj, cf){
function jfrefreshgrid_deleteCell(data, cfg, ctrl, calc, filterObj, cf, dataVerification){
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
//merge改变对应的单元格值改变
@ -568,7 +624,7 @@ function jfrefreshgrid_deleteCell(data, cfg, ctrl, calc, filterObj, cf){
for(let i = 0; i < calc.length; i++){
let clc = calc[i];
let clc_r = clc.r, clc_c = clc.c, clc_i = clc.index, clc_funcStr = getcellFormula(clc_r, clc_c, clc_i);
let clc_r = clc.r, clc_c = clc.c, clc_i = clc.index, clc_funcStr = getcellFormula(clc_r, clc_c, clc_i, data);
let clc_result = formula.execfunction(clc_funcStr, clc_r, clc_c, null, true);
clc.func = clc_result;
@ -598,6 +654,8 @@ function jfrefreshgrid_deleteCell(data, cfg, ctrl, calc, filterObj, cf){
"curFilterObj": filterObj,
"cf": $.extend(true, [], file.luckysheet_conditionformat_save),
"curCf": cf,
"dataVerification": $.extend(true, {}, file.dataVerification),
"curDataVerification": dataVerification
});
}
@ -671,6 +729,11 @@ function jfrefreshgrid_deleteCell(data, cfg, ctrl, calc, filterObj, cf){
file.luckysheet_conditionformat_save = cf;
server.saveParam("all", Store.currentSheetIndex, file.luckysheet_conditionformat_save, { "k": "luckysheet_conditionformat_save" });
//数据验证
dataVerificationCtrl.dataVerification = dataVerification;
file.dataVerification = dataVerification;
server.saveParam("all", Store.currentSheetIndex, file.dataVerification, { "k": "dataVerification" });
setTimeout(function () {
luckysheetrefreshgrid();
}, 1);
@ -795,6 +858,16 @@ function jfrefreshgrid_pastcut(source, target, RowlChange){
Store.luckysheetfile[getSheetIndex(source["sheetIndex"])].luckysheet_conditionformat_save = source["curCdformat"];
Store.luckysheetfile[getSheetIndex(target["sheetIndex"])].luckysheet_conditionformat_save = target["curCdformat"];
//数据验证
if(Store.currentSheetIndex == source["sheetIndex"]){
dataVerificationCtrl.dataVerification = source["curDataVerification"];
}
else if(Store.currentSheetIndex == target["sheetIndex"]){
dataVerificationCtrl.dataVerification = target["curDataVerification"]
}
Store.luckysheetfile[getSheetIndex(source["sheetIndex"])].dataVerification = source["curDataVerification"];
Store.luckysheetfile[getSheetIndex(target["sheetIndex"])].dataVerification = target["curDataVerification"];
setTimeout(function () {
luckysheetrefreshgrid();
}, 1);
@ -811,6 +884,16 @@ function jfrefreshgrid_pastcut(source, target, RowlChange){
server.historyParam(source["curData"], source["sheetIndex"], {"row": source["range"]["row"], "column": source["range"]["column"]});
//目的表
server.historyParam(target["curData"], target["sheetIndex"], {"row": target["range"]["row"], "column": target["range"]["column"]});
//来源表
server.saveParam("all", source["sheetIndex"], source["curCdformat"], { "k": "luckysheet_conditionformat_save" });
//目的表
server.saveParam("all", target["sheetIndex"], target["curCdformat"], { "k": "luckysheet_conditionformat_save" });
//来源表
server.saveParam("all", source["sheetIndex"], source["curDataVerification"], { "k": "dataVerification" });
//目的表
server.saveParam("all", target["sheetIndex"], target["curDataVerification"], { "k": "dataVerification" });
}
//行高、列宽改变 刷新表格

22
src/global/sort.js

@ -267,15 +267,18 @@ function sortSelection(isAsc) {
}
}
let allParam = {};
if(Store.config["rowlen"] != null){
let cfg = $.extend(true, {}, Store.config);
cfg = rowlenByRange(d, str, edr, cfg);
jfrefreshgrid(d, [{ "row": [str, edr], "column": [c1, c2] }], cfg, null, true);
}
else{
jfrefreshgrid(d, [{ "row": [str, edr], "column": [c1, c2] }]);
allParam = {
"cfg": cfg,
"RowlChange": true
}
}
jfrefreshgrid(d, [{ "row": [str, edr], "column": [c1, c2] }], allParam);
}
//排序一列数据
@ -352,15 +355,18 @@ function sortColumnSeletion(colIndex, isAsc) {
}
}
let allParam = {};
if(Store.config["rowlen"] != null){
let cfg = $.extend(true, {}, Store.config);
cfg = rowlenByRange(d, str, edr, cfg);
jfrefreshgrid(d, [{ "row": [str, edr], "column": [c1, c2] }], cfg, null, true);
}
else{
jfrefreshgrid(d, [{ "row": [str, edr], "column": [c1, c2] }]);
allParam = {
"cfg": cfg,
"RowlChange": true
}
}
jfrefreshgrid(d, [{ "row": [str, edr], "column": [c1, c2] }], allParam);
}
export {

41
src/index.html

@ -38,7 +38,7 @@
// "ct":{
// "fa":"General",
// "t":"inlineStr",
// "sharedStrings":[
// "s":[
// {
// "ff":"等线", //font family
// "fc":"#fff000",//font color
@ -80,6 +80,45 @@
plugins: ['chart'],
data:
[sheetCell,sheetFormula,sheetConditionFormat,sheetSparkline,sheetTable,sheetComment,sheetPivotTableData,sheetPivotTable,sheetChart]
// [{"name":"Sheet1","config":{"columnlen":{"0":241},"rowlen":{"0":81}},"index":"1","status":"1","order":"0","luckysheet_select_save":[{"row":[0,0],"column":[4,4],"sheetIndex":1}],"zoomRatio":1,"showGridLines":"1","defaultColWidth":72,"defaultRowHeight":18,"celldata":[
// {"r":0,"c":0,
// "v":{
// "ct":{
// "fa":"General",
// "t":"inlineStr",
// "s":[
// {
// "ff":"Arial", //font family
// "fc":"#fff000",//font color
// "fs":12,//font size
// "cl":0,//strike
// "un":0,//underline
// "bl":0,//blod
// "it":0,//italic
// v:"我在马路\r\n边捡到\r\n\r\n一分钱"
// },
// {
// "ff":"Arial", //font family
// "fc":"#ff0000",//font color
// "fs":14,//font size
// "cl":"1",//strike
// "un":"1",//underline
// "bl":"1",//blod
// "it":"0",//italic
// v:"交给警\r\n察叔叔\r\n"
// },
// ]
// },
// "fs":11,
// "ff":"等线",
// "vt":0,
// "tb":2,
// "v":"",
// "qp":1,
// }
// },
// {"r":17,"c":2,"v":{"v":"Luckysheet","ct":{"fa":"General","t":"g"},"bg":null,"bl":0,"it":0,"ff":0,"fs":"11","fc":"rgb(51, 51, 51)","ht":1,"vt":1,"m":"Luckysheet"}}
// ],"calcChain":[]}]
})
})

52
src/locale/en.js

@ -46,6 +46,7 @@ export default {
screenshot: 'Screenshot',
splitColumn: 'Split text',
insertImage: 'Insert image',
dataVerification: 'Data verification',
clearText:"Clear color",
noColorSelectedText:"No color is selected",
@ -609,7 +610,6 @@ export default {
"space":"space",
},
findAndReplace:{
find:"Find",
replace:"Replace",
@ -640,6 +640,7 @@ export default {
findBtn:"Find next",
noFindTip:"The content was not found",
modeTip:"This operation is not available in this mode",
searchTargetSheet:"Sheet",
searchTargetCell:"Cell",
@ -867,6 +868,55 @@ export default {
fiveQuadrantDiagram: 'Five-quadrant diagram',
fiveBoxes: '5 Boxes',
},
dataVerification: {
cellRange: 'Cell range',
selectCellRange: 'Click to select cell range',
selectCellRange2: 'Please select a range of cells',
verificationCondition: 'Verification condition',
dropdown: 'drop-down list',
checkbox: 'Checkbox',
number: 'Number',
number_integer: 'Number-integer',
number_decimal: 'Number-decimal',
text_content: 'Text-content',
text_length: 'Text-length',
date: 'Date',
validity: 'Effectiveness',
placeholder1: 'Please enter the options, separated by commas, such as 1,2,3,4,5',
placeholder2: 'Please enter content',
placeholder3: 'Numeric value, such as 10',
placeholder4: 'Please enter the specified text',
placeholder5: 'Please enter the prompt displayed when the cell is selected',
selected: 'Selected',
notSelected: 'Not selected',
between: 'Between',
notBetween: 'Not between',
equal: 'Equal',
notEqualTo: 'Not equal to',
moreThanThe: 'More than the',
lessThan: 'Less than',
greaterOrEqualTo: 'Greater or equal to',
lessThanOrEqualTo: 'Less than or equal to',
include: 'Include',
exclude: 'Exclude',
earlierThan: 'Earlier than',
noEarlierThan: 'No earlier than',
laterThan: 'Later than',
noLaterThan: 'No later than',
identificationNumber: 'Identification number',
phoneNumber: 'Phone number',
remote: 'Automatic remote acquisition option',
prohibitInput: 'Prohibit input when input data is invalid',
hintShow: 'Show prompt when cell is selected',
deleteVerification: 'Delete verification',
tooltipInfo1: 'The drop-down list option cannot be empty',
tooltipInfo2: 'Checkbox content cannot be empty',
tooltipInfo3: 'The value entered is not a numeric type',
tooltipInfo4: 'The value 2 cannot be less than the value 1',
tooltipInfo5: 'The text content cannot be empty',
tooltipInfo6: 'The value entered is not a date type',
tooltipInfo7: 'Date 2 cannot be less than date 1',
},
formula:{
sum:"Sum",
average:"Average",

51
src/locale/zh.js

@ -46,6 +46,7 @@ export default {
screenshot: '截图',
splitColumn: '分列',
insertImage: '插入图片',
dataVerification: '数据验证',
clearText:"清除颜色选择",
noColorSelectedText:"没有颜色被选择",
@ -655,6 +656,7 @@ export default {
findBtn:"查找下一个",
noFindTip:"没有查找到该内容",
modeTip:"该模式下不可进行此操作",
searchTargetSheet:"工作表",
searchTargetCell:"单元格",
@ -884,6 +886,55 @@ export default {
fiveQuadrantDiagram: '五象限图',
fiveBoxes: '5个框',
},
dataVerification: {
cellRange: '单元格范围',
selectCellRange: '点击选择单元格范围',
selectCellRange2: '请选择单元格范围',
verificationCondition: '验证条件',
dropdown: '下拉列表',
checkbox: '复选框',
number: '数字',
number_integer: '数字-整数',
number_decimal: '数字-小数',
text_content: '文本-内容',
text_length: '文本-长度',
date: '日期',
validity: '有效性',
placeholder1: '请输入选项,以英文逗号分隔,如1,2,3,4,5',
placeholder2: '请输入内容',
placeholder3: '数值,如10',
placeholder4: '请输入指定的文本',
placeholder5: '请输入选中单元格时显示的提示语',
selected: '选择时',
notSelected: '未选择',
between: '介于',
notBetween: '不介于',
equal: '等于',
notEqualTo: '不等于',
moreThanThe: '大于',
lessThan: '小于',
greaterOrEqualTo: '大于等于',
lessThanOrEqualTo: '小于等于',
include: '包括',
exclude: '不包括',
earlierThan: '早于',
noEarlierThan: '不早于',
laterThan: '晚于',
noLaterThan: '不晚于',
identificationNumber: '身份证号码',
phoneNumber: '手机号',
remote: '自动远程获取选项',
prohibitInput: '输入数据无效时禁止输入',
hintShow: '选中单元格时显示提示语',
deleteVerification: '删除验证',
tooltipInfo1: '下拉列表选项不可为空',
tooltipInfo2: '复选框内容不可为空',
tooltipInfo3: '输入的值不是数值类型',
tooltipInfo4: '数值2不能小于数值1',
tooltipInfo5: '文本内容不能为空',
tooltipInfo6: '输入的值不是日期类型',
tooltipInfo7: '日期2不能小于日期1',
},
formula:{
sum:"求和",
average:"平均值",

2
src/store/index.js

@ -127,6 +127,8 @@ const Store = {
showGridLines:true,
toobarObject: {}, //toolbar constant
inlineStringEditCache:null,
inlineStringEditRange:null,
}

Loading…
Cancel
Save