Browse Source

fix(bug): 渲染换行空行

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

24
src/global/formula.js

@ -380,7 +380,7 @@ const luckysheetformula = {
return offsetRange; return offsetRange;
}, },
parseDatetoNum: function (date) { //函数中获取到时间格式或者数字形式统一转化为数字进行运算 parseDatetoNum: function (date) { //函数中获取到时间格式或者数字形式统一转化为数字进行运算
let _this = this; let _this = this;
if (typeof (date) == "object" && typeof date.v == "number") { if (typeof (date) == "object" && typeof date.v == "number") {
@ -1263,6 +1263,17 @@ const luckysheetformula = {
let isPrevInline = isInlineStringCell(curv); let isPrevInline = isInlineStringCell(curv);
let isCurInline = (inputText.slice(0, 1) != "=" && inputHtml.substr(0, 5) == "<span"); 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) { if (!value && !isCurInline && isPrevInline) {
delete curv.ct.s; delete curv.ct.s;
curv.ct.t = "g"; curv.ct.t = "g";
@ -1284,6 +1295,13 @@ const luckysheetformula = {
curv.ct.t = "inlineStr"; curv.ct.t = "inlineStr";
curv.ct.s = convertSpanToShareString($input.find("span")); curv.ct.s = convertSpanToShareString($input.find("span"));
if(isCopyVal) {
curv.ct.s = [
{
v: inputText,
}
];
}
} }
// API, we get value from user // API, we get value from user
@ -1448,7 +1466,7 @@ const luckysheetformula = {
delete curv.f; delete curv.f;
delete curv.spl; 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; curv.qp = 0;
if (curv.ct != null) { if (curv.ct != null) {
curv.ct.fa = "General"; curv.ct.fa = "General";
@ -5269,7 +5287,7 @@ const luckysheetformula = {
// if(key in updateValueOjects){ // if(key in updateValueOjects){
// updateValueArray.push(item); // updateValueArray.push(item);
// } // }
// }); // });
// } // }
} }

29
src/global/getRowlen.js

@ -314,7 +314,7 @@ function getCellTextInfo(cell , ctx, option){
let scfontset = luckysheetfontformat(shareCell); let scfontset = luckysheetfontformat(shareCell);
let fc = shareCell.fc, cl=shareCell.cl,un = shareCell.un, v = shareCell.v, fs=shareCell.fs; 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_"); 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++){ for(let x=0;x<splitArr.length;x++){
let newValue = splitArr[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({ inlineStringArr.push({
fontset:scfontset, fontset:scfontset,
fc:fc==null?"#000":fc, fc:fc==null?"#000":fc,
@ -359,8 +359,6 @@ function getCellTextInfo(cell , ctx, option){
} }
} }
preNewValue = newValue;
} }
similarIndex++; 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 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 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(lastWord==" " || checkWordByteLength(lastWord)==2){
if(preMeasureText!=null){ if(preMeasureText!=null){
spaceOrTwoByte = { spaceOrTwoByte = {
@ -1058,25 +1052,6 @@ function getCellTextInfo(cell , ctx, option){
splitIndex +=1; 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){ else if(i== value.length){
if(text_all_split[splitIndex]==null){ if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= []; text_all_split[splitIndex]= [];

Loading…
Cancel
Save