swen-xiong 5 years ago
parent
commit
a4009ad73f
  1. 6
      docs/guide/data.md
  2. 1346
      docs/guide/sheet.md
  3. 4
      src/controllers/formulaBar.js
  4. 2
      src/controllers/handler.js
  5. 2
      src/controllers/keyboard.js
  6. 142
      src/global/getRowlen.js

6
docs/guide/data.md

@ -29,15 +29,15 @@
"colhidden":{}, //hidden columns
"borderInfo":{}, //borders
},
"celldata": [], //initialize the cell data used
"data": [], //Update and store the cell data used
"celldata": [], //initialize the cell data
"data": [], //Update and store the cell data
"scrollLeft": 0, //Left and right scroll bar position
"scrollTop": 315, //Up and down scroll bar position
"luckysheet_select_save": [], //selected area
"luckysheet_conditionformat_save": {},//Conditional format
"calcChain": [],//Formula chain
"isPivotTable":false,//Whether to pivot table
"pivotTable":{},//Pivot table settings
"pivotTable":{},//Pivot table configuration
"filter_select": null,//Filter range
"filter": null,//Filter configuration
"luckysheet_alternateformat_save": [], //Alternate colors

1346
docs/guide/sheet.md

File diff suppressed because it is too large

4
src/controllers/formulaBar.js

@ -33,6 +33,10 @@ export function formulaBarInitial(){
let row_index = last["row_focus"], col_index = last["column_focus"];
let $input = $("#luckysheet-rich-text-editor"),value = $input.text();
if(value) {
formula.updatecell(row_index, col_index);
}
luckysheetupdateCell(row_index, col_index, Store.flowdata, null, true);
formula.rangeResizeTo = $("#luckysheet-functionbox-cell");
}

2
src/controllers/handler.js

@ -4580,7 +4580,7 @@ export default function luckysheetHandler() {
}
}
let fs = Math.floor(parseInt($td.css("font-size")) * 72 / dpi_y) + 1;
let fs = Math.floor(parseInt($td.css("font-size")) * 72 / 96) + 1;
cell.fs = fs;
let fc = $td.css("color");

2
src/controllers/keyboard.js

@ -834,7 +834,7 @@ export function keyboardInitial(){
else if (kcode == keycode.RIGHT && parseInt($inputbox.css("top")) > 0) {
formulaMoveEvent("right", ctrlKey, shiftKey);
}
else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40))) || kcode == 8 || kcode == 32 || kcode == 46 || (event.ctrlKey && kcode == 86)) {
else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40 || kcode == keycode.WIN || kcode == keycode.WIN_R || kcode == keycode.MENU))) || kcode == 8 || kcode == 32 || kcode == 46 || (event.ctrlKey && kcode == 86)) {
formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode);
setCenterInputPosition(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1], Store.flowdata);
}

142
src/global/getRowlen.js

