From 32fd31d9897b425451e8cbb4bb56da25777105ef Mon Sep 17 00:00:00 2001 From: liuyang Date: Wed, 16 Sep 2020 18:44:23 +0800 Subject: [PATCH] refactor(inline string): develop --- src/global/getRowlen.js | 153 ++++++++++++++++++++++++---------------- src/index.html | 42 ++++++++++- 2 files changed, 132 insertions(+), 63 deletions(-) diff --git a/src/global/getRowlen.js b/src/global/getRowlen.js index a0d64c5..8727025 100644 --- a/src/global/getRowlen.js +++ b/src/global/getRowlen.js @@ -325,12 +325,16 @@ function getCellTextInfo(cell , ctx, option){ let scfontset = luckysheetfontformat(shareCell); let fc = shareCell.fc, cl=shareCell.cl,un = shareCell.un, v = shareCell.v; v = v.replace(/\r\n/g, "_x000D_").replace(/ /g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_"); - let splitArr = v.split("_x000D_"); + let splitArr = v.split("_x000D_"), preNewValue=null; for(let x=0;x1){ + for(let s=0;scellHeight && text_all_split[splitIndex]!=null){ + if((height+space_height)>cellHeight && text_all_split[splitIndex]!=null && tb=="2"){ // console.log("cut",anchor, i , str); anchor = i-1; @@ -610,13 +647,11 @@ function getCellTextInfo(cell , ctx, option){ text_all_split[splitIndex].push({ content:sc.v, style:sc, - width:sc.width, - height:sc.height, + width:sc.measureText.width, + height:sc.measureText.actualBoundingBoxAscent+sc.measureText.actualBoundingBoxDescent, left:0, top:0, splitIndex:splitIndex, - textHeight:sc.textHeight, - textWidth:sc.textWidth, asc:sc.measureText.actualBoundingBoxAscent, desc:sc.measureText.actualBoundingBoxDescent, inline:true, @@ -635,13 +670,11 @@ function getCellTextInfo(cell , ctx, option){ text_all_split[splitIndex].push({ content:sc.v, style:sc, - width:sc.width, - height:sc.height, + width:sc.measureText.width, + height:sc.measureText.actualBoundingBoxAscent+sc.measureText.actualBoundingBoxDescent, left:0, top:0, splitIndex:splitIndex, - textHeight:sc.textHeight, - textWidth:sc.textWidth, asc:sc.measureText.actualBoundingBoxAscent, desc:sc.measureText.actualBoundingBoxDescent, inline:true, @@ -657,7 +690,7 @@ function getCellTextInfo(cell , ctx, option){ } } else{//plain - if((width+space_width)>cellWidth && text_all_split[splitIndex]!=null){ + if((width+space_width)>cellWidth && text_all_split[splitIndex]!=null && tb=="2"){ anchor = i-1; @@ -666,8 +699,8 @@ function getCellTextInfo(cell , ctx, option){ text_all_split[splitIndex].push({ content:sc.v, style:sc, - width:sc.width, - height:sc.height, + width:sc.measureText.width, + height:sc.measureText.actualBoundingBoxAscent+sc.measureText.actualBoundingBoxDescent, left:0, top:0, splitIndex:splitIndex, @@ -689,8 +722,8 @@ function getCellTextInfo(cell , ctx, option){ text_all_split[splitIndex].push({ content:sc.v, style:sc, - width:sc.width, - height:sc.height, + width:sc.measureText.width, + height:sc.measureText.actualBoundingBoxAscent+sc.measureText.actualBoundingBoxDescent, left:0, top:0, splitIndex:splitIndex, @@ -735,13 +768,11 @@ function getCellTextInfo(cell , ctx, option){ text_all_split[splitIndex].push({ content:preStr, style:fontset, - width:preWidth, - height:preHeight, left:0, top:0, splitIndex:splitIndex, - textHeight:preTextHeight, - textWidth:preTextWidth, + height:preTextHeight, + width:preTextWidth, asc:measureText.actualBoundingBoxAscent, desc:measureText.actualBoundingBoxDescent }); @@ -756,13 +787,11 @@ function getCellTextInfo(cell , ctx, option){ text_all_split[splitIndex].push({ content:str, style:fontset, - width:width, - height:height, left:0, top:0, splitIndex:splitIndex, - textHeight:textHeight, - textWidth:textWidth, + height:textHeight, + width:textWidth, asc:measureText.actualBoundingBoxAscent, desc:measureText.actualBoundingBoxDescent }); @@ -783,8 +812,8 @@ function getCellTextInfo(cell , ctx, option){ text_all_split[splitIndex].push({ content:preStr, style:fontset, - width:preWidth, - height:preHeight, + width:preTextWidth, + height:preTextHeight, left:0, top:0, splitIndex:splitIndex, @@ -801,8 +830,8 @@ function getCellTextInfo(cell , ctx, option){ text_all_split[splitIndex].push({ content:str, style:fontset, - width:width, - height:height, + width:textWidth, + height:textHeight, left:0, top:0, splitIndex:splitIndex, @@ -820,8 +849,6 @@ function getCellTextInfo(cell , ctx, option){ } } - preWidth = width; - preHeight = height; preStr = str; preTextHeight = textHeight; preTextWidth = textWidth; @@ -841,8 +868,8 @@ function getCellTextInfo(cell , ctx, option){ for(let s=0;s