dushusir 5 years ago
parent
commit
13da5bf907
  1. 13
      docs/guide/api.md
  2. 13
      docs/zh/guide/api.md
  3. 6
      src/controllers/controlHistory.js
  4. 53
      src/controllers/menuButton.js
  5. 6
      src/controllers/select.js
  6. 39
      src/global/api.js
  7. 3
      src/global/refresh.js

13
docs/guide/api.md

@ -2596,6 +2596,19 @@ Use note:
------------
### checkTheStatusOfTheSelectedCells(type,status)
- **Parameter**
- {String} type: type
- {String} status: Target state value
- **Explanation**
Check whether the status of all specified types of cells in the selection meets the conditions (mainly bold, italics, strikeouts, underscores, etc.).
------------
## Chart
### insertChart([setting])

13
docs/zh/guide/api.md

@ -2514,6 +2514,19 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
------------
### checkTheStatusOfTheSelectedCells(type,status)
- **参数**
- {String} type: 类型
- {String} status: 目标状态值
- **说明**
检查选区内所有cell指定类型的状态是否满足条件(主要是粗体、斜体、删除线和下划线等等)。
------------
## 图表
### insertChart([setting])

6
src/controllers/controlHistory.js

@ -25,7 +25,6 @@ import { getSheetIndex } from '../methods/get';
import Store from '../store';
import { selectHightlightShow } from './select';
import method from '../global/method';
import {refreshMenuButtonFocus} from "../global/api";
function formulaHistoryHanddler(ctr, type="redo"){
if(ctr==null){
@ -429,9 +428,6 @@ const controlHistory = {
}
Store.clearjfundo = true;
/* 刷新当前状态栏 */
refreshMenuButtonFocus();
// 撤销的时候curdata 跟 data 数据要调换一下
let newCtr = {...ctr, ...{data: ctr.curdata, curdata: ctr.data}}
// 钩子函数
@ -748,8 +744,6 @@ const controlHistory = {
}
Store.clearjfundo = true;
/* 刷新当前状态栏 */
refreshMenuButtonFocus();
}
};

53
src/controllers/menuButton.js

@ -37,6 +37,7 @@ import { replaceHtml, getObjType, rgbTohex, mouseclickposition, luckysheetfontfo
import {openProtectionModal,checkProtectionFormatCells,checkProtectionNotEnable} from './protection';
import Store from '../store';
import locale from '../locale/locale';
import {checkTheStatusOfTheSelectedCells} from '../global/api';
const menuButton = {
"menu": '<div class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-menuButton ${subclass} luckysheet-mousedown-cancel" id="luckysheet-icon-${id}-menuButton">${item}</div>',
@ -2171,19 +2172,11 @@ const menuButton = {
e.stopPropagation();
}).click(function(e){
let d = editor.deepCopyFlowData(Store.flowdata);
let row_index = Store.luckysheet_select_save[0]["row_focus"],
col_index = Store.luckysheet_select_save[0]["column_focus"];
let foucsStatus = _this.checkstatus(d, row_index, col_index, "bl");
if(foucsStatus == 1){
foucsStatus = 0;
}
else{
foucsStatus = 1;
}
let flag = checkTheStatusOfTheSelectedCells("bl",1);
let foucsStatus = flag ? 0 : 1;
_this.updateFormat(d, "bl", foucsStatus);
_this.menuButtonFocus(d, row_index, col_index);
});
//斜体
@ -2192,19 +2185,11 @@ const menuButton = {
e.stopPropagation();
}).click(function(){
let d = editor.deepCopyFlowData(Store.flowdata);
let row_index = Store.luckysheet_select_save[0]["row_focus"],
col_index = Store.luckysheet_select_save[0]["column_focus"];
let foucsStatus = _this.checkstatus(d, row_index, col_index, "it");
if(foucsStatus == 1){
foucsStatus = 0;
}
else{
foucsStatus = 1;
}
let flag = checkTheStatusOfTheSelectedCells("it",1);
let foucsStatus = flag ? 0 : 1;
_this.updateFormat(d, "it", foucsStatus);
_this.menuButtonFocus(d, row_index, col_index);
});
//删除线
@ -2213,19 +2198,10 @@ const menuButton = {
e.stopPropagation();
}).click(function(){
let d = editor.deepCopyFlowData(Store.flowdata);
let row_index = Store.luckysheet_select_save[0]["row_focus"],
col_index = Store.luckysheet_select_save[0]["column_focus"];
let foucsStatus = _this.checkstatus(d, row_index, col_index, "cl");
if(foucsStatus == 1){
foucsStatus = 0;
}
else{
foucsStatus = 1;
}
let flag = checkTheStatusOfTheSelectedCells("cl",1);
let foucsStatus = flag ? 0 : 1;
_this.updateFormat(d, "cl", foucsStatus);
_this.menuButtonFocus(d, row_index, col_index);
});
//下划线
@ -2234,19 +2210,10 @@ const menuButton = {
e.stopPropagation();
}).click(function(){
let d = editor.deepCopyFlowData(Store.flowdata);
let row_index = Store.luckysheet_select_save[0]["row_focus"],
col_index = Store.luckysheet_select_save[0]["column_focus"];
let foucsStatus = _this.checkstatus(d, row_index, col_index, "un");
if(foucsStatus == 1){
foucsStatus = 0;
}
else{
foucsStatus = 1;
}
let flag = checkTheStatusOfTheSelectedCells("un",1);
let foucsStatus = flag ? 0 : 1;
_this.updateFormat(d, "un", foucsStatus);
_this.menuButtonFocus(d, row_index, col_index);
});
//条件格式

6
src/controllers/select.js

