Browse Source

fix(bug): 渲染换行空行

master
break-wave 5 years ago
parent
commit
4162b7a049
  1. 18
      src/global/formula.js
  2. 29
      src/global/getRowlen.js

18
src/global/formula.js

@ -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";
@ -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

29
src/global/getRowlen.js

@ -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];
@ -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,
@ -359,8 +359,6 @@ function getCellTextInfo(cell , ctx, option){
}
}
preNewValue = newValue;
}
similarIndex++;
@ -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 = {
@ -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]= [];

Loading…
Cancel
Save