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

Commit

Permalink
feat(editor box position fit): show diffrent position acording to align
Browse files Browse the repository at this point in the history
  • Loading branch information
DR-Univer committed Aug 8, 2020
1 parent d884a69 commit 636046d
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 106 deletions.
24 changes: 3 additions & 21 deletions src/controllers/formulaBar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import menuButton from './menuButton';
import luckysheetupdateCell from './updateCell';
import {luckysheetupdateCell} from './updateCell';
import { keycode } from './constant';
import {
luckysheetMoveHighlightCell,
Expand Down Expand Up @@ -32,22 +32,8 @@ export function formulaBarInitial(){
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];

let row_index = last["row_focus"], col_index = last["column_focus"];
let row = Store.visibledatarow[row_index],
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1];
let col = Store.visibledatacolumn[col_index],
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1];

let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
if(!!margeset){
row = margeset.row[1];
row_pre = margeset.row[0];
row_index = margeset.row[2];
col = margeset.column[1];
col_pre = margeset.column[0];
col_index = margeset.column[2];
}

luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata, null, true);
luckysheetupdateCell(row_index, col_index, Store.flowdata, null, true);
formula.rangeResizeTo = $("#luckysheet-functionbox-cell");
}
}).keydown(function (event) {
Expand Down Expand Up @@ -174,12 +160,8 @@ export function formulaBarInitial(){
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];

let row_index = last["row_focus"], col_index = last["column_focus"];
let row = Store.visibledatarow[row_index],
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1];
let col = Store.visibledatacolumn[col_index],
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1];

luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata);
luckysheetupdateCell(row_index, col_index, Store.flowdata);

let cell = Store.flowdata[row_index][col_index];
if(cell != null && cell.f != null){
Expand Down
20 changes: 4 additions & 16 deletions src/controllers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import alternateformat from './alternateformat';
import ifFormulaGenerator from './ifFormulaGenerator';
import sheetmanage from './sheetmanage';
import server from './server';
import luckysheetupdateCell from './updateCell';
import {luckysheetupdateCell} from './updateCell';
import { luckysheet_searcharray } from './sheetSearch';
import luckysheetsizeauto from './resize';
import {
Expand Down Expand Up @@ -1015,13 +1015,11 @@ export default function luckysheetHandler() {
let y = mouse[1] + scrollTop;

let row_location = rowLocation(y),
row = row_location[1],
row_pre = row_location[0],

row_index = row_location[2];

let col_location = colLocation(x),
col = col_location[1],
col_pre = col_location[0],

col_index = col_location[2];

if (pivotTable.isPivotRange(row_index, col_index)) {
Expand Down Expand Up @@ -1072,16 +1070,6 @@ export default function luckysheetHandler() {
return;
}

let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
if (!!margeset) {
row = margeset.row[1];
row_pre = margeset.row[0];
row_index = margeset.row[2];
col = margeset.column[1];
col_pre = margeset.column[0];
col_index = margeset.column[2];
}

if ($("#luckysheet-search-formula-parm").is(":visible") || $("#luckysheet-search-formula-parm-select").is(":visible")) {
//公式参数栏显示
$("#luckysheet-cell-selected").hide();
Expand All @@ -1099,7 +1087,7 @@ export default function luckysheetHandler() {
menuButton.cancelPaintModel();
}

luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata);
luckysheetupdateCell(row_index, col_index, Store.flowdata);
}
});

Expand Down
8 changes: 2 additions & 6 deletions src/controllers/ifFormulaGenerator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import formula from '../global/formula';
import editor from '../global/editor';
import luckysheetupdateCell from './updateCell';
import {luckysheetupdateCell} from './updateCell';
import { modelHTML } from './constant';
import { replaceHtml } from '../utils/util';
import Store from '../store';
Expand Down Expand Up @@ -260,12 +260,8 @@ const ifFormulaGenerator = {
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
let row_index = last["row_focus"],
col_index = last["column_focus"];
let row = Store.visibledatarow[row_index],
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1];
let col = Store.visibledatacolumn[col_index],
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1];

luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata);
luckysheetupdateCell(row_index, col_index, Store.flowdata);