@ -8,6 +8,7 @@ import { getSheetIndex, getRangetxt } from '../methods/get';
import Store from '../store';
import method from '../global/method';
import locale from '../locale/locale';
import { refreshMenuButtonFocus } from "../global/api";
//公式函数 选区实体框
function seletedHighlistByindex(id, r1, r2, c1, c2) {
@ -180,6 +181,9 @@ function selectHightlightShow(isRestore = false) {
if (Store.luckysheet_select_save.length == 1 && Store.luckysheet_select_save[0].row[0] == Store.luckysheet_select_save[0].row[1] && Store.luckysheet_select_save[0].column[0] == Store.luckysheet_select_save[0].column[1]) {
dynamicArrayHightShow(Store.luckysheet_select_save[0].row[0], Store.luckysheet_select_save[0].column[0]);
}
/* 刷新当前状态栏 */
refreshMenuButtonFocus();
}
Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].luckysheet_select_save = Store.luckysheet_select_save;
@ -311,6 +315,7 @@ function selectIsOverlap(range) {
if (range == null) {
range = Store.luckysheet_select_save;
}
range = JSON.parse(JSON.stringify(range));
let overlap = false;
let map = {};
@ -454,6 +459,7 @@ function selectionCopyShow(range) {
if (range == null) {
range = Store.luckysheet_selection_range;
}
range = JSON.parse(JSON.stringify(range));
if (range.length > 0) {
for (let s = 0; s < range.length; s++) {

39
src/global/api.js

@ -1577,7 +1577,8 @@ export function getDefaultColWidth(options = {}) {
* @returns {Array}
*/
export function getRange() {
let rangeArr = Store.luckysheet_select_save;
let rangeArr = JSON.parse(JSON.stringify(Store.luckysheet_select_save));
let result = [];
for (let i = 0; i < rangeArr.length; i++) {
@ -1641,7 +1642,7 @@ export function getRangeValuesWithFlatte(range){
*/
export function getRangeAxis() {
let result = [];
let rangeArr = Store.luckysheet_select_save;
let rangeArr = JSON.parse(JSON.stringify(Store.luckysheet_select_save));
let sheetIndex = Store.currentSheetIndex;
rangeArr.forEach(ele=>{
@ -1691,6 +1692,7 @@ export function getRangeHtml(options = {}) {
order = getSheetIndex(Store.currentSheetIndex),
success
} = {...options}
range = JSON.parse(JSON.stringify(range));
if(getObjType(range) == 'string'){
if(!formula.iscelldata(range)){
@ -2395,7 +2397,7 @@ export function getRangeDiagonal(type, options = {}) {
}
let curSheetOrder = getSheetIndex(Store.currentSheetIndex);
let curRange = Store.luckysheet_select_save;
let curRange = JSON.parse(JSON.stringify(Store.luckysheet_select_save));
let {
column = 1,
range = curRange,
@ -2498,7 +2500,7 @@ export function getRangeDiagonal(type, options = {}) {
*/
export function getRangeBoolean(options = {}) {
let curSheetOrder = getSheetIndex(Store.currentSheetIndex);
let curRange = Store.luckysheet_select_save;
let curRange = JSON.parse(JSON.stringify(Store.luckysheet_select_save));
let {
range = curRange,
order = curSheetOrder
@ -2813,7 +2815,7 @@ export function setSingleRangeFormat(attr, value, options = {}) {
*/
export function setRangeFormat(attr, value, options = {}) {
let curSheetOrder = getSheetIndex(Store.currentSheetIndex);
let curRange = Store.luckysheet_select_save;
let curRange = JSON.parse(JSON.stringify(Store.luckysheet_select_save));
let {
range = curRange,
order = curSheetOrder,
@ -2966,7 +2968,7 @@ export function setRangeMerge(type, options = {}) {
}
let curSheetOrder = getSheetIndex(Store.currentSheetIndex),
curRange = Store.luckysheet_select_save;
curRange = JSON.parse(JSON.stringify(Store.luckysheet_select_save));
let {
range = curRange,
order = curSheetOrder,
@ -3550,6 +3552,8 @@ export function setRangeConditionalFormatDefault(conditionName, conditionValue,
success
} = {...options}
cellrange = JSON.parse(JSON.stringify(cellrange));
let file = Store.luckysheetfile[order];
let data = file.data;
@ -3816,6 +3820,7 @@ export function setRangeConditionalFormat(type, options = {}) {
success
} = {...options}
cellrange = JSON.parse(JSON.stringify(cellrange));
let file = Store.luckysheetfile[order];
if(file == null){
@ -4137,6 +4142,7 @@ export function clearRange(options = {}) {
success
} = {...options}
range = JSON.parse(JSON.stringify(range));
if(getObjType(range) == 'string'){
if(!formula.iscelldata(range)){
return tooltip.info("The range parameter is invalid.", "");
@ -6666,4 +6672,25 @@ export function refreshMenuButtonFocus(data ,r,c , success){
success();
}
})
}
/**
* 检查选区内所有cell指定类型的状态是否满足条件主要是粗体斜体删除线和下划线等等
* @param {String} type 类型
* @param {String} status 目标状态值
*/
export function checkTheStatusOfTheSelectedCells(type,status){
/* 获取选区内所有的单元格-扁平后的处理 */
let cells = getRangeWithFlatten();
let flag = cells.every(({r,c})=>{
let cell = Store.flowdata[r][c];
if(cell == null){
return false;
}
return cell[type] == status;
})
return flag;
}

3
src/global/refresh.js

@ -44,11 +44,10 @@ function jfrefreshgrid(data, range, allParam, isRunExecFunction = true, isRefres
if(range == null){
range = Store.luckysheet_select_save;
}
range = JSON.parse(JSON.stringify(range));
clearTimeout(refreshCanvasTimeOut);
//关联参数
if(allParam == null){
allParam = {};

Loading…
Cancel
Save