Browse Source

fix(lineheight change to 0.5): similar to excel

master
liuyang 5 years ago
parent
commit
760378b369
  1. 14
      src/controllers/inlineString.js
  2. 34
      src/controllers/select.js
  3. 2
      src/controllers/sheetmanage.js
  4. 4
      src/global/getRowlen.js

14
src/controllers/inlineString.js

@ -372,20 +372,20 @@ export function convertCssToStyleList(cssText){
return {}; return {};
} }
let cssTextArray = cssText.split(";"); let cssTextArray = cssText.split(";");
const _locale = locale();
const locale_fontarray = _locale.fontarray;
const locale_fontjson = _locale.fontjson;
let styleList = { let styleList = {
"ff":"Arial", //font family "ff":locale_fontarray[0], //font family
"fc":"#000000",//font color "fc":"#000000",//font color
"fs":12,//font size "fs":10,//font size
"cl":0,//strike "cl":0,//strike
"un":0,//underline "un":0,//underline
"bl":0,//blod "bl":0,//blod
"it":0,//italic "it":0,//italic
}; };
const _locale = locale();
const locale_fontarray = _locale.fontarray;
const locale_fontjson = _locale.fontjson;
cssTextArray.forEach(s => { cssTextArray.forEach(s => {
s = s.toLowerCase(); s = s.toLowerCase();
let key = textTrim(s.substr(0, s.indexOf(':'))); let key = textTrim(s.substr(0, s.indexOf(':')));

34
src/controllers/select.js

@ -24,7 +24,7 @@ function seletedHighlistByindex(id, r1, r2, c1, c2) {
} }
//Set selection highlight //Set selection highlight
function selectHightlightShow() { function selectHightlightShow(isRestore=false) {
$("#luckysheet-cell-selected-boxs").show(); $("#luckysheet-cell-selected-boxs").show();
$("#luckysheet-cell-selected-boxs #luckysheet-cell-selected").siblings(".luckysheet-cell-selected").remove(); $("#luckysheet-cell-selected-boxs #luckysheet-cell-selected").siblings(".luckysheet-cell-selected").remove();
@ -80,10 +80,19 @@ function selectHightlightShow() {
Store.luckysheet_select_save[i]["top"] = row_pre_f; Store.luckysheet_select_save[i]["top"] = row_pre_f;
Store.luckysheet_select_save[i]["height"] = row_f - row_pre_f - 1; Store.luckysheet_select_save[i]["height"] = row_f - row_pre_f - 1;
Store.luckysheet_select_save[i]["left_move"] = col_pre; if(isRestore){
Store.luckysheet_select_save[i]["width_move"] = col - col_pre - 1; Store.luckysheet_select_save[i]["left_move"] = col_pre_f;
Store.luckysheet_select_save[i]["top_move"] = row_pre; Store.luckysheet_select_save[i]["width_move"] = col_f - col_pre_f - 1;
Store.luckysheet_select_save[i]["height_move"] = row - row_pre - 1; Store.luckysheet_select_save[i]["top_move"] = row_pre_f;
Store.luckysheet_select_save[i]["height_move"] = row_f - row_pre_f - 1;
}
else{
Store.luckysheet_select_save[i]["left_move"] = col_pre;
Store.luckysheet_select_save[i]["width_move"] = col - col_pre - 1;
Store.luckysheet_select_save[i]["top_move"] = row_pre;
Store.luckysheet_select_save[i]["height_move"] = row - row_pre - 1;
}
if(i == 0){ if(i == 0){
if(Store.luckysheet_select_save.length == 1){ if(Store.luckysheet_select_save.length == 1){
@ -170,7 +179,7 @@ function selectHightlightShow() {
} }
//行列标题栏 //行列标题栏
selectTitlesShow(Store.luckysheet_select_save); selectTitlesShow(Store.luckysheet_select_save,isRestore);
//左上角范围显示 //左上角范围显示
selectHelpboxFill(); selectHelpboxFill();
@ -185,13 +194,24 @@ function selectHightlightShow() {
} }
//选区标题栏 //选区标题栏
function selectTitlesShow(rangeArr) { function selectTitlesShow(rangeArr,isRestore=false) {
let s = $.extend(true, [], rangeArr); let s = $.extend(true, [], rangeArr);
let rowTitleMap = {}, columnTitleMap = {}; let rowTitleMap = {}, columnTitleMap = {};
for(let i = 0; i < s.length; i++){ for(let i = 0; i < s.length; i++){
let r1 = s[i]["row"][0], r2 = s[i]["row"][1], c1 = s[i]["column"][0], c2 = s[i]["column"][1]; let r1 = s[i]["row"][0], r2 = s[i]["row"][1], c1 = s[i]["column"][0], c2 = s[i]["column"][1];
if(isRestore){
let margeset = menuButton.mergeborer(Store.flowdata, r1, c1);
if(!!margeset){
r1 = margeset.row[2];
r2 = margeset.row[3];
c1 = margeset.column[2];
c2 = margeset.column[3];
}
}
//行、列标题栏 //行、列标题栏
rowTitleMap = selectTitlesMap(rowTitleMap, r1, r2); rowTitleMap = selectTitlesMap(rowTitleMap, r1, r2);
columnTitleMap = selectTitlesMap(columnTitleMap, c1, c2); columnTitleMap = selectTitlesMap(columnTitleMap, c1, c2);

2
src/controllers/sheetmanage.js

@ -917,7 +917,7 @@ const sheetmanage = {
let file = Store.luckysheetfile[index]; let file = Store.luckysheetfile[index];
//选区 //选区
selectHightlightShow(); selectHightlightShow(true);
//复制选区虚线框 //复制选区虚线框
selectionCopyShow(); selectionCopyShow();

4
src/global/getRowlen.js

@ -982,7 +982,7 @@ function getCellTextInfo(cell , ctx, option){
maxWordCount++; maxWordCount++;
} }
lineHeight = sHeight/1.5; lineHeight = sHeight/2;
oneLinemaxWordCount = Math.max(oneLinemaxWordCount, maxWordCount); oneLinemaxWordCount = Math.max(oneLinemaxWordCount, maxWordCount);
if(rt!=0){//rotate if(rt!=0){//rotate
sHeight+=lineHeight; sHeight+=lineHeight;
@ -1334,7 +1334,7 @@ function getCellTextInfo(cell , ctx, option){
textContent.textHeightAll = textHeightAll; textContent.textHeightAll = textHeightAll;
} }
else{ else{
textContent.textHeightAll = textHeightAll+textHeight/1.5-measureText.actualBoundingBoxDescent-space_height; textContent.textHeightAll = textHeightAll+textHeight/2-measureText.actualBoundingBoxDescent-space_height;
} }
textContent.textWidthAll = textWidthAll; textContent.textWidthAll = textWidthAll;

Loading…
Cancel
Save