diff --git a/docs/guide/api.md b/docs/guide/api.md index f2ec2e3..78f99ff 100644 --- a/docs/guide/api.md +++ b/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]) diff --git a/docs/zh/guide/api.md b/docs/zh/guide/api.md index 6ffe795..441160a 100644 --- a/docs/zh/guide/api.md +++ b/docs/zh/guide/api.md @@ -2514,6 +2514,19 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 ------------ +### checkTheStatusOfTheSelectedCells(type,status) + +- **参数**: + + - {String} type: 类型 + - {String} status: 目标状态值 + +- **说明**: + + 检查选区内所有cell指定类型的状态是否满足条件(主要是粗体、斜体、删除线和下划线等等)。 + +------------ + ## 图表 ### insertChart([setting]) diff --git a/src/global/api.js b/src/global/api.js index a2a9457..549dfdb 100644 --- a/src/global/api.js +++ b/src/global/api.js @@ -6666,4 +6666,22 @@ 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]; + return cell[type] == status; + }) + + return flag; } \ No newline at end of file