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

Commit

Permalink
feat(inline string): when focus cell, show inline string content
Browse files Browse the repository at this point in the history
  • Loading branch information
DR-Univer committed Sep 17, 2020
1 parent a93bc86 commit 713805c
Show file tree
Hide file tree
Showing 6 changed files with 341 additions and 240 deletions.
231 changes: 43 additions & 188 deletions src/controllers/menuButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { rowLocationByIndex, colLocationByIndex } from '../global/location';
import { isdatatypemulti } from '../global/datecontroll';
import { rowlenByRange, getCellTextSplitArr } from '../global/getRowlen';
import { setcellvalue } from '../global/setdata';
import { getFontStyleByCell, checkstatusByCell} from '../global/getdata';
import { countfunc } from '../global/count';
import { getSheetIndex, getRangetxt, getluckysheetfile } from '../methods/get';
import { setluckysheetfile } from '../methods/set';
Expand Down Expand Up @@ -3312,165 +3313,9 @@ const menuButton = {
}
}
},
checkstatusByCell:function(cell, a){
let foucsStatus =cell;
let tf = {"bl":1, "it":1 , "ff":1, "cl":1, "un":1};

if(a in tf){
if(foucsStatus == null){
foucsStatus = "0";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "fc"){
if(foucsStatus == null){
foucsStatus = "#000000";
}
else{
foucsStatus = foucsStatus[a];

if(foucsStatus == null){
foucsStatus = "#000000";
}

if(foucsStatus.indexOf("rgba") > -1){
foucsStatus = rgbTohex(foucsStatus);
}
}
}
else if(a == "bg"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];

if(foucsStatus == null){
foucsStatus = null;
}
else if(foucsStatus.toString().indexOf("rgba") > -1){
foucsStatus = rgbTohex(foucsStatus);
}
}
}
else if(a.substr(0, 2) == "bs"){
if(foucsStatus == null){
foucsStatus = "none";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "none";
}
}
}
else if(a.substr(0, 2) == "bc"){
if(foucsStatus == null){
foucsStatus = "#000000";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "#000000";
}
}
}
else if(a == "ht"){
if(foucsStatus == null){
foucsStatus = "1";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "1";
}
}

if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
foucsStatus = "1";
}
}
else if(a == "vt"){
if(foucsStatus == null){
foucsStatus = "2";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "2";
}
}

