From 78033268cda6c17ec32ccee26545d7e9980023e1 Mon Sep 17 00:00:00 2001 From: mengshukeji Date: Fri, 11 Dec 2020 17:38:55 +0800 Subject: [PATCH] docs(readme): sponsor 1.Add sponsors 2.Add api:enterEditMode 3.Add hook function:cellEditBefore --- README-zh.md | 4 + README.md | 4 + deploy.bat | 8 +- docs/about/README.md | 2 + docs/about/sponsor.md | 2 + docs/guide/config.md | 157 +++++++++++++++++++++++++++------- docs/zh/about/README.md | 2 + docs/zh/about/sponsor.md | 4 +- docs/zh/guide/config.md | 65 ++++++++------ src/controllers/updateCell.js | 4 + src/global/api.js | 49 ++++++++++- src/index.html | 3 + 12 files changed, 244 insertions(+), 60 deletions(-) diff --git a/README-zh.md b/README-zh.md index b847caa..2eaac5b 100644 --- a/README-zh.md +++ b/README-zh.md @@ -158,17 +158,21 @@ Luckysheet是MIT许可的开源项目,其持续稳定的开发离不开这些 - 爱乐 ¥ 100 - 小李飞刀刀 ¥ 66 - 张铭 ¥ 200 +- 曹治军 ¥ 1 +- *特 ¥ 10 ## 贡献者和感谢 ### 核心团队活跃成员 - [@wbfsa](https://github.com/wbfsa) +- [@iamxuchen800117](https://github.com/iamxuchen800117) - [@wpxp123456](https://github.com/wpxp123456) - [@tonytonychopper123](https://github.com/tonytonychopper123) - [@Dushusir](https://github.com/Dushusir) - [@c19c19i](https://weibo.com/u/3884623955) - [@zhangchen915](https://github.com/zhangchen915) - [@jerry-f](https://github.com/jerry-f) +- [@flowerField](https://github.com/flowerField) ### 社区伙伴 - [@danielcai1987](https://github.com/danielcai1987) diff --git a/README.md b/README.md index 065d411..5841835 100644 --- a/README.md +++ b/README.md @@ -154,17 +154,21 @@ Funds donated via Patreon go directly to support mengshukeji's work on Luckyshee - 爱乐 ¥ 100 - 小李飞刀刀 ¥ 66 - 张铭 ¥ 200 +- 曹治军 ¥ 1 +- *特 ¥ 10 ## Authors and acknowledgment ### Active Core Team Members - [@wbfsa](https://github.com/wbfsa) +- [@iamxuchen800117](https://github.com/iamxuchen800117) - [@wpxp123456](https://github.com/wpxp123456) - [@tonytonychopper123](https://github.com/tonytonychopper123) - [@Dushusir](https://github.com/Dushusir) - [@c19c19i](https://weibo.com/u/3884623955) - [@zhangchen915](https://github.com/zhangchen915) - [@jerry-f](https://github.com/jerry-f) +- [@flowerField](https://github.com/flowerField) ### Community Partners - [@danielcai1987](https://github.com/danielcai1987) diff --git a/deploy.bat b/deploy.bat index bcc6745..30f113a 100644 --- a/deploy.bat +++ b/deploy.bat @@ -51,11 +51,11 @@ git branch -d fea # test pull request: https://docs.github.com/cn/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/checking-out-pull-requests-locally # 139 is ID, dev is branch name -git fetch origin pull/139/head:dev -git checkout dev +git fetch origin pull/139/head:test-139 +git checkout test-139 # test code -git push origin dev -# create new PR ,merge dev to master +git push origin test-139 +# create new PR ,merge test-139 to master # list all remote and local branchs git branch -a diff --git a/docs/about/README.md b/docs/about/README.md index 5c4426e..0d82f7a 100644 --- a/docs/about/README.md +++ b/docs/about/README.md @@ -4,12 +4,14 @@ Luckysheet is a project led by an individual and jointly developed by several fr ### Active Core Team Members - [@wbfsa](https://github.com/wbfsa) +- [@iamxuchen800117](https://github.com/iamxuchen800117) - [@wpxp123456](https://github.com/wpxp123456) - [@tonytonychopper123](https://github.com/tonytonychopper123) - [@Dushusir](https://github.com/Dushusir) - [@c19c19i](https://weibo.com/u/3884623955) - [@zhangchen915](https://github.com/zhangchen915) - [@jerry-f](https://github.com/jerry-f) +- [@flowerField](https://github.com/flowerField) ### Community Partners - [@danielcai1987](https://github.com/danielcai1987) diff --git a/docs/about/sponsor.md b/docs/about/sponsor.md index 5be0a6b..1450bc9 100644 --- a/docs/about/sponsor.md +++ b/docs/about/sponsor.md @@ -38,3 +38,5 @@ Funds donated via Patreon go directly to support mengshukeji's work on Luckyshee - 爱乐 ¥ 100 - 小李飞刀刀 ¥ 66 - 张铭 ¥ 200 +- 曹治军 ¥ 1 +- *特 ¥ 10 diff --git a/docs/guide/config.md b/docs/guide/config.md index 27b2c70..4758fcc 100644 --- a/docs/guide/config.md +++ b/docs/guide/config.md @@ -531,50 +531,149 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura ## Cell -### cellRenderAfter -- Type: Function -- Default: null -- Usage: Triggered after the cell rendering ends -- Parameter: - - {Number} [r]: Row number of cell - - {Number} [c]: Column number of cell - - {Object} [v]: Cell object +### cellEditBefore ------------- -### cellHover - Type: Function - Default: null -- Usage: Triggered when the mouse moves over the cell (hover) +- Usage: Triggered before entering the cell editing mode. When a cell is selected and in the non-editing state, there are usually the following three conventional methods to trigger the edit mode + - Double click the cell + - Hit Enter + - Use API: enterEditMode - Parameter: - - {Number} [r]: Row number of cell - - {Number} [c]: Column number of cell - - {Object} [v]: Cell object + - {Array} [range]: Current selection range ------------ ### cellUpdateBefore -- Type:Function -- Default:null -- Usage:Triggered before updating this cell -- Parameter: - - {Number} [r]: Row number of cell - - {Number} [c]: Column number of cell - - {Object | String | Number} [value]: Cell content to be modified +- Type: Function +- Default: null +- Usage: Triggered before updating this cell value, `return false` will not perform subsequent updates. After modifying the cell in the editing state, this hook is triggered before exiting the editing mode and updating the data. +- Parameter: + - {Number} [r]: The row number of the cell + - {Number} [c]: The column number of the cell + - {Object | String | Number} [value]: The content of the cell to be modified - {Boolean} [isRefresh]: Whether to refresh the entire table ------------ ### cellUpdated -- Type:Function -- Default:null -- Usage:Triggered after updating this cell -- Parameter: - - {Number} [r]: Row number of cell - - {Number} [c]: Column number of cell +- Type: Function +- Default: null +- Usage: Triggered after updating this cell +- Parameter: + - {Number} [r]: The row number of the cell + - {Number} [c]: The column number of the cell - {Object} [oldValue]: Cell object before modification - - {Object} [newValue]: Cell object after modification + - {Object} [newValue]: Modified cell object - {Boolean} [isRefresh]: Whether to refresh the entire table +------------ +### cellRenderBefore + +- Type: Function +- Default: null +- Usage: Triggered before the cell is rendered, `return false` will not render the cell +- Parameter: + - {Object} [cell]:Cell object + - {Object} [postion]: + + {Number} [r]: The row number of the cell + + {Number} [c]: The column number of the cell + + {Number} [start_r]: The horizontal coordinate of the upper left corner of the cell + + {Number} [start_c]: The vertical coordinate of the upper left corner of the cell + + {Number} [end_r]: The horizontal coordinate of the lower right corner of the cell + + {Number} [end_c]: The vertical coordinate of the lower right corner of the cell + - {Object} [sheet]: Current sheet object + - {Object} [ctx]: The context of the current canvas + +------------ +### cellRenderAfter + +- Type: Function +- Default: null +- Usage: Triggered after the cell rendering ends, `return false` will not render the cell +- Parameter: + - {Object} [cell]: Cell object + - {Object} [postion]: + + {Number} [r]: The row number of the cell + + {Number} [c]: The column number of the cell + + {Number} [start_r]: The horizontal coordinate of the upper left corner of the cell + + {Number} [start_c]: The vertical coordinate of the upper left corner of the cell + + {Number} [end_r]: The horizontal coordinate of the lower right corner of the cell + + {Number} [end_c]: The vertical coordinate of the lower right corner of the cell + - {Object} [sheet]: Current worksheet object + - {Object} [ctx]: The context of the current canvas + +------------ +### cellAllRenderBefore + +- Type: Function +- Default: null +- Usage:The method executed before all cells are rendered. Internally, this method is added before `luckysheetDrawMain` renders the table. +- Parameter: + - {Object} [data]: Two-dimensional array data of the current worksheet + - {Object} [sheet]: Current worksheet object + - {Object} [ctx]: The context of the current canvas + +------------ +### rowTitleCellRenderBefore + +- Type: Function +- Default: null +- Usage: Triggered before the row header cell is rendered, `return false` will not render the row header +- Parameter: + - {String} [rowNum]: Row number + - {Object} [postion]: + + {Number} [r]: The row number of the cell + + {Number} [top]: The vertical coordinate of the upper left corner of the cell + + {Number} [width]: Cell width + + {Number} [height]: Cell height + - {Object} [ctx]: The context of the current canvas + +------------ +### rowTitleCellRenderAfter + +- Type: Function +- Default: null +- Usage: Triggered after the row header cell is rendered, `return false` will not render the row header +- Parameter: + - {String} [rowNum]: Row number + - {Object} [postion]: + + {Number} [r]: The row number of the cell + + {Number} [top]: The vertical coordinate of the upper left corner of the cell + + {Number} [width]: Cell width + + {Number} [height]: Cell height + - {Object} [ctx]: The context of the current canvas + +------------ +### columnTitleCellRenderBefore + +- Type: Function +- Default: null +- Usage: Triggered before the column header cell is rendered, `return false` will not render the column header +- Parameter: + - {Object} [columnAbc]: Column header characters + - {Object} [postion]: + - {Number} [c]: The column number of the cell + - {Number} [left]: The horizontal coordinate of the upper left corner of the cell + - {Number} [width]: Cell width + - {Number} [height]: Cell height + - {Object} [ctx]: The context of the current canvas + +------------ +### columnTitleCellRenderAfter + +- Type: Function +- Default: null +- Usage: Triggered after the column header cell is rendered, `return false` will not render the column header +- Parameter: + - {Object} [columnAbc]: Column header characters + - {Object} [postion]: + - {Number} [c]: The column number of the cell + - {Number} [left]: The horizontal coordinate of the upper left corner of the cell + - {Number} [width]: Cell width + - {Number} [height]: Cell height + - {Object} [ctx]: The context of the current canvas + ------------ ## Selected area @@ -584,7 +683,7 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura - Default: null - Usage: Frame selection or trigger after setting selection - Parameter: - - {Object} [sheet]: Current sheet object + - {Object} [sheet]: Current worksheet object - {Object | Array} [range]: Selection area, may be multiple selection areas ------------ diff --git a/docs/zh/about/README.md b/docs/zh/about/README.md index e981d69..4ca550d 100644 --- a/docs/zh/about/README.md +++ b/docs/zh/about/README.md @@ -4,12 +4,14 @@ Luckysheet是由个人主导、几个志同道合的小伙伴一同开发的项 ## 核心团队活跃成员 - [@wbfsa](https://github.com/wbfsa) +- [@iamxuchen800117](https://github.com/iamxuchen800117) - [@wpxp123456](https://github.com/wpxp123456) - [@tonytonychopper123](https://github.com/tonytonychopper123) - [@Dushusir](https://github.com/Dushusir) - [@c19c19i](https://weibo.com/u/3884623955) - [@zhangchen915](https://github.com/zhangchen915) - [@jerry-f](https://github.com/jerry-f) +- [@flowerField](https://github.com/flowerField) ## 社区伙伴 - [@danielcai1987](https://github.com/danielcai1987) diff --git a/docs/zh/about/sponsor.md b/docs/zh/about/sponsor.md index 23146d3..7445147 100644 --- a/docs/zh/about/sponsor.md +++ b/docs/zh/about/sponsor.md @@ -37,4 +37,6 @@ Luckysheet是MIT许可的开源项目,其持续稳定的开发离不开这些 - yangxshn ¥ 10 - 爱乐 ¥ 100 - 小李飞刀刀 ¥ 66 -- 张铭 ¥ 200 \ No newline at end of file +- 张铭 ¥ 200 +- 曹治军 ¥ 1 +- *特 ¥ 10 \ No newline at end of file diff --git a/docs/zh/guide/config.md b/docs/zh/guide/config.md index a15cbc7..f0811b3 100644 --- a/docs/zh/guide/config.md +++ b/docs/zh/guide/config.md @@ -623,8 +623,47 @@ Luckysheet开放了更细致的自定义配置选项,分别有 > 使用案例可参考源码 [src/index.html](https://github.com/mengshukeji/Luckysheet/blob/master/src/index.html) -## 单元格渲染 +## 单元格 +### cellEditBefore + +- 类型:Function +- 默认值:null +- 作用:进入单元格编辑模式之前触发。在选中了某个单元格且在非编辑状态下,通常有以下三种常规方法触发进入编辑模式 + + - 双击单元格 + - 敲Enter键 + - 使用API:enterEditMode + +- 参数: + - {Array} [range]: 当前选区范围 + +------------ +### cellUpdateBefore + +- 类型:Function +- 默认值:null +- 作用:更新这个单元格值之前触发,`return false` 则不执行后续的更新。在编辑状态下修改了单元格之后,退出编辑模式并进行数据更新之前触发这个钩子。 +- 参数: + - {Number} [r]: 单元格所在行数 + - {Number} [c]: 单元格所在列数 + - {Object | String | Number} [value]: 要修改的单元格内容 + - {Boolean} [isRefresh]: 是否刷新整个表格 + +------------ +### cellUpdated + +- 类型:Function +- 默认值:null +- 作用:更新这个单元格后触发 +- 参数: + - {Number} [r]: 单元格所在行数 + - {Number} [c]: 单元格所在列数 + - {Object} [oldValue]: 修改前的单元格对象 + - {Object} [newValue]: 修改后的单元格对象 + - {Boolean} [isRefresh]: 是否刷新整个表格 + +------------ ### cellRenderBefore - 类型:Function @@ -670,30 +709,6 @@ Luckysheet开放了更细致的自定义配置选项,分别有 - {Object} [data]: 当前工作表二维数组数据 - {Object} [sheet]:当前sheet对象 - {Object} [ctx]: 当前画布的context ------------- -### cellUpdateBefore - -- 类型:Function -- 默认值:null -- 作用:更新这个单元格之前触发,`return false` 则不执行后续的更新 -- 参数: - - {Number} [r]: 单元格所在行数 - - {Number} [c]: 单元格所在列数 - - {Object | String | Number} [value]: 要修改的单元格内容 - - {Boolean} [isRefresh]: 是否刷新整个表格 - ------------- -### cellUpdated - -- 类型:Function -- 默认值:null -- 作用:更新这个单元格后触发 -- 参数: - - {Number} [r]: 单元格所在行数 - - {Number} [c]: 单元格所在列数 - - {Object} [oldValue]: 修改前的单元格对象 - - {Object} [newValue]: 修改后的单元格对象 - - {Boolean} [isRefresh]: 是否刷新整个表格 ------------ ### rowTitleCellRenderBefore diff --git a/src/controllers/updateCell.js b/src/controllers/updateCell.js index 26e7bfd..690d658 100644 --- a/src/controllers/updateCell.js +++ b/src/controllers/updateCell.js @@ -16,6 +16,7 @@ import cleargridelement from '../global/cleargridelement'; import {isInlineStringCell} from './inlineString'; import Store from '../store'; import server from './server'; +import method from '../global/method'; export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocus) { if(!checkProtectionLocked(row_index1, col_index1, Store.currentSheetIndex)){ @@ -27,6 +28,9 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu return; } + // 钩子函数 + method.createHookFunction('cellEditBefore',Store.luckysheet_select_save) + // 编辑单元格时发送指令到后台,通知其他单元格更新为“正在输入”状态 server.saveParam("mv", Store.currentSheetIndex, {op:"enterEdit",range:Store.luckysheet_select_save}); diff --git a/src/global/api.js b/src/global/api.js index 01b0965..1418ce8 100644 --- a/src/global/api.js +++ b/src/global/api.js @@ -40,6 +40,7 @@ import dataVerificationCtrl from "../controllers/dataVerificationCtrl"; import imageCtrl from '../controllers/imageCtrl'; import dayjs from "dayjs"; import {getRangetxt } from '../methods/get'; +import {luckysheetupdateCell} from '../controllers/updateCell'; const IDCardReg = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i; /** @@ -481,7 +482,53 @@ export function replace(content, replaceContent, options = {}) { */ export function exitEditMode(options = {}){ if(parseInt($("#luckysheet-input-box").css("top")) > 0){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + + + if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { + formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); + } + else { + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + Store.luckysheet_select_save = [{ + "row": [Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[0]], + "column": [Store.luckysheetCellUpdate[1], Store.luckysheetCellUpdate[1]], + "row_focus": Store.luckysheetCellUpdate[0], + "column_focus": Store.luckysheetCellUpdate[1] + }]; + } + + //若有参数弹出框,隐藏 + if($("#luckysheet-search-formula-parm").is(":visible")){ + $("#luckysheet-search-formula-parm").hide(); + } + //若有参数选取范围弹出框,隐藏 + if($("#luckysheet-search-formula-parm-select").is(":visible")){ + $("#luckysheet-search-formula-parm-select").hide(); + } + + } + + if (options.success && typeof options.success === 'function') { + options.success(); + } +} + +/** + * 手动触发进入编辑模式 + * @param {Object} options 可选参数 + * @param {Function} options.success 操作结束的回调函数 + */ +export function enterEditMode(options = {}){ + + if($("#luckysheet-conditionformat-dialog").is(":visible")){ + return; + } + else if ($("#luckysheet-cell-selected").is(":visible")) { + let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; + + let row_index = last["row_focus"], col_index = last["column_focus"]; + + luckysheetupdateCell(row_index, col_index, Store.flowdata); } if (options.success && typeof options.success === 'function') { diff --git a/src/index.html b/src/index.html index ae8fffc..0dcf8a6 100644 --- a/src/index.html +++ b/src/index.html @@ -159,6 +159,9 @@ commentUpdateAfter:function(r, c, oldCell, newCell ){ // console.info(r, c, oldCell, newCell) }, + cellEditBefore:function(range ){ + // console.info(range) + }, },