$("#luckysheet-rich-text-editor").html("=" + str);
$("#luckysheet-functionbox-cell").html($("#luckysheet-rich-text-editor").html());
Expand Down
43 changes: 6 additions & 37 deletions src/controllers/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import luckysheetConfigsetting from './luckysheetConfigsetting';
import menuButton from './menuButton';
import conditionformat from './conditionformat';
import server from './server';
import luckysheetupdateCell from './updateCell';
import {luckysheetupdateCell,setCenterInputPosition} from './updateCell';
import { keycode } from './constant';
import {
luckysheetMoveHighlightCell,
Expand Down Expand Up @@ -344,12 +344,8 @@ export function keyboardInitial(){
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];

let row_index = last["row_focus"], col_index = last["column_focus"];
let row = Store.visibledatarow[row_index],
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1];
let col = Store.visibledatacolumn[col_index],
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1];

luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata);
luckysheetupdateCell(row_index, col_index, Store.flowdata);
event.preventDefault();
}
else if (kcode == keycode.F4 && parseInt($inputbox.css("top")) > 0) {
Expand All @@ -369,22 +365,8 @@ export function keyboardInitial(){
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];

let row_index = last["row_focus"], col_index = last["column_focus"];
let row = Store.visibledatarow[row_index],
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1];
let col = Store.visibledatacolumn[col_index],
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1];

let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
if(!!margeset){
row = margeset.row[1];
row_pre = margeset.row[0];
row_index = margeset.row[2];
col = margeset.column[1];
col_pre = margeset.column[0];
col_index = margeset.column[2];
}

luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata);

luckysheetupdateCell(row_index, col_index, Store.flowdata);
event.preventDefault();
}
}
Expand Down Expand Up @@ -787,22 +769,8 @@ export function keyboardInitial(){
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];

let row_index = last["row_focus"], col_index = last["column_focus"];
let row = Store.visibledatarow[row_index],
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1];
let col = Store.visibledatacolumn[col_index],
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1];

let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
if(!!margeset){
row = margeset.row[1];
row_pre = margeset.row[0];
row_index = margeset.row[2];
col = margeset.column[1];
col_pre = margeset.column[0];
col_index = margeset.column[2];
}

luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata, true);
luckysheetupdateCell(row_index, col_index, Store.flowdata, true);
if(kcode == 8){
$("#luckysheet-rich-text-editor").html("<br/>");
}
Expand Down Expand Up @@ -868,6 +836,7 @@ export function keyboardInitial(){
}
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)) {
formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode);
setCenterInputPosition(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1], Store.flowdata);
}
}).keyup(function (e) {
let kcode = e.keyCode;
Expand Down
21 changes: 7 additions & 14 deletions src/controllers/menuButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { createFilter } from './filter';
import luckysheetSearchReplace from './searchReplace';
import luckysheetLocationCell from './locationCell';
import ifFormulaGenerator from './ifFormulaGenerator';
import luckysheetupdateCell from './updateCell';
import {luckysheetupdateCell} from './updateCell';
import insertFormula from './insertFormula';
import sheetmanage from './sheetmanage';
import luckysheetPostil from './postil';
Expand Down Expand Up @@ -2024,12 +2024,8 @@ const menuButton = {
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];

let row_index = last["row_focus"], col_index = last["column_focus"];
let row = Store.visibledatarow[row_index],
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1];
let col = Store.visibledatacolumn[col_index],
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1];

luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata);
luckysheetupdateCell(row_index, col_index, Store.flowdata);

let cell = Store.flowdata[row_index][col_index];
if(cell != null && cell.f != null){
Expand Down Expand Up @@ -3857,10 +3853,7 @@ const menuButton = {
isnull = false;
}

let row_range = rowLocationByIndex(row_index);
let col_range = colLocationByIndex(col_index);

luckysheetupdateCell(row_range[1], row_range[0], row_index, col_range[1], col_range[0], col_index, Store.flowdata, true);
luckysheetupdateCell(row_index, col_index, Store.flowdata, true);

if(isnull){
let formulaTxt = '<span dir="auto" class="luckysheet-formula-text-color">=</span><span dir="auto" class="luckysheet-formula-text-color">'+ formula.toUpperCase() +'</span><span dir="auto" class="luckysheet-formula-text-color">(</span><span dir="auto" class="luckysheet-formula-text-color">)</span>';
Expand Down Expand Up @@ -4293,12 +4286,12 @@ const menuButton = {
}
}

if(key == "vt" && value != "0"){
if(value == "1"){
style += "vertical-align: top;";
if(key == "vt" && value != "1"){
if(value == "0"){
style += "align-items: center;";
}
else if(value == "2"){
style += "vertical-align: bottom;";
style += "align-items: flex-end;";
}
}
}
Expand Down
Loading

0 comments on commit 636046d

Please sign in to comment.