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

Commit

Permalink
fix(bug): 渲染换行空行
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry-f committed Jan 4, 2021
1 parent 18f13af commit 4162b7a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
24 changes: 21 additions & 3 deletions src/global/formula.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ const luckysheetformula = {

return offsetRange;
},
parseDatetoNum: function (date) { //函数中获取到时间格式或者数字形式统一转化为数字进行运算
parseDatetoNum: function (date) { //函数中获取到时间格式或者数字形式统一转化为数字进行运算
let _this = this;

if (typeof (date) == "object" && typeof date.v == "number") {
Expand Down Expand Up @@ -1263,6 +1263,17 @@ const luckysheetformula = {

let isPrevInline = isInlineStringCell(curv);
let isCurInline = (inputText.slice(0, 1) != "=" && inputHtml.substr(0, 5) == "<span");

let isCopyVal = false;
if(!isCurInline && inputText && inputText.length > 0) {
let splitArr = inputText.replace(/\r\n/g, "_x000D_").replace(/&#13;&#10;/g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_").split("_x000D_");
if(splitArr.length > 1) {
isCopyVal = true;
isCurInline = true;
inputText = splitArr.join('\r\n');
}
}

if (!value && !isCurInline && isPrevInline) {
delete curv.ct.s;
curv.ct.t = "g";
Expand All @@ -1284,6 +1295,13 @@ const luckysheetformula = {

curv.ct.t = "inlineStr";
curv.ct.s = convertSpanToShareString($input.find("span"));
if(isCopyVal) {
curv.ct.s = [
{
v: inputText,
}
];
}
}

// API, we get value from user
Expand Down Expand Up @@ -1448,7 +1466,7 @@ const luckysheetformula = {
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
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";
Expand Down Expand Up @@ -5269,7 +5287,7 @@ const luckysheetformula = {
// if(key in updateValueOjects){
// updateValueArray.push(item);
// }
// });
// });
// }

}
Expand Down
29 changes: 2 additions & 27 deletions src/global/getRowlen.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ function getCellTextInfo(cell , ctx, option){
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;
let splitArr = v.split("_x000D_");
for(let x=0;x<splitArr.length;x++){
let newValue = splitArr[x];

Expand Down Expand Up @@ -346,7 +346,7 @@ function getCellTextInfo(cell , ctx, option){

}

if(x!=splitArr.length-1 && preNewValue!="" ){
if(x!=splitArr.length-1 ){
inlineStringArr.push({
fontset:scfontset,
fc:fc==null?"#000":fc,
Expand All @@ -359,8 +359,6 @@ function getCellTextInfo(cell , ctx, option){
}
}

preNewValue = newValue;

}

similarIndex++;
Expand Down Expand Up @@ -903,10 +901,6 @@ function getCellTextInfo(cell , ctx, option){

let height = textWidth * Math.sin(rt*Math.PI/180) + textHeight * Math.cos(rt*Math.PI/180);//consider text box wdith and line height
let lastWord = str.substr(str.length-1,1);
let isSpace = false;
if(checkWordByteLength(lastWord)===1 && lastWord !== ' ' && !/^.$/.test(lastWord) && !/^.$/u.test(lastWord)) {
isSpace = lastWord.replace(/\r\n/g, "_x000D_").replace(/&#13;&#10;/g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_") === '_x000D_';
}
if(lastWord==" " || checkWordByteLength(lastWord)==2){
if(preMeasureText!=null){
spaceOrTwoByte = {
Expand Down Expand Up @@ -1058,25 +1052,6 @@ function getCellTextInfo(cell , ctx, option){
splitIndex +=1;
}
}
else if(isSpace && text_all_split[splitIndex]!=null && i!= value.length) {

spaceOrTwoByte = null;
anchor = i;

text_all_split[splitIndex].push({
content:str,
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]= [];
Expand Down

0 comments on commit 4162b7a

Please sign in to comment.