Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(lineheight change to 0.5): similar to excel
Browse files Browse the repository at this point in the history
  • Loading branch information
tubiaoge committed Oct 14, 2020
1 parent a4f1ad3 commit 760378b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
14 changes: 7 additions & 7 deletions src/controllers/inlineString.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,20 +372,20 @@ export function convertCssToStyleList(cssText){
return {};
}
let cssTextArray = cssText.split(";");


const _locale = locale();
const locale_fontarray = _locale.fontarray;
const locale_fontjson = _locale.fontjson;
let styleList = {
"ff":"Arial", //font family
"ff":locale_fontarray[0], //font family
"fc":"#000000",//font color
"fs":12,//font size
"fs":10,//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(':')));
Expand Down
34 changes: 27 additions & 7 deletions src/controllers/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function seletedHighlistByindex(id, r1, r2, c1, c2) {
}

//Set selection highlight
function selectHightlightShow() {
function selectHightlightShow(isRestore=false) {
$("#luckysheet-cell-selected-boxs").show();
$("#luckysheet-cell-selected-boxs #luckysheet-cell-selected").siblings(".luckysheet-cell-selected").remove();

Expand Down Expand Up @@ -80,10 +80,19 @@ function selectHightlightShow() {
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]["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(isRestore){
Store.luckysheet_select_save[i]["left_move"] = col_pre_f;
Store.luckysheet_select_save[i]["width_move"] = col_f - col_pre_f - 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(Store.luckysheet_select_save.length == 1){
Expand Down Expand Up @@ -170,7 +179,7 @@ function selectHightlightShow() {
}

//行列标题栏
selectTitlesShow(Store.luckysheet_select_save);
selectTitlesShow(Store.luckysheet_select_save,isRestore);

//左上角范围显示
selectHelpboxFill();
Expand All @@ -185,13 +194,24 @@ function selectHightlightShow() {
}

//选区标题栏
function selectTitlesShow(rangeArr) {
function selectTitlesShow(rangeArr,isRestore=false) {
let s = $.extend(true, [], rangeArr);

let rowTitleMap = {}, columnTitleMap = {};
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];

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);
columnTitleMap = selectTitlesMap(columnTitleMap, c1, c2);
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/sheetmanage.js
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ const sheetmanage = {
let file = Store.luckysheetfile[index];

//选区
selectHightlightShow();
selectHightlightShow(true);

//复制选区虚线框
selectionCopyShow();
Expand Down
4 changes: 2 additions & 2 deletions src/global/getRowlen.js
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ function getCellTextInfo(cell , ctx, option){
maxWordCount++;
}

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

Expand Down

0 comments on commit 760378b

Please sign in to comment.