Browse Source

feat(api): find

API find add type option
master
dushusir 5 years ago
parent
commit
ea97233a66
  1. 16
      docs/guide/FAQ.md
  2. 12
      docs/guide/api.md
  3. 15
      docs/guide/operate.md
  4. 16
      docs/zh/guide/FAQ.md
  5. 9
      docs/zh/guide/api.md
  6. 15
      docs/zh/guide/operate.md
  7. 14
      src/global/api.js

16
docs/guide/FAQ.md

@ -275,4 +275,20 @@ In this case, after Luckysheet is modified in real time, the changes can be seen
- Triggered before the workbook is created [workbookCreateBefore](/guide/config.html#workbookcreatebefore)
- Triggered after the workbook is created [workbookCreateAfter](/guide/config.html#workbookcreateafter)
------------
## **<span style="font-size:20px;">Q</span>** When create, the first cell is selected by default, how to remove it?
**<span style="font-size:20px;">A</span>** When the cell is selected, it is highlighted by default, just remove the highlight, use API: [setRangeShow](/guide/api.html#setrangeshow-range-setting)
```js
luckysheet.setRangeShow("A2",{show:false})
```
------------
## **<span style="font-size:20px;">Q</span>** Where is the right-click event bound?
**<span style="font-size:20px;">A</span>** In the source code [src/controllers/hander.js](https://github.com/mengshukeji/Luckysheet/blob/master/src/controllers/handler.js), search for `event.which == "3"` to find the code executed by the right-click event.
------------

12
docs/guide/api.md

@ -175,6 +175,7 @@ Use note:
+ {Boolean} [isWholeWord]: Whether to match the whole word; the default is `false`
+ {Boolean} [isCaseSensitive]: Whether to match case sensitively; the default is `false`
+ {Number} [order]: Worksheet subscript; the default value is the current worksheet subscript
+ {String} [type]: cell attribute; the default value is `"m"`
- **Explanation**
@ -184,6 +185,8 @@ Use note:
- Find the string `"value"` in the current worksheet
`luckysheet.find("value")`
- Find cells in the current worksheet whose formula contains `"SUM"`
`luckysheet.find("SUM",{type:"f"})`
------------
@ -869,7 +872,6 @@ Use note:
------------
### getRangeJson(title [,setting])
- **Parameter**
@ -896,8 +898,7 @@ Use note:
The returned result is:
```json
[
{ "A": "value1", "B": "value3" },
{ "A": "value2", "B": "value4" }
{ "value1": "value2", "value3": "value4" }
]
```
@ -908,7 +909,8 @@ Use note:
The returned result is:
```json
[
{ "value1": "value2", "value3": "value4" }
{ "A": "value1", "B": "value3" },
{ "A": "value2", "B": "value4" }
]
```
@ -1121,8 +1123,6 @@ Use note:
### setRangeShow(range [,setting])<div id='setRangeShow'></div>
[todo]
- **Parameter**
- {Array | Object | String} [range]: The range of the selection, the format of the supported selection is `"A1:B2"`, `"sheetName!A1:B2"` or `{row:[0,1],column: [0,1]}`, allows an array of multiple selections; the default is the current selection

15
docs/guide/operate.md

@ -886,3 +886,18 @@ There are four types of chart operations: add new chart -"add", move chart posit
```js
luckysheetfile[0].chart[v.chart_id] = v;
```
## Backend return format
Data format returned by websocket backend
```js
{
createTime: command sending time
data:{} modified command
id: "7a" websocket id
returnMessage: "success"
status: "0" 0 tells the front end to modify according to the data command 1 meaningless
type: 0: connection is successful, 1: send to the currently connected user, 2: send information to other users, 3: send selection location information, 999: user disconnected
username: username
}
```

16
docs/zh/guide/FAQ.md

@ -276,4 +276,20 @@ Luckysheet教程里采用的CDN链接是 [jsdelivr](https://www.jsdelivr.com/pac
- 表格创建之前触发 [workbookCreateBefore](/zh/guide/config.html#workbookcreatebefore)
- 表格创建之后触发 [workbookCreateAfter](/zh/guide/config.html#workbookcreateafter)
------------
## **<span style="font-size:20px;">Q</span>** create的时候默认选中第一个单元格,怎么去除?
**<span style="font-size:20px;">A</span>** 选中单元格时默认是高亮,把高亮去除即可,使用API: [setRangeShow](/zh/guide/api.html#setrangeshow-range-setting)
```js
luckysheet.setRangeShow("A2",{show:false})
```
------------
## **<span style="font-size:20px;">Q</span>** 右键事件绑定在哪?
**<span style="font-size:20px;">A</span>** 在源码的 [src/controllers/hander.js](https://github.com/mengshukeji/Luckysheet/blob/master/src/controllers/handler.js) 搜索`event.which == "3"`即可找到右键事件触发执行的代码。
------------

9
docs/zh/guide/api.md

@ -178,6 +178,7 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
+ {Boolean} [isWholeWord]: 是否整词匹配;默认为 `false`
+ {Boolean} [isCaseSensitive]: 是否区分大小写匹配;默认为 `false`
+ {Number} [order]: 工作表下标;默认值为当前工作表下标
+ {String} [type]: 单元格属性;默认值为`"m"`
- **说明**
@ -187,6 +188,8 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
- 当前工作表查找`"value"`字符串
`luckysheet.find("value")`
- 当前工作表查找公式包含`"SUM"`的单元格
`luckysheet.find("SUM",{type:"f"})`
------------
@ -882,8 +885,7 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
则返回结果为:
```json
[
{ "A": "value1", "B": "value3" },
{ "A": "value2", "B": "value4" }
{ "value1": "value2", "value3": "value4" }
]
```
@ -894,7 +896,8 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
则返回结果为:
```json
[
{ "value1": "value2", "value3": "value4" }
{ "A": "value1", "B": "value3" },
{ "A": "value2", "B": "value4" }
]
```

15
docs/zh/guide/operate.md

@ -1266,3 +1266,18 @@
```js
luckysheetfile[0].chart[v.chart_id] = v;
```
## 后端返回格式
websocket 后端返回的数据格式
```js
{
createTime: 命令发送时间
data:{} 修改的命令
id: "7a" websocket的id
returnMessage: "success"
status: "0" 0告诉前端需要根据data的命令修改 1无意义
type: 0:连接成功,1:发送给当前连接的用户,2:发送信息给其他用户,3:发送选区位置信息,999:用户连接断开
username: 用户名
}
```

14
src/global/api.js

@ -383,6 +383,7 @@ export function setCellFormat(row, column, attr, value, options = {}) {
* @param {Boolean} options.isWholeWord 是否整词匹配默认为 false
* @param {Boolean} options.isCaseSensitive 是否区分大小写匹配默认为 false
* @param {Number} options.order 工作表索引默认值为当前工作表索引
* @param {String} options.type 单元格属性默认值为m
*/
export function find(content, options = {}) {
if (!content && content != 0) {
@ -394,7 +395,8 @@ export function find(content, options = {}) {
isRegularExpression = false,
isWholeWord = false,
isCaseSensitive = false,
order = curSheetOrder
order = curSheetOrder,
type = "m"
} = { ...options };
let targetSheetData = Store.luckysheetfile[order].data;
@ -416,11 +418,11 @@ export function find(content, options = {}) {
if (isWholeWord) {
if (isCaseSensitive) {
if (content.toString() == cell.m) {
if (content.toString() == cell[type]) {
result.push(cell)
}
} else {
if (cell.m && content.toString().toLowerCase() == cell.m.toLowerCase()) {
if (cell[type] && content.toString().toLowerCase() == cell[type].toLowerCase()) {
result.push(cell)
}
}
@ -431,17 +433,17 @@ export function find(content, options = {}) {
} else {
reg = new RegExp(func_methods.getRegExpStr(content), 'ig')
}
if (reg.test(cell.m)) {
if (reg.test(cell[type])) {
result.push(cell)
}
} else if (isCaseSensitive) {
let reg = new RegExp(func_methods.getRegExpStr(content), 'g');
if (reg.test(cell.m)) {
if (reg.test(cell[type])) {
result.push(cell);
}
} else {
let reg = new RegExp(func_methods.getRegExpStr(content), 'ig');
if (reg.test(cell.m)) {
if (reg.test(cell[type])) {
result.push(cell);
}
}

Loading…
Cancel
Save