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

Commit

Permalink
feat(api): hook function
Browse files Browse the repository at this point in the history
1.Add API:getRangeByTxt / getTxtByRange 2.Add hook function:rangeSelect 3.fix IFERROR formula 4.Add
Java backend link
  • Loading branch information
mengshukeji committed Nov 23, 2020
1 parent ec02dcd commit a0db530
Show file tree
Hide file tree
Showing 19 changed files with 140 additions and 61 deletions.
3 changes: 2 additions & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

## 在线案例

- [协同编辑Demo](http://luckysheet.lashuju.com/demo/)(注意:官方Java后台待整理后也会开源,采用OT算法。请大家别操作频繁,防止搞崩服务器)
- [协同编辑Demo](http://luckysheet.lashuju.com/demo/)
- [Java后台Luckysheet Server](https://github.com/mengshukeji/LuckysheetServer)

## 插件
- excel导入导出库: [Luckyexcel](https://github.com/mengshukeji/Luckyexcel)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ English| [简体中文](./README-zh.md)

## Online Case

- [Cooperative editing demo](http://luckysheet.lashuju.com/demo/)(Note: The official Java backend will also be open source after finishing,using OT algorithm. Please do not operate frequently to prevent the server from crashing)
- [Cooperative editing demo](http://luckysheet.lashuju.com/demo/)
- [Java backend Luckysheet Server](https://github.com/mengshukeji/LuckysheetServer)

## Plugins
- Excel import and export library: [Luckyexcel](https://github.com/mengshukeji/Luckyexcel)
Expand Down
20 changes: 10 additions & 10 deletions docs/guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,15 +567,15 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura
- Default: null
- Usage: Frame selection or trigger before setting selection
- Parameter:
- {Object || Array} [range]: Selection area, may be multiple selection areas
- {Object | Array} [range]: Selection area, may be multiple selection areas

------------
### rangeSelectAfter
- Type: Function
- Default: null
- Usage: Frame selection or trigger after setting selection
- Parameter:
- {Object || Array} [range]: Selection area, may be multiple selection areas
- {Object | Array} [range]: Selection area, may be multiple selection areas

------------
### rangeMoveBefore
Expand All @@ -600,7 +600,7 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura
- Default: null
- Usage: Before the selection
- Parameter:
- {Object || Array} [range]: Selection area, may be multiple selection areas
- {Object | Array} [range]: Selection area, may be multiple selection areas
- {Object} [data]: Data corresponding to the selection area

------------
Expand All @@ -609,7 +609,7 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura
- Default: null
- Usage: After the selection is modified
- Parameter:
- {Object || Array} [range]: Selection area, may be multiple selection areas
- {Object | Array} [range]: Selection area, may be multiple selection areas
- {Object} [oldData]: Before modification, the data corresponding to the selection area
- {Object} [newData]: After modification, the data corresponding to the selection area

Expand All @@ -619,7 +619,7 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura
- Default: null
- Usage: Before copying selection
- Parameter:
- {Object || Array} [range]: Selection area, may be multiple selection areas
- {Object | Array} [range]: Selection area, may be multiple selection areas
- {Object} [data]: Data corresponding to the selection area

------------
Expand All @@ -628,7 +628,7 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura
- Default: null
- Usage: After copying selection
- Parameter:
- {Object || Array} [range]: Selection area, may be multiple selection areas
- {Object | Array} [range]: Selection area, may be multiple selection areas
- {Object} [data]: Data corresponding to the selection area

------------
Expand All @@ -637,7 +637,7 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura
- Default: null
- Usage: Before pasting the selection
- Parameter:
- {Object || Array} [range]: Selection area, may be multiple selection areas
- {Object | Array} [range]: Selection area, may be multiple selection areas
- {Object} [data]: The data corresponding to the selection area to be pasted

------------
Expand All @@ -646,7 +646,7 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura
- Default: null
- Usage: After pasting the selection
- Parameter:
- {Object || Array} [range]: Selection area, may be multiple selection areas
- {Object | Array} [range]: Selection area, may be multiple selection areas
- {Object} [originData]: The data corresponding to the selection area to be pasted
- {Object} [pasteData]: Data to paste

Expand Down Expand Up @@ -692,7 +692,7 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura
- Default: null
- Usage: Before the selection is cleared
- Parameter:
- {Object || Array} [range]: Selection area, may be multiple selection areas
- {Object | Array} [range]: Selection area, may be multiple selection areas
- {Object} [data]: The data corresponding to the selection area to be cleared

------------
Expand All @@ -701,7 +701,7 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura
- Default: null
- Usage: After the selection is cleared
- Parameter:
- {Object || Array} [range]: Selection area, may be multiple selection areas
- {Object | Array} [range]: Selection area, may be multiple selection areas
- {Object} [data]: The data corresponding to the selection area to be cleared

------------
Expand Down
3 changes: 3 additions & 0 deletions docs/guide/resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ If you have written or found an excellent tutorial and want to recommend it to u

## Back-end

### Official case
- [Java backend Luckysheet Server](https://github.com/mengshukeji/LuckysheetServer)

### Community Case
- [Luckysheet save and restore](https://gitee.com/ichiva/luckysheet-saved-in-recovery) (Java version)
- [Online form for collaborative editing based on Luckysheet](https://github.com/DilemmaVi/ecsheet) (Java version)
Expand Down
39 changes: 38 additions & 1 deletion docs/zh/guide/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2440,7 +2440,7 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开

------------

## 公共方法
## 工具方法

### transToCellData(data [,setting])<div id='transToCellData'></div>

Expand Down Expand Up @@ -2481,6 +2481,43 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开

------------

### getRangeByTxt([txt])

- **说明**

将字符串格式的工作表范围转换为数组形式

- **参数**

+ {String} [txt]: 选区范围,支持选区的格式为`"A1:B2"`或者指定工作表名称的写法`"sheetName!A1:B2"`,只支持单个选区;默认为当前最后一个选区

- **示例**:

- 当前选区为`A1:B2`,`luckysheet.getRangeByTxt()`返回:`{column: (2) [0, 1],row: (2) [0, 1]}`
- `luckysheet.getRangeByTxt("A1:B2")`返回:`{column: (2) [0, 1],row: (2) [0, 1]}`
- `luckysheet.getRangeByTxt("Cell!A1:B2")`返回:`{column: (2) [0, 1],row: (2) [0, 1]}`

------------

### getTxtByRange([range])

- **说明**

将数组格式的工作表范围转换为字符串格式的形式

- **参数**

+ {Array | Object} [range]: 选区范围,支持选区的格式为`{row:[0,1],column:[0,1]}`,允许多个选区组成的数组;默认为当前选区

- **示例**:

- 当前选区为`A1:B3`,`luckysheet.getTxtByRange()`返回:当前选区`"A1:B3"`
- `luckysheet.getTxtByRange({column:[0,1],row:[0,2]})`返回:`"A1:B3"`
- `luckysheet.getTxtByRange([{column:[0,1],row:[0,2]}])`返回:`"A1:B3"`
- `luckysheet.getTxtByRange([{column:[0,1],row:[0,2]},{column:[1,1],row:[1,2]}])`返回:`"A1:B3,B2:B3"`

------------


## 旧版API

Expand Down
33 changes: 12 additions & 21 deletions docs/zh/guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ Luckysheet开放了更细致的自定义配置选项,分别有

> 使用案例可参考源码 [src/index.html](https://github.com/mengshukeji/Luckysheet/blob/master/src/index.html)

## 单元格
## 单元格渲染

### cellRenderBefore

Expand Down Expand Up @@ -844,24 +844,15 @@ Luckysheet开放了更细致的自定义配置选项,分别有

------------

## 选区
## 选区操作(包括单元格)

### rangeSelectBefore
(TODO)
- 类型:Function
- 默认值:null
- 作用:框选或者设置选区前触发
- 参数:
- {Object || Array} [range]: 选区范围,可能为多个选区
### rangeSelect

------------
### rangeSelectAfter
(TODO)
- 类型:Function
- 默认值:null
- 作用:框选或者设置选区后触发
- 参数:
- {Object || Array} [range]: 选区范围,可能为多个选区
- {Object | Array} [range]: 选区范围,可能为多个选区

------------
### rangeMoveBefore
Expand Down Expand Up @@ -889,7 +880,7 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 默认值:null
- 作用:选区修改前
- 参数:
- {Object || Array} [range]: 选区范围,可能为多个选区
- {Object | Array} [range]: 选区范围,可能为多个选区
- {Object} [data]: 选区范围所对应的数据

------------
Expand All @@ -899,7 +890,7 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 默认值:null
- 作用:选区修改后
- 参数:
- {Object || Array} [range]: 选区范围,可能为多个选区
- {Object | Array} [range]: 选区范围,可能为多个选区
- {Object} [oldData]: 修改前选区范围所对应的数据
- {Object} [newData]: 修改后选区范围所对应的数据

Expand All @@ -910,7 +901,7 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 默认值:null
- 作用:选区复制前
- 参数:
- {Object || Array} [range]: 选区范围,可能为多个选区
- {Object | Array} [range]: 选区范围,可能为多个选区
- {Object} [data]: 选区范围所对应的数据

------------
Expand All @@ -920,7 +911,7 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 默认值:null
- 作用:选区复制后
- 参数:
- {Object || Array} [range]: 选区范围,可能为多个选区
- {Object | Array} [range]: 选区范围,可能为多个选区
- {Object} [data]: 选区范围所对应的数据

------------
Expand All @@ -930,7 +921,7 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 默认值:null
- 作用:选区粘贴前
- 参数:
- {Object || Array} [range]: 选区范围,可能为多个选区
- {Object | Array} [range]: 选区范围,可能为多个选区
- {Object} [data]: 要被粘贴的选区范围所对应的数据

------------
Expand All @@ -940,7 +931,7 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 默认值:null
- 作用:选区粘贴后
- 参数:
- {Object || Array} [range]: 选区范围,可能为多个选区
- {Object | Array} [range]: 选区范围,可能为多个选区
- {Object} [originData]: 要被粘贴的选区范围所对应的数据
- {Object} [pasteData]: 要粘贴的数据

Expand Down Expand Up @@ -991,7 +982,7 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 默认值:null
- 作用:选区清除前
- 参数:
- {Object || Array} [range]: 选区范围,可能为多个选区
- {Object | Array} [range]: 选区范围,可能为多个选区
- {Object} [data]: 要被清除的选区范围所对应的数据

------------
Expand All @@ -1001,7 +992,7 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 默认值:null
- 作用:选区清除后
- 参数:
- {Object || Array} [range]: 选区范围,可能为多个选区
- {Object | Array} [range]: 选区范围,可能为多个选区
- {Object} [data]: 被清除的选区范围所对应的数据

------------
Expand Down
5 changes: 4 additions & 1 deletion docs/zh/guide/resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@

## 后台

### 官方案例
- [Java 后台 Luckysheet Server](https://github.com/mengshukeji/LuckysheetServer)

### 社区案例
- [Luckysheet保存与恢复](https://gitee.com/ichiva/luckysheet-saved-in-recovery)(Java版)
- [基于Luckysheet实现的协同编辑在线表格](https://github.com/DilemmaVi/ecsheet)(Java版)
- [使用.net core 3.1和Npoi 制作基于LuckSheet的基础导出](https://blog.csdn.net/DCDC2020/article/details/108486525)
- [使用.net core 3.1和Npoi 制作基于LuckSheet的基础导出](https://blog.csdn.net/DCDC2020/article/details/108486525)(.NET 版本)

## 学习资料

Expand Down
1 change: 0 additions & 1 deletion src/controllers/conditionformat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,6 @@ const conditionformat = {
range.push(formula.getcellrange(txt));
}
}

return range;
},
colorSelectInit: function(){
Expand Down
8 changes: 3 additions & 5 deletions src/controllers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ export default function luckysheetHandler() {
});
}
else {
Store.luckysheet_select_save = [];
Store.luckysheet_select_save.length = 0;
Store.luckysheet_select_save.push({
"left": col_pre,
"width": col - col_pre - 1,
Expand Down Expand Up @@ -1095,10 +1095,8 @@ export default function luckysheetHandler() {
luckysheetactiveCell();
}

if (server.allowUpdate) {
//允许编辑后的后台更新时
server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
}
//允许编辑后的后台更新时
server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
}

//交替颜色
Expand Down
3 changes: 1 addition & 2 deletions src/controllers/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import {createProxy} from '../utils/util'
import Store from '../store/index'
const initListener = function(){
createProxy(Store,['jfredo'])
createProxy(Store,['jfredo']);
}


export {
initListener
}
16 changes: 6 additions & 10 deletions src/controllers/rowColumnOperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export function rowColumnOperationInitial(){
});
}
else{
Store.luckysheet_select_save = [];
Store.luckysheet_select_save.length = 0;
Store.luckysheet_select_save.push({
"left": colLocationByIndex(0)[0],
"width": colLocationByIndex(0)[1] - colLocationByIndex(0)[0] - 1,
Expand All @@ -343,10 +343,8 @@ export function rowColumnOperationInitial(){

selectHightlightShow();

if(server.allowUpdate){
//允许编辑后的后台更新时
server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
}
//允许编辑后的后台更新时
server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
}

selectHelpboxFill();
Expand Down Expand Up @@ -737,7 +735,7 @@ export function rowColumnOperationInitial(){
});
}
else{
Store.luckysheet_select_save = [];
Store.luckysheet_select_save.length = 0;
Store.luckysheet_select_save.push({
"left": left,
"width": width,
Expand All @@ -757,10 +755,8 @@ export function rowColumnOperationInitial(){

selectHightlightShow();

if(server.allowUpdate){
//允许编辑后的后台更新时
server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
}
//允许编辑后的后台更新时
server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
}

selectHelpboxFill();
Expand Down
Loading

0 comments on commit a0db530

Please sign in to comment.