if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
foucsStatus = "2";
}
}
else if(a == "ct"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
}
}
else if(a == "fs"){
if(foucsStatus == null){
foucsStatus = "10";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "10";
}
}
}
else if(a == "tb"){
if(foucsStatus == null){
foucsStatus = "0";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "tr"){
if(foucsStatus == null){
foucsStatus = "0";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "rt"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
}
}

return foucsStatus;
},
checkstatus: function(d, r, c, a){
let foucsStatus = d[r][c];
return this.checkstatusByCell(foucsStatus, a);
return checkstatusByCell(foucsStatus, a);
},
setLineDash: function(canvasborder, type, hv, m_st, m_ed, line_st, line_ed){
let borderType = {
Expand Down Expand Up @@ -4232,6 +4077,10 @@ const menuButton = {
const locale_fontarray = locale().fontarray;

let cell = d[r][c];
let ct = cell.ct, isInline=false;
if(ct!=null && ct.t=="inlineStr" && ct.s!=null && ct.s.length>0){
isInline = true;
}
for(let key in cell){
let value = _this.checkstatus(d, r, c , key);

Expand Down Expand Up @@ -4260,37 +4109,39 @@ const menuButton = {
}
}

if(key == "bl" && value != "0"){
style += "font-weight: bold;";
}

if(key == "it" && value != "0"){
style += "font-style:italic;";
}

if(key == "ff" && value != "0"){
let f = value;
if(!isNaN(parseInt(value))){
f = locale_fontarray[parseInt(value)];
}
style += "font-family: " + f + ";";
}

if(key == "fs" && value != "10"){
style += "font-size: "+ value + "pt;";
}

if((key == "fc" && value != "#000000") || checksAF != null || (checksCF != null && checksCF["textColor"] != null)){
if(checksCF != null && checksCF["textColor"] != null){
style += "color: " + checksCF["textColor"] + ";";
}
else if(checksAF != null){
style += "color: " + checksAF[0] + ";";
}
else{
style += "color: " + value + ";";
}
}
// if(!isInline){
// if(key == "bl" && value != "0"){
// style += "font-weight: bold;";
// }

// if(key == "it" && value != "0"){
// style += "font-style:italic;";
// }

// if(key == "ff" && value != "0"){
// let f = value;
// if(!isNaN(parseInt(value))){
// f = locale_fontarray[parseInt(value)];
// }
// style += "font-family: " + f + ";";
// }

// if(key == "fs" && value != "10"){
// style += "font-size: "+ value + "pt;";
// }

// if((key == "fc" && value != "#000000") || checksAF != null || (checksCF != null && checksCF["textColor"] != null)){
// if(checksCF != null && checksCF["textColor"] != null){
// style += "color: " + checksCF["textColor"] + ";";
// }
// else if(checksAF != null){
// style += "color: " + checksAF[0] + ";";
// }
// else{
// style += "color: " + value + ";";
// }
// }
// }

if(key == "ht" && value != "1"){
if(value == "0"){
Expand All @@ -4311,6 +4162,10 @@ const menuButton = {
}
}

if(!isInline){
style += getFontStyleByCell(cell,checksAF,checksCF);
}

return style;
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/controllers/updateCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import alternateformat from './alternateformat';
import dataVerificationCtrl from './dataVerificationCtrl';
import { chatatABC } from '../utils/util';
import { isEditMode } from '../global/validate';
import { getcellvalue } from '../global/getdata';
import { getcellvalue,getInlineStringStyle } from '../global/getdata';
import { valueShowEs } from '../global/format';
import formula from '../global/formula';
import { luckysheetRangeLast } from '../global/cursorPos';
Expand Down Expand Up @@ -135,7 +135,10 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu


if (!cover) {
if(cell.f!=null){
if(cell.ct!=null && cell.ct.t=="inlineStr" && cell.ct.s!=null && cell.ct.s.length>0){
value = getInlineStringStyle(row_index, col_index, d);
}
else if(cell.f!=null){
value = getcellvalue(row_index, col_index, d, "f");
}
else{
Expand Down
7 changes: 5 additions & 2 deletions src/global/formula.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { seletedHighlistByindex, luckysheet_count_show } from '../controllers/se
import { isRealNum, isRealNull, valueIsError, isEditMode } from './validate';
import { isdatetime, isdatatype } from './datecontroll';
import { getCellTextSplitArr } from '../global/getRowlen';
import { getcellvalue,getcellFormula } from './getdata';
import { getcellvalue,getcellFormula,getInlineStringNoStyle } from './getdata';
import { setcellvalue } from './setdata';
import { genarate, valueShowEs } from './format';
import editor from './editor';
Expand Down Expand Up @@ -325,7 +325,10 @@ const luckysheetformula = {
if (d[r] != null && d[r][c] != null) {
let cell = d[r][c];

if(cell.f != null){
if(cell.ct!=null && cell.ct.t=="inlineStr" && cell.ct.s!=null && cell.ct.s.length>0){
value = getInlineStringNoStyle(r, c);
}
else if(cell.f != null){
value = getcellvalue(r, c, d, "f");
}
else{
Expand Down
16 changes: 8 additions & 8 deletions src/global/getRowlen.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { luckysheetfontformat } from '../utils/util';
import menuButton from '../controllers/menuButton';
import { getcellvalue } from './getdata';
import { getcellvalue,checkstatusByCell } from './getdata';
import { colLocationByIndex } from './location';
import { hasChinaword, isRealNull } from './validate';
import Store from '../store';
Expand Down Expand Up @@ -277,13 +277,13 @@ function getCellTextInfo(cell , ctx, option){
}

//水平对齐
let horizonAlign = menuButton.checkstatusByCell(cell, "ht");
let horizonAlign = checkstatusByCell(cell, "ht");
//垂直对齐
let verticalAlign = menuButton.checkstatusByCell(cell, "vt");
let verticalAlign = checkstatusByCell(cell, "vt");

let tb = menuButton.checkstatusByCell(cell ,"tb");//wrap overflow
let tr = menuButton.checkstatusByCell(cell ,"tr");//rotate
let rt = menuButton.checkstatusByCell(cell ,"rt");//rotate angle
let tb = checkstatusByCell(cell ,"tb");//wrap overflow
let tr = checkstatusByCell(cell ,"tr");//rotate
let rt = checkstatusByCell(cell ,"rt");//rotate angle

let isRotateUp = 1, isRotateDown=0;

Expand Down Expand Up @@ -388,8 +388,8 @@ function getCellTextInfo(cell , ctx, option){
fontset = luckysheetfontformat(cell);
ctx.font = fontset;

cancelLine = menuButton.checkstatusByCell(cell ,"cl");//cancelLine
underLine = menuButton.checkstatusByCell(cell ,"un");//underLine
cancelLine = checkstatusByCell(cell ,"cl");//cancelLine
underLine = checkstatusByCell(cell ,"un");//underLine

if(cell instanceof Object){
value = cell.m;
Expand Down
Loading

0 comments on commit 713805c

Please sign in to comment.