@ -416,7 +416,7 @@ function getCellTextInfo(cell , ctx, option){
textContent.rotate = rt;
rt = Math.abs(rt);
let anchor = 0, preHeight = 0, preWidth=0, preStr, preTextHeight;
let anchor = 0, preHeight = 0, preWidth=0, preStr, preTextHeight, preTextWidth;
for(let i = 1; i <= value.length; i++){
let str = value.substring(anchor, i);
let measureText = getMeasureText(str, ctx);
@ -434,7 +434,7 @@ function getCellTextInfo(cell , ctx, option){
}
if(rt!=0){//rotate
if(height>cellHeight){
if((height+space_height)>cellHeight){
anchor = i-1;
text_all_split[splitIndex].push({
@ -445,7 +445,10 @@ function getCellTextInfo(cell , ctx, option){
left:0,
top:0,
splitIndex:splitIndex,
textHeight:preTextHeight
textHeight:preTextHeight,
textWidth:preTextWidth,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent
});
splitIndex +=1;
@ -460,12 +463,15 @@ function getCellTextInfo(cell , ctx, option){
left:0,
top:0,
splitIndex:splitIndex,
textHeight:textHeight
textHeight:textHeight,
textWidth:textWidth,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent
});
}
}
else{//plain
if(width>cellWidth){
if((width+space_width)>cellWidth){
anchor = i-1;
@ -477,6 +483,8 @@ function getCellTextInfo(cell , ctx, option){
left:0,
top:0,
splitIndex:splitIndex,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent
});
splitIndex +=1;
@ -491,6 +499,8 @@ function getCellTextInfo(cell , ctx, option){
left:0,
top:0,
splitIndex:splitIndex,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent
});
}
}
@ -499,15 +509,21 @@ function getCellTextInfo(cell , ctx, option){
preHeight = height;
preStr = str;
preTextHeight = textHeight;
preTextWidth = textWidth;
}
let split_all_size = [];
for(let i = 0; i <= splitIndex; i++){
console.log(splitIndex, text_all_split);
let splitLen = Object.keys(text_all_split).length;
for(let i = 0; i < splitLen; i++){
let splitLists = text_all_split[i];
if(splitLists==null){
continue;
}
let sWidth = 0, sHeight=0, textHeight=0;
for(let s=0;s<splitLists.length;s++){
let sp = splitLists[i];
let sp = splitLists[s];
if(rt!=0){//rotate
sWidth += sp.width;
sHeight += sp.height;
@ -515,15 +531,22 @@ function getCellTextInfo(cell , ctx, option){
}
else{//plain
sWidth += sp.width;
sHeight = Math.max(sHeight, sp.height);
sHeight = Math.max(sHeight, sp.height-(supportBoundBox?sp.desc:0));
}
}
if(rt!=0){//rotate
textW_all += textHeight/Math.sin(rt);
if(i==splitIndex){
textW_all += sWidth;
}
else{
textW_all += space_width;
}
textH_all = Math.max(textH_all, sHeight);
}
else{//plain
sHeight+=sHeight/1.5;
textW_all=Math.max(textW_all, sWidth);
textH_all+=sHeight;
}
@ -535,41 +558,86 @@ function getCellTextInfo(cell , ctx, option){
});
}
let cumColumnWidth = 0;
for(let i = 0; i < text_all_split.length; i++){
let splitTexts = text_all_split[i];
let cumWordHeight = 0;
for(let c=0;c<splitTexts.length;c++){
let wordGroup = splitTexts[c];
let left = space_width + cumColumnWidth;
if(horizonAlign == "0"){
left = cellWidth / 2 + cumColumnWidth - textW_all/2 + space_width*textH_all_ColumnHeight.length;
}
else if(horizonAlign == "2"){
left = cellWidth + cumColumnWidth - textW_all + space_width;
}
// let cumColumnWidth = 0;
let cumWordHeight = 0,cumColumnWidth = 0;
for(let i = 0; i < splitLen; i++){
let splitLists = text_all_split[i];
if(splitLists==null){
continue;
}
let size = split_all_size[i];
let top = (cellHeight - space_height) + cumWordHeight - columnHeight;
if(verticalAlign == "0"){
top = cellHeight / 2 + cumWordHeight - columnHeight/2;
if(rt!=0){//rotate
}
else{
cumColumnWidth = 0;
}
for(let c=0;c<splitLists.length;c++){
let wordGroup = splitLists[c];
let left, top;
if(rt!=0){//rotate
left = space_width + wordGroup.textHeight * Math.sin(rt*Math.PI/180)*isRotateDown; //默认为1,左对齐
if(horizonAlign == "0"){ //居中对齐
left = cellWidth / 2 - ( wordGroup.width / 2) + wordGroup.textHeight * Math.sin(rt*Math.PI/180)*isRotateDown;
}
else if(horizonAlign == "2"){ //右对齐
left = (cellWidth - space_width) - wordGroup.width + wordGroup.textHeight * Math.sin(rt*Math.PI/180)*isRotateDown;
}
top = (cellHeight - space_height) - wordGroup.height + wordGroup.textWidth * Math.sin(rt*Math.PI/180)*isRotateUp; //默认为2,下对齐
if(verticalAlign == "0"){ //居中对齐
top = cellHeight / 2 - ( wordGroup.height / 2) + wordGroup.textWidth * Math.sin(rt*Math.PI/180)*isRotateUp;
}
else if(verticalAlign == "1"){ //上对齐
top = space_height + wordGroup.textWidth * Math.sin(rt*Math.PI/180)*isRotateUp;
}
// left+=10;
// top=top+30;
if(c==0){
textContent.textLeftAll = left;
textContent.textTopAll = top;
}
console.log("plainWrap" ,left , top);
}
else if(verticalAlign == "1"){
top = space_height + cumWordHeight;
else{//plain
left = space_width + cumColumnWidth;
if(horizonAlign == "0"){
//+ space_width*textH_all_ColumnHeight.length
left = cellWidth / 2 + cumColumnWidth - size.width/2;
}
else if(horizonAlign == "2"){
left = cellWidth + cumColumnWidth - size.width;
}
top = (cellHeight - space_height) + cumWordHeight - textH_all - (supportBoundBox?wordGroup.desc:0) + wordGroup.height*2/1.5;
if(verticalAlign == "0"){
top = cellHeight / 2 + cumWordHeight - textH_all/2 + wordGroup.asc/2 + wordGroup.height*2/3;
}
else if(verticalAlign == "1"){
top = space_height + cumWordHeight+ wordGroup.asc;
}
cumColumnWidth += wordGroup.width;
}
cumWordHeight += word.height;
word.left = left;
word.top = top;
wordGroup.left = left;
wordGroup.top = top;
textContent.values.push(word);
textContent.values.push(wordGroup);
}
cumColumnWidth+=columnWidth;
if(rt!=0){//rotate
}
else{
cumWordHeight += size.height;
}
// cumColumnWidth+=columnWidth;
}
@ -625,6 +693,8 @@ function getCellTextInfo(cell , ctx, option){
textContent.textLeftAll = left;
textContent.textTopAll = top;
console.log("plain",left,top);
}
}

Loading…
Cancel
Save