Browse Source

Merge branch 'master' into add-button

master
mengshukeji 5 years ago
committed by GitHub
parent
commit
bd4e379ddc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      CHANGELOG.md
  2. 48
      README-zh.md
  3. 45
      README.md
  4. 3
      deploy.bat
  5. 25
      docs/.vuepress/config.js
  6. 97
      docs/guide/FAQ.md
  7. 36
      docs/guide/README.md
  8. 14
      docs/guide/api.md
  9. 256
      docs/guide/config.md
  10. 20
      docs/guide/resource.md
  11. 72
      docs/zh/guide/FAQ.md
  12. 36
      docs/zh/guide/README.md
  13. 14
      docs/zh/guide/api.md
  14. 2
      docs/zh/guide/cell.md
  15. 444
      docs/zh/guide/config.md
  16. 20
      docs/zh/guide/resource.md
  17. 19
      gulpfile.js
  18. 14
      package.json
  19. 92
      src/assets/iconfont/demo_index.html
  20. 28
      src/assets/iconfont/iconfont.css
  21. BIN
      src/assets/iconfont/iconfont.eot
  22. 2
      src/assets/iconfont/iconfont.js
  23. 28
      src/assets/iconfont/iconfont.json
  24. 12
      src/assets/iconfont/iconfont.svg
  25. BIN
      src/assets/iconfont/iconfont.ttf
  26. BIN
      src/assets/iconfont/iconfont.woff
  27. BIN
      src/assets/iconfont/iconfont.woff2
  28. 15
      src/config.js
  29. 223
      src/controllers/constant.js
  30. 37
      src/controllers/controlHistory.js
  31. 38
      src/controllers/dataVerificationCtrl.js
  32. 188
      src/controllers/freezen.js
  33. 352
      src/controllers/handler.js
  34. 361
      src/controllers/hyperlinkCtrl.js
  35. 4
      src/controllers/imageCtrl.js
  36. 2
      src/controllers/luckysheetConfigsetting.js
  37. 9
      src/controllers/menuButton.js
  38. 581
      src/controllers/resize.js
  39. 1012
      src/controllers/rowColumnOperation.js
  40. 9
      src/controllers/sheetBar.js
  41. 42
      src/controllers/sheetmanage.js
  42. 49
      src/controllers/updateCell.js
  43. 23
      src/core.js
  44. 43
      src/css/luckysheet-core.css
  45. 5
      src/css/luckysheet-print.css
  46. 5
      src/css/luckysheet-zoom.css
  47. 65
      src/global/api.js
  48. 41
      src/global/border.js
  49. 10
      src/global/createdom.js
  50. 181
      src/global/draw.js
  51. 158
      src/global/extend.js
  52. 2
      src/global/location.js
  53. 26
      src/global/method.js
  54. 41
      src/global/refresh.js
  55. 6
      src/global/rhchInit.js
  56. 35
      src/index.html
  57. 16
      src/locale/en.js
  58. 16
      src/locale/zh.js
  59. 3
      src/store/index.js
  60. 2
      src/utils/util.js

29
CHANGELOG.md

@ -2,6 +2,35 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [2.1.5](https://github.com/mengshukeji/Luckysheet/compare/v2.1.4...v2.1.5) (2020-11-03)
### Features
* **cell date picker:** cell date picker and bug solve ([2996ae9](https://github.com/mengshukeji/Luckysheet/commit/2996ae9cab724714903d00e0b63022abc4a1a3b6))
* **cell hooks add:** go to document for detail ([927ff46](https://github.com/mengshukeji/Luckysheet/commit/927ff46949f688a5bcffcb3fe48dc6b4b12b61c9))
* **config:** custom menu button config ([14eb78e](https://github.com/mengshukeji/Luckysheet/commit/14eb78e153cbce726adf9e093702f9b93af1fa03))
* **config:** sheetbar ([3555746](https://github.com/mengshukeji/Luckysheet/commit/3555746f4cc8ef2c1fe163a34edd428f1a6377ed))
* **date format:** date format Chinese ([8f8d0cb](https://github.com/mengshukeji/Luckysheet/commit/8f8d0cb8c5563a31afba3fe11b525e6bccd5eb56))
* **hyperlink:** add hyperlink function ([439dff4](https://github.com/mengshukeji/Luckysheet/commit/439dff4330ab5053643331286091d44ae910fb8d))
* **hyperlink:** perfect hyperlink function ([5adfc60](https://github.com/mengshukeji/Luckysheet/commit/5adfc6055bf4cfed7f1ff40933d292057196bc7e))
* **statisticbar:** config docs ([c1ed417](https://github.com/mengshukeji/Luckysheet/commit/c1ed417074e89e665f9ef39ee186db9106904c4e))
* **tojson:** api/docs ([8e410f5](https://github.com/mengshukeji/Luckysheet/commit/8e410f5d3cd61724230b3024898d6de3c6c41101))
### Bug Fixes
* **bug:** bug ([ad73f9a](https://github.com/mengshukeji/Luckysheet/commit/ad73f9a679d77721d8af0a483dffe70b90e56412)), closes [#129](https://github.com/mengshukeji/Luckysheet/issues/129)
* **bug:** bug ([801cbe5](https://github.com/mengshukeji/Luckysheet/commit/801cbe5a8040d80f2e672b3607c0b92c922281a9))
* **bug:** bug ([f8716c1](https://github.com/mengshukeji/Luckysheet/commit/f8716c18db05c7ab8bf59d1feb0dc4c3b364c560)), closes [#67](https://github.com/mengshukeji/Luckysheet/issues/67) [#85](https://github.com/mengshukeji/Luckysheet/issues/85)
* **bug:** bug ([0909f5e](https://github.com/mengshukeji/Luckysheet/commit/0909f5e4c957e3d3248a8c86d6e092c5a5396112)), closes [#142](https://github.com/mengshukeji/Luckysheet/issues/142) [#132](https://github.com/mengshukeji/Luckysheet/issues/132)
* **bug:** dataVerification and sheet move and delete cell bug ([4815d86](https://github.com/mengshukeji/Luckysheet/commit/4815d86ce564da43aa1ced3b48d38e88afc39f77))
* **conflict:** conflict ([b11de26](https://github.com/mengshukeji/Luckysheet/commit/b11de26c4d2dbdd7e9d4363558e95d4433f26585))
* **conflict:** toolbar ([8cfa6ac](https://github.com/mengshukeji/Luckysheet/commit/8cfa6ac1bec8bcb156fe45e8c488aa7026b65738))
* **fix bug with inline string rotate wrap:** add change to max, fix height error ([1988687](https://github.com/mengshukeji/Luckysheet/commit/198868719ffb19738ee5ecc1ee060a0840fa92df))
* **hide row/column:** right click menu ([8070858](https://github.com/mengshukeji/Luckysheet/commit/8070858f6c35f11ee8cf2692d8828d0e78c46d92)), closes [#37](https://github.com/mengshukeji/Luckysheet/issues/37)
* **restore demo:** restore demo ([e799862](https://github.com/mengshukeji/Luckysheet/commit/e7998627400b82bf082bad3c984f4d26e3c9f43a))
### [2.1.3](https://github.com/mengshukeji/Luckysheet/compare/v2.1.2...v2.1.3) (2020-10-22)

48
README-zh.md

@ -35,6 +35,7 @@
+ **数据类型**
+ **货币, 百分比, 数字, 日期**
+ **Custom** (和excel保持一致,例如: `##,###0.00` , `$1,234.56$##,###0.00_);[Red]($##,###0.00)`, `_($* ##,###0.00_);_(...($* "-"_);_(@_)`, `08-05 PM 01:30MM-dd AM/PM hh:mm` )
+ **单元格内多样式** (Alt+Enter单元格内换行、上标、下标、单元格内科定义每个文字的不同样式)
### 🧬单元格
+ **拖拽选取来修改单元格** (对选区进行操作,可以拖动四边来移动选区,也可以在右下角对选区进行下拉填充操作)
@ -44,6 +45,7 @@
+ **查找和替换** (对内容进行查找替换,支持正则表达式,整词,大小写敏感)
+ **定位** (可以根据单元格的数据类型进行自动定位并选中,选中后可以批量进行格式等操作)
+ **合并单元格**
+ **数据验证(表单功能)** (支持Checkbox, drop-down list, datePicker)
### 🖱️行和列操作
+ **隐藏,插入,删除行或列**
@ -90,19 +92,21 @@
+ **评论** (评论的删除、添加、修改、隐藏)
+ **共享编辑** (支持多用户共享编辑,内置API)
### 📚插入对象
+ **插入图片** (支持JPG,PNG,SVG的插入、修改和删除,并且随表格的变动而产生变化)
### ⚡Luckysheet专有
+ **矩阵计算** (通过右键菜单进行支持:对选区内的数据进行转置、旋转、数值计算)
+ **截图** (把选区的内容进行截图展示)
+ **复制到其他格式** (右键菜单的"复制为", 支持复制为json、array、对角线数据、去重等)
+ **EXCEL,CSV,TXT 导入及导出** (专为Luckysheet打造的导入导出插件,支持密码、水印、公式等的本地导入导出)
+ **插入图片和svg形状** (支持JPG,PNG,SVG,Pen tool的插入、修改和删除,并且随表格的变动而产生变化)
+ **数据验证(表单功能)** (支持Checkbox, drop-down list, datePicker)
+ **单元格内多样式** (Alt+Enter单元格内换行、上标、下标、单元格内科定义每个文字的不同样式)
+ **EXCEL导入及导出** (专为Luckysheet打造的导入导出插件,支持密码、水印、公式等的本地导入导出,导出正在开发)
### ⏱️未来开发计划
+ **打印及设置** (像excel一样进行打印设置,并导出为图片或者PDF)
+ **树形菜单** (类似excel中的分级显示(分组))
+ **表格新功能** (类似excel中表格的筛选器和切片器)
+ **CSV,TXT导入及导出** (专为Luckysheet打造的导入导出插件,支持密码、水印、公式等的本地导入导出)
+ **插入svg形状** (支持[Pen tool](https://github.com/mengshukeji/Pentool)的插入、修改和删除,并且随表格的变动而产生变化)
+ **文档** (完善文档和API)
+ **敬请期待...** (可以提出好的建议给我们)
@ -161,6 +165,7 @@ npm run build
- [鲁班h5](https://github.com/ly525/luban-h5)
- [excelize](https://github.com/360EntSecGroup-Skylar/excelize)
- [h5-Dooring](https://github.com/MrXujiang/h5-Dooring)
## 加入共建
@ -190,6 +195,31 @@ npm run build
[英文社群](./README.md)
## 赞助
如果你感觉这个项目对你有用或者有所启发,可以请作者喝杯果汁:
注意事项:
1. 付款留言请备注:昵称,您的网站地址
2. 默认会将您加入到下方的赞助者列表。如果您想匿名赞助,付款留言请备注:匿名
3. 如果您忘记留言昵称或者网站地址,请联系小编email: alexads@foxmail.com或者微信:dushusir2。
| 微信 | 支付宝 |
|---|---|
| <img src="https://minio.cnbabylon.com/public/luckysheet/wechat.jpg" width="140" />| <img src="https://minio.cnbabylon.com/public/luckysheet/alipay.jpg" width="130" /> |
### [Paypal Me](https://www.paypal.me/wbfsa)
## 赞助者列表
(按时间顺序排列)
- *勇 ¥ 30
- 虚我 ¥ 200
- 甜党 ¥ 50
- Alphabet(Google)-gcf ¥ 1
- **平 ¥ 100
- **东 ¥ 10
- debugger ¥ 20
## 贡献者和感谢
### 团队成员
@ -207,16 +237,6 @@ npm run build
- [@gsw945](https://github.com/gsw945)
- [@swen-xiong](https://github.com/swen-xiong)
## 捐赠
如果你感觉这个项目对你有用或者有所启发,可以请作者喝杯果汁:
| 微信 | 支付宝 |
|---|---|
| <img src="https://minio.cnbabylon.com/public/luckysheet/wechat.jpg" width="140" />| <img src="https://minio.cnbabylon.com/public/luckysheet/alipay.jpg" width="130" /> |
[Paypal Me](https://www.paypal.me/wbfsa)
## 版权信息
[MIT](http://opensource.org/licenses/MIT)

45
README.md

@ -37,6 +37,7 @@ English| [简体中文](./README-zh.md)
+ **Data types**
+ **currency, percentages, decimals, dates**
+ **Custom** (E.g `##,###0.00` , `$1,234.56$##,###0.00_);[Red]($##,###0.00)`, `_($* ##,###0.00_);_(...($* "-"_);_(@_)`, `08-05 PM 01:30MM-dd AM/PM hh:mm` )
+ **Cell segmentation style** (Alt+Enter line break, sub,super, in-cell style)
### 🧬Cells
+ **Move cells by drag and dropping** (Operate on selection)
@ -46,6 +47,7 @@ English| [简体中文](./README-zh.md)
+ **Find and replace** (Such as a particular number or text string, Support regular expression, whole word, case sensitive)
+ **Location** (Cells can be selected according to the data type)
+ **Merge cells**
+ **Data validation** (Checkbox, drop-down list, datePicker)
### 🖱️Row & columns
+ **Hide, Insert, Delete rows and columns**
@ -92,19 +94,21 @@ English| [简体中文](./README-zh.md)
+ **Comments** (Add, delete, update)
+ **Collaborate** (Simultaneous editing by multiple users)
### 📚Insert object
+ **Insert picture** (JPG,PNG,SVG and so on)
### ⚡Luckysheet
+ **Matrix operation** (Operate selection through the right-click menu: transpose, rotate, numerical calculation)
+ **Screenshot** (Take a screenshot with selection)
+ **Copy to** (In the right-click menu, copy selection to json, array etc.)
+ **EXCEL,CSV,TXT import/export** (Specially adapted to Luckysheet)
+ **Insert picture and Shapes** (JPG,PNG,SVG,Pen tool and so on)
+ **Data validation** (Checkbox, drop-down list, datePicker)
+ **Cell segmentation style** (Alt+Enter line break, sub,super, in-cell style)
+ **EXCEL import/export** (Specially adapted to Luckysheet, export is under development)
### ⏱️Coming soon
+ **Print** (Like excel print option, save to PDF)
+ **Tree menu** (Just like the outline (group) function of excel)
+ **Table new Features** (filter, slicer)
+ **CSV,TXT import/export** (Specially adapted to Luckysheet)
+ **Insert Shapes** ([Pen tool](https://github.com/mengshukeji/Pentool) Shapes)
+ **Documentation** (Improve documentation and API)
+ **More...** (Please advise us)
@ -162,6 +166,7 @@ Create a table
- [luban-h5](https://github.com/ly525/luban-h5)
- [excelize](https://github.com/360EntSecGroup-Skylar/excelize)
- [h5-Dooring](https://github.com/MrXujiang/h5-Dooring)
## Co-construction
@ -183,6 +188,31 @@ Create a table
[Chinese community](./README-zh.md)
## Sponsor
If you find this project useful, you can buy author a glass of juice:
Note:
1. Please note the payment message: nickname, your website address
2. By default, you will be added to the sponsor list below. If you want to sponsor anonymously, please leave a note on payment: anonymous
3. If you forget your nickname or website address, please contact the editor email: alexads@foxmail.com or WeChat: dushusir2.
| WeChat | Alipay |
|---|---|
| <img src="https://minio.cnbabylon.com/public/luckysheet/wechat.jpg" width="140" />| <img src="https://minio.cnbabylon.com/public/luckysheet/alipay.jpg" width="130" /> |
### [Paypal Me](https://www.paypal.me/wbfsa)
## Sponsors List
(Sort by time)
- *勇 ¥ 30
- 虚我 ¥ 200
- 甜党 ¥ 50
- Alphabet(Google)-gcf ¥ 1
- **平 ¥ 100
- **东 ¥ 10
- debugger ¥ 20
## Authors and acknowledgment
### Team
@ -202,13 +232,6 @@ Create a table
## Donate
If you find this project useful, you can buy author a glass of juice:
| WeChat | Alipay |
|---|---|
| <img src="https://minio.cnbabylon.com/public/luckysheet/wechat.jpg" width="140" />| <img src="https://minio.cnbabylon.com/public/luckysheet/alipay.jpg" width="130" /> |
[Paypal Me](https://www.paypal.me/wbfsa)
## License

3
deploy.bat

@ -24,5 +24,8 @@ npm publish
# only publish
npm run build
git add .
npm run commit
npm version patch
git push -u origin master
npm publish

25
docs/.vuepress/config.js

@ -16,8 +16,9 @@ module.exports = {
},
themeConfig: {
domain: 'https://mengshukeji.github.io/LuckysheetDemo',
logo: '/img/logo.png',
author: 'Luckysheet',
// 仓库地址
repo: 'mengshukeji/Luckysheet',
// 允许编辑链接文字
@ -53,6 +54,7 @@ module.exports = {
'cell',
'operate',
'api',
'resource',
'FAQ'
],
},
@ -88,6 +90,7 @@ module.exports = {
'cell',
'operate',
'api',
'resource',
'FAQ'
],
},
@ -95,4 +98,24 @@ module.exports = {
},
},
plugins: {
'vuepress-plugin-baidu-autopush': {},
'sitemap': {
hostname: 'https://mengshukeji.github.io/LuckysheetDocs'
},
'vuepress-plugin-code-copy': true,
'seo': {
siteTitle: (_, $site) => $site.title,
title: $page => $page.title,
description: $page => $page.frontmatter.description,
author: (_, $site) => $site.themeConfig.author,
tags: $page => $page.frontmatter.tags,
twitterCard: _ => 'summary_large_image',
type: $page => ['guide'].some(folder => $page.regularPath.startsWith('/' + folder)) ? 'article' : 'website',
url: (_, $site, path) => ($site.themeConfig.domain || '') + path,
image: ($page, $site) => $page.frontmatter.image && (($site.themeConfig.domain && !$page.frontmatter.image.startsWith('http') || '') + $page.frontmatter.image),
publishedAt: $page => $page.frontmatter.date && new Date($page.frontmatter.date),
modifiedAt: $page => $page.lastUpdated && new Date($page.lastUpdated),
}
}
}

97
docs/guide/FAQ.md

@ -2,25 +2,25 @@
## **<span style="font-size:20px;">Q</span>** What is the difference between data and celldata in luckysheetfile?
**<span style="font-size:20px;">A</span>**: Use one-dimensional array format [celldata](/zh/guide/sheet.html#celldata), after the initialization is completed, the data converted into a two-dimensional array format is used for storage and update, and celldata is no longer used.
**<span style="font-size:20px;">A</span>**: Use one-dimensional array format [celldata](/guide/sheet.html#celldata), after the initialization is completed, the data converted into a two-dimensional array format is used for storage and update, and celldata is no longer used.
If you need to take out data as initial data, you need to execute `luckysheet.getGridData(data)` to convert it to celldata data.
Among them, the celldata in `{ r, c, v }` format is converted to a two-dimensional array using `luckysheet.buildGridData(luckysheetfile)`, and the input parameter is the table data object `luckysheetfile`
If you need to take out `data` as initial data, you need to execute [transToCellData(data)](/guide/api.html#transtocelldata-data-setting) to convert it to celldata data.
Among them, the celldata in `{ r, c, v }` format is converted to a two-dimensional array using [transToData(celldata)](/guide/api.html#transtodata-celldata-setting)
Summarized as follows:
```js
// data => celldata two-dimensional array data is converted into {r, c, v} format one-dimensional array, the input parameter is two-dimensional data
luckysheet.getGridData(data)
// data => celldata two-dimensional array data into {r, c, v} format one-dimensional array
luckysheet.transToCellData(data)
// celldata => data The two-dimensional array required to generate the table, the input parameter is the table data object file
luckysheet.buildGridData(luckysheetfile)
// celldata => data to generate the two-dimensional array required for the table
luckysheet.transToData(celldata)
```
------------
## **<span style="font-size:20px;">Q</span>** What are the cell types?
**<span style="font-size:20px;">A</span>**: Refer to [Cell Format List](/zh/guide/cell.html), with examples of available cell formats
**<span style="font-size:20px;">A</span>**: Refer to [Cell Format List](/guide/cell.html), with examples of available cell formats
------------
@ -35,13 +35,13 @@ luckysheet.buildGridData(luckysheetfile)
## **<span style="font-size:20px;">Q</span>** Why will the formula in the table not be triggered after initialization?
**<span style="font-size:20px;">A</span>** : Refer to [Table data format](/zh/guide/sheet.html#calcchain) ,just set the calcChain corresponding to the cell data.
**<span style="font-size:20px;">A</span>** : Refer to [Table data format](/guide/sheet.html#calcchain) ,just set the calcChain corresponding to the cell data.
------------
## **<span style="font-size:20px;">Q</span>** Is the remote loading data loadUrl or updateUrl?
**<span style="font-size:20px;">A</span>**: [loadUrl](/zh/guide/config.html#loadurl). Configure loadUrl, Luckysheet will request the entire table data through ajax, and updateUrl will be used as the interface address for collaborative editing in real-time saving.
**<span style="font-size:20px;">A</span>**: [loadUrl](/guide/config.html#loadurl). Configure loadUrl, Luckysheet will request the entire table data through ajax, and updateUrl will be used as the interface address for collaborative editing in real-time saving.
Note: Initial data needs to be configured with loadUrl and loadSheetUrl parameters, while for collaborative editing, the four parameters of loadUrl, loadSheetUrl, updateUrl and allowUpdate can be configured to take effect.
------------
@ -63,14 +63,17 @@ Note: Initial data needs to be configured with loadUrl and loadSheetUrl paramete
## **<span style="font-size:20px;">Q</span>** How to import and export excel?
**<span style="font-size:20px;">A</span>**: The excel import and export library developed with Luckysheet-[Luckyexcel](https://github.com/mengshukeji/Luckyexcel) has realized the excel import function, and the export function is under development. You can refer to this blog post for excel export at this stage: https://www.cnblogs.com/recode-hyh/p/13168226.html.
**<span style="font-size:20px;">A</span>**: The excel import and export library developed with Luckysheet-[Luckyexcel](https://github.com/mengshukeji/Luckyexcel) has realized the excel import function, and the export function is under development.You can refer to these 2 blog posts for excel export at this stage:
- [Development of Excel download function based on LuckySheet online form](https://www.cnblogs.com/recode-hyh/p/13168226.html)
- [Use exceljs to export luckysheet form](https://blog.csdn.net/csdn_lsy/article/details/107179708)
------------
## **<span style="font-size:20px;">Q</span>** How to merge cells during initialization?
**<span style="font-size:20px;">A</span>**: Refer to the following case
- Luckysheet initializes data with merged cells: https://www.cnblogs.com/DuShuSir/p/13272397.html
**<span style="font-size:20px;">A</span>**: Refer to the following case:
- [How Luckysheet initializes the data with merged cells](https://www.cnblogs.com/DuShuSir/p/13272397.html)
------------
@ -80,20 +83,21 @@ Note: Initial data needs to be configured with loadUrl and loadSheetUrl paramete
- 1. after the table operation is completed, you can use `luckysheet.getAllSheets()` to get all sheet data that stroed in the back-end.
- 2. enable the collaborative editing function to transmit data to the back-end in real-time.
refer this article:https://www.cnblogs.com/DuShuSir/p/13857874.html
refer this article:
[How Luckysheet saves the data in the table to the database](https://www.cnblogs.com/DuShuSir/p/13857874.html)
------------
## **<span style="font-size:20px;">Q</span>** How to monitor cell hover or click events? how to monitor `cellRenderAfter` in real-time?
**<span style="font-size:20px;">A</span>** :我们搜集到需要针对单元格事件的二次开发需求,规划了单元格相关的钩子函数,参考[单元格钩子函数](/zh/guide/config.html#cellrenderafter)(显示的TODO的暂未开放)
**<span style="font-size:20px;">A</span>** :我们搜集到需要针对单元格事件的二次开发需求,规划了单元格相关的钩子函数,参考[单元格钩子函数](/guide/config.html#cellrenderafter)(显示的TODO的暂未开放)
------------
## **<span style="font-size:20px;">Q</span>** How to customize the top toolbar?
**<span style="font-size:20px;">A</span>** :
reference: [options.showtoolbarconfig](/zh/guide/config.html#showtoolbarconfig)(TODO means waiting to developed)
reference: [options.showtoolbarconfig](/guide/config.html#showtoolbarconfig)(TODO means waiting to developed)
------------
@ -109,7 +113,7 @@ if you want to remove jQuery in `Luckysheet`, you can find `jQuery` in source co
## **<span style="font-size:20px;">Q</span>** How to add a field to a cell object?
**<span style="font-size:20px;">A</span>** reference [cell object format](/zh/guide/cell.html),then read this annotation[src/controllers/postil.js](https://github.com/mengshukeji/Luckysheet/blob/master/src/controllers/postil.js)。the annotation is a configuration in a cell object.
**<span style="font-size:20px;">A</span>** reference [cell object format](/guide/cell.html),then read this annotation[src/controllers/postil.js](https://github.com/mengshukeji/Luckysheet/blob/master/src/controllers/postil.js)。the annotation is a configuration in a cell object.
------------
@ -117,7 +121,7 @@ if you want to remove jQuery in `Luckysheet`, you can find `jQuery` in source co
**<span style="font-size:20px;">A</span>** The luckysheet use iconfont icon in this project, if any icon cannot be loaded ,plz check your iconfont.css. we are so sorry that we did not describe it clearly in the old version documents.
Now the documents have been updated.[official documents](/zh/guide/#使用步骤)
Now the documents have been updated.[official documents](/guide/#steps-for-usage)
------------
@ -136,7 +140,7 @@ more information:[Luckyexcel](https://github.com/mengshukeji/Luckyexcel/)
## **<span style="font-size:20px;">Q</span>** How to disable editing of cells?How to open sheet protection?
**<span style="font-size:20px;">A</span>** Sheet protection includes disable editing of cells that you need to make some configurations on each sheets. `config.authority`, the latest configurations[sheet protection](/zh/guide/sheet.html#config-authority)。
**<span style="font-size:20px;">A</span>** Sheet protection includes disable editing of cells that you need to make some configurations on each sheets. `config.authority`, the latest configurations[sheet protection](/guide/sheet.html#config-authority)。
In order to make it easier for you to understand the function of sheet protection, the following video shows how to make the whole sheet uneditable, but allow a column of cells to be edited:
@ -148,7 +152,7 @@ In you local browser, you can open the control pannel, use `luckysheet.getLuckys
## **<span style="font-size:20px;">Q</span>** How to configure data validation?
**<span style="font-size:20px;">A</span>** there is the configuration of data validation,[data validation](/zh/guide/sheet.html#dataVerification)。Also there is the API that you can use `data validation` in any time. [setDataVerification](/zh/guide/api.html#setdataverification-optionitem-setting).
**<span style="font-size:20px;">A</span>** there is the configuration of data validation,[data validation](/guide/sheet.html#dataVerification)。Also there is the API that you can use `data validation` in any time. [setDataVerification](/guide/api.html#setdataverification-optionitem-setting).
------------
@ -177,6 +181,57 @@ if you want to get the position of the picture, you can overlap the picture with
**<span style="font-size:20px;">A</span>** There are two ways to get it
- 1. use `luckysheet.getLuckysheetfile()` to get all configuration data, so you can get the `defaultRowHeight` and `defaultColWidth` in the sheet configuration data。
- 2. use API to get the default row height [getDefaultRowHeight](/zh/guide/api.html#getdefaultrowheight-setting) and column width.[getDefaultColWidth](/zh/guide/api.html#getdefaultcolwidth-setting)
- 2. use API to get the default row height [getDefaultRowHeight](/guide/api.html#getdefaultrowheight-setting) and column width.[getDefaultColWidth](/guide/api.html#getdefaultcolwidth-setting)
------------
## **<span style="font-size:20px;">Q</span>** How to hide the add row button and the back to top button below the worksheet?
**<span style="font-size:20px;">A</span>** Configuration is open
- Allow adding rows [enableAddRow](/guide/config.html#enableaddrow)
- Allow back to top [enableAddBackTop](/guide/config.html#enableAddBackTop)
------------
## **<span style="font-size:20px;">Q</span>** How to hide the row and column headings of the worksheet?
**<span style="font-size:20px;">A</span>** Configuration is open
- The width of the row header area [rowHeaderWidth](/guide/config.html#rowheaderwidth)
- The height of the column header area [columnHeaderHeight](/guide/config.html#columnHeaderHeight)
------------
## **<span style="font-size:20px;">Q</span>** What method can be called to set `config.merge`?
**<span style="font-size:20px;">A</span>** Three methods
- Interface operation
- Use API: [setRangeMerge](/guide/api.html#setrangemerge-type-setting)
- Manually assemble merge parameters
------------
## **<span style="font-size:20px;">Q</span>** Why is the official new feature ineffective?
**<span style="font-size:20px;">A</span>** The first step is to check whether you have used CDN to import,
The CDN link used in the Luckysheet tutorial is the service provided by [jsdelivr](https://www.jsdelivr.com/package/npm/luckysheet), and the code is from [npmjs.com](https://www.npmjs.com/) automatically sync the past, not from [Github](https://github.com/mengshukeji/Luckysheet/). Because our newly submitted code still needs to be tested for a period of time, it will not be released to npm immediately, causing the npm code to lag behind Github.
If you need to try the latest code, we strongly recommend that you pull the code from the [Luckysheet Github](https://github.com/mengshukeji/Luckysheet/) main repository. After our version is stable, we will consider releasing the npm package in real time.
The second step, if it is to import the packaged code of the github repository, test to determine whether there is a bug, you can find the problem and try to fix it, and then [submit a PR](https://github.com/mengshukeji/Luckysheet/pulls), if can't fix it, please [submit issues](https://github.com/mengshukeji/Luckysheet/issues).
------------
## **<span style="font-size:20px;">Q</span>** `npm run dev` reported an error: ʻError: Cannot find module'rollup'`?
**<span style="font-size:20px;">A</span>** It may be a problem with the npm package installation, try the following steps:
1. `npm cache clean --force`
2. `npm i rimraf -g`
3. `rimraf node_modules`
4. Delete the package-lock.json file
5. `npm i`
6. `npm run dev`
Tip: Most other npm installation problems can also be solved by trying above steps.
------------

36
docs/guide/README.md

@ -10,7 +10,7 @@ Luckysheet is an online spreadsheet like excel that is powerful, simple to confi
## Features
### Formatting
### 🛠️Formatting
+ **Styling** (Change font style, size, color, or apply effects)
+ **Conditional formatting** (highlight interesting cells or ranges of cells, emphasize unusual values, and visualize data by using data bars, color scales, and icon sets that correspond to specific variations in the data)
+ **Align or rotate text**
@ -18,8 +18,9 @@ Luckysheet is an online spreadsheet like excel that is powerful, simple to confi
+ **Data types**
+ **currency, percentages, decimals, dates**
+ **Custom** (E.g `##,###0.00` , `$1,234.56$##,###0.00_);[Red]($##,###0.00)`, `_($* ##,###0.00_);_(...($* "-"_);_(@_)`, `08-05 PM 01:30MM-dd AM/PM hh:mm` )
+ **Cell segmentation style** (Alt+Enter line break, sub,super, in-cell style)
### Cells
### 🧬Cells
+ **Move cells by drag and dropping** (Operate on selection)
+ **Fill handle** (For a series like 1, 2, 3, 4, 5..., type 1 and 2 in the first two cells. For the series 2, 4, 6, 8..., type 2 and 4. Support arithmetic sequence, geometric sequence,date, week,chinese numbers)
+ **Auto Fill Options** (Fill copy, sequence, only format, no format, day, month, year)
@ -27,20 +28,21 @@ Luckysheet is an online spreadsheet like excel that is powerful, simple to confi
+ **Find and replace** (Such as a particular number or text string, Support regular expression, whole word, case sensitive)
+ **Location** (Cells can be selected according to the data type)
+ **Merge cells**
+ **Data validation** (Checkbox, drop-down list, datePicker)
### Row & columns
### 🖱️Row & columns
+ **Hide, Insert, Delete rows and columns**
+ **Frozen rows and columns** (First row, first column, Frozen to selection, freeze adjustment lever can be dragged)
+ **Split text** (Split text into different columns with the Convert Text to Columns Wizard)
### Operation
### 🔨Operation
+ **Undo/Redo**
+ **Copy/Paste/Cut** (Copy from excel to luckysheet with format, vice versa)
+ **Copy/Paste/Cut** (Copy from excel to Luckysheet with format, vice versa)
+ **Hot key** (The operating experience is consistent with excel, if there are differences or missing, please feedback to us)
+ **Format Painter** (Similar to google sheet)
+ **Selection by drag and dropping** (Change the parameters of formula and chart through selection)
### Formulas & functions
### ⚙️Formulas & functions
+ **Built-in formulas**
+ Math (SUMIFS, AVERAGEIFS, SUMIF, SUM, etc.)
+ Text (CONCATENATE, REGEXMATCH, MID)
@ -53,39 +55,41 @@ Luckysheet is an online spreadsheet like excel that is powerful, simple to confi
+ **Remote formulas** (DM_TEXT_TFIDF, DM_TEXT_TEXTRANK,DATA_CN_STOCK_CLOSE etc. Need remote interface, can realize complex calculation)
+ **Custom** (Some formula suitable for use in China have been added. AGE_BY_IDCARD, SEX_BY_IDCARD, BIRTHDAY_BY_IDCARD, PROVINCE_BY_IDCARD, CITY_BY_IDCARD, etc. You can define any formula you want)
### Tables
### 📐Tables
+ **Filters** (Support color , numerical, date, text filtering)
+ **Sort** (Sort multiple fields simultaneously)
### Pivot table
### 📈Pivot table
+ **Arrange fields** (Add fileds to rows, columns, values, area, it is similar to excel)
+ **Aggregation** (Surport Sum,Count,CountA,CountUnique,Average,Max,Min,Median,Product,Stdev,Stdevp,Var,VarP etc.)
+ **Filter data** (Add fileds to filters area and analyze the desired data )
+ **Drill down** (Double click pivot table cell to drill down for detail data )
+ **Create a PivotChart** (Pivot table can create a chart )
### Chart
### 📊Chart
+ **Support types** (Line, Column, Area, Bar, Pie, comming soon Scatter, Radar, Gauge, Funnel etc.)
+ **Chart Plugins** (Link to another project [ChartMix](https://github.com/mengshukeji/chartMix)(MIT): ECharts is currently supported,Highcharts, Ali G2, amCharts, googleChart, chart.js are being developed gradually)
+ **Sparklines** (Support by formula : Line, Pie, Box, Pie etc.)
### Share
### ✍️Share
+ **Comments** (Add, delete, update)
+ **Collaborate** (Simultaneous editing by multiple users)
### LuckySheet
### 📚Insert object
+ **Insert picture** (JPG,PNG,SVG and so on)
### ⚡Luckysheet
+ **Matrix operation** (Operate selection through the right-click menu: transpose, rotate, numerical calculation)
+ **Screenshot** (Take a screenshot with selection)
+ **Copy to** (In the right-click menu, copy selection to json, array etc.)
+ **EXCEL,CSV,TXT import/export** (Specially adapted to luckysheet)
+ **Insert picture and Shapes** (JPG,PNG,SVG,Pen tool and so on)
+ **Data validation** (Checkbox, drop-down list, datePicker)
+ **Cell segmentation style** (Alt+Enter line break, sub,super, in-cell style)
+ **EXCEL import/export** (Specially adapted to Luckysheet, export is under development)
### Coming soon
### ⏱️Coming soon
+ **Print** (Like excel print option, save to PDF)
+ **Tree menu** (Just like the outline (group) function of excel)
+ **Table new Features** (filter, slicer)
+ **CSV,TXT import/export** (Specially adapted to Luckysheet)
+ **Insert Shapes** ([Pen tool](https://github.com/mengshukeji/Pentool) Shapes)
+ **Documentation** (Improve documentation and API)
+ **More...** (Please advise us)

14
docs/guide/api.md

@ -1823,13 +1823,12 @@ Use note:
### getAllSheets()
[todo]
- **Explanation**
Return all worksheet configurations, the format is the same as the worksheet configuration, and the results obtained can be used as options.data when the form is initialized.
Therefore, this API is suitable for manually operating and configuring a table, and then taking out all the worksheet information to save it, and then use it for table creation in other places. If you want to get all the workbook data including the workbook configuration, you can use [toJson](#toJson())
Therefore, this API is suitable for manually operating and configuring a table, and then taking out all the worksheet information to save it, and then use it for table creation in other places. If you want to get all the workbook data including the workbook configuration, it is recommended to use [toJson](#toJson()), and it can be directly used to initialize Luckysheet.
- **Usage**:
@ -1844,6 +1843,13 @@ Use note:
Returns a one-dimensional array `luckysheetfile` of all table data structures. Unlike the `getAllSheets` method, the worksheet parameters obtained by this method will contain many internal variables. The most obvious difference is that the table data operation will maintain `luckysheetfile[i]. data`, and the initialization data uses `options.data[i].celldata`, so `luckysheetfile` can be used for debugging, but the initialization table is not applicable.
In addition, a `load = 1` will be added to the loaded worksheet parameters, this parameter needs to be set to 0 when initializing the data. Therefore, to initialize the workbook with the data obtained by `getLuckysheetfile()`, two tasks need to be done:
- Convert celldata to data, refer to: [transToData](/zh/guide/api.html#transtodata-celldata-setting)
- Load reset to 0 or delete this field
Now there is `getAllSheets` to complete this work, no need to manually convert the data.
- **Usage**:
- Get all the debugging information of the first worksheet
@ -1922,7 +1928,7 @@ Use note:
- **Parameter**
- {PlainObject} [setting]: optional parameters
+ {Object} [sheetObject]: The data of the newly added worksheet; the default value is an empty object
+ {Object} [sheetObject]: The data of the newly added worksheet; the default value is an empty object.Worksheet data format reference [options.data](/guide/sheet.html#initial)
+ {Number} [order]: New worksheet subscript; the default value is the last subscript
+ {Function} [success]: callback function for the end of the operation
@ -2562,8 +2568,6 @@ Use note:
### toJson()
[todo]
- **Explanation**
The exported json string can be directly used as the parameter `options` when the workbook is initialized by `luckysheet.create(options)`. The usage scenario is to manually save all the parameters after the user manipulates the table, and then initialize the table elsewhere. Use, similar to the import and export of a luckysheet proprietary format.

256
docs/guide/config.md

@ -28,7 +28,6 @@ Luckysheet has opened more detailed custom configuration options, which are as f
- Customize the toolbar ([showtoolbarConfig](#showtoolbarConfig))
- Customize the bottom sheet bar ([showsheetbarConfig](#showsheetbarConfig))
- Customize the counting bar ([showstatisticBarConfig](#showstatisticBarConfig))
- Custom add row and back to the top ([sheetBottomConfig](#sheetBottomConfig))
- Custom cell right-click menu ([cellRightClickConfig](#cellRightClickConfig))
- Customize the right-click menu of the bottom sheet bar ([sheetRightClickConfig](#sheetRightClickConfig))
@ -59,22 +58,20 @@ The following are all supported setting parameters
- Customize the bottom sheet bar [showsheetbarConfig](#showsheetbarConfig)
- The bottom count bar [showstatisticBar](#showstatisticBar)
- Custom Count Bar [showstatisticBarConfig](#showstatisticBarConfig)
- Custom add row and back to top [sheetBottomConfig](#sheetBottomConfig)
- Allow editing [allowEdit](#allowEdit)
- Allow adding rows [enableAddRow](#enableAddRow)
- Allow adding columns [enableAddCol](#enableAddCol)
- Allow back to top [enableAddBackTop](#enableAddBackTop)
- User Info [userInfo](#userInfo)
- User Information Menu [userMenuItem](#userMenuItem)
- Back button link [myFolderUrl](#myFolderUrl)
- Ratio [devicePixelRatio](#devicePixelRatio)
- Function Button [functionButton](#functionButton)
- Auto-indent interface [showConfigWindowResize](#showConfigWindowResize)
- Load the next page [enablePage](#enablePage)
- Refresh formula [forceCalculation](#forceCalculation)
- Custom cell right-click menu [cellRightClickConfig](#cellRightClickConfig)
- Customize the right-click menu of the bottom sheet bar [sheetRightClickConfig](#sheetRightClickConfig)
- Whether to show the row number area [showRowBar](#showRowBar)
- Whether to show the column number area [showColumnBar](#showColumnBar)
- The width of the row header area [rowHeaderWidth](#rowHeaderWidth)
- The height of the column header area [columnHeaderHeight](#columnHeaderHeight)
- Whether to show the formula bar [sheetFormulaBar](#sheetFormulaBar)
- Initialize the default font size [defaultFontSize](#defaultFontSize)
@ -186,11 +183,9 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect
------------
### showtoolbarConfig
[todo]
- Type: Object
- Default: {}
- Usage: Custom configuration toolbar
- Usage: Custom configuration toolbar,can be used in conjunction with `showtoolbar`, `showtoolbarConfig` has a higher priority.
- Format:
```json
{
@ -214,19 +209,48 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect
verticalAlignMode: false, //'Vertical alignment'
textWrapMode: false, //'Wrap mode'
textRotateMode: false, //'Text Rotation Mode'
frozenMode: false, //'freeze mode'
sort: false, //'sort'
filter: false, //'filter'
findAndReplace: false, //'Find and Replace'
function: false, //'formula'
conditionalFormat: false, //'Conditional Format'
postil: false, //'comment'
pivotTable: false, //'PivotTable'
chart: false, //'chart' (the icon is hidden, but if the chart plugin is configured, you can still create a new chart by right click)
screenshot: false, //'screenshot'
splitColumn: false, //'Split column'
image:false, // 'Insert picture'
link:false, // 'Insert link'
chart: false, //'chart' (the icon is hidden, but if the chart plugin is configured, you can still create a new chart by right click)
postil: false, //'comment'
pivotTable: false, //'PivotTable'
function: false, //'formula'
frozenMode: false, //'freeze mode'
sortAndFilter: false, //'Sort and filter'
conditionalFormat: false, //'Conditional Format'
dataVerification: false, // 'Data Verification'
splitColumn: false, //'Split column'
screenshot: false, //'screenshot'
findAndReplace: false, //'Find and Replace'
protection:false, // 'Worksheet protection'
print:false, // 'Print'
}
```
- Example:
- Show only the `undo/redo` and `font` buttons:
```js
//options
{
showtoolbar: false,
showtoolbarConfig:{
undoRedo: true,
font: true,
}
}
```
- Hide only the `image` and `print` buttons:
```js
//options
{
showtoolbar: true, // The default is true, you can leave it unset
showtoolbarConfig:{
image: false,
print: false,
}
}
```
------------
### showinfobar
@ -243,11 +267,9 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect
------------
### showsheetbarConfig
[todo]
- Type: Object
- Default: {}
- Usage: Custom configuration bottom sheet button
- Usage: Custom configuration bottom sheet button, can be used in conjunction with `showsheetbar`, `showsheetbarConfig` has a higher priority.
- Format:
```json
{
@ -256,6 +278,30 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect
sheet: false //Worksheet display
}
```
- Example:
- Only display the `Add worksheet` button:
```js
//options
{
showsheetbar: false,
showsheetbarConfig:{
add: true,
}
}
```
- Only hide the `Add worksheet` and `Worksheet management menu` buttons:
```js
//options
{
showsheetbar: true, // The default is true, you can leave it unset
showsheetbarConfig:{
add: false,
menu: false,
}
}
```
------------
### showstatisticBar
@ -266,33 +312,40 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect
------------
### showstatisticBarConfig
[todo]
- Type: Object
- Default: {}
- Usage: Customize the bottom count bar
- Usage: Customize the bottom count bar, can be used in conjunction with `showstatisticBar`, `showstatisticBarConfig` has a higher priority.
- Format:
```json
{
count: false, // Count bar
count: false, // Count bar
view: false, // Print view
zoom: false // Zoom
}
------------
### sheetBottomConfig
[todo]
- Type: Object
- Default: {}
- Usage: Add row button and back to top button configuration below the worksheet
- Format:
```json
{
addRow: false, // Add row button
backTop: false // Back to the top
}
```
- Example:
- Only display the `Zoom` button:
```js
//options
{
showstatisticBar: false,
showstatisticBarConfig:{
zoom: true,
}
}
```
- Only hide the `print view` button:
```js
//options
{
showstatisticBar: true, // The default is true, you can leave it unset
showstatisticBarConfig:{
view: false,
}
}
```
------------
### allowEdit
- Type: Boolean
@ -306,10 +359,10 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect
- Usage: Allow additional rows
------------
### enableAddCol
### enableAddBackTop
- Type: Boolean
- Default: true
- Usage: Allow adding columns
- Usage: Allow back to top
------------
### userInfo
@ -347,12 +400,6 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect
- Default: true
- Usage: The configuration of the chart or pivot table will pop up on the right, set whether the workbook will be automatically indented after popping up
------------
### enablePage
- Type: Boolean
- Default: false
- Usage: Allow to load next page
------------
### forceCalculation
- Type: Boolean
@ -368,33 +415,65 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect
------------
### cellRightClickConfig
[todo]
- Type: Object
- Default: {}
- Usage: Custom configuration cell right-click menu
- Format:
```json
- Format:
```json
{
copy: false, //Copy
copyAs: false, //Copy as
paste: false, //Paste
insert: false, //Insert
delete: false, //Delete
hide: false, //Hide
deleteCell: false, //Delete cell
clear: false, //Clear content
matrix: false, //Matrix operation selection
sort: false, //Sort selection
filter: false, //Filter selection
chart: false //Chart generation
}
copy: false, // copy
copyAs: false, // copy as
paste: false, // paste
insertRow: false, // insert row
insertColumn: false, // insert column
deleteRow: false, // delete the selected row
deleteColumn: false, // delete the selected column
deleteCell: false, // delete cell
hideRow: false, // hide the selected row and display the selected row
hideColumn: false, // hide the selected column and display the selected column
rowHeight: false, // row height
columnWidth: false, // column width
clear: false, // clear content
matrix: false, // matrix operation selection
sort: false, // sort selection
filter: false, // filter selection
chart: false, // chart generation
image: false, // insert picture
link: false, // insert link
data: false, // data verification
cellFormat: false // Set cell format
}
```
In addition to the cells, the configuration here also includes the row header right-click menu, the column header right-click menu, and the column header drop-down arrow menu. The specific configuration relationships are as follows:
|Right-click menu configuration|Cell|Row header|Column header|Column arrow|
| ------------ | ------------ | ------------ | ----------- | ------------ |
|copy|copy|copy|copy|copy|
|copyAs|copy as|copy as|copy as|copy as|
|paste|paste|paste|paste|paste|
|insertRow|Insert a row|Increase N rows upwards and N rows downwards|-|-|
|insertColumn|Insert Column|-|Add N columns to the left and N columns to the right|Add N columns to the left and N columns to the right|
|deleteRow|Delete selected row|Delete selected row|-|-|
|deleteColumn|Delete selected column|-|Delete selected column|Delete selected column|
|deleteCell|Delete cell|-|-|-|
|hideRow|-|Hide the selected row and show the selected row|-|-|
|hideColumn|-|-|Hide the selected column and show the selected column|Hide the selected column and show the selected column|
|rowHeight|-|row height|-|-|
|columnWidth|-|-|Column Width|Column Width|
|clear|clear content|clear content|clear content|-|
|matrix|Matrix Operation Selection|Matrix Operation Selection|Matrix Operation Selection|-|
|sort|Sort selection|Sort selection|Sort selection|A-Z sort and Z-A sort|
|filter|Filter selection|Filter selection|Filter selection|-|
|chart|chart generation|chart generation|chart generation|-|
|image|Insert Picture|Insert Picture|Insert Picture|-|
|link|Insert link|Insert link|Insert link|-|
|data|Data Verification|Data Verification|Data Verification|-|
|cellFormat|Set cell format|Set cell format|Set cell format|-|
------------
### sheetRightClickConfig
[todo]
- Type: Object
- Default: {}
- Usage: Customize the right-click menu of the bottom sheet bar
@ -405,23 +484,21 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect
copy: false, //Copy
rename: false, //Rename
color: false, //Change color
hide: false, //Hide
show: false, //Unhide
left: false, //Move to the left
right: false //Move to the right
hide: false, //Hide, unhide
move: false, //Move to the left, move to the right
}
------------
### showRowBar
- Type: Boolean
- Default: true
- Usage: Whether to show the row number area
### rowHeaderWidth
- Type: Number
- Default: 46
- Usage: The width of the row header area, if set to 0, it means to hide the row header
------------
### showColumnBar
- Type: Boolean
- Default: true
- Usage: Whether to show the column number area
### columnHeaderHeight
- Type: Number
- Default: 20
- Usage: The height of the column header area, if set to 0, it means hide the column header
------------
### sheetFormulaBar
@ -485,12 +562,6 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura
- {Object} [oldV]: Cell object before Modified
- {Object} [newV]: Cell object after Modified
------------
### fireMousedown
- Type: Function
- Default: null
- Usage: Customized method of drilling down cell data
------------
## Selected area
@ -972,4 +1043,13 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura
- Parameter:
- {Object} [frozen]: Freeze type information
------------
#### Legacy Hook Function
### fireMousedown
- Type: Function
- Default: null
- Usage: Customized method of drilling down cell data, note that this hook function is mounted under options: `options.fireMousedown`
------------

20
docs/guide/resource.md

@ -0,0 +1,20 @@
# Tutorials and resources
Open source software is inseparable from the contribution of the community. Here will be a list of tutorials, learning materials and supporting solutions provided by the community.
If you have written or found an excellent tutorial and want to recommend it to us, please directly [edit this page](https://github.com/mengshukeji/Luckysheet/edit/master/docs/guide/resource.md) submit a PR.
## Blog
- [How Luckysheet initializes the data with merged cells](https://www.cnblogs.com/DuShuSir/p/13272397.html)[Pending translation]
- [How Luckysheet saves the data in the table to the database](https://www.cnblogs.com/DuShuSir/p/13857874.html)[Pending translation]
- [Case of introducing Luckysheet into local HTML using CDN loading](https://www.cnblogs.com/DuShuSir/p/13859103.html)[Pending translation]
## Collaborative editing background
### Community Case
- Java background [Luckysheet save and restore](https://gitee.com/ichiva/luckysheet-saved-in-recovery)[Pending translation]
## Learning Materials
- [How to build a web data analysis report from 0 to 1](https://github.com/mengshukeji/LuckyResources/blob/master/ppt/%E5%A6%82%E4%BD%95%E4%BB%8E0%E5%88%B01%E6%90%AD%E5%BB%BA%20Web%20%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E6%8A%A5%E8%A1%A8.pptx)[Pending translation]

72
docs/zh/guide/FAQ.md

@ -6,16 +6,16 @@
**<span style="font-size:20px;">A</span>** : 表格初始化时使用一维数组格式的 [celldata](/zh/guide/sheet.html#celldata),初始化完成后转化为二维数组格式的data作为存储更新使用,celldata不再使用。
如果需要将data拿出来作为初始化数据,则需要执行 `luckysheet.getGridData(data)`转换为celldata数据。
其中`{ r, c, v }`格式的celldata转换为二维数组使用的是`luckysheet.buildGridData(luckysheetfile)`,传入参数为表格数据对象`luckysheetfile`
如果需要将`data`拿出来作为初始化数据,则需要执行 [transToCellData(data)](/zh/guide/api.html#transtocelldata-data-setting)转换为celldata数据。
其中`{ r, c, v }`格式的celldata转换为二维数组使用的是[transToData(celldata)](/zh/guide/api.html#transtodata-celldata-setting)
总结如下:
```js
// data => celldata 二维数组数据 转化成 {r, c, v}格式 一维数组,传入参数为二维数据data
luckysheet.getGridData(data)
// data => celldata 二维数组数据 转化成 {r, c, v}格式 一维数组
luckysheet.transToCellData(data)
// celldata => data 生成表格所需二维数组,传入参数为表格数据对象file
luckysheet.buildGridData(luckysheetfile)
// celldata => data 生成表格所需二维数组
luckysheet.transToData(celldata)
```
------------
@ -65,14 +65,17 @@ luckysheet.buildGridData(luckysheetfile)
## **<span style="font-size:20px;">Q</span>** excel导入导出怎么做?
**<span style="font-size:20px;">A</span>** :配合Luckysheet开发的excel导入导出库-[Luckyexcel](https://github.com/mengshukeji/Luckyexcel)已经实现了excel导入功能,导出功能正在开发当中。现阶段excel导出可以参考这篇博文: https://www.cnblogs.com/recode-hyh/p/13168226.html。
**<span style="font-size:20px;">A</span>** :配合Luckysheet开发的excel导入导出库-[Luckyexcel](https://github.com/mengshukeji/Luckyexcel)已经实现了excel导入功能,导出功能正在开发当中。现阶段excel导出可以参考这2篇博文:
- [基于LuckySheet在线表格的Excel下载功能开发](https://www.cnblogs.com/recode-hyh/p/13168226.html)
- [使用exceljs导出luckysheet表格](https://blog.csdn.net/csdn_lsy/article/details/107179708)
------------
## **<span style="font-size:20px;">Q</span>** 初始化时合并单元格怎么做?
**<span style="font-size:20px;">A</span>** :参考以下案例
- Luckysheet初始化含合并单元格的数据: https://www.cnblogs.com/DuShuSir/p/13272397.html
- [Luckysheet如何初始化含合并单元格的数据](https://www.cnblogs.com/DuShuSir/p/13272397.html)
------------
@ -82,7 +85,7 @@ luckysheet.buildGridData(luckysheetfile)
- 一是表格操作完成后,使用`luckysheet.getAllSheets()`方法获取到全部的工作表数据,全部发送到后台存储。
- 二是开启协同编辑功能,实时传输数据给后端。
具体的操作步骤参考这篇文章:https://www.cnblogs.com/DuShuSir/p/13857874.html
具体的操作步骤参考这篇文章:[Luckysheet如何把表格里的数据保存到数据库](https://www.cnblogs.com/DuShuSir/p/13857874.html)
------------
@ -181,4 +184,55 @@ Luckyexcel是excel导入导出库,项目采用了gulp作为打包工具,旧
- 一是使用`luckysheet.getLuckysheetfile()`获取到所有工作表配置后,在各个工作表的配置中直接取得默认行高`defaultRowHeight`和默认列宽`defaultColWidth`。
- 二是开放了API可以获取到工作表默认的行高[getDefaultRowHeight](/zh/guide/api.html#getdefaultrowheight-setting)和列宽[getDefaultColWidth](/zh/guide/api.html#getdefaultcolwidth-setting)
------------
## **<span style="font-size:20px;">Q</span>** 如何隐藏工作表下方的添加行按钮和回到顶部按钮?
**<span style="font-size:20px;">A</span>** 已开放配置
- 允许添加行 [enableAddRow](/zh/guide/config.html#enableaddrow)
- 允许回到顶部 [enableAddBackTop](/zh/guide/config.html#enableAddBackTop)
------------
## **<span style="font-size:20px;">Q</span>** 如何隐藏工作表的行标题和列标题?
**<span style="font-size:20px;">A</span>** 已开放配置
- 行标题区域的宽度 [rowHeaderWidth](/zh/guide/config.html#rowheaderwidth)
- 列标题区域的高度 [columnHeaderHeight](/zh/guide/config.html#columnHeaderHeight)
------------
## **<span style="font-size:20px;">Q</span>** 调用什么方法能设置`config.merge`?
**<span style="font-size:20px;">A</span>** 三个方法
- 界面操作
- 用API:[setRangeMerge](/zh/guide/api.html#setrangemerge-type-setting)
- 手动组装merge参数
------------
## **<span style="font-size:20px;">Q</span>** 为什么官方公布的新功能没有效果?
**<span style="font-size:20px;">A</span>** 第一步,检查下您是否使用了CDN的方式引入,
Luckysheet教程里采用的CDN链接是 [jsdelivr](https://www.jsdelivr.com/package/npm/luckysheet) 提供的服务,代码是从 [npmjs.com](https://www.npmjs.com/) 自动同步过去的,不是从 [Github](https://github.com/mengshukeji/Luckysheet/) 同步过去的。因为我们新提交的代码,还需要经过一段时间的测试,所以不会立即发布到npm使用,导致了npm的代码稍滞后于Github。
如果需要尝试最新代码,我们强烈建议您从 [Luckysheet Github](https://github.com/mengshukeji/Luckysheet/) 主仓库拉取代码。后续我们版本稳定了,会考虑实时发布npm包。
第二步,如果是引用github仓库打包后的代码,测试判断是否有bug,您可以查找问题并尝试修复,再[提交PR](https://github.com/mengshukeji/Luckysheet/pulls),如果修复不了,请[提交issues](https://github.com/mengshukeji/Luckysheet/issues)。
------------
## **<span style="font-size:20px;">Q</span>** `npm run dev`报错:`Error: Cannot find module 'rollup'`?
**<span style="font-size:20px;">A</span>** 可能是npm包安装问题,尝试以下步骤:
1. `npm cache clean --force`
2. `npm i rimraf -g`
3. `rimraf node_modules`
4. 删除package-lock.json文件
5. `npm i`
6. `npm run dev`
提示:大多数的其他npm安装问题,也可以尝试此步骤来解决。
------------

36
docs/zh/guide/README.md

@ -10,7 +10,7 @@ Luckysheet ,一款纯前端类似excel的在线表格,功能强大、配置
## 特性
### 格式设置
### 🛠️格式设置
+ **样式** (修改字体样式,字号,颜色或者其他通用的样式)
+ **条件格式** (突出显示所关注的单元格或单元格区域;强调异常值;使用数据栏、色阶和图标集(与数据中的特定变体对应)直观地显示数据)
+ **文本对齐及旋转**
@ -18,8 +18,9 @@ Luckysheet ,一款纯前端类似excel的在线表格,功能强大、配置
+ **数据类型**
+ **货币, 百分比, 数字, 日期**
+ **Custom** (和excel保持一致,例如: `##,###0.00` , `$1,234.56$##,###0.00_);[Red]($##,###0.00)`, `_($* ##,###0.00_);_(...($* "-"_);_(@_)`, `08-05 PM 01:30MM-dd AM/PM hh:mm` )
+ **单元格内多样式** (Alt+Enter单元格内换行、上标、下标、单元格内科定义每个文字的不同样式)
### 单元格
### 🧬单元格
+ **拖拽选取来修改单元格** (对选区进行操作,可以拖动四边来移动选区,也可以在右下角对选区进行下拉填充操作)
+ **选取下拉填充** (对于一个1,2,3,4,5的序列,将会按照间隔为1进行下拉填充,而对2,4,6,8将会以2作为间隔。支持等差数列,等比数列,日期,周,天,月,年,中文数字填充)
+ **自动填充选项** (下拉填充后,会出现填充选项的菜单,支持选择复制,序列,仅格式,只填充格式,天,月,年的选择)
@ -27,20 +28,21 @@ Luckysheet ,一款纯前端类似excel的在线表格,功能强大、配置
+ **查找和替换** (对内容进行查找替换,支持正则表达式,整词,大小写敏感)
+ **定位** (可以根据单元格的数据类型进行自动定位并选中,选中后可以批量进行格式等操作)
+ **合并单元格**
+ **数据验证(表单功能)** (支持Checkbox, drop-down list, datePicker)
### 行和列操作
### 🖱️行和列操作
+ **隐藏,插入,删除行或列**
+ **冻结行或列** (支持冻结首行和首列,冻结到选区,冻结调节杆可以进行拖动操作)
+ **文本分列** (可以把文本根据不同符号进行拆分,和excel的分列功能类似)
### 操作体验
### 🔨操作体验
+ **撤销/重做**
+ **复制/粘贴/剪切操作** (支持luckysheet到excel和excel到luckysheet带格式的互相拷贝)
+ **复制/粘贴/剪切操作** (支持Luckysheet到excel和excel到Luckysheet带格式的互相拷贝)
+ **快捷键支持** (快捷键操作保持与excel一致,如果有不同或者缺失请反馈给我们)
+ **格式刷** (与google sheet类似)
+ **任意选区拖拽** (选择单元格,输入公式,插入图表,会与选区相关,可以通过任意拖动和放大缩小选区来改变与之关联的参数)
### 公式和函数
### ⚙️公式和函数
+ **内置公式**
+ 数学 (SUMIFS, AVERAGEIFS, SUMIF, SUM, etc.)
+ 文本 (CONCATENATE, REGEXMATCH, MID)
@ -53,39 +55,41 @@ Luckysheet ,一款纯前端类似excel的在线表格,功能强大、配置
+ **远程公式** (DM_TEXT_TFIDF, DM_TEXT_TEXTRANK,DATA_CN_STOCK_CLOSE etc. Need remote interface, can realize complex calculation)
+ **自定义公式** (根据身份证识别年龄,性别,生日,省份,城市等. AGE_BY_IDCARD, SEX_BY_IDCARD, BIRTHDAY_BY_IDCARD, PROVINCE_BY_IDCARD, CITY_BY_IDCARD, etc. 可以任意加入自己的公式哦)
### 表格操作
### 📐表格操作
+ **筛选** (支持颜色、数字、字符、日期的筛选)
+ **排序** (同时加入多个字段进行排序)
### 数据透视表
### 📈数据透视表
+ **字段拖拽** (操作方式与excel类似,拖动字段到行、列、数值、筛选等4个区域)
+ **聚合方式** (支持汇总、计数、去重计数、平均、最大、最小、中位数、协方差、标准差、方差等计算)
+ **筛选数据** (可对字段进行筛选后再进行汇总)
+ **数据透视表下钻** (双击数据透视表中的数据,可以下钻查看到明细,操作方式与excel一致)
+ **根据数据透视表新建图表** (数据透视表产生的数据也可以进行图表的制作)
### 图表
### 📊图表
+ **支持的图表类型** (目前折线图、柱状图、面积图、条形图、饼图可以使用,散点图、雷达图、仪表盘、漏斗图正在接入,其他图表正在陆续开发中,请大家给予建议)
+ **关于图表插件** (图表使用了一个中间插件[ChartMix](https://github.com/mengshukeji/chartMix)(MIT协议): 目前支持ECharts,正在逐步接入Highcharts、阿里G2、amCharts、googleChart、chart.js)
+ **Sparklines小图** (以公式的形式进行设置和展示,目前支持:折线图、面积图、柱状图、累积图、条形图、离散图、三态图、饼图、箱线图等)
### 分享及写作
### ✍️分享及写作
+ **评论** (评论的删除、添加、修改、隐藏)
+ **共享编辑** (支持多用户共享编辑,内置API)
### LuckySheet专有
### 📚插入对象
+ **插入图片** (支持JPG,PNG,SVG的插入、修改和删除,并且随表格的变动而产生变化)
### ⚡Luckysheet专有
+ **矩阵计算** (通过右键菜单进行支持:对选区内的数据进行转置、旋转、数值计算)
+ **截图** (把选区的内容进行截图展示)
+ **复制到其他格式** (右键菜单的"复制为", 支持复制为json、array、对角线数据、去重等)
+ **EXCEL,CSV,TXT 导入及导出** (专为luckysheet打造的导入导出插件,支持密码、水印、公式等的本地导入导出)
+ **插入图片和svg形状** (支持JPG,PNG,SVG,Pen tool的插入、修改和删除,并且随表格的变动而产生变化)
+ **数据验证(表单功能)** (支持Checkbox, drop-down list, datePicker)
+ **单元格内多样式** (Alt+Enter单元格内换行、上标、下标、单元格内科定义每个文字的不同样式)
+ **EXCEL导入及导出** (专为Luckysheet打造的导入导出插件,支持密码、水印、公式等的本地导入导出,导出正在开发)
### 未来开发计划
### ⏱️未来开发计划
+ **打印及设置** (像excel一样进行打印设置,并导出为图片或者PDF)
+ **树形菜单** (类似excel中的分级显示(分组))
+ **表格新功能** (类似excel中表格的筛选器和切片器)
+ **CSV,TXT导入及导出** (专为Luckysheet打造的导入导出插件,支持密码、水印、公式等的本地导入导出)
+ **插入svg形状** (支持[Pen tool](https://github.com/mengshukeji/Pentool)的插入、修改和删除,并且随表格的变动而产生变化)
+ **文档** (完善文档和API)
+ **敬请期待...** (可以提出好的建议给我们)

14
docs/zh/guide/api.md

@ -1791,7 +1791,7 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
返回所有工作表配置,格式同工作表配置,得到的结果可用于表格初始化时作为options.data使用。
所以此API适用于,手动操作配置完一个表格后,将所有工作表信息取出来自行保存,再用于其他地方的表格创建。如果想得到包括工作簿配置在内的所有工作簿数据,可以使用 [toJson](#toJson())
所以此API适用于,手动操作配置完一个表格后,将所有工作表信息取出来自行保存,再用于其他地方的表格创建。如果想得到包括工作簿配置在内的所有工作簿数据,推荐使用 [toJson](#toJson()),并且可以直接用于初始化Luckysheet。
- **示例**:
@ -1806,6 +1806,13 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
返回所有表格数据结构的一维数组`luckysheetfile`,不同于`getAllSheets`方法,此方法得到的工作表参数会包含很多内部使用变量,最明显的区别是表格数据操作会维护`luckysheetfile[i].data`,而初始化数据采用的是`options.data[i].celldata`,所以`luckysheetfile`可用于调试使用,但是不适用初始化表格。
除此之外,加载过的工作表参数中会增加一个`load = 1`,这个参数在初始化数据的时候需要置为0才行。所以,将`getLuckysheetfile()`得到的数据拿来初始化工作簿,需要做两个工作:
- celldata转为data,参考:[transToData](/zh/guide/api.html#transtodata-celldata-setting)
- load重置为0或者删除此字段
现在已有`getAllSheets`来完成这个工作,无需再手动转化数据。
- **示例**:
- 取得第一个工作表的所有调试信息
@ -1873,13 +1880,13 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
- **参数**
- {PlainObject} [setting]: 可选参数
+ {Object} [sheetObject]: 新增的工作表的数据;默认值为空对象
+ {Object} [sheetObject]: 新增的工作表的数据;默认值为空对象,工作表数据格式参考[options.data](/zh/guide/sheet.html#初始化配置)
+ {Number} [order]: 新增的工作表下标;默认值为最后一个下标位置
+ {Function} [success]: 操作结束的回调函数
- **说明**
新增一个sheet,返回新增的工作表对象,`setting`中可选设置数据为 `sheetObject`,不传`sheetObject`则会新增一个空白的工作表
新增一个sheet,返回新增的工作表对象,`setting`中可选设置数据为 `sheetObject`,不传`sheetObject`则会新增一个空白的工作表
- **示例**:
@ -2467,7 +2474,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### toJson()
[todo]
- **说明**

2
docs/zh/guide/cell.md

@ -330,7 +330,7 @@ Luckysheet在存储数字类型的内容时,支持多种格式转换,所以
]
```
> borderInfo 详细参考:[表格数据config](/zh/guide/data.html#config)
> borderInfo 详细参考:[config.borderInfo](/zh/guide/sheet.html#config-borderinfo)
## 简化的单元格数据

444
docs/zh/guide/config.md

@ -28,7 +28,6 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 自定义工具栏([showtoolbarConfig](#showtoolbarConfig))
- 自定义底部sheet页([showsheetbarConfig](#showsheetbarConfig))
- 自定义计数栏([showstatisticBarConfig](#showstatisticBarConfig))
- 自定义添加行和回到顶部([sheetBottomConfig](#sheetBottomConfig))
- 自定义单元格右键菜单([cellRightClickConfig](#cellRightClickConfig))
- 自定义底部sheet页右击菜单([sheetRightClickConfig](#sheetRightClickConfig))
@ -60,22 +59,20 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 自定义底部sheet页 [showsheetbarConfig](#showsheetbarConfig)
- 底部计数栏 [showstatisticBar](#showstatisticBar)
- 自定义计数栏 [showstatisticBarConfig](#showstatisticBarConfig)
- 自定义添加行和回到顶部 [sheetBottomConfig](#sheetBottomConfig)
- 允许编辑 [allowEdit](#allowEdit)
- 允许加行 [enableAddRow](#enableAddRow)
- 允许增加列 [enableAddCol](#enableAddCol)
- 允许加行 [enableAddRow](#enableAddRow)
- 允许回到顶部 [enableAddBackTop](#enableAddBackTop)
- 用户信息 [userInfo](#userInfo)
- 用户信息菜单 [userMenuItem](#userMenuItem)
- 返回按钮链接 [myFolderUrl](#myFolderUrl)
- 比例 [devicePixelRatio](#devicePixelRatio)
- 功能按钮 [functionButton](#functionButton)
- 自动缩进界面 [showConfigWindowResize](#showConfigWindowResize)
- 加载下一页 [enablePage](#enablePage)
- 刷新公式 [forceCalculation](#forceCalculation)
- 自定义单元格右键菜单 [cellRightClickConfig](#cellRightClickConfig)
- 自定义sheet页右击菜单 [sheetRightClickConfig](#sheetRightClickConfig)
- 是否显示行号区域 [showRowBar](#showRowBar)
- 是否显示列号区域 [showColumnBar](#showColumnBar)
- 行标题区域的宽度 [rowHeaderWidth](#rowHeaderWidth)
- 列标题区域的高度 [columnHeaderHeight](#columnHeaderHeight)
- 是否显示公式栏 [sheetFormulaBar](#sheetFormulaBar)
- 初始化默认字体大小 [defaultFontSize](#defaultFontSize)
@ -213,6 +210,8 @@ Luckysheet开放了更细致的自定义配置选项,分别有
+ 配置了`loadSheetUrl`
+ 配置了`updateUrl`
注意,发送给后端的数据默认是经过pako压缩过后的。后台拿到数据需要先解压。
通过共享编辑功能,可以实现Luckysheet实时保存数据和多人同步数据,每一次操作都会发送不同的参数到后台,具体的操作类型和参数参见[表格操作](/zh/guide/operate.html)
------------
@ -272,15 +271,13 @@ Luckysheet开放了更细致的自定义配置选项,分别有
------------
### showtoolbarConfig
[todo]
- 类型:Object
- 默认值:{}
- 作用:自定义配置工具栏
- 作用:自定义配置工具栏,可以与showtoolbar配合使用,`showtoolbarConfig`拥有更高的优先级。
- 格式:
```json
{
undoRedo: false, //撤销重做
undoRedo: false, //撤销重做,注意撤消重做是两个按钮,由这一个配置决定显示还是隐藏
paintFormat: false, //格式刷
currencyFormat: false, //货币格式
percentageFormat: false, //百分比格式
@ -300,19 +297,48 @@ Luckysheet开放了更细致的自定义配置选项,分别有
verticalAlignMode: false, // '垂直对齐方式'
textWrapMode: false, // '换行方式'
textRotateMode: false, // '文本旋转方式'
frozenMode: false, // '冻结方式'
sort: false, // '排序'
filter: false, // '筛选'
findAndReplace: false, // '查找替换'
function: false, // '公式'
conditionalFormat: false, // '条件格式'
image:false, // '插入图片'
link:false, // '插入链接'
chart: false, // '图表'(图标隐藏,但是如果配置了chart插件,右击仍然可以新建图表)
postil: false, //'批注'
pivotTable: false, //'数据透视表'
chart: false, // '图表'(图标隐藏,但是如果配置了chart插件,右击仍然可以新建图表)
function: false, // '公式'
frozenMode: false, // '冻结方式'
sortAndFilter: false, // '排序和筛选'
conditionalFormat: false, // '条件格式'
dataVerification: false, // '数据验证'
splitColumn: false, // '分列'
screenshot: false, // '截图'
splitColumn: false, // '分列'
findAndReplace: false, // '查找替换'
protection:false, // '工作表保护'
print:false, // '打印'
}
```
- 示例:
- 仅显示撤消重做和字体按钮:
```js
//options
{
showtoolbar: false,
showtoolbarConfig:{
undoRedo: true,
font: true,
}
}
```
- 仅隐藏图片和打印按钮:
```js
//options
{
showtoolbar: true, // 默认就是true,可以不设置
showtoolbarConfig:{
image: false,
print: false,
}
}
```
------------
### showinfobar
@ -329,11 +355,9 @@ Luckysheet开放了更细致的自定义配置选项,分别有
------------
### showsheetbarConfig
[todo]
- 类型:Object
- 默认值:{}
- 作用:自定义配置底部sheet页按钮
- 作用:自定义配置底部sheet页按钮,可以与showsheetbar配合使用,`showsheetbarConfig`拥有更高的优先级。
- 格式:
```json
{
@ -342,6 +366,30 @@ Luckysheet开放了更细致的自定义配置选项,分别有
sheet: false //sheet页显示
}
```
- 示例:
- 仅显示新增sheet按钮:
```js
//options
{
showsheetbar: false,
showsheetbarConfig:{
add: true,
}
}
```
- 仅隐藏新增sheet和管理按钮:
```js
//options
{
showsheetbar: true, // 默认就是true,可以不设置
showsheetbarConfig:{
add: false,
menu: false,
}
}
```
------------
### showstatisticBar
@ -352,32 +400,40 @@ Luckysheet开放了更细致的自定义配置选项,分别有
------------
### showstatisticBarConfig
[todo]
- 类型:Object
- 默认值:{}
- 作用:自定义配置底部计数栏
- 作用:自定义配置底部计数栏,可以与showstatisticBar配合使用,`showstatisticBarConfig`拥有更高的优先级。
- 格式:
```json
{
count: false, // 计数栏
zoom: false // 缩放
}
------------
### sheetBottomConfig
[todo]
- 类型:Object
- 默认值:{}
- 作用:sheet页下方的添加行按钮和回到顶部按钮配置
- 格式:
```json
{
addRow: false, // 添加行按钮
backTop: false // 回到顶部
view: false, // 打印视图
zoom: false, // 缩放
}
```
- 示例:
- 仅显示缩放按钮:
```js
//options
{
showstatisticBar: false,
showstatisticBarConfig:{
zoom: true,
}
}
```
- 仅隐藏打印视图按钮:
```js
//options
{
showstatisticBar: true, // 默认就是true,可以不设置
showstatisticBarConfig:{
view: false,
}
}
```
------------
### allowEdit
@ -389,13 +445,13 @@ Luckysheet开放了更细致的自定义配置选项,分别有
### enableAddRow
- 类型:Boolean
- 默认值:true
- 作用:允许加行
- 作用:允许加行
------------
### enableAddCol
### enableAddBackTop
- 类型:Boolean
- 默认值:true
- 作用:允许增加列
- 作用:允许回到顶部
------------
### userInfo
@ -433,12 +489,6 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 默认值:true
- 作用:图表或数据透视表的配置会在右侧弹出,设置弹出后表格是否会自动缩进
------------
### enablePage
- 类型:Boolean
- 默认值:false
- 作用:允许加载下一页
------------
### forceCalculation
- 类型:Boolean
@ -454,8 +504,6 @@ Luckysheet开放了更细致的自定义配置选项,分别有
------------
### cellRightClickConfig
[todo]
- 类型:Object
- 默认值:{}
- 作用:自定义配置单元格右击菜单
@ -465,22 +513,56 @@ Luckysheet开放了更细致的自定义配置选项,分别有
copy: false, // 复制
copyAs: false, // 复制为
paste: false, // 粘贴
insert: false, // 插入
delete: false, // 删除
hide: false, // 隐藏
insertRow: false, // 插入行
insertColumn: false, // 插入列
deleteRow: false, // 删除选中行
deleteColumn: false, // 删除选中列
deleteCell: false, // 删除单元格
hideRow: false, // 隐藏选中行和显示选中行
hideColumn: false, // 隐藏选中列和显示选中列
rowHeight: false, // 行高
columnWidth: false, // 列宽
clear: false, // 清除内容
matrix: false, // 矩阵操作选区
sort: false, // 排序选区
filter: false, // 筛选选区
chart: false // 图表生成
chart: false, // 图表生成
image: false, // 插入图片
link: false, // 插入链接
data: false, // 数据验证
cellFormat: false // 设置单元格格式
}
```
除了单元格,这里的配置还包括行标题右击菜单、列标题右击菜单和列标题下拉箭头的菜单,具体配置关系如下表格:
|右击菜单配置|单元格|行标题|列标题|列箭头|
| ------------ | ------------ | ------------ | ------------ | ------------ |
|copy|复制|复制|复制|复制|
|copyAs|复制为|复制为|复制为|复制为|
|paste|粘贴|粘贴|粘贴|粘贴|
|insertRow|插入行|向上增加N行,向下增加N行|-|-|
|insertColumn|插入列|-|向左增加N列,向右增加N列|向左增加N列,向右增加N列|
|deleteRow|删除选中行|删除选中行|-|-|
|deleteColumn|删除选中列|-|删除选中列|删除选中列|
|deleteCell|删除单元格|-|-|-|
|hideRow|-|隐藏选中行和显示选中行|-|-|
|hideColumn|-|-|隐藏选中列和显示选中列|隐藏选中列和显示选中列|
|rowHeight|-|行高|-|-|
|columnWidth|-|-|列宽|列宽|
|clear|清除内容|清除内容|清除内容|-|
|matrix|矩阵操作选区|矩阵操作选区|矩阵操作选区|-|
|sort|排序选区|排序选区|排序选区|A-Z排序和Z-A排序|
|filter|筛选选区|筛选选区|筛选选区|-|
|chart|图表生成|图表生成|图表生成|-|
|image|插入图片|插入图片|插入图片|-|
|link|插入链接|插入链接|插入链接|-|
|data|数据验证|数据验证|数据验证|-|
|cellFormat|设置单元格格式|设置单元格格式|设置单元格格式|-|
------------
### sheetRightClickConfig
[todo]
- 类型:Object
- 默认值:{}
- 作用:自定义配置sheet页右击菜单
@ -491,29 +573,27 @@ Luckysheet开放了更细致的自定义配置选项,分别有
copy: false, // 复制
rename: false, //重命名
color: false, //更改颜色
hide: false, //隐藏
show: false, //取消隐藏
left: false, //向左移
right: false //向右移
hide: false, //隐藏,取消隐藏
move: false, //向左移,向右移
}
------------
### showRowBar
[todo]
- 类型:Boolean
- 默认值:true
- 作用:是否显示行号区域
### rowHeaderWidth
- 类型:Number
- 默认值:46
- 作用:行标题区域的宽度,如果设置为0,则表示隐藏行标题
------------
### showColumnBar
[todo]
- 类型:Boolean
- 默认值:true
- 作用:是否显示列号区域
### columnHeaderHeight
- 类型:Number
- 默认值:20
- 作用:列标题区域的高度,如果设置为0,则表示隐藏列标题
------------
### sheetFormulaBar
[todo]
- 类型:Boolean
- 默认值:true
- 作用:是否显示公式栏
@ -534,26 +614,40 @@ Luckysheet开放了更细致的自定义配置选项,分别有
## 单元格
### cellRenderAfter
(TODO)
### cellRenderBefore
- 类型:Function
- 默认值:null
- 作用:单元格渲染结束后触发
- 作用:单元格渲染前触发,`return false` 则不渲染该单元格
- 参数:
- {Number} [r]: 单元格所在行数
- {Number} [c]: 单元格所在列数
- {Object} [v]: 单元格对象
- {Object} [cell]:单元格对象
- {Object} [postion]:
+ {Number} [r]:单元格所在行号
+ {Number} [c]:单元格所在列号
+ {Number} [start_r]:单元格左上角的水平坐标
+ {Number} [start_c]:单元格左上角的垂直坐标
+ {Number} [end_r]:单元格右下角的水平坐标
+ {Number} [end_c]:单元格右下角的垂直坐标
- {Object} [sheet]:当前sheet对象
- {Object} [ctx]: 当前画布的context
------------
### cellHover
(TODO)
### cellRenderAfter
- 类型:Function
- 默认值:null
- 作用:鼠标移过单元格时(hover)触发
- 作用:单元格渲染结束后触发,`return false` 则不渲染该单元格
- 参数:
- {Number} [r]: 单元格所在行数
- {Number} [c]: 单元格所在列数
- {Object} [v]: 单元格对象
- {Object} [cell]:单元格对象
- {Object} [postion]:
+ {Number} [r]:单元格所在行号
+ {Number} [c]:单元格所在列号
+ {Number} [start_r]:单元格左上角的水平坐标
+ {Number} [start_c]:单元格左上角的垂直坐标
+ {Number} [end_r]:单元格右下角的水平坐标
+ {Number} [end_c]:单元格右下角的垂直坐标
- {Object} [sheet]:当前sheet对象
- {Object} [ctx]: 当前画布的context
------------
### cellEditBefore
@ -579,11 +673,175 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- {Object} [newV]: 修改后单元格对象
------------
### fireMousedown
(TODO)
### rowTitleCellRenderBefore
- 类型:Function
- 默认值:null
- 作用:单元格数据下钻自定义方法
- 作用:行标题单元格渲染前触发,`return false` 则不渲染行标题
- 参数:
- {String} [rowNum]:行号
- {Object} [postion]:
+ {Number} [r]:单元格所在行号
+ {Number} [top]:单元格左上角的垂直坐标
+ {Number} [width]:单元格宽度
+ {Number} [height]:单元格高度
- {Object} [ctx]: 当前画布的context
------------
### rowTitleCellRenderAfter
- 类型:Function
- 默认值:null
- 作用:行标题单元格渲染后触发,`return false` 则不渲染行标题
- 参数:
- {String} [rowNum]:行号
- {Object} [postion]:
+ {Number} [r]:单元格所在行号
+ {Number} [top]:单元格左上角的垂直坐标
+ {Number} [width]:单元格宽度
+ {Number} [height]:单元格高度
- {Object} [ctx]: 当前画布的context
------------
### columnTitleCellRenderBefore
- 类型:Function
- 默认值:null
- 作用:列标题单元格渲染前触发,`return false` 则不渲染列标题
- 参数:
- {Object} [columnAbc]:列标题字符
- {Object} [postion]:
- {Number} [c]:单元格所在列号
- {Number} [left]:单元格左上角的水平坐标
- {Number} [width]:单元格宽度
- {Number} [height]:单元格高度
- {Object} [ctx]: 当前画布的context
------------
### columnTitleCellRenderAfter
- 类型:Function
- 默认值:null
- 作用:列标题单元格渲染后触发,`return false` 则不渲染列标题
- 参数:
- {Object} [columnAbc]:列标题字符
- {Object} [postion]:
- {Number} [c]:单元格所在列号
- {Number} [left]:单元格左上角的水平坐标
- {Number} [width]:单元格宽度
- {Number} [height]:单元格高度
- {Object} [ctx]: 当前画布的context
------------
## 鼠标钩子
### cellMousedownBefore
- 类型:Function
- 默认值:null
- 作用:单元格点击前的事件,`return false`则终止之后的点击操作
- 参数:
- {Object} [cell]:单元格对象
- {Object} [postion]:
+ {Number} [r]:单元格所在行号
+ {Number} [c]:单元格所在列号
+ {Number} [start_r]:单元格左上角的水平坐标
+ {Number} [start_c]:单元格左上角的垂直坐标
+ {Number} [end_r]:单元格右下角的水平坐标
+ {Number} [end_c]:单元格右下角的垂直坐标
- {Object} [sheet]:当前sheet对象
- {Object} [ctx]: 当前画布的context
------------
### cellMousedown
- 类型:Function
- 默认值:null
- 作用:单元格点击后的事件,`return false`则终止之后的点击操作
- 参数:
- {Object} [cell]:单元格对象
- {Object} [postion]:
+ {Number} [r]:单元格所在行号
+ {Number} [c]:单元格所在列号
+ {Number} [start_r]:单元格左上角的水平坐标
+ {Number} [start_c]:单元格左上角的垂直坐标
+ {Number} [end_r]:单元格右下角的水平坐标
+ {Number} [end_c]:单元格右下角的垂直坐标
- {Object} [sheet]:当前sheet对象
- {Object} [ctx]: 当前画布的context
------------
### sheetMousemove
- 类型:Function
- 默认值:null
- 作用:鼠标移动事件,可通过cell判断鼠标停留在哪个单元格
- 参数:
- {Object} [cell]:单元格对象
- {Object} [postion]:
+ {Number} [r]:单元格所在行号
+ {Number} [c]:单元格所在列号
+ {Number} [start_r]:单元格左上角的水平坐标
+ {Number} [start_c]:单元格左上角的垂直坐标
+ {Number} [end_r]:单元格右下角的水平坐标
+ {Number} [end_c]:单元格右下角的垂直坐标
- {Object} [sheet]:当前sheet对象
- {Object} [moveState]:鼠标移动状态,可判断现在鼠标操作的对象,false和true
+ {Boolean} [functionResizeStatus]:工具栏拖动
+ {Boolean} [horizontalmoveState]:水平冻结分割烂拖动
+ {Boolean} [verticalmoveState]:垂直冻结分割烂拖动
+ {Boolean} [pivotTableMoveState]:数据透视表字段拖动
+ {Boolean} [sheetMoveStatus]:sheet改变你位置拖动
+ {Boolean} [scrollStatus]:鼠标触发了滚动条移动
+ {Boolean} [selectStatus]:鼠标移动框选数据
+ {Boolean} [rowsSelectedStatus]:通过行标题来选择整行操作
+ {Boolean} [colsSelectedStatus]:通过列标题来选择整列操作
+ {Boolean} [cellSelectedMove]:选框的移动
+ {Boolean} [cellSelectedExtend]:选框下拉填充
+ {Boolean} [colsChangeSize]:拖拽改变列宽
+ {Boolean} [rowsChangeSize]:拖拽改变行高
+ {Boolean} [chartMove]:图表移动
+ {Boolean} [chartResize]:图表改变大小
+ {Boolean} [rangeResize]:公式参数高亮选区的大小拖拽
+ {Boolean} [rangeMove]:公式参数高亮选区的位置拖拽
- {Object} [ctx]: 当前画布的context
------------
### sheetMouseup
- 类型:Function
- 默认值:null
- 作用:鼠标按钮释放事件,可通过cell判断鼠标停留在哪个单元格
- 参数:
- {Object} [cell]:单元格对象
- {Object} [postion]:
+ {Number} [r]:单元格所在行号
+ {Number} [c]:单元格所在列号
+ {Number} [start_r]:单元格左上角的水平坐标
+ {Number} [start_c]:单元格左上角的垂直坐标
+ {Number} [end_r]:单元格右下角的水平坐标
+ {Number} [end_c]:单元格右下角的垂直坐标
- {Object} [sheet]:当前sheet对象
- {Object} [moveState]:鼠标移动状态,可判断现在鼠标操作的对象,false和true
+ {Boolean} [functionResizeStatus]:工具栏拖动
+ {Boolean} [horizontalmoveState]:水平冻结分割烂拖动
+ {Boolean} [verticalmoveState]:垂直冻结分割烂拖动
+ {Boolean} [pivotTableMoveState]:数据透视表字段拖动
+ {Boolean} [sheetMoveStatus]:sheet改变你位置拖动
+ {Boolean} [scrollStatus]:鼠标触发了滚动条移动
+ {Boolean} [selectStatus]:鼠标移动框选数据
+ {Boolean} [rowsSelectedStatus]:通过行标题来选择整行操作
+ {Boolean} [colsSelectedStatus]:通过列标题来选择整列操作
+ {Boolean} [cellSelectedMove]:选框的移动
+ {Boolean} [cellSelectedExtend]:选框下拉填充
+ {Boolean} [colsChangeSize]:拖拽改变列宽
+ {Boolean} [rowsChangeSize]:拖拽改变行高
+ {Boolean} [chartMove]:图表移动
+ {Boolean} [chartResize]:图表改变大小
+ {Boolean} [rangeResize]:公式参数高亮选区的大小拖拽
+ {Boolean} [rangeMove]:公式参数高亮选区的位置拖拽
- {Object} [ctx]: 当前画布的context
------------
@ -1120,4 +1378,14 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 参数:
- {Object} [frozen]: 冻结类型信息
------------
## 旧版钩子函数
### fireMousedown
- 类型:Function
- 默认值:null
- 作用:单元格数据下钻自定义方法,注意此钩子函数是挂载在options下:`options.fireMousedown`
------------

20
docs/zh/guide/resource.md

@ -0,0 +1,20 @@
# 教程与资源
开源软件离不开社区的贡献,这里将会列举出社区提供的教程、学习资料及配套解决方案。
如果您写了或者发现了优秀的教程想要推荐给我们,请直接[编辑此页](https://github.com/mengshukeji/Luckysheet/edit/master/docs/zh/guide/resource.md)提交PR。
## 博客
- [Luckysheet如何初始化含合并单元格的数据](https://www.cnblogs.com/DuShuSir/p/13272397.html)
- [Luckysheet如何把表格里的数据保存到数据库](https://www.cnblogs.com/DuShuSir/p/13857874.html)
- [本地HTML采用cdn加载方式引入Luckysheet的案例](https://www.cnblogs.com/DuShuSir/p/13859103.html)
## 协同编辑后台
### 社区案例
- Java后台 [Luckysheet保存与恢复](https://gitee.com/ichiva/luckysheet-saved-in-recovery)
## 学习资料
- [如何从0到1搭建 Web 数据分析报表](https://github.com/mengshukeji/LuckyResources/blob/master/ppt/%E5%A6%82%E4%BD%95%E4%BB%8E0%E5%88%B01%E6%90%AD%E5%BB%BA%20Web%20%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%E6%8A%A5%E8%A1%A8.pptx)

19
gulpfile.js

@ -43,7 +43,14 @@ const babelConfig = {
plugins: [
],
presets: [
'@babel/preset-env'
['@babel/preset-env', {
useBuiltIns: 'usage',
corejs: 3,
targets: {
chrome: 58,
ie: 11
}
}]
]
};
@ -68,7 +75,7 @@ const paths = {
destStaticCssImages: ['dist/css'],
//core es module
core: ['src/**/*.js','!src/demoData/*.js','src/expendPlugins/**/plugin.js','!src/plugins/js/*.js'],
core: ['src/**/*.js','!src/demoData/*.js','src/expendPlugins/**/plugin.js','!src/plugins/js/*.js'],
//plugins src
pluginsCss: ['src/plugins/css/*.css'],
@ -98,7 +105,7 @@ const paths = {
concatPlugins: 'plugins.css',
concatCss: 'luckysheet.css',
concatPluginsJs: 'plugin.js',
//plugins dest
destPluginsCss: ['dist/plugins/css'],
destPlugins: ['dist/plugins'],
@ -187,7 +194,7 @@ async function core() {
inlineDynamicImports:true,
});
}
}
// According to the build tag in html, package js and css
@ -196,7 +203,7 @@ function pluginsCss() {
.pipe(concat(paths.concatPluginsCss))
.pipe(gulpif(production, cleanCSS()))
.pipe(dest(paths.destPluginsCss))
}
function plugins() {
@ -255,4 +262,4 @@ const build = series(clean, parallel(pluginsCss, plugins, css, pluginsJs, copySt
exports.dev = dev;
exports.build = build;
exports.default = dev;
exports.default = dev;

14
package.json

@ -1,14 +1,15 @@
{
"name": "luckysheet",
"version": "2.1.4",
"version": "2.1.5",
"main": "dist/luckysheet.cjs.js",
"module": "dist/luckysheet.esm.js",
"browser": "dist/luckysheet.umd.js",
"devDependencies": {
"@babel/preset-env": "^7.10.2",
"@babel/runtime-corejs3": "^7.12.1",
"@commitlint/cli": "^9.1.1",
"@commitlint/config-conventional": "^9.1.1",
"@rollup/plugin-babel": "^5.0.3",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-commonjs": "^13.0.0",
"@rollup/plugin-node-resolve": "^8.0.1",
"browser-sync": "^2.26.7",
@ -21,12 +22,17 @@
"gulp-if": "^3.0.0",
"gulp-uglify": "^3.0.2",
"gulp-useref": "^4.0.1",
"rollup": "^2.16.1",
"rollup": "^2.32.1",
"rollup-plugin-terser": "^6.1.0",
"standard-version": "^8.0.2",
"vuepress": "^1.5.0"
"vuepress": "^1.5.0",
"vuepress-plugin-baidu-autopush": "^1.0.1",
"vuepress-plugin-code-copy": "^1.0.6",
"vuepress-plugin-seo": "^0.1.4",
"vuepress-plugin-sitemap": "^2.3.1"
},
"dependencies": {
"@babel/runtime": "^7.12.1",
"jspdf": "^2.1.1"
},
"scripts": {

92
src/assets/iconfont/demo_index.html

@ -30,6 +30,30 @@
<div class="content unicode" style="display: block;">
<ul class="icon_lists dib-box">
<li class="dib">
<span class="icon iconfont">&#xe7f8;</span>
<div class="name">链接</div>
<div class="code-name">&amp;#xe7f8;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe7f5;</span>
<div class="name">打印区域</div>
<div class="code-name">&amp;#xe7f5;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe7f6;</span>
<div class="name">打印页面配置</div>
<div class="code-name">&amp;#xe7f6;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe7f7;</span>
<div class="name">打印标题</div>
<div class="code-name">&amp;#xe7f7;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe7f2;</span>
<div class="name">分页预览</div>
@ -716,6 +740,42 @@
<div class="content font-class">
<ul class="icon_lists dib-box">
<li class="dib">
<span class="icon iconfont icon-lianjie"></span>
<div class="name">
链接
</div>
<div class="code-name">.icon-lianjie
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-dayinquyu"></span>
<div class="name">
打印区域
</div>
<div class="code-name">.icon-dayinquyu
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-dayinyemianpeizhi"></span>
<div class="name">
打印页面配置
</div>
<div class="code-name">.icon-dayinyemianpeizhi
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-dayinbiaoti"></span>
<div class="name">
打印标题
</div>
<div class="code-name">.icon-dayinbiaoti
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-fenyeyulan"></span>
<div class="name">
@ -1699,6 +1759,38 @@
<div class="content symbol">
<ul class="icon_lists dib-box">
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-lianjie"></use>
</svg>
<div class="name">链接</div>
<div class="code-name">#icon-lianjie</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-dayinquyu"></use>
</svg>
<div class="name">打印区域</div>
<div class="code-name">#icon-dayinquyu</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-dayinyemianpeizhi"></use>
</svg>
<div class="name">打印页面配置</div>
<div class="code-name">#icon-dayinyemianpeizhi</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-dayinbiaoti"></use>
</svg>
<div class="name">打印标题</div>
<div class="code-name">#icon-dayinbiaoti</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-fenyeyulan"></use>

28
src/assets/iconfont/iconfont.css

File diff suppressed because one or more lines are too long

BIN
src/assets/iconfont/iconfont.eot

Binary file not shown.

2
src/assets/iconfont/iconfont.js

File diff suppressed because one or more lines are too long

28
src/assets/iconfont/iconfont.json

@ -5,6 +5,34 @@
"css_prefix_text": "icon-",
"description": "",
"glyphs": [
{
"icon_id": "17878780",
"name": "链接",
"font_class": "lianjie",
"unicode": "e7f8",
"unicode_decimal": 59384
},
{
"icon_id": "17612330",
"name": "打印区域",
"font_class": "dayinquyu",
"unicode": "e7f5",
"unicode_decimal": 59381
},
{
"icon_id": "17612331",
"name": "打印页面配置",
"font_class": "dayinyemianpeizhi",
"unicode": "e7f6",
"unicode_decimal": 59382
},
{
"icon_id": "17612332",
"name": "打印标题",
"font_class": "dayinbiaoti",
"unicode": "e7f7",
"unicode_decimal": 59383
},
{
"icon_id": "17600443",
"name": "分页预览",

12
src/assets/iconfont/iconfont.svg

@ -20,6 +20,18 @@ Created by iconfont
/>
<missing-glyph />
<glyph glyph-name="lianjie" unicode="&#59384;" d="M771.584 644.266667c-49.066667 51.2-132.266667 51.2-181.333333 0l-74.666667-76.8c-8.533333-8.533333-8.533333-23.466667 0-32 8.533333-8.533333 21.333333-8.533333 29.866667 0l74.666666 76.8c34.133333 34.133333 87.466667 34.133333 121.6 0 34.133333-34.133333 34.133333-89.6 0-123.733334l-121.6-123.733333c-34.133333-34.133333-87.466667-34.133333-121.6 0-8.533333 8.533333-21.333333 8.533333-29.866666 0-8.533333-8.533333-8.533333-23.466667 0-32 49.066667-51.2 132.266667-51.2 181.333333 0l121.6 123.733333c51.2 53.333333 51.2 136.533333 0 187.733334zM477.184 232.533333l-74.666667-76.8c-34.133333-34.133333-87.466667-34.133333-121.6 0-34.133333 34.133333-34.133333 89.6 0 123.733334l121.6 123.733333c34.133333 34.133333 87.466667 34.133333 121.6 0 8.533333-8.533333 21.333333-8.533333 29.866667 0 8.533333 8.533333 8.533333 23.466667 0 32-49.066667 51.2-132.266667 51.2-181.333333 0l-121.6-123.733333c-51.2-51.2-49.066667-134.4 0-185.6 49.066667-51.2 132.266667-51.2 181.333333 0l74.666667 76.8c8.533333 8.533333 8.533333 23.466667 0 32-8.533333 6.4-21.333333 6.4-29.866667-2.133334z" horiz-adv-x="1024" />
<glyph glyph-name="dayinquyu" unicode="&#59381;" d="M727.04 189.781333a11.946667 11.946667 0 0 0 8.704-3.754666 13.312 13.312 0 0 0 3.626667-9.130667V85.333333H583.253333v91.52c0 3.413333 1.28 6.741333 3.626667 9.173334a11.946667 11.946667 0 0 0 8.661333 3.754666zM362.666667 170.666667v-42.666667h-128v42.666667h128z m128 0v-42.666667h-42.666667v42.666667h42.666667z m301.696 143.957333a18.773333 18.773333 0 0 0 18.304-19.2v-117.205333c0-10.581333-8.277333-19.2-18.346667-19.2h-28.458667v11.434666c-0.128 21.333333-16.554667 38.570667-36.778666 38.570667h-131.498667c-20.224 0-36.693333-17.237333-36.778667-38.570667v-11.477333h-28.458666a18.858667 18.858667 0 0 0-18.346667 19.2v117.248c0 10.581333 8.277333 19.2 18.346667 19.2zM256 362.666667v-128H213.333333v128h42.666667z m411.477333-85.845334H567.04a12.586667 12.586667 0 0 1-12.245333-12.8c0.042667-7.125333 5.546667-12.885333 12.245333-12.842666h100.394667a12.586667 12.586667 0 0 1 12.202666 12.8c0 7.082667-5.504 12.8-12.202666 12.8zM723.072 384a14.506667 14.506667 0 0 0 14.165333-14.805333v-35.84H585.386667v35.84a14.506667 14.506667 0 0 0 14.165333 14.805333zM768 533.333333v-128h-42.666667v128h42.666667z m-512 42.666667v-128H213.333333v128h42.666667zM768 682.666667v-64h-42.666667V640h-64V682.666667H768zM362.666667 682.666667v-42.666667H256v-21.333333H213.333333V682.666667h149.333334z m213.333333 0v-42.666667h-128V682.666667h128z" horiz-adv-x="1024" />
<glyph glyph-name="dayinyemianpeizhi" unicode="&#59382;" d="M635.477333 682.666667H388.522667c-15.530667 0-28.16-13.226667-28.288-29.610667v-71.68h303.530666v71.68c0 16.298667-12.586667 29.568-28.288 29.568V682.666667z m7.978667-388.48H380.586667a23.893333 23.893333 0 0 1-17.365334-7.509334 26.581333 26.581333 0 0 1-7.253333-18.261333V85.333333h312.149333v183.125334a26.581333 26.581333 0 0 1-7.253333 18.218666 23.893333 23.893333 0 0 1-17.365333 7.509334z m130.602667 249.728H250.069333c-20.224 0-36.736-17.28-36.736-38.4v-234.410667c0-21.162667 16.512-38.442667 36.693334-38.442667h56.96v22.912c0.213333 42.666667 33.109333 77.184 73.557333 77.098667h262.912c40.448 0.085333 73.386667-34.389333 73.557333-77.098667v-22.912h56.917334c20.224 0 36.736 17.28 36.736 38.4V505.514667c-0.042667 21.290667-16.426667 38.485333-36.608 38.442666z m-249.813334-126.933334H323.498667c-13.44 0-24.405333 11.434667-24.490667 25.642667a25.173333 25.173333 0 0 0 24.490667 25.685333h200.746666c13.44 0 24.490667-11.52 24.490667-25.685333 0-14.08-11.050667-25.6-24.490667-25.6v-0.042667z" horiz-adv-x="1024" />
<glyph glyph-name="dayinbiaoti" unicode="&#59383;" d="M727.04 189.781333a11.946667 11.946667 0 0 0 8.704-3.754666 13.312 13.312 0 0 0 3.626667-9.130667V85.333333H583.253333v91.52c0 3.413333 1.28 6.741333 3.626667 9.173334a11.946667 11.946667 0 0 0 8.661333 3.754666zM768 682.666667v-277.333334h-42.666667V640H256v-469.333333h234.666667v-42.666667H213.333333V682.666667h554.666667z m24.362667-368.042667a18.773333 18.773333 0 0 0 18.304-19.2v-117.205333c0-10.581333-8.277333-19.2-18.346667-19.2h-28.458667v11.434666c-0.128 21.333333-16.554667 38.570667-36.778666 38.570667h-131.498667c-20.224 0-36.693333-17.237333-36.778667-38.570667v-11.477333h-28.458666a18.858667 18.858667 0 0 0-18.346667 19.2v117.248c0 10.581333 8.277333 19.2 18.346667 19.2z m-124.885334-37.802667H567.04a12.586667 12.586667 0 0 1-12.245333-12.8c0.042667-7.125333 5.546667-12.885333 12.245333-12.842666h100.394667a12.586667 12.586667 0 0 1 12.202666 12.8c0 7.082667-5.504 12.8-12.202666 12.8zM723.072 384a14.506667 14.506667 0 0 0 14.165333-14.805333v-35.84H585.386667v35.84a14.506667 14.506667 0 0 0 14.165333 14.805333zM341.333333 554.666667h298.666667v-42.666667H341.333333zM341.333333 469.333333h170.666667v-42.666666H341.333333z" horiz-adv-x="1024" />
<glyph glyph-name="fenyeyulan" unicode="&#59378;" d="M810.666667 682.666667v-597.333334H213.333333V682.666667h597.333334z m-42.666667-42.666667H256v-512h512V640zM256 384h256v-42.666667H256zM554.666667 640v-298.666667h-42.666667V640zM405.333333 640v-298.666667h-42.666666V640z" horiz-adv-x="1024" />

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 85 KiB

BIN
src/assets/iconfont/iconfont.ttf

Binary file not shown.

BIN
src/assets/iconfont/iconfont.woff

Binary file not shown.

BIN
src/assets/iconfont/iconfont.woff2

Binary file not shown.

15
src/config.js

@ -31,9 +31,9 @@ export default {
allowUpdate: false, //是否允许编辑后的后台更新
functionButton: "", //右上角功能按钮,例如'<button id="" class="btn btn-primary" style="padding:3px 6px;font-size: 12px;margin-right: 10px;">下载</button> <button id="" class="btn btn-primary btn-danger" style=" padding:3px 6px; font-size: 12px; margin-right: 10px;">分享</button> <button id="luckysheet-share-btn-title" class="btn btn-primary btn-danger" style=" padding:3px 6px; font-size: 12px; margin-right: 10px;">秀数据</button>'
showConfigWindowResize: true, //图表和数据透视表的配置会在右侧弹出,设置弹出后表格是否会自动缩进
enableAddRow: true,//允许加行
enableAddCol: true,//允许增加列
enablePage: false,//允许加载下一页
enableAddRow: true,//允许加行
enableAddBackTop: true,//允许回到顶部
// enablePage: false,//允许加载下一页
autoFormatw: false, //自动格式化超过4位数的数字为 亿万格式 例:true or "true" or "TRUE"
accuracy: undefined, //设置传输来的数值的精确位数,小数点后n位 传参数为数字或数字字符串,例: "0" 或 0
pageInfo:{
@ -53,8 +53,15 @@ export default {
plugins: [], //plugins, e.g. ['chart']
forceCalculation:false,//强制刷新公式,公式较多会有性能问题,慎用
rowHeaderWidth: 46,
columeHeaderHeight: 20,
columnHeaderHeight: 20,
defaultColWidth:73,
defaultRowHeight:19,
defaultFontSize:10,
sheetFormulaBar:true, //是否显示公式栏
showtoolbarConfig:{}, //自定义工具栏
showsheetbarConfig:{}, //自定义底部sheet页
showstatisticBarConfig:{}, //自定义计数栏
cellRightClickConfig:{}, //自定义单元格右键菜单
sheetRightClickConfig:{}, //自定义底部sheet页右击菜单
}

223
src/controllers/constant.js

@ -1,5 +1,6 @@
import locale from '../locale/locale';
import Store from '../store';
import luckysheetConfigsetting from './luckysheetConfigsetting';
//dom variable
const gridHTML = function(){
@ -238,7 +239,7 @@ const gridHTML = function(){
<div type="viewPage" class="luckysheet-print-viewBtn luckysheet-print-viewPage" title="${locale_print.pageBtn}"><i class="icon iconfont icon-fenyeyulan"></i></div>
</div>
<div class="luckysheet-sta-content" id="luckysheet-sta-content"></div>
<div class="luckysheet-bottom-content" id="luckysheet-bottom-content-show"></div>
<!--<div class="luckysheet-bottom-content" id="luckysheet-bottom-content-show"></div> -->
</div>
</div>
</div>
@ -259,36 +260,63 @@ function rightclickHTML(){
const rightclick = _locale.rightclick;
const toolbar = _locale.toolbar;
return `<div id="luckysheet-rightclick-menu" class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-mousedown-cancel">
<div id="luckysheet-copy-btn" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel luckysheet-copy-btn" data-clipboard-action="copy" data-clipboard-target="#luckysheet-copy-content">
const config = customCellRightClickConfig();
// 当一个功能菜单块内所有的按钮都隐藏的时候,它顶部的分割线也需要隐藏掉
let handleincellMenuseparator = true;
if(!config.insertRow && !config.insertColumn && !config.deleteRow && !config.deleteColumn && !config.deleteCell ){
handleincellMenuseparator = false;
}
let dataMenuseparator = true;
if(!config.clear && !config.matrix && !config.sort && !config.filter && !config.chart && !config.image && !config.link && !config.data && !config.cellFormat){
dataMenuseparator = false;
}
const rightclickContainer = `<div id="luckysheet-rightclick-menu" class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-mousedown-cancel">
<div id="luckysheet-copy-btn" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel luckysheet-copy-btn" data-clipboard-action="copy" data-clipboard-target="#luckysheet-copy-content" style="display:${config.copy ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${rightclick.copy}</div>
</div>
<div id="luckysheetcopyfor" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel">
<div id="luckysheetcopyfor" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel" style="display:${config.copyAs ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
${rightclick.copyAs}<span class="luckysheet-submenu-arrow iconfont icon-youjiantou" style="user-select: none;"></span>
</div>
</div>
<div id="luckysheet-copy-paste" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div id="luckysheet-copy-paste" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.paste ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${rightclick.paste}</div>
</div>
<div id="luckysheet-cols-rows-handleincell">
<div class="luckysheet-menuseparator luckysheet-mousedown-cancel" role="separator"></div>
<div id="luckysheetColsRowsHandleAdd" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel">
<div class="luckysheet-menuseparator luckysheet-mousedown-cancel" role="separator" style="display:${handleincellMenuseparator ? 'block' : 'none'};"></div>
<div id="luckysheetColsRowsHandleAdd_row" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.insertRow ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
${rightclick.insert}<span class="luckysheet-submenu-arrow iconfont icon-youjiantou" style="user-select: none;"></span>
${rightclick.insert}${rightclick.row}<span class="luckysheet-submenu-arrow" style="user-select: none;"></span>
</div>
</div>
<div id="luckysheetColsRowsHandleDel" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel">
<div id="luckysheetColsRowsHandleAdd_column" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.insertColumn ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
${rightclick.delete}<span class="luckysheet-submenu-arrow iconfont icon-youjiantou" style="user-select: none;"></span>
${rightclick.insert}${rightclick.column}<span class="luckysheet-submenu-arrow" style="user-select: none;"></span>
</div>
</div>
<div id="luckysheet-delRows" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel" style="display:${config.deleteRow ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
${rightclick.deleteSelected}${rightclick.row}<span class="luckysheet-submenu-arrow" style="user-select: none;"></span>
</div>
</div>
<div id="luckysheet-delCols" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel" style="display:${config.deleteColumn ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
${rightclick.deleteSelected}${rightclick.column}<span class="luckysheet-submenu-arrow" style="user-select: none;"></span>
</div>
</div>
<!-- cell right click remove hide button
<div id="luckysheetColsRowsHandleHid" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
${rightclick.hide}<span class="luckysheet-submenu-arrow iconfont icon-youjiantou" style="user-select: none;"></span>
</div>
</div>
<div id="luckysheetCellsHandleDel" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel">
-->
<div id="luckysheetCellsHandleDel" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel" style="display:${config.deleteCell ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
${rightclick.deleteCell}<span class="luckysheet-submenu-arrow iconfont icon-youjiantou" style="user-select: none;"></span>
</div>
@ -322,8 +350,8 @@ function rightclickHTML(){
</div>
<div id="luckysheet-hide-selected" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
${rightclick.hideSelected}
<span class="luckysheet-cols-rows-shift-word luckysheet-mousedown-cancel">${rightclick.column}</span>
${rightclick.hideSelected}
<span class="luckysheet-cols-rows-shift-word luckysheet-mousedown-cancel">${rightclick.column}</span>
</div>
</div>
<div id="luckysheet-show-selected" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
@ -342,40 +370,43 @@ function rightclickHTML(){
</div>
</div>
<div id="luckysheet-cols-rows-shift">
<div class="luckysheet-menuseparator luckysheet-mousedown-cancel" role="separator"></div>
<div id="luckysheetorderbyasc" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div class="luckysheet-menuseparator luckysheet-mousedown-cancel" role="separator" style="display:${config.sort ? 'block' : 'none'};"></div>
<div id="luckysheetorderbyasc" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.sort ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${rightclick.orderAZ}</div>
</div>
<div id="luckysheetorderbydesc" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div id="luckysheetorderbydesc" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.sort ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${rightclick.orderZA}</div>
</div>
</div>
<div id="luckysheet-cols-rows-data">
<div class="luckysheet-menuseparator luckysheet-mousedown-cancel" role="separator"></div>
<div id="luckysheet-delete-text" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div class="luckysheet-menuseparator luckysheet-mousedown-cancel" role="separator" style="display:${dataMenuseparator ? 'block' : 'none'};"></div>
<div id="luckysheet-delete-text" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.clear ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${rightclick.clearContent}</div>
</div>
<div id="luckysheetmatrix" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel">
<div id="luckysheetmatrix" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel" style="display:${config.matrix ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
${rightclick.matrix}<span class="luckysheet-submenu-arrow iconfont icon-youjiantou" style="user-select: none;"></span>
</div>
</div>
<div id="luckysheetorderby" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div id="luckysheetorderby" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.sort ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${rightclick.sortSelection}</div>
</div>
<div id="luckysheetfilter" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div id="luckysheetfilter" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.filter ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${rightclick.filterSelection}</div>
</div>
<div id="luckysheetdatavisual" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div id="luckysheetdatavisual" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.chart ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${rightclick.chartGeneration}</div>
</div>
<div id="luckysheetInsertImage" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div id="luckysheetInsertImage" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.image ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${toolbar.insertImage}</div>
</div>
<div id="luckysheetDataVerification" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div id="luckysheetInsertLink" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.link ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${toolbar.insertLink}</div>
</div>
<div id="luckysheetDataVerification" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.data ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${toolbar.dataVerification}</div>
</div>
<div id="luckysheetCellFormatRightClickMenu" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div id="luckysheetCellFormatRightClickMenu" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.cellFormat ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${toolbar.cellFormat}</div>
</div>
</div>
@ -419,6 +450,9 @@ function rightclickHTML(){
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${rightclick.boolean}</div>
</div>
</div>
<!-- Revision: modeled on google sheet
<div id="luckysheetColsRowsHandleAdd_sub" class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-rightgclick-menu-sub luckysheet-mousedown-cancel">
<div class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
@ -449,6 +483,11 @@ function rightclickHTML(){
</div>
</div>
</div>
-->
<!-- delete row or column
<div id="luckysheetColsRowsHandleDel_sub" class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-rightgclick-menu-sub luckysheet-mousedown-cancel">
<div id="luckysheet-delRows" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
@ -461,6 +500,10 @@ function rightclickHTML(){
</div>
</div>
</div>
-->
<!--
<div id="luckysheetColsRowsHandleHid_sub" class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-rightgclick-menu-sub luckysheet-mousedown-cancel">
<div id="luckysheet-hidRows" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
@ -483,6 +526,9 @@ function rightclickHTML(){
</div>
</div>
</div>
-->
<div id="luckysheetCellsHandleDel_sub" class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-rightgclick-menu-sub luckysheet-mousedown-cancel">
<div id="luckysheet-delCellsMoveLeft" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
@ -546,6 +592,8 @@ function rightclickHTML(){
</div>
</div>
</div>`;
return rightclickContainer;
}
const pivottableconfigHTML = function(){
@ -575,33 +623,55 @@ const sheetHTML = '<div style="${style}" id="luckysheet-sheets-item${index}" dat
function sheetconfigHTML(){
const sheetconfig = locale().sheetconfig;
return `<div id="luckysheet-rightclick-sheet-menu" class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-mousedown-cancel">
<div id="luckysheetsheetconfigdelete" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
const config = customSheetRightClickConfig();
let hideTopMenuseparator = true;
let moveTopMenuseparator = true;
// 1. 当一个功能菜单块上方的功能块按钮都隐藏的时候,下方的功能块的顶部分割线也需要隐藏
if(!config.delete && !config.copy && !config.rename && !config.color){
hideTopMenuseparator = false;
if(!config.hide){
moveTopMenuseparator = false;
}
}
// 2. 当一个功能菜单块内所有的按钮都隐藏的时候,它顶部的分割线也需要隐藏掉
if(!config.hide){
hideTopMenuseparator = false;
}
if(!config.move){
moveTopMenuseparator = false;
}
const sheetconfigModel = `<div id="luckysheet-rightclick-sheet-menu" class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-mousedown-cancel">
<div id="luckysheetsheetconfigdelete" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.delete ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${sheetconfig.delete}</div>
</div>
<div id="luckysheetsheetconfigcopy" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div id="luckysheetsheetconfigcopy" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.copy ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${sheetconfig.copy}</div>
</div>
<div id="luckysheetsheetconfigrename" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div id="luckysheetsheetconfigrename" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.rename ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${sheetconfig.rename}</div>
</div>
<div id="luckysheetsheetconfigcolor" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel">
<div id="luckysheetsheetconfigcolor" class="luckysheet-cols-menuitem luckysheet-cols-submenu luckysheet-mousedown-cancel" style="display:${config.color ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">
${sheetconfig.changeColor} <span class="luckysheet-submenu-arrow iconfont icon-youjiantou" style="user-select: none;"></span>
</div>
</div>
<div class="luckysheet-menuseparator luckysheet-mousedown-cancel" role="separator"></div>
<div id="luckysheetsheetconfighide" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div class="luckysheet-menuseparator luckysheet-mousedown-cancel" role="separator" style="display:${hideTopMenuseparator ? 'block' : 'none'};"></div>
<div id="luckysheetsheetconfighide" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.hide ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${sheetconfig.hide}</div>
</div>
<div id="luckysheetsheetconfigshow" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div id="luckysheetsheetconfigshow" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.hide ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${sheetconfig.unhide}</div>
</div>
<div class="luckysheet-menuseparator luckysheet-mousedown-cancel" role="separator"></div>
<div id="luckysheetsheetconfigmoveleft" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div class="luckysheet-menuseparator luckysheet-mousedown-cancel" role="separator" style="display:${moveTopMenuseparator ? 'block' : 'none'};"></div>
<div id="luckysheetsheetconfigmoveleft" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.move ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${sheetconfig.moveLeft}</div>
</div>
<div id="luckysheetsheetconfigmoveright" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel">
<div id="luckysheetsheetconfigmoveright" class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" style="display:${config.move ? 'block' : 'none'};">
<div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel">${sheetconfig.moveRight}</div>
</div>
</div>
@ -615,6 +685,8 @@ function sheetconfigHTML(){
</div>
</div>
</div>`;
return sheetconfigModel;
}
const luckysheetPivotTableHTML = function(){
@ -1216,6 +1288,23 @@ function menuToolBar (){
</div>
</div>
<div class="luckysheet-toolbar-button-split-left luckysheet-toolbar-button luckysheet-inline-block"
data-tips="${toolbar.insertLink}" id="luckysheet-insertLink-btn-title" role="button" style="user-select: none;">
<div class="luckysheet-toolbar-button-outer-box luckysheet-inline-block"
style="user-select: none;">
<div class="luckysheet-toolbar-menu-button-inner-box luckysheet-inline-block"
style="user-select: none;">
<div class="luckysheet-toolbar-menu-button-caption luckysheet-inline-block"
style="user-select: none;">
<div class="luckysheet-icon luckysheet-inline-block " style="user-select: none;">
<div aria-hidden="true" class="luckysheet-icon-img-container luckysheet-icon-img luckysheet-icon-rotation-none iconfont icon-lianjie"
style="user-select: none;">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="luckysheet-toolbar-button-split-left luckysheet-toolbar-button luckysheet-inline-block"
data-tips="${toolbar.chart}" id="luckysheet-chart-btn-title" role="button" style="user-select: none;">
<div class="luckysheet-toolbar-button-outer-box luckysheet-inline-block"
style="user-select: none;">
@ -1226,7 +1315,6 @@ function menuToolBar (){
<div class="luckysheet-icon luckysheet-inline-block " style="user-select: none;">
<div aria-hidden="true" class="luckysheet-icon-img-container luckysheet-icon-img luckysheet-icon-rotation-none iconfont icon-tubiao"
style="user-select: none;">
<input id="luckysheet-imgUpload" type="file" accept="image/*" style="display:none;"></input>
</div>
</div>
</div>
@ -1259,7 +1347,6 @@ function menuToolBar (){
<div class="luckysheet-icon luckysheet-inline-block " style="user-select: none;">
<div aria-hidden="true" class="luckysheet-icon-img-container luckysheet-icon-img luckysheet-icon-rotation-none iconfont icon-shujutoushi"
style="user-select: none;">
<input id="luckysheet-imgUpload" type="file" accept="image/*" style="display:none;"></input>
</div>
</div>
</div>
@ -1616,6 +1703,66 @@ const iconfontObjects = {
}
}
/**
*单元格右击菜单配置
*
*/
function customCellRightClickConfig() {
const config = {
copy: true, // copy
copyAs: true, // copy as
paste: true, // paste
insertRow: true, // insert row
insertColumn: true, // insert column
deleteRow: true, // delete the selected row
deleteColumn: true, // delete the selected column
deleteCell: true, // delete cell
hideRow: true, // hide the selected row and display the selected row
hideColumn: true, // hide the selected column and display the selected column
rowHeight: true, // row height
columnWidth: true, // column width
clear: true, // clear content
matrix: true, // matrix operation selection
sort: true, // sort selection
filter: true, // filter selection
chart: true, // chart generation
image: true, // insert picture
link: true, // insert link
data: true, // data verification
cellFormat: true // Set cell format
}
// cellRightClickConfig determines the final result
if(JSON.stringify(luckysheetConfigsetting.cellRightClickConfig) !== '{}'){
Object.assign(config,luckysheetConfigsetting.cellRightClickConfig);
}
console.info('=======cellRightClickConfig======'),
luckysheetConfigsetting.cellRightClickConfig = config;
return config;
}
/**
*sheet页右击菜单配置
*
*/
function customSheetRightClickConfig() {
const config = {
delete: true, //Delete
copy: true, //Copy
rename: true, //Rename
color: true, //Change color
hide: true, //Hide, unhide
move: true, //Move to the left, move to the right
}
// sheetRightClickConfig determines the final result
if(JSON.stringify(luckysheetConfigsetting.sheetRightClickConfig) !== '{}'){
Object.assign(config,luckysheetConfigsetting.sheetRightClickConfig);
}
luckysheetConfigsetting.sheetRightClickConfig = config;
return config;
}
export {
gridHTML,
columeHeader_word,

37
src/controllers/controlHistory.js

@ -5,6 +5,7 @@ import conditionformat from './conditionformat';
import luckysheetPostil from './postil';
import imageCtrl from './imageCtrl';
import dataVerificationCtrl from './dataVerificationCtrl';
import hyperlinkCtrl from './hyperlinkCtrl';
import {zoomRefreshView,zoomNumberDomBind} from './zoom';
import { createFilter, createFilterOptions, labelFilterOptionState } from './filter';
import formula from '../global/formula';
@ -22,6 +23,7 @@ import {
} from '../global/refresh';
import { getSheetIndex } from '../methods/get';
import Store from '../store';
import { selectHightlightShow } from './select';
function formulaHistoryHanddler(ctr, type="redo"){
if(ctr==null){
@ -82,7 +84,6 @@ const controlHistory = {
"dataVerification": ctr.dataVerification,
"dynamicArray": ctr.dynamicArray
}
jfrefreshgrid(ctr.data, ctr.range, allParam);
// formula.execFunctionGroup(null, null, null, null, ctr.data);//取之前的数据
}
@ -166,7 +167,8 @@ const controlHistory = {
ctr.cf,
ctr.af,
ctr.freezen,
ctr.dataVerification
ctr.dataVerification,
ctr.hyperlink
);
}
else if (ctr.type == "delRC") { //删除行列撤销操作
@ -184,7 +186,8 @@ const controlHistory = {
ctr.cf,
ctr.af,
ctr.freezen,
ctr.dataVerification
ctr.dataVerification,
ctr.hyperlink
);
}
else if (ctr.type == "deleteCell") { //删除单元格撤销操作
@ -195,7 +198,8 @@ const controlHistory = {
ctr.calc,
ctr.filterObj,
ctr.cf,
ctr.dataVerification
ctr.dataVerification,
ctr.hyperlink
);
}
else if (ctr.type == "showHidRows") { // 隐藏、显示行 撤销操作
@ -344,6 +348,9 @@ const controlHistory = {
else if (ctr.type == "updateDataVerificationOfCheckbox"){
dataVerificationCtrl.refOfCheckbox(ctr.currentDataVerification, ctr.historyDataVerification, ctr.sheetIndex, ctr.data, ctr.range);
}
else if (ctr.type == "updateHyperlink"){
hyperlinkCtrl.ref(ctr.currentHyperlink, ctr.historyHyperlink, ctr.sheetIndex, ctr.data, ctr.range);
}
else if (ctr.type == "updateCF"){
let historyRules = ctr["data"]["historyRules"];
@ -414,6 +421,10 @@ const controlHistory = {
}
cleargridelement(e);
if (ctr.range) {
Store.luckysheet_select_save = ctr.range;
selectHightlightShow();
}
Store.clearjfundo = true;
},
undo: function () {
@ -493,7 +504,8 @@ const controlHistory = {
ctr.curCf,
ctr.curAf,
ctr.curFreezen,
ctr.curDataVerification
ctr.curDataVerification,
ctr.curHyperlink
);
}
else if (ctr.type == "delRC") { //删除行列重做操作
@ -507,7 +519,8 @@ const controlHistory = {
ctr.curCf,
ctr.curAf,
ctr.curFreezen,
ctr.curDataVerification
ctr.curDataVerification,
ctr.curHyperlink
);
}
else if (ctr.type == "deleteCell") { //删除单元格重做操作
@ -518,7 +531,8 @@ const controlHistory = {
ctr.curCalc,
ctr.curFilterObj,
ctr.curCf,
ctr.curDataVerification
ctr.curDataVerification,
ctr.curHyperlink
);
}
else if (ctr.type == "showHidRows") { // 隐藏、显示行 重做操作
@ -650,6 +664,9 @@ const controlHistory = {
else if (ctr.type == "updateDataVerificationOfCheckbox"){
dataVerificationCtrl.refOfCheckbox(ctr.historyDataVerification, ctr.currentDataVerification, ctr.sheetIndex, ctr.curData, ctr.range);
}
else if (ctr.type == "updateHyperlink") {
hyperlinkCtrl.ref(ctr.historyHyperlink, ctr.currentHyperlink, ctr.sheetIndex, ctr.curData, ctr.range);
}
else if (ctr.type == "updateCF"){
let currentRules = ctr["data"]["currentRules"];
@ -713,7 +730,11 @@ const controlHistory = {
zoomNumberDomBind();
zoomRefreshView();
}
if (ctr.range) {
Store.luckysheet_select_save = ctr.range;
selectHightlightShow();
}
Store.clearjfundo = true;
}
};

38
src/controllers/dataVerificationCtrl.js

@ -573,6 +573,28 @@ const dataVerificationCtrl = {
return;
}
let str = range[range.length - 1].row[0],
edr = range[range.length - 1].row[1],
stc = range[range.length - 1].column[0],
edc = range[range.length - 1].column[1];
let d = editor.deepCopyFlowData(Store.flowdata);
if(str < 0){
str = 0;
}
if(edr > d.length - 1){
edr = d.length - 1;
}
if(stc < 0){
stc = 0;
}
if(edc > d[0].length - 1){
edc = d[0].length - 1;
}
let type = $("#luckysheet-dataVerification-dialog #data-verification-type-select").val();
let type2 = null, value1 = "", value2 = "";
@ -699,13 +721,6 @@ const dataVerificationCtrl = {
let historyDataVerification = $.extend(true, {}, _this.dataVerification);
let currentDataVerification = $.extend(true, {}, _this.dataVerification);
let str = range[range.length - 1].row[0],
edr = range[range.length - 1].row[1],
stc = range[range.length - 1].column[0],
edc = range[range.length - 1].column[1];
let d = editor.deepCopyFlowData(Store.flowdata);
for(let r = str; r <= edr; r++){
for(let c = stc; c <= edc; c++){
currentDataVerification[r + '_' + c] = item;
@ -1432,6 +1447,15 @@ const dataVerificationCtrl = {
'left': col_pre,
'top': row,
});
let myh = $("#luckysheet-dataVerification-dropdown-List").outerHeight();
let currentWinH = $("#luckysheet-cell-main")[0].scrollHeight;
if(row + myh > currentWinH - 42 - 6){
$("#luckysheet-dataVerification-dropdown-List").css({
'top': row_pre - myh,
})
}
},
getDropdownList: function(txt){
let list = [];

188
src/controllers/freezen.js

@ -377,7 +377,7 @@ const luckysheetFreezen = {
dataset_row_st = 0;
}
top = Store.visibledatarow[dataset_row_st] - 2 - scrollTop + Store.columeHeaderHeight;
top = Store.visibledatarow[dataset_row_st] - 2 - scrollTop + Store.columnHeaderHeight;
freezenhorizontaldata = [
Store.visibledatarow[dataset_row_st],
dataset_row_st + 1,
@ -437,11 +437,11 @@ const luckysheetFreezen = {
freezen_vertical_scrollTop = _this.freezenverticaldata[2];
//3
_this.createCanvas("freezen_3", freezen_vertical_px - freezen_vertical_scrollTop, freezen_horizon_px - freezen_horizon_scrollTop + 1, Store.rowHeaderWidth - 1, Store.columeHeaderHeight - 1);
_this.createCanvas("freezen_3", freezen_vertical_px - freezen_vertical_scrollTop, freezen_horizon_px - freezen_horizon_scrollTop + 1, Store.rowHeaderWidth - 1, Store.columnHeaderHeight - 1);
//4
_this.createCanvas("freezen_4", drawWidth - freezen_vertical_px + freezen_vertical_scrollTop, freezen_horizon_px - freezen_horizon_scrollTop + 1, freezen_vertical_px - freezen_vertical_scrollTop + Store.rowHeaderWidth - 1, Store.columeHeaderHeight - 1);
_this.createCanvas("freezen_4", drawWidth - freezen_vertical_px + freezen_vertical_scrollTop, freezen_horizon_px - freezen_horizon_scrollTop + 1, freezen_vertical_px - freezen_vertical_scrollTop + Store.rowHeaderWidth - 1, Store.columnHeaderHeight - 1);
//7
_this.createCanvas("freezen_7", freezen_vertical_px - freezen_vertical_scrollTop, drawHeight - freezen_horizon_px + freezen_horizon_scrollTop - Store.columeHeaderHeight, Store.rowHeaderWidth - 1, freezen_horizon_px - freezen_horizon_scrollTop + Store.columeHeaderHeight - 1);
_this.createCanvas("freezen_7", freezen_vertical_px - freezen_vertical_scrollTop, drawHeight - freezen_horizon_px + freezen_horizon_scrollTop - Store.columnHeaderHeight, Store.rowHeaderWidth - 1, freezen_horizon_px - freezen_horizon_scrollTop + Store.columnHeaderHeight - 1);
}
//水平freezen
else if (_this.freezenhorizontaldata != null) {
@ -449,7 +449,7 @@ const luckysheetFreezen = {
freezen_horizon_ed = _this.freezenhorizontaldata[1];
freezen_horizon_scrollTop = _this.freezenhorizontaldata[2];
_this.createCanvas("freezen_h", drawWidth, freezen_horizon_px - freezen_horizon_scrollTop + 1, Store.rowHeaderWidth - 1, Store.columeHeaderHeight - 1);
_this.createCanvas("freezen_h", drawWidth, freezen_horizon_px - freezen_horizon_scrollTop + 1, Store.rowHeaderWidth - 1, Store.columnHeaderHeight - 1);
}
//垂直freezen
else if (_this.freezenverticaldata != null) {
@ -457,7 +457,7 @@ const luckysheetFreezen = {
freezen_vertical_ed = _this.freezenverticaldata[1];
freezen_vertical_scrollTop = _this.freezenverticaldata[2];
_this.createCanvas("freezen_v", freezen_vertical_px - freezen_vertical_scrollTop, drawHeight, Store.rowHeaderWidth - 1, Store.columeHeaderHeight - 1);
_this.createCanvas("freezen_v", freezen_vertical_px - freezen_vertical_scrollTop, drawHeight, Store.rowHeaderWidth - 1, Store.columnHeaderHeight - 1);
}
_this.scrollAdapt();
@ -1176,61 +1176,73 @@ const luckysheetFreezen = {
let show = true;
let show2 = true;
if(postil_top + postil_height < freezenTop){
$(e).show().find(".luckysheet-postil-show-main").css("top", postil_top + offTop);
$(e).show().find(".arrowCanvas").css("top", size[1] + offTop);
}
else{
if(postil_top < freezenTop + offTop){
if(postil_top + postil_height <= freezenTop + offTop){
show = false;
if(r >= _this.freezenhorizontaldata[1]){
if(postil_top + postil_height < freezenTop){
$(e).show().find(".luckysheet-postil-show-main").css("top", postil_top + offTop);
$(e).show().find(".arrowCanvas").css("top", size[1] + offTop);
}
else{
if(postil_top < freezenTop + offTop){
if(postil_top + postil_height <= freezenTop + offTop){
show = false;
}
else{
$(e).show().find(".luckysheet-postil-show-main").css({ "top": freezenTop + offTop, "height": postil_height - (freezenTop + offTop - postil_top) });
$(e).show().find(".formulaInputFocus").css("margin-top", -(freezenTop + offTop - postil_top));
$(e).show().find(".arrowCanvas").hide();
show2 = false;
}
}
else{
$(e).show().find(".luckysheet-postil-show-main").css({ "top": freezenTop + offTop, "height": postil_height - (freezenTop + offTop - postil_top) });
$(e).show().find(".formulaInputFocus").css("margin-top", -(freezenTop + offTop - postil_top));
$(e).show().find(".arrowCanvas").hide();
show2 = false;
$(e).show().find(".luckysheet-postil-show-main").css({
"top": postil_top,
"height": postil_height
});
$(e).show().find(".formulaInputFocus").css("margin-top", 0);
$(e).show().find(".arrowCanvas").css("top", size[1]);
// luckysheetPostil.buildPs(r, c, postil);
}
}
else{
$(e).show().find(".luckysheet-postil-show-main").css({
"top": postil_top,
"height": postil_height
});
$(e).show().find(".formulaInputFocus").css("margin-top", 0);
$(e).show().find(".arrowCanvas").css("top", size[1]);
// luckysheetPostil.buildPs(r, c, postil);
}
}
if(postil_left + postil_width < freezenLeft){
$(e).show().find(".luckysheet-postil-show-main").css("left", postil_left + offLeft);
$(e).show().find(".arrowCanvas").css("left", size[0] + offLeft);
}
else{
if(postil_left < freezenLeft + offLeft){
if(postil_left + postil_width <= freezenLeft + offLeft){
show = false;
}
else{
$(e).show().find(".luckysheet-postil-show-main").css({ "left": freezenLeft + offLeft, "width": postil_width - (freezenLeft + offLeft - postil_left) });
$(e).show().find(".formulaInputFocus").css("margin-left", -(freezenLeft + offLeft - postil_left));
$(e).show().find(".arrowCanvas").hide();
$(e).show().find(".luckysheet-postil-show-main").css("top", postil_top + offTop);
$(e).show().find(".arrowCanvas").css("top", size[1] + offTop);
}
show2 = false;
}
if(c >= _this.freezenverticaldata[1]){
if(postil_left + postil_width < freezenLeft){
$(e).show().find(".luckysheet-postil-show-main").css("left", postil_left + offLeft);
$(e).show().find(".arrowCanvas").css("left", size[0] + offLeft);
}
else{
$(e).show().find(".luckysheet-postil-show-main").css({
"left": postil_left,
"width": postil_width
});
$(e).show().find(".formulaInputFocus").css("margin-left", 0);
$(e).show().find(".arrowCanvas").css("left", size[0]);
// luckysheetPostil.buildPs(r, c, postil);
if(postil_left < freezenLeft + offLeft){
if(postil_left + postil_width <= freezenLeft + offLeft){
show = false;
}
else{
$(e).show().find(".luckysheet-postil-show-main").css({ "left": freezenLeft + offLeft, "width": postil_width - (freezenLeft + offLeft - postil_left) });
$(e).show().find(".formulaInputFocus").css("margin-left", -(freezenLeft + offLeft - postil_left));
$(e).show().find(".arrowCanvas").hide();
show2 = false;
}
}
else{
$(e).show().find(".luckysheet-postil-show-main").css({
"left": postil_left,
"width": postil_width
});
$(e).show().find(".formulaInputFocus").css("margin-left", 0);
$(e).show().find(".arrowCanvas").css("left", size[0]);
// luckysheetPostil.buildPs(r, c, postil);
}
}
}
else{
$(e).show().find(".luckysheet-postil-show-main").css("left", postil_left + offLeft);
$(e).show().find(".arrowCanvas").css("left", size[0] + offLeft);
}
if(!show){
$(e).hide();
@ -1281,24 +1293,30 @@ const luckysheetFreezen = {
let size = luckysheetPostil.getArrowCanvasSize(postil_left, postil_top, toX, toY);
if(postil_top + postil_height < freezenTop){
$(e).show().find(".luckysheet-postil-show-main").css("top", postil_top + offTop);
$(e).show().find(".arrowCanvas").css("top", size[1] + offTop);
}
else{
if(postil_top < freezenTop + offTop){
if(postil_top + postil_height <= freezenTop + offTop){
$(e).hide();
if(r >= _this.freezenhorizontaldata[1]){
if(postil_top + postil_height < freezenTop){
$(e).show().find(".luckysheet-postil-show-main").css("top", postil_top + offTop);
$(e).show().find(".arrowCanvas").css("top", size[1] + offTop);
}
else{
if(postil_top < freezenTop + offTop){
if(postil_top + postil_height <= freezenTop + offTop){
$(e).hide();
}
else{
$(e).show().find(".luckysheet-postil-show-main").css({ "top": freezenTop + offTop, "height": postil_height - (freezenTop + offTop - postil_top) });
$(e).show().find(".formulaInputFocus").css("margin-top", -(freezenTop + offTop - postil_top));
$(e).show().find(".arrowCanvas").hide();
}
}
else{
$(e).show().find(".luckysheet-postil-show-main").css({ "top": freezenTop + offTop, "height": postil_height - (freezenTop + offTop - postil_top) });
$(e).show().find(".formulaInputFocus").css("margin-top", -(freezenTop + offTop - postil_top));
$(e).show().find(".arrowCanvas").hide();
luckysheetPostil.buildPs(r, c, postil);
}
}
else{
luckysheetPostil.buildPs(r, c, postil);
}
}
else{
$(e).show().find(".luckysheet-postil-show-main").css("top", postil_top + offTop);
$(e).show().find(".arrowCanvas").css("top", size[1] + offTop);
}
})
}
@ -1342,24 +1360,30 @@ const luckysheetFreezen = {
let size = luckysheetPostil.getArrowCanvasSize(postil_left, postil_top, toX, toY);
if(postil_left + postil_width < freezenLeft){
$(e).show().find(".luckysheet-postil-show-main").css("left", postil_left + offLeft);
$(e).show().find(".arrowCanvas").css("left", size[0] + offLeft);
}
else{
if(postil_left < freezenLeft + offLeft){
if(postil_left + postil_width <= freezenLeft + offLeft){
$(e).hide();
if(c >= _this.freezenverticaldata[1]){
if(postil_left + postil_width < freezenLeft){
$(e).show().find(".luckysheet-postil-show-main").css("left", postil_left + offLeft);
$(e).show().find(".arrowCanvas").css("left", size[0] + offLeft);
}
else{
if(postil_left < freezenLeft + offLeft){
if(postil_left + postil_width <= freezenLeft + offLeft){
$(e).hide();
}
else{
$(e).show().find(".luckysheet-postil-show-main").css({ "left": freezenLeft + offLeft, "width": postil_width - (freezenLeft + offLeft - postil_left) });
$(e).show().find(".formulaInputFocus").css("margin-left", -(freezenLeft + offLeft - postil_left));
$(e).show().find(".arrowCanvas").hide();
}
}
else{
$(e).show().find(".luckysheet-postil-show-main").css({ "left": freezenLeft + offLeft, "width": postil_width - (freezenLeft + offLeft - postil_left) });
$(e).show().find(".formulaInputFocus").css("margin-left", -(freezenLeft + offLeft - postil_left));
$(e).show().find(".arrowCanvas").hide();
luckysheetPostil.buildPs(r, c, postil);
}
}
else{
luckysheetPostil.buildPs(r, c, postil);
}
}
else{
$(e).show().find(".luckysheet-postil-show-main").css("left", postil_left + offLeft);
$(e).show().find(".arrowCanvas").css("left", size[0] + offLeft);
}
})
}
@ -1648,7 +1672,7 @@ const luckysheetFreezen = {
if(row_st == -1){
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
freezen = {
@ -1681,7 +1705,7 @@ const luckysheetFreezen = {
if(row_st == -1){
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
let scrollLeft = 0;
@ -1718,7 +1742,7 @@ const luckysheetFreezen = {
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
freezen = {
@ -1768,7 +1792,7 @@ const luckysheetFreezen = {
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
let scrollLeft = 0;

352
src/controllers/handler.js

@ -5,6 +5,7 @@ import pivotTable from './pivotTable';
import luckysheetDropCell from './dropCell';
import luckysheetPostil from './postil';
import imageCtrl from './imageCtrl';
import hyperlinkCtrl from './hyperlinkCtrl';
import dataVerificationCtrl from './dataVerificationCtrl';
import menuButton from './menuButton';
import conditionformat from './conditionformat';
@ -35,6 +36,7 @@ import {
showrightclickmenu,
luckysheetactiveCell,
luckysheetContainerFocus,
$$
} from '../utils/util';
import { getSheetIndex, getRangetxt } from '../methods/get';
import {
@ -186,6 +188,10 @@ export default function luckysheetHandler() {
let col_st = luckysheet_searcharray(visibledatacolumn_c, scrollLeft);
let row_st = luckysheet_searcharray(visibledatarow_c, scrollTop);
if (luckysheetFreezen.freezenhorizontaldata != null) {
row_st = luckysheet_searcharray(visibledatarow_c, scrollTop + luckysheetFreezen.freezenhorizontaldata[0]);
}
let colscroll = 0;
let rowscroll = 0;
@ -211,6 +217,10 @@ export default function luckysheetHandler() {
rowscroll = row_ed == 0 ? 0 : visibledatarow_c[row_ed - 1];
if (luckysheetFreezen.freezenhorizontaldata != null) {
rowscroll -= luckysheetFreezen.freezenhorizontaldata[0];
}
$("#luckysheet-scrollbar-y").scrollTop(rowscroll);
}
else if(event.deltaX != 0){
@ -311,6 +321,9 @@ export default function luckysheetHandler() {
y = mouse[1] + luckysheetFreezen.freezenhorizontaldata[2];
}
let sheetFile = sheetmanage.getSheetByIndex();
let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
let row_location = rowLocation(y),
row = row_location[1],
row_pre = row_location[0],
@ -335,6 +348,18 @@ export default function luckysheetHandler() {
col_index_ed = margeset.column[3];
}
//单元格单击之前
if(!method.createHookFunction("cellMousedownBefore", Store.flowdata[row_index][col_index], {
r:row_index,
c:col_index,
"start_r": row_pre,
"start_c": col_pre,
"end_r": row,
"end_c": col
}, sheetFile,luckysheetTableContent)){ return; }
//数据验证 单元格聚焦
dataVerificationCtrl.cellFocus(row_index, col_index, true);
@ -373,6 +398,12 @@ export default function luckysheetHandler() {
}
}
//链接 单元格聚焦
if(hyperlinkCtrl.hyperlink && hyperlinkCtrl.hyperlink[row_index + "_" + col_index] && event.which != "3"){
hyperlinkCtrl.cellFocus(row_index, col_index);
return;
}
Store.luckysheet_scroll_status = true;
//公式相关
@ -1087,6 +1118,15 @@ export default function luckysheetHandler() {
luckysheetContainerFocus();
method.createHookFunction("cellMousedown", Store.flowdata[row_index][col_index], {
r:row_index,
c:col_index,
"start_r": row_pre,
"start_c": col_pre,
"end_r": row,
"end_c": col
}, sheetFile,luckysheetTableContent);
//$("#luckysheet-cols-h-c .luckysheet-cols-h-cells-c .luckysheet-cols-h-cells-clip .luckysheet-cols-h-cell-sel").removeClass("luckysheet-cols-h-cell-sel").addClass("luckysheet-cols-h-cell-nosel");
//$("#luckysheet-rows-h .luckysheet-rows-h-cells .luckysheet-rows-h-cells-c .luckysheet-rows-h-cells-clip .luckysheet-rows-h-cell-sel").removeClass("luckysheet-rows-h-cell-sel").addClass("luckysheet-rows-h-cell-nosel");
@ -1115,11 +1155,22 @@ export default function luckysheetHandler() {
let obj_s = Store.luckysheet_select_save[0];
const cellRightClickConfig = luckysheetConfigsetting.cellRightClickConfig;
$("#luckysheet-cols-rows-data").show();
$("#luckysheet-cols-rows-handleincell").show();
$("#luckysheet-cols-rows-add, #luckysheet-cols-rows-shift").hide();
$$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'block';
$$('#luckysheet-cols-rows-handleincell .luckysheet-menuseparator').style.display = 'block';
if (obj_s["row"] != null && obj_s["row"][0] == 0 && obj_s["row"][1] == Store.flowdata.length - 1) {
// 如果全部按钮都隐藏,则整个菜单容器也要隐藏
if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste && !cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.hideColumn && !cellRightClickConfig.columnWidth && !cellRightClickConfig.clear && !cellRightClickConfig.matrix && !cellRightClickConfig.sort && !cellRightClickConfig.filter && !cellRightClickConfig.chart && !cellRightClickConfig.image && !cellRightClickConfig.link && !cellRightClickConfig.data && !cellRightClickConfig.cellFormat){
return;
}
Store.luckysheetRightHeadClickIs = "column";
$("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-word").text(locale().rightclick.column);
@ -1128,11 +1179,36 @@ export default function luckysheetHandler() {
$("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-right").text(locale().rightclick.right);
$("#luckysheet-cols-rows-add").show();
$("#luckysheet-cols-rows-data").show();
// $("#luckysheet-cols-rows-data").show();
$("#luckysheet-cols-rows-shift").hide();
$("#luckysheet-cols-rows-handleincell").hide();
Store.luckysheet_cols_menu_status = true;
$$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'block';
// 自定义右键菜单:向左向右增加列,删除列,隐藏显示列,设置列宽
$$('#luckysheet-top-left-add-selected').style.display = cellRightClickConfig.insertColumn ? 'block' : 'none';
$$('#luckysheet-bottom-right-add-selected').style.display = cellRightClickConfig.insertColumn ? 'block' : 'none';
$$('#luckysheet-del-selected').style.display = cellRightClickConfig.deleteColumn ? 'block' : 'none';
$$('#luckysheet-hide-selected').style.display = cellRightClickConfig.hideColumn ? 'block' : 'none';
$$('#luckysheet-show-selected').style.display = cellRightClickConfig.hideColumn ? 'block' : 'none';
$$('#luckysheet-column-row-width-selected').style.display = cellRightClickConfig.columnWidth ? 'block' : 'none';
// 1. 当一个功能菜单块上方的功能块按钮都隐藏的时候,下方的功能块的顶部分割线也需要隐藏
if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste){
$$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'none';
if(!cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.hideColumn && !cellRightClickConfig.columnWidth){
$$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'none';
}
}
// 2.当一个功能菜单块内所有的按钮都隐藏的时候,它顶部的分割线也需要隐藏掉
if(!cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.hideColumn && !cellRightClickConfig.columnWidth){
$$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'none';
}
//列宽默认值
let cfg = $.extend(true, {}, Store.config);
if (cfg["columnlen"] == null) {
@ -1164,6 +1240,12 @@ export default function luckysheetHandler() {
}
}
else if (obj_s["column"] != null && obj_s["column"][0] == 0 && obj_s["column"][1] == Store.flowdata[0].length - 1) {
// 如果全部按钮都隐藏,则整个菜单容器也要隐藏
if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste && !cellRightClickConfig.insertRow && !cellRightClickConfig.deleteRow && !cellRightClickConfig.hideRow && !cellRightClickConfig.rowHeight && !cellRightClickConfig.clear && !cellRightClickConfig.matrix && !cellRightClickConfig.sort && !cellRightClickConfig.filter && !cellRightClickConfig.chart && !cellRightClickConfig.image && !cellRightClickConfig.link && !cellRightClickConfig.data && !cellRightClickConfig.cellFormat){
return;
}
Store.luckysheetRightHeadClickIs = "row";
$("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-word").text(locale().rightclick.row);
@ -1171,12 +1253,36 @@ export default function luckysheetHandler() {
$("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-left").text(locale().rightclick.top);
$("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-right").text(locale().rightclick.bottom);
$("#luckysheet-cols-rows-add").show();
$("#luckysheet-cols-rows-data").show();
// $("#luckysheet-cols-rows-data").show();
$("#luckysheet-cols-rows-shift").hide();
$("#luckysheet-cols-rows-handleincell").hide();
Store.luckysheet_cols_menu_status = true;
$$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'block';
// 自定义右键菜单:向上向下增加行,删除行,隐藏显示行,设置行高
$$('#luckysheet-top-left-add-selected').style.display = cellRightClickConfig.insertRow ? 'block' : 'none';
$$('#luckysheet-bottom-right-add-selected').style.display = cellRightClickConfig.insertRow ? 'block' : 'none';
$$('#luckysheet-del-selected').style.display = cellRightClickConfig.deleteRow ? 'block' : 'none';
$$('#luckysheet-hide-selected').style.display = cellRightClickConfig.hideRow ? 'block' : 'none';
$$('#luckysheet-show-selected').style.display = cellRightClickConfig.hideRow ? 'block' : 'none';
$$('#luckysheet-column-row-width-selected').style.display = cellRightClickConfig.rowHeight ? 'block' : 'none';
// 1. 当一个功能菜单块上方的功能块按钮都隐藏的时候,下方的功能块的顶部分割线也需要隐藏
if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste){
$$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'none';
if(!cellRightClickConfig.insertRow && !cellRightClickConfig.deleteRow && !cellRightClickConfig.hideRow && !cellRightClickConfig.rowHeight){
$$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'none';
}
}
// 2. 当一个功能菜单块内所有的按钮都隐藏的时候,它顶部的分割线也需要隐藏掉
if(!cellRightClickConfig.insertRow && !cellRightClickConfig.deleteRow && !cellRightClickConfig.hideRow && !cellRightClickConfig.rowHeight){
$$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'none';
}
//行高默认值
let cfg = $.extend(true, {}, Store.config);
if (cfg["rowlen"] == null) {
@ -1206,8 +1312,32 @@ export default function luckysheetHandler() {
else {
$("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val("");
}
}else{
// 如果全部按钮都隐藏,则整个菜单容器也要隐藏
if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste && !cellRightClickConfig.insertRow && !cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteRow && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.deleteCell && !cellRightClickConfig.clear && !cellRightClickConfig.matrix && !cellRightClickConfig.sort && !cellRightClickConfig.filter && !cellRightClickConfig.chart && !cellRightClickConfig.image && !cellRightClickConfig.link && !cellRightClickConfig.data && !cellRightClickConfig.cellFormat){
return;
}
// 当一个功能菜单块上方的功能块按钮都隐藏的时候,下方的功能块的顶部分割线也需要隐藏
if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste){
$$('#luckysheet-cols-rows-handleincell .luckysheet-menuseparator').style.display = 'none';
if(!cellRightClickConfig.insertRow && !cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteRow && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.deleteCell){
$$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'none';
}
}
if(!cellRightClickConfig.insertRow && !cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteRow && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.deleteCell){
$$('#luckysheet-cols-rows-handleincell .luckysheet-menuseparator').style.display = 'none';
}
}
// 当一个功能菜单块内所有的按钮都隐藏的时候,它顶部的分割线也需要隐藏掉
if(!cellRightClickConfig.clear && !cellRightClickConfig.matrix && !cellRightClickConfig.sort && !cellRightClickConfig.filter && !cellRightClickConfig.chart && !cellRightClickConfig.image && !cellRightClickConfig.link && !cellRightClickConfig.data && !cellRightClickConfig.cellFormat){
$$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'none';
}
showrightclickmenu($("#luckysheet-rightclick-menu"), x, y);
}
}).dblclick(function (event) {
@ -1234,6 +1364,14 @@ export default function luckysheetHandler() {
let x = mouse[0] + scrollLeft;
let y = mouse[1] + scrollTop;
if(luckysheetFreezen.freezenverticaldata != null && mouse[0] < (luckysheetFreezen.freezenverticaldata[0] - luckysheetFreezen.freezenverticaldata[2])){
x = mouse[0] + luckysheetFreezen.freezenverticaldata[2];
}
if(luckysheetFreezen.freezenhorizontaldata != null && mouse[1] < (luckysheetFreezen.freezenhorizontaldata[0] - luckysheetFreezen.freezenhorizontaldata[2])){
y = mouse[1] + luckysheetFreezen.freezenhorizontaldata[2];
}
let row_location = rowLocation(y),
row_index = row_location[2];
@ -1342,8 +1480,71 @@ export default function luckysheetHandler() {
//表格mousemove
$(document).on("mousemove.luckysheetEvent",function (event) {
luckysheetPostil.overshow(event); //有批注显示
hyperlinkCtrl.overshow(event); //链接提示显示
window.cancelAnimationFrame(Store.jfautoscrollTimeout);
if(luckysheetConfigsetting && luckysheetConfigsetting.hook && luckysheetConfigsetting.hook.sheetMousemove){
let mouse = mouseposition(event.pageX, event.pageY);
let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
let row_location = rowLocation(y),
row = row_location[1],
row_pre = row_location[0],
row_index = row_location[2];
let col_location = colLocation(x),
col = col_location[1],
col_pre = col_location[0],
col_index = col_location[2];
let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
if (!!margeset) {
row = margeset.row[1];
row_pre = margeset.row[0];
row_index = margeset.row[2];
col = margeset.column[1];
col_pre = margeset.column[0];
col_index = margeset.column[2];
}
// if(Store.flowdata[row_index] && Store.flowdata[row_index][col_index]){
let sheetFile = sheetmanage.getSheetByIndex();
let moveState = {
functionResizeStatus:formula.functionResizeStatus,
horizontalmoveState:!!luckysheetFreezen.horizontalmovestate,
verticalmoveState:!!luckysheetFreezen.verticalmovestate,
pivotTableMoveState:!!pivotTable && pivotTable.movestate,
sheetMoveStatus:Store.luckysheet_sheet_move_status,
scrollStatus:!!Store.luckysheet_scroll_status,
selectStatus:!!Store.luckysheet_select_status,
rowsSelectedStatus:!!Store.luckysheet_rows_selected_status,
colsSelectedStatus:!!Store.luckysheet_cols_selected_status,
cellSelectedMove:!!Store.luckysheet_cell_selected_move,
cellSelectedExtend:!!Store.luckysheet_cell_selected_extend,
colsChangeSize:!!Store.luckysheet_cols_change_size,
rowsChangeSize:!!Store.luckysheet_rows_change_size,
chartMove:!!Store.chartparam.luckysheetCurrentChartMove,
chartResize:!!Store.chartparam.luckysheetCurrentChartResize,
rangeResize:!!formula.rangeResize ,
rangeMove:!!formula.rangeMove,
}
let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
method.createHookFunction("sheetMousemove", Store.flowdata[row_index][col_index], {
r:row_index,
c:col_index,
"start_r": row_pre,
"start_c": col_pre,
"end_r": row,
"end_c": col
}, sheetFile,moveState,luckysheetTableContent);
// }
}
if(formula.functionResizeStatus){
let y = event.pageY;
@ -1384,10 +1585,10 @@ export default function luckysheetHandler() {
row = row_location[1],
row_pre = row_location[0],
row_index = row_location[2];
let top = mouse[1] + Store.columeHeaderHeight;
let top = mouse[1] + Store.columnHeaderHeight;
if (top < Store.columeHeaderHeight) {
top = Store.columeHeaderHeight;
if (top < Store.columnHeaderHeight) {
top = Store.columnHeaderHeight;
}
if (top > luckysheetFreezen.windowHeight - 4) {
@ -1396,12 +1597,12 @@ export default function luckysheetHandler() {
$("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-handle").css({ "top": top });
if (top + scrollTop - Store.columeHeaderHeight >= row_pre + (row - row_pre) / 2) {
top = row - 2 - scrollTop + Store.columeHeaderHeight;
if (top + scrollTop - Store.columnHeaderHeight >= row_pre + (row - row_pre) / 2) {
top = row - 2 - scrollTop + Store.columnHeaderHeight;
luckysheetFreezen.freezenhorizontaldata = [row, row_index + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_index + 1), top];
}
else {
top = row_pre - 2 - scrollTop + Store.columeHeaderHeight;
top = row_pre - 2 - scrollTop + Store.columnHeaderHeight;
luckysheetFreezen.freezenhorizontaldata = [row_pre, row_index, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_index), top];
}
@ -2297,7 +2498,7 @@ export default function luckysheetHandler() {
maxLeft = imageCtrl.currentWinW - myw - 22 - 36;
if(imgItem.isFixedPos){
minTop = Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columeHeaderHeight;
minTop = Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight;
maxTop = minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - myh;
minLeft = Store.rowHeaderWidth;
maxLeft = minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - myw;
@ -2347,7 +2548,7 @@ export default function luckysheetHandler() {
let imgItem = imageCtrl.images[imageCtrl.currentImgId];
if(imgItem.isFixedPos){
let minTop = Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columeHeaderHeight;
let minTop = Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight;
let minLeft = Store.rowHeaderWidth;
if(resize == 'lt'){//左上
@ -3055,6 +3256,69 @@ export default function luckysheetHandler() {
});
//表格mouseup
$(document).on("mouseup.luckysheetEvent",function (event) {
if(luckysheetConfigsetting && luckysheetConfigsetting.hook && luckysheetConfigsetting.hook.sheetMouseup){
let mouse = mouseposition(event.pageX, event.pageY);
let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
let row_location = rowLocation(y),
row = row_location[1],
row_pre = row_location[0],
row_index = row_location[2];
let col_location = colLocation(x),
col = col_location[1],
col_pre = col_location[0],
col_index = col_location[2];
let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
if (!!margeset) {
row = margeset.row[1];
row_pre = margeset.row[0];
row_index = margeset.row[2];
col = margeset.column[1];
col_pre = margeset.column[0];
col_index = margeset.column[2];
}
// if(Store.flowdata[row_index] && Store.flowdata[row_index][col_index]){
let sheetFile = sheetmanage.getSheetByIndex();
let moveState = {
functionResizeStatus:formula.functionResizeStatus,
horizontalmoveState:!!luckysheetFreezen.horizontalmovestate,
verticalmoveState:!!luckysheetFreezen.verticalmovestate,
pivotTableMoveState:!!pivotTable && pivotTable.movestate,
sheetMoveStatus:Store.luckysheet_sheet_move_status,
scrollStatus:!!Store.luckysheet_scroll_status,
selectStatus:!!Store.luckysheet_select_status,
rowsSelectedStatus:!!Store.luckysheet_rows_selected_status,
colsSelectedStatus:!!Store.luckysheet_cols_selected_status,
cellSelectedMove:!!Store.luckysheet_cell_selected_move,
cellSelectedExtend:!!Store.luckysheet_cell_selected_extend,
colsChangeSize:!!Store.luckysheet_cols_change_size,
rowsChangeSize:!!Store.luckysheet_rows_change_size,
chartMove:!!Store.chartparam.luckysheetCurrentChartMove,
chartResize:!!Store.chartparam.luckysheetCurrentChartResize,
rangeResize:!!formula.rangeResize ,
rangeMove:!!formula.rangeMove,
}
let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
method.createHookFunction("sheetMouseup", Store.flowdata[row_index][col_index], {
r:row_index,
c:col_index,
"start_r": row_pre,
"start_c": col_pre,
"end_r": row,
"end_c": col
}, sheetFile,moveState,luckysheetTableContent);
// }
}
//数据窗格主体
if (Store.luckysheet_select_status) {
clearTimeout(Store.countfuncTimeout);
@ -3097,7 +3361,7 @@ export default function luckysheetHandler() {
luckysheetFreezen.horizontalmovestate = false;
$("#luckysheet-freezebar-horizontal").removeClass("luckysheet-freezebar-active");
$("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-handle").css("cursor", "-webkit-grab");
if (luckysheetFreezen.freezenhorizontaldata[4] <= Store.columeHeaderHeight) {
if (luckysheetFreezen.freezenhorizontaldata[4] <= Store.columnHeaderHeight) {
luckysheetFreezen.cancelFreezenHorizontal();
}
luckysheetFreezen.createAssistCanvas();
@ -3339,7 +3603,26 @@ export default function luckysheetHandler() {
cfg["customHeight"][Store.luckysheet_rows_change_size_start[1]] = 1;
cfg["rowlen"][Store.luckysheet_rows_change_size_start[1]] = Math.ceil(size/Store.zoomRatio);
const changeRowIndex = Store.luckysheet_rows_change_size_start[1];
let changeRowSelected = false;
if(Store["luckysheet_select_save"].length > 0) {
Store["luckysheet_select_save"].filter(select => select.row_select).some((select) => {
if(changeRowIndex >= select.row[0] && changeRowIndex <= select.row[1]) {
changeRowSelected = true;
}
return changeRowSelected;
});
}
if(changeRowSelected) {
Store["luckysheet_select_save"].filter(select => select.row_select).forEach(select => {
for(let r = select.row[0]; r <= select.row[1]; r++) {
cfg["rowlen"][r] = Math.ceil(size/Store.zoomRatio);
}
})
}
else {
cfg["rowlen"][Store.luckysheet_rows_change_size_start[1]] = Math.ceil(size/Store.zoomRatio);
}
let images = imageCtrl.moveChangeSize("row", Store.luckysheet_rows_change_size_start[1], size);
@ -3421,7 +3704,27 @@ export default function luckysheetHandler() {
cfg["customWidth"][Store.luckysheet_cols_change_size_start[1]] = 1;
cfg["columnlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size/Store.zoomRatio);
const changeColumnIndex = Store.luckysheet_cols_change_size_start[1];
let changeColumnSelected = false;
if(Store["luckysheet_select_save"].length > 0) {
Store["luckysheet_select_save"].filter(select => select.column_select).some((select) => {
if(changeColumnIndex >= select.column[0] && changeColumnIndex <= select.column[1]) {
changeColumnSelected = true;
}
return changeColumnSelected;
});
}
if(changeColumnSelected) {
Store["luckysheet_select_save"].filter(select => select.column_select).forEach(select => {
for(let r = select.column[0]; r <= select.column[1]; r++) {
cfg["columnlen"][r] = Math.ceil(size/Store.zoomRatio);
}
})
}
else {
cfg["columnlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size/Store.zoomRatio);
}
let images = imageCtrl.moveChangeSize("column", Store.luckysheet_cols_change_size_start[1], size);
@ -4531,6 +4834,24 @@ export default function luckysheetHandler() {
}
});
//菜单栏 插入链接按钮
$("#luckysheet-insertLink-btn-title").click(function () {
if(!checkProtectionNotEnable(Store.currentSheetIndex)){
return;
}
if (Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0) {
return;
}
hyperlinkCtrl.createDialog();
hyperlinkCtrl.init();
})
$("#luckysheetInsertLink").click(function () {
$("#luckysheet-insertLink-btn-title").click();
$("#luckysheet-rightclick-menu").hide();
})
//菜单栏 数据验证按钮
$("#luckysheet-dataVerification-btn-title").click(function () {
if(!checkProtectionNotEnable(Store.currentSheetIndex)){
@ -4648,7 +4969,7 @@ export default function luckysheetHandler() {
$("#luckysheet-wa-functionbox-confirm").click();
Store.luckysheet_select_status = false;
Store.luckysheet_select_save = [{ "row": [0, Store.flowdata.length - 1], "column": [0, Store.flowdata[0].length - 1], "row_focus": 0, "column_focus": 0 }];
Store.luckysheet_select_save = [{ "row": [0, Store.flowdata.length - 1], "column": [0, Store.flowdata[0].length - 1], "row_focus": 0, "column_focus": 0, row_select: true, column_select: true }];
selectHightlightShow();
clearTimeout(Store.countfuncTimeout);
@ -5233,7 +5554,6 @@ export default function luckysheetHandler() {
//是否允许加载下一页
if (luckysheetConfigsetting.enablePage) {
$("#luckysheet-bottom-page-next").click(function () {
// rptapp
let queryExps = luckysheetConfigsetting.pageInfo.queryExps;
let reportId = luckysheetConfigsetting.pageInfo.reportId;
let fields = luckysheetConfigsetting.pageInfo.fields;

361
src/controllers/hyperlinkCtrl.js

@ -0,0 +1,361 @@
import { replaceHtml } from '../utils/util';
import { getcellvalue } from '../global/getdata';
import { luckysheetrefreshgrid } from '../global/refresh';
import { rowLocation, colLocation, mouseposition } from '../global/location';
import formula from '../global/formula';
import tooltip from '../global/tooltip';
import editor from '../global/editor';
import { modelHTML } from './constant';
import { selectHightlightShow } from './select';
import server from './server';
import sheetmanage from './sheetmanage';
import luckysheetFreezen from './freezen';
import menuButton from './menuButton';
import { getSheetIndex } from '../methods/get';
import locale from '../locale/locale';
import Store from '../store';
const hyperlinkCtrl = {
item: {
linkType: 'external', //链接类型 external外部链接,internal内部链接
linkAddress: '', //链接地址 网页地址或工作表单元格引用
linkTooltip: '', //提示
},
hyperlink: null,
createDialog: function(){
let _this = this;
const _locale = locale();
const hyperlinkText = _locale.insertLink;
const toolbarText = _locale.toolbar;
const buttonText = _locale.button;
$("#luckysheet-modal-dialog-mask").show();
$("#luckysheet-insertLink-dialog").remove();
let sheetListOption = '';
Store.luckysheetfile.forEach(item => {
sheetListOption += `<option value="${item.name}">${item.name}</option>`;
})
let content = `<div class="box">
<div class="box-item">
<label for="luckysheet-insertLink-dialog-linkText">${hyperlinkText.linkText}</label>
<input type="text" id="luckysheet-insertLink-dialog-linkText"/>
</div>
<div class="box-item">
<label for="luckysheet-insertLink-dialog-linkType">${hyperlinkText.linkType}</label>
<select id="luckysheet-insertLink-dialog-linkType">
<option value="external">${hyperlinkText.external}</option>
<option value="internal">${hyperlinkText.internal}</option>
</select>
</div>
<div class="show-box show-box-external">
<div class="box-item">
<label for="luckysheet-insertLink-dialog-linkAddress">${hyperlinkText.linkAddress}</label>
<input type="text" id="luckysheet-insertLink-dialog-linkAddress" placeholder="${hyperlinkText.placeholder1}" />
</div>
</div>
<div class="show-box show-box-internal">
<div class="box-item">
<label for="luckysheet-insertLink-dialog-linkSheet">${hyperlinkText.linkSheet}</label>
<select id="luckysheet-insertLink-dialog-linkSheet">
${sheetListOption}
</select>
</div>
<div class="box-item">
<label for="luckysheet-insertLink-dialog-linkCell">${hyperlinkText.linkCell}</label>
<input type="text" id="luckysheet-insertLink-dialog-linkCell" value="A1" placeholder="${hyperlinkText.placeholder2}" />
</div>
</div>
<div class="box-item">
<label for="luckysheet-insertLink-dialog-linkTooltip">${hyperlinkText.linkTooltip}</label>
<input type="text" id="luckysheet-insertLink-dialog-linkTooltip" placeholder="${hyperlinkText.placeholder3}" />
</div>
</div>`;
$("body").append(replaceHtml(modelHTML, {
"id": "luckysheet-insertLink-dialog",
"addclass": "luckysheet-insertLink-dialog",
"title": toolbarText.insertLink,
"content": content,
"botton": `<button id="luckysheet-insertLink-dialog-confirm" class="btn btn-primary">${buttonText.confirm}</button>
<button class="btn btn-default luckysheet-model-close-btn">${buttonText.cancel}</button>`,
"style": "z-index:100003"
}));
let $t = $("#luckysheet-insertLink-dialog").find(".luckysheet-modal-dialog-content").css("min-width", 350).end(),
myh = $t.outerHeight(),
myw = $t.outerWidth();
let winw = $(window).width(),
winh = $(window).height();
let scrollLeft = $(document).scrollLeft(),
scrollTop = $(document).scrollTop();
$("#luckysheet-insertLink-dialog").css({
"left": (winw + scrollLeft - myw) / 2,
"top": (winh + scrollTop - myh) / 3
}).show();
_this.dataAllocation();
},
init: function (){
let _this = this;
const _locale = locale();
const hyperlinkText = _locale.insertLink;
//链接类型
$(document).off("change.linkType").on("change.linkType", "#luckysheet-insertLink-dialog-linkType", function(e){
let value = this.value;
$("#luckysheet-insertLink-dialog .show-box").hide();
$("#luckysheet-insertLink-dialog .show-box-" + value).show();
})
//确认按钮
$(document).off("click.confirm").on("click.confirm", "#luckysheet-insertLink-dialog-confirm", function(e){
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
let rowIndex = last.row_focus || last.row[0];
let colIndex = last.column_focus || last.column[0];
//文本
let linkText = $("#luckysheet-insertLink-dialog-linkText").val();
let linkType = $("#luckysheet-insertLink-dialog-linkType").val();
let linkAddress = $("#luckysheet-insertLink-dialog-linkAddress").val();
let linkSheet = $("#luckysheet-insertLink-dialog-linkSheet").val();
let linkCell = $("#luckysheet-insertLink-dialog-linkCell").val();
let linkTooltip = $("#luckysheet-insertLink-dialog-linkTooltip").val();
if(linkType == 'external'){
if(!/^http[s]?:\/\/([\w\-\.]+)+[\w-]*([\w\-\.\/\?%&=]+)?$/ig.test(linkAddress)){
tooltip.info('<i class="fa fa-exclamation-triangle"></i>', hyperlinkText.tooltipInfo1);
return;
}
}
else{
if(!formula.iscelldata(linkCell)){
tooltip.info('<i class="fa fa-exclamation-triangle"></i>', hyperlinkText.tooltipInfo2);
return;
}
linkAddress = linkSheet + "!" + linkCell;
}
if(linkText == null || linkText.replace(/\s/g, '') == ''){
linkText = linkAddress;
}
let item = {
linkType: linkType,
linkAddress: linkAddress,
linkTooltip: linkTooltip,
}
let historyHyperlink = $.extend(true, {}, _this.hyperlink);
let currentHyperlink = $.extend(true, {}, _this.hyperlink);
currentHyperlink[rowIndex + "_" + colIndex] = item;
let d = editor.deepCopyFlowData(Store.flowdata);
let cell = d[rowIndex][colIndex];
if(cell == null){
cell = {};
}
cell.fc = 'rgb(0, 0, 255)';
cell.un = 1;
cell.v = linkText;
d[rowIndex][colIndex] = cell;
_this.ref(
historyHyperlink,
currentHyperlink,
Store.currentSheetIndex,
d,
{ row: [rowIndex, rowIndex], column: [colIndex, colIndex] }
);
$("#luckysheet-modal-dialog-mask").hide();
$("#luckysheet-insertLink-dialog").hide();
})
},
dataAllocation: function(){
let _this = this;
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
let rowIndex = last.row_focus || last.row[0];
let colIndex = last.column_focus || last.column[0];
let hyperlink = _this.hyperlink || {};
let item = hyperlink[rowIndex + "_" + colIndex] || {};
//文本
let text = getcellvalue(rowIndex, colIndex, null, 'm');
$("#luckysheet-insertLink-dialog-linkText").val(text);
//链接类型
let linkType = item.linkType || 'external';
$("#luckysheet-insertLink-dialog-linkType").val(linkType);
$("#luckysheet-insertLink-dialog .show-box").hide();
$("#luckysheet-insertLink-dialog .show-box-" + linkType).show();
//链接地址
let linkAddress = item.linkAddress || '';
if(linkType == 'external'){
$("#luckysheet-insertLink-dialog-linkAddress").val(linkAddress);
}
else{
if(formula.iscelldata(linkAddress)){
let sheettxt = linkAddress.split("!")[0];
let rangetxt = linkAddress.split("!")[1];
$("#luckysheet-insertLink-dialog-linkSheet").val(sheettxt);
$("#luckysheet-insertLink-dialog-linkCell").val(rangetxt);
}
}
//提示
let linkTooltip = item.linkTooltip || '';
$("#luckysheet-insertLink-dialog-linkTooltip").val(linkTooltip);
},
cellFocus: function(r, c){
let _this = this;
if(_this.hyperlink == null || _this.hyperlink[r + '_' + c] == null){
return;
}
let item = _this.hyperlink[r + '_' + c];
if(item.linkType == 'external'){
window.open(item.linkAddress);
}
else{
let cellrange = formula.getcellrange(item.linkAddress);
let sheetIndex = cellrange.sheetIndex;
let range = [{
row: cellrange.row,
column: cellrange.column
}];
if(sheetIndex != Store.currentSheetIndex){
$("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active");
$("#luckysheet-sheets-item" + sheetIndex).addClass("luckysheet-sheets-item-active");
sheetmanage.changeSheet(sheetIndex);
}
Store.luckysheet_select_save = range;
selectHightlightShow(true);
let row_pre = cellrange.row[0] - 1 == -1 ? 0 : Store.visibledatarow[cellrange.row[0] - 1];
let col_pre = cellrange.column[0] - 1 == -1 ? 0 : Store.visibledatacolumn[cellrange.column[0] - 1];
$("#luckysheet-scrollbar-x").scrollLeft(col_pre);
$("#luckysheet-scrollbar-y").scrollTop(row_pre);
}
},
overshow: function(event){
let _this = this;
$("#luckysheet-hyperlink-overshow").remove();
if($(event.target).closest("#luckysheet-cell-main").length == 0){
return;
}
let mouse = mouseposition(event.pageX, event.pageY);
let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
let scrollTop = $("#luckysheet-cell-main").scrollTop();
let x = mouse[0] + scrollLeft;
let y = mouse[1] + scrollTop;
if(luckysheetFreezen.freezenverticaldata != null && mouse[0] < (luckysheetFreezen.freezenverticaldata[0] - luckysheetFreezen.freezenverticaldata[2])){
return;
}
if(luckysheetFreezen.freezenhorizontaldata != null && mouse[1] < (luckysheetFreezen.freezenhorizontaldata[0] - luckysheetFreezen.freezenhorizontaldata[2])){
return;
}
let row_index = rowLocation(y)[2];
let col_index = colLocation(x)[2];
let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
if(!!margeset){
row_index = margeset.row[2];
col_index = margeset.column[2];
}
if(_this.hyperlink == null || _this.hyperlink[row_index + "_" + col_index] == null){
return;
}
let item = _this.hyperlink[row_index + "_" + col_index];
let linkTooltip = item.linkTooltip;
if(linkTooltip == null || linkTooltip.replace(/\s/g, '') == ''){
linkTooltip = item.linkAddress;
}
let row = Store.visibledatarow[row_index],
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1];
let col = Store.visibledatacolumn[col_index],
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1];
if(!!margeset){
row = margeset.row[1];
row_pre = margeset.row[0];
col = margeset.column[1];
col_pre = margeset.column[0];
}
let html = `<div id="luckysheet-hyperlink-overshow" style="background:#fff;padding:5px 10px;border:1px solid #000;box-shadow:2px 2px #999;position:absolute;left:${col_pre}px;top:${row + 5}px;z-index:100;">
<div>${linkTooltip}</div>
<div>单击鼠标可以追踪</div>
</div>`;
$(html).appendTo($("#luckysheet-cell-main"));
},
ref: function(historyHyperlink, currentHyperlink, sheetIndex, d, range){
let _this = this;
if (Store.clearjfundo) {
Store.jfundo = [];
let redo = {};
redo["type"] = "updateHyperlink";
redo["sheetIndex"] = sheetIndex;
redo["historyHyperlink"] = historyHyperlink;
redo["currentHyperlink"] = currentHyperlink;
redo["data"] = Store.flowdata;
redo["curData"] = d;
redo["range"] = range;
Store.jfredo.push(redo);
}
_this.hyperlink = currentHyperlink;
Store.luckysheetfile[getSheetIndex(sheetIndex)].hyperlink = currentHyperlink;
Store.flowdata = d;
editor.webWorkerFlowDataCache(Store.flowdata);//worker存数据
Store.luckysheetfile[getSheetIndex(sheetIndex)].data = Store.flowdata;
//共享编辑模式
if(server.allowUpdate){
server.saveParam("all", sheetIndex, currentHyperlink, { "k": "hyperlink" });
server.historyParam(Store.flowdata, sheetIndex, range);
}
setTimeout(function () {
luckysheetrefreshgrid();
}, 1);
}
}
export default hyperlinkCtrl;

4
src/controllers/imageCtrl.js

@ -657,7 +657,7 @@ const imageCtrl = {
scrollLeft = $("#luckysheet-cell-main").scrollLeft();
imgItem.fixedLeft = img.left - scrollLeft + Store.rowHeaderWidth;
imgItem.fixedTop = img.top - scrollTop + Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columeHeaderHeight;
imgItem.fixedTop = img.top - scrollTop + Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight;
let id = _this.generateRandomId();
let modelHtml = _this.modelHtml(id, imgItem);
@ -908,7 +908,7 @@ const imageCtrl = {
scrollLeft = $("#luckysheet-cell-main").scrollLeft();
img.fixedLeft = img.default.left - scrollLeft + Store.rowHeaderWidth;
img.fixedTop = img.default.top - scrollTop + Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columeHeaderHeight;
img.fixedTop = img.default.top - scrollTop + Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight;
let id = _this.generateRandomId();
let modelHtml = _this.modelHtml(id, img);

2
src/controllers/luckysheetConfigsetting.js

@ -19,7 +19,7 @@ const luckysheetConfigsetting = {
showConfigWindowResize: true,
enableAddRow: true,
enableAddCol: true,
enableAddBackTop: true,
enablePage: true,
pageInfo: null,

9
src/controllers/menuButton.js

@ -1624,7 +1624,7 @@ const menuButton = {
if(row_st == -1){
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
luckysheetFreezen.saveFreezen(freezenhorizontaldata, top, null, null);
@ -1664,7 +1664,7 @@ const menuButton = {
if(row_st == -1){
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
luckysheetFreezen.saveFreezen(freezenhorizontaldata, top, null, null);
@ -1710,7 +1710,7 @@ const menuButton = {
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
luckysheetFreezen.saveFreezen(freezenhorizontaldata, top, null, null);
@ -1790,7 +1790,7 @@ const menuButton = {
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [Store.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_st + 1), top];
luckysheetFreezen.saveFreezen(freezenhorizontaldata, top, null, null);
@ -2897,6 +2897,7 @@ const menuButton = {
$attr.css({ "top": top, "left": left }).show();
_this.rightclickmenu = $t;
} else {
clearTimeout(_this.submenuhide);
_this.submenuhide = setTimeout(function () { $attr.hide(); }, 200);
}
}).on("mouseover mouseleave",".luckysheet-menuButton-sub", function(e){

581
src/controllers/resize.js

@ -20,40 +20,53 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) {
Store.infobarHeight = document.querySelector('#luckysheet_info_detail').offsetHeight;
}
if (!luckysheetConfigsetting.showtoolbar) {
$("#" + Store.container).find(".luckysheet-wa-editor, .luckysheet-share-logo").hide();
if (!!Store.toobarObject && !!Store.toobarObject.toobarElements && Store.toobarObject.toobarElements.length === 0) {
$("#" + Store.container).find(".luckysheet-wa-editor").hide();
Store.toolbarHeight = 0;
}
else {
$("#" + Store.container).find(".luckysheet-wa-editor, .luckysheet-share-logo").show();
$("#" + Store.container).find(".luckysheet-wa-editor").show();
// Store.toolbarHeight = 72;
Store.toolbarHeight = document.querySelector('#' + Store.container +' .luckysheet-wa-editor').offsetHeight;
}
if (!luckysheetConfigsetting.showsheetbar) {
$("#" + Store.container).find("#luckysheet-sheet-area").hide();
Store.sheetBarHeight = 0;
}
else {
$("#" + Store.container).find("#luckysheet-sheet-area").show();
Store.sheetBarHeight = 31;
}
// if (!luckysheetConfigsetting.showsheetbar) {
// $("#" + Store.container).find("#luckysheet-sheet-area").hide();
// Store.sheetBarHeight = 0;
// }
// else {
// $("#" + Store.container).find("#luckysheet-sheet-area").show();
// Store.sheetBarHeight = 31;
// }
if (!luckysheetConfigsetting.showstatisticBar) {
$("#" + Store.container).find(".luckysheet-stat-area").hide();
Store.statisticBarHeight = 0;
customSheetbarConfig();
// if (!luckysheetConfigsetting.showstatisticBar) {
// $("#" + Store.container).find(".luckysheet-stat-area").hide();
// Store.statisticBarHeight = 0;
// }
// else {
// $("#" + Store.container).find(".luckysheet-stat-area").show();
// Store.statisticBarHeight = 23;
// }
customStatisticBarConfig();
// 公式栏
const formulaEle = document.querySelector("#" + Store.container + ' .luckysheet-wa-calculate');
if (!luckysheetConfigsetting.sheetFormulaBar) {
formulaEle.style.display = 'none';
Store.calculatebarHeight = 0;
}
else {
$("#" + Store.container).find(".luckysheet-stat-area").show();
Store.statisticBarHeight = 23;
formulaEle.style.display = 'block';
Store.calculatebarHeight = formulaEle.offsetHeight;
}
// 公式栏
Store.calculatebarHeight = document.querySelector('#luckysheet-wa-calculate').offsetHeight;
$("#" + Store.container).find(".luckysheet-grid-container").css("top", Store.toolbarHeight + Store.infobarHeight + Store.calculatebarHeight);
gridW = $("#" + Store.container).width(), gridH = $("#" + Store.container).height();
gridW = $("#" + Store.container).width();
if(luckysheetConfigsetting.showConfigWindowResize){//数据透视表 图表 交替颜色 Protection
if($("#luckysheet-modal-dialog-slider-pivot").is(":visible")){
@ -70,18 +83,10 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) {
}
}
$("#" + Store.container).find(".luckysheet").height(gridH - 2).width(gridW - 2);
changeSheetContainerSize(gridW, gridH)
if(isRefreshCanvas){
luckysheetrefreshgrid($("#luckysheet-cell-main").scrollLeft(), $("#luckysheet-cell-main").scrollTop());
}
const _locale = locale();
const locale_toolbar = _locale.toolbar;
let ismore = false,
toolbarW = 0,
// morebtn = '<div class="luckysheet-toolbar-separator luckysheet-inline-block" style="user-select: none;"> </div><div class="luckysheet-toolbar-button luckysheet-inline-block" data-tips="'+ locale_toolbar.toolMoreTip +'" id="luckysheet-icon-morebtn" role="button" style="user-select: none;"> <div class="luckysheet-toolbar-button-outer-box luckysheet-inline-block" style="user-select: none;"> <div class="luckysheet-toolbar-button-inner-box luckysheet-inline-block" style="user-select: none;"> <div class="luckysheet-toolbar-menu-button-caption luckysheet-inline-block" style="user-select: none;color:#0188fb;"><i class="fa fa-list-ul"></i> '+ locale_toolbar.toolMore +'... </div> </div> </div> </div>',
toolbarW = 0,
morebtn = `<div class="luckysheet-toolbar-button luckysheet-inline-block" data-tips="${locale_toolbar.toolMoreTip}" id="luckysheet-icon-morebtn" role="button" style="user-select: none;">
<div class="luckysheet-toolbar-button-outer-box luckysheet-inline-block" style="user-select: none;">
<div class="luckysheet-toolbar-button-inner-box luckysheet-inline-block" style="user-select: none;">
@ -95,7 +100,6 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) {
</div>
</div>
</div>`,
// morediv = '<div id="luckysheet-icon-morebtn-div" class="luckysheet-wa-editor" style="position:absolute;top:'+ (Store.infobarHeight + Store.toolbarHeight + 3 + $("#" + Store.container).offset().top + $("body").scrollTop() - $("#luckysheet-functionbox-container").height() ) +'px; right:0px;z-index:1003;padding:8px;display:none;height:auto;white-space:initial;"></div>';
morediv = '<div id="luckysheet-icon-morebtn-div" class="luckysheet-wa-editor" style="position:absolute;top:'+ (Store.infobarHeight + Store.toolbarHeight + $("#" + Store.container).offset().top + $("body").scrollTop()) +'px; right:0px;z-index:1003;padding:5.5px;display:none;height:auto;white-space:initial;"></div>';
if($("#luckysheet-icon-morebtn-div").length == 0){
@ -113,25 +117,8 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) {
$container.appendChild($t);
});
// $("#luckysheet-wa-editor > div").trigger("create");
// $("#luckysheet-icon-morebtn-div > div").trigger("create");
$("#luckysheet-icon-morebtn").remove();
//计算前面按钮宽度加起来总和,超过 容器宽度-更多按钮,则剩下的按钮移动到展开的容器内,这种方式计算宽度不准确,且会导致下拉箭头和主按钮分离的情况,改为 计算left作为宽度依据,和容器宽度比较的方式
// $("#luckysheet-wa-editor > div").each(function(){
// let $t = $(this);
// // toolbarW += $t.outerWidth();
// toolbarW += $t.outerWidth();
// if(!ismore && toolbarW > gridW - 140){
// ismore = true;
// }
// if(ismore){
// $("#luckysheet-icon-morebtn-div").append($(this));
// }
// });
// 所有按钮宽度与元素定位
const toobarWidths = Store.toobarObject.toobarWidths;
const toobarElements = Store.toobarObject.toobarElements;
@ -230,6 +217,17 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) {
$(this).prev(".luckysheet-toolbar-button-split-left").removeClass("luckysheet-toolbar-button-hover");
});
// When adding elements to the luckysheet-icon-morebtn-div element of the toolbar, it will affect the height of the entire workbook area, so the height is obtained here
gridH = $("#" + Store.container).height();
$("#" + Store.container).find(".luckysheet").height(gridH - 2).width(gridW - 2);
changeSheetContainerSize(gridW, gridH)
if(isRefreshCanvas){
luckysheetrefreshgrid($("#luckysheet-cell-main").scrollLeft(), $("#luckysheet-cell-main").scrollTop());
}
sheetmanage.sheetArrowShowAndHide();
sheetmanage.sheetBarShowAndHide();
}
@ -243,14 +241,14 @@ export function changeSheetContainerSize(gridW, gridH){
if(gridH==null){
gridH = $("#" + Store.container).height();
}
Store.cellmainHeight = gridH - (Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columeHeaderHeight + Store.sheetBarHeight + Store.statisticBarHeight);
Store.cellmainHeight = gridH - (Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight + Store.sheetBarHeight + Store.statisticBarHeight);
Store.cellmainWidth = gridW - Store.rowHeaderWidth;
$("#luckysheet-cols-h-c, #luckysheet-cell-main").width(Store.cellmainWidth);
$("#luckysheet-cell-main").height(Store.cellmainHeight);
$("#luckysheet-rows-h").height(Store.cellmainHeight - Store.cellMainSrollBarSize);
$("#luckysheet-scrollbar-y").height(Store.cellmainHeight + Store.columeHeaderHeight - Store.cellMainSrollBarSize - 3);
$("#luckysheet-scrollbar-y").height(Store.cellmainHeight + Store.columnHeaderHeight - Store.cellMainSrollBarSize - 3);
$("#luckysheet-scrollbar-x").height(Store.cellMainSrollBarSize);
$("#luckysheet-scrollbar-y").width(Store.cellMainSrollBarSize);
@ -258,7 +256,7 @@ export function changeSheetContainerSize(gridW, gridH){
Store.luckysheetTableContentHW = [
Store.cellmainWidth + Store.rowHeaderWidth - Store.cellMainSrollBarSize,
Store.cellmainHeight + Store.columeHeaderHeight - Store.cellMainSrollBarSize
Store.cellmainHeight + Store.columnHeaderHeight - Store.cellMainSrollBarSize
];
$("#luckysheetTableContent, #luckysheetTableContentF").attr({
@ -289,87 +287,410 @@ export function changeSheetContainerSize(gridW, gridH){
}
/**
* 统计工具栏各个按钮宽度值,用于计算哪些需要放到 更多按钮里
*
* 注意每增加一个工具栏按钮都要在toobarWidths和toobarElements这两个数组里加上按钮的统计数据
*
* Toolbar judgment rules: First set the display and hide of all tool buttons according to showtoolbar, and then override the judgment of showtoolbar according to showtoolbarConfig rules
*
* The width value of each button in the statistics toolbar is used to calculate which needs to be placed in more buttons
*/
export function menuToolBarWidth() {
const toobarObject = Store.toobarObject;
toobarObject.toobarWidths= [
$('#luckysheet-icon-undo').offset().left,
$('#luckysheet-icon-redo').offset().left,
$('#luckysheet-icon-paintformat').offset().left,
$('#luckysheet-icon-currency').offset().left,
$('#luckysheet-icon-percent').offset().left,
$('#luckysheet-icon-fmt-decimal-decrease').offset().left,
$('#luckysheet-icon-fmt-decimal-increase').offset().left,
$('#luckysheet-icon-fmt-other').offset().left,
$('#luckysheet-icon-font-family').offset().left,
$('#luckysheet-icon-font-size').offset().left,
$('#luckysheet-icon-bold').offset().left,
$('#luckysheet-icon-italic').offset().left,
$('#luckysheet-icon-strikethrough').offset().left,
$('#luckysheet-icon-underline').offset().left,
$('#luckysheet-icon-text-color').offset().left,
$('#luckysheet-icon-cell-color').offset().left,
$('#luckysheet-icon-border-all').offset().left,
$('#luckysheet-icon-merge-button').offset().left,
$('#luckysheet-icon-align').offset().left,
$('#luckysheet-icon-valign').offset().left,
$('#luckysheet-icon-textwrap').offset().left,
$('#luckysheet-icon-rotation').offset().left,
$('#luckysheet-insertImg-btn-title').offset().left,
$('#luckysheet-chart-btn-title').offset().left,
$('#luckysheet-icon-postil').offset().left,
$('#luckysheet-pivot-btn-title').offset().left,
$('#luckysheet-icon-function').offset().left,
$('#luckysheet-freezen-btn-horizontal').offset().left,
$('#luckysheet-icon-autofilter').offset().left,
$('#luckysheet-icon-conditionformat').offset().left,
$('#luckysheet-dataVerification-btn-title').offset().left,
$('#luckysheet-splitColumn-btn-title').offset().left,
$('#luckysheet-chart-btn-screenshot').offset().left,
$('#luckysheet-icon-seachmore').offset().left,
$('#luckysheet-icon-protection').offset().left,
$('#luckysheet-icon-print').offset().left,
$('#luckysheet-icon-print').offset().left + $('#luckysheet-icon-protection').outerWidth() + 5,
];
toobarObject.toobarElements = [
'#luckysheet-icon-undo',
'#luckysheet-icon-redo',
['#luckysheet-icon-paintformat','#toolbar-separator-paint-format'],
'#luckysheet-icon-currency',
'#luckysheet-icon-percent',
'#luckysheet-icon-fmt-decimal-decrease',
'#luckysheet-icon-fmt-decimal-increase',
['#luckysheet-icon-fmt-other','#toolbar-separator-more-format'],
['#luckysheet-icon-font-family','#toolbar-separator-font-family'],
['#luckysheet-icon-font-size','#toolbar-separator-font-size'],
'#luckysheet-icon-bold',
'#luckysheet-icon-italic',
'#luckysheet-icon-strikethrough',
'#luckysheet-icon-underline',
['#luckysheet-icon-text-color','#luckysheet-icon-text-color-menu','#toolbar-separator-text-color'],
['#luckysheet-icon-cell-color','#luckysheet-icon-cell-color-menu'],
['#luckysheet-icon-border-all','#luckysheet-icon-border-menu'],
['#luckysheet-icon-merge-button','#luckysheet-icon-merge-menu','#toolbar-separator-merge-cell'],
['#luckysheet-icon-align','#luckysheet-icon-align-menu'],
['#luckysheet-icon-valign','#luckysheet-icon-valign-menu'],
['#luckysheet-icon-textwrap','#luckysheet-icon-textwrap-menu'],
['#luckysheet-icon-rotation','#luckysheet-icon-rotation-menu','#toolbar-separator-text-rotate'],
'#luckysheet-insertImg-btn-title',
'#luckysheet-chart-btn-title',
'#luckysheet-icon-postil',
['#luckysheet-pivot-btn-title','#toolbar-separator-pivot-table'],
['#luckysheet-icon-function','#luckysheet-icon-function-menu'],
['#luckysheet-freezen-btn-horizontal','#luckysheet-icon-freezen-menu'],
'#luckysheet-icon-autofilter',
'#luckysheet-icon-conditionformat',
'#luckysheet-dataVerification-btn-title',
'#luckysheet-splitColumn-btn-title',
'#luckysheet-chart-btn-screenshot',
'#luckysheet-icon-seachmore',
'#luckysheet-icon-protection',
'#luckysheet-icon-print',
]
const showtoolbar = luckysheetConfigsetting.showtoolbar;
const showtoolbarConfig = luckysheetConfigsetting.showtoolbarConfig;
const toobarWidths = Store.toobarObject.toobarWidths = [];
const toobarElements = Store.toobarObject.toobarElements = [];
const toobarConfig = Store.toobarObject.toobarConfig = {
undo: {
ele:'#luckysheet-icon-undo',
index:0,
}, //Undo redo
redo: {
ele:'#luckysheet-icon-redo',
index:1,
},
paintFormat: {
ele:['#luckysheet-icon-paintformat','#toolbar-separator-paint-format'],
index:2,
}, //Format brush
currencyFormat: {
ele:'#luckysheet-icon-currency',
index:3,
}, //currency format
percentageFormat: {
ele:'#luckysheet-icon-percent',
index:4,
}, //Percentage format
numberDecrease: {
ele:'#luckysheet-icon-fmt-decimal-decrease',
index:5,
}, //'Decrease the number of decimal places'
numberIncrease: {
ele:'#luckysheet-icon-fmt-decimal-increase',
index:6,
}, //'Increase the number of decimal places
moreFormats: {
ele:['#luckysheet-icon-fmt-other','#toolbar-separator-more-format'],
index:7,
}, //'More Formats'
font: {
ele:['#luckysheet-icon-font-family','#toolbar-separator-font-family'],
index:8,
}, //'font'
fontSize: {
ele:['#luckysheet-icon-font-size','#toolbar-separator-font-size'],
index:9,
}, //'Font size'
bold: {
ele:'#luckysheet-icon-bold',
index:10,
}, //'Bold (Ctrl+B)'
italic: {
ele:'#luckysheet-icon-italic',
index:11,
}, //'Italic (Ctrl+I)'
strikethrough: {
ele:'#luckysheet-icon-strikethrough',
index:12,
}, //'Strikethrough (Alt+Shift+5)'
underline: {
ele:'#luckysheet-icon-underline',
index:13,
}, //'Strikethrough (Alt+Shift+6)'
textColor: {
ele:['#luckysheet-icon-text-color','#luckysheet-icon-text-color-menu','#toolbar-separator-text-color'],
index:14,
}, //'Text color'
fillColor: {
ele:['#luckysheet-icon-cell-color','#luckysheet-icon-cell-color-menu'],
index:15,
}, //'Cell color'
border: {
ele:['#luckysheet-icon-border-all','#luckysheet-icon-border-menu'],
index:16,
}, //'border'
mergeCell: {
ele:['#luckysheet-icon-merge-button','#luckysheet-icon-merge-menu','#toolbar-separator-merge-cell'],
index:17,
}, //'Merge cells'
horizontalAlignMode: {
ele:['#luckysheet-icon-align','#luckysheet-icon-align-menu'],
index:18,
}, //'Horizontal alignment'
verticalAlignMode: {
ele:['#luckysheet-icon-valign','#luckysheet-icon-valign-menu'],
index:19,
}, //'Vertical alignment'
textWrapMode: {
ele:['#luckysheet-icon-textwrap','#luckysheet-icon-textwrap-menu'],
index:20,
}, //'Wrap mode'
textRotateMode: {
ele:['#luckysheet-icon-rotation','#luckysheet-icon-rotation-menu','#toolbar-separator-text-rotate'],
index:21,
}, //'Text Rotation Mode'
image:{
ele:'#luckysheet-insertImg-btn-title',
index:22,
}, //'Insert link'
link:{
ele:'#luckysheet-insertLink-btn-title',
index:23,
}, //'Insert picture'
chart: {
ele:'#luckysheet-chart-btn-title',
index:24,
}, //'chart' (the icon is hidden, but if the chart plugin is configured, you can still create a new chart by right click)
postil: {
ele:'#luckysheet-icon-postil',
index:25,
}, //'comment'
pivotTable: {
ele:['#luckysheet-pivot-btn-title','#toolbar-separator-pivot-table'],
index:26,
}, //'PivotTable'
function: {
ele:['#luckysheet-icon-function','#luckysheet-icon-function-menu'],
index:27,
}, //'formula'
frozenMode: {
ele:['#luckysheet-freezen-btn-horizontal','#luckysheet-icon-freezen-menu'],
index:28,
}, //'freeze mode'
sortAndFilter: {
ele:'#luckysheet-icon-autofilter',
index:29,
}, //'sort and filter'
conditionalFormat: {
ele:'#luckysheet-icon-conditionformat',
index:30,
}, //'Conditional Format'
dataVerification: {
ele:'#luckysheet-dataVerification-btn-title',
index:31,
}, // 'Data Verification'
splitColumn: {
ele:'#luckysheet-splitColumn-btn-title',
index:32,
}, //'Split column'
screenshot: {
ele:'#luckysheet-chart-btn-screenshot',
index:33,
}, //'screenshot'
findAndReplace: {
ele:'#luckysheet-icon-seachmore',
index:34,
}, //'Find and Replace'
protection:{
ele:'#luckysheet-icon-protection',
index:35,
}, // 'Worksheet protection'
print:{
ele:'#luckysheet-icon-print',
index:36,
}, // 'print'
};
const config = {
undo: true, //Undo
redo: true, //Redo
paintFormat: true, //Format brush
currencyFormat: true, //currency format
percentageFormat: true, //Percentage format
numberDecrease: true, //'Decrease the number of decimal places'
numberIncrease: true, //'Increase the number of decimal places
moreFormats: true, //'More Formats'
font: true, //'font'
fontSize: true, //'Font size'
bold: true, //'Bold (Ctrl+B)'
italic: true, //'Italic (Ctrl+I)'
strikethrough: true, //'Strikethrough (Alt+Shift+5)'
textColor: true, //'Text color'
fillColor: true, //'Cell color'
border: true, //'border'
mergeCell: true, //'Merge cells'
horizontalAlignMode: true, //'Horizontal alignment'
verticalAlignMode: true, //'Vertical alignment'
textWrapMode: true, //'Wrap mode'
textRotateMode: true, //'Text Rotation Mode'
image:true, // 'Insert picture'
chart: true, //'chart' (the icon is hidden, but if the chart plugin is configured, you can still create a new chart by right click)
postil:true, //'comment'
pivotTable: true, //'PivotTable'
function: true, //'formula'
frozenMode: true, //'freeze mode'
sortAndFilter: true, //'Sort and filter'
conditionalFormat: true, //'Conditional Format'
dataVerification: true, // 'Data Verification'
splitColumn: true, //'Split column'
screenshot: true, //'screenshot'
findAndReplace: true, //'Find and Replace'
protection: true, // 'Worksheet protection'
print: true, // 'print'
// link: true, // 'Insert link'(TODO)
}
// false means all false
if(!showtoolbar){
for(let s in config){
config[s] = false;
}
}
// showtoolbarConfig determines the final result
if(JSON.stringify(showtoolbarConfig) !== '{}'){
if(showtoolbarConfig.hasOwnProperty('undoRedo')){
config.undo = config.redo = showtoolbarConfig.undoRedo;
delete showtoolbarConfig.undoRedo;
}
Object.assign(config,showtoolbarConfig);
}
// 1. The button set to false, remove the dom
// 2. Build toobarWidths and toobarElements
for(let s in config){
if(config[s]){
toobarElements.push($.extend(true,{},toobarConfig[s]));
}else{
if(toobarConfig[s].ele instanceof Array){
for(const item of toobarConfig[s].ele){
$(item).remove();
}
}else{
$(toobarConfig[s].ele).remove();
}
}
}
toobarElements.sort(sortToolbar);
function sortToolbar(a,b) {
if(a.index > b.index){
return 1;
}else{
return -1;
}
}
toobarElements.forEach((curr,index,arr)=>{
arr[index] = curr.ele;
if(index !== toobarElements.length - 1){
if(curr.ele instanceof Array){
toobarWidths.push($(curr.ele[0]).offset().left);
}else{
toobarWidths.push($(curr.ele).offset().left);
}
}else{
if(curr.ele instanceof Array){
toobarWidths.push($(curr.ele[0]).offset().left);
toobarWidths.push($(curr.ele[0]).offset().left + $(curr.ele[0]).outerWidth() + 5);
}else{
toobarWidths.push($(curr.ele).offset().left);
toobarWidths.push($(curr.ele).offset().left + $(curr.ele).outerWidth() + 5);
}
}
});
}
/**
*Custom configuration bottom sheet button
*/
function customSheetbarConfig() {
if(!luckysheetConfigsetting.initShowsheetbarConfig){
luckysheetConfigsetting.initShowsheetbarConfig = true;
const config = {
add: true, //Add worksheet
menu: true, //Worksheet management menu
sheet: true //Worksheet display
}
if(!luckysheetConfigsetting.showsheetbar){
for(let s in config){
config[s] = false;
}
}
// showsheetbarConfig determines the final result
if(JSON.stringify(luckysheetConfigsetting.showsheetbarConfig) !== '{}'){
Object.assign(config,luckysheetConfigsetting.showsheetbarConfig);
}
luckysheetConfigsetting.showsheetbarConfig = config;
}
const config = luckysheetConfigsetting.showsheetbarConfig;
let isHide = 0;
for (let s in config) {
if(!config[s]){
switch (s) {
case 'add':
$('#luckysheet-sheets-add').hide();
isHide++;
break;
case 'menu':
$('#luckysheet-sheets-m').hide();
isHide++;
break;
case 'sheet':
$('#luckysheet-sheet-container').hide();
$('#luckysheet-sheets-leftscroll').hide();
$('#luckysheet-sheets-rightscroll').hide();
isHide++;
break;
default:
break;
}
}
}
if (isHide === 3) {
$("#" + Store.container).find("#luckysheet-sheet-area").hide();
Store.sheetBarHeight = 0;
}
else {
$("#" + Store.container).find("#luckysheet-sheet-area").show();
Store.sheetBarHeight = 31;
}
}
/**
* Customize the bottom count bar
*/
function customStatisticBarConfig() {
if(!luckysheetConfigsetting.initStatisticBarConfig){
luckysheetConfigsetting.initStatisticBarConfig = true;
const config = {
count: true, // Count bar
view: true, // print view
zoom: true // Zoom
}
if(!luckysheetConfigsetting.showstatisticBar){
for(let s in config){
config[s] = false;
}
}
// showstatisticBarConfig determines the final result
if(JSON.stringify(luckysheetConfigsetting.showstatisticBarConfig) !== '{}'){
Object.assign(config,luckysheetConfigsetting.showstatisticBarConfig);
}
luckysheetConfigsetting.showstatisticBarConfig = config;
}
const config = luckysheetConfigsetting.showstatisticBarConfig;
let isHide = 0;
for (let s in config) {
if(!config[s]){
switch (s) {
case 'count':
$('#luckysheet-sta-content').hide();
isHide++;
break;
case 'view':
$('.luckysheet-print-viewList').hide();
isHide++;
break;
case 'zoom':
$('#luckysheet-zoom-content').hide();
isHide++;
break;
default:
break;
}
}
}
if (isHide === 3) {
$("#" + Store.container).find(".luckysheet-stat-area").hide();
Store.statisticBarHeight = 0;
}
else {
$("#" + Store.container).find(".luckysheet-stat-area").show();
Store.statisticBarHeight = 23;
}
}

1012
src/controllers/rowColumnOperation.js

File diff suppressed because it is too large

9
src/controllers/sheetBar.js

@ -15,7 +15,7 @@ import tooltip from '../global/tooltip';
import {selectTextDom} from '../global/cursorPos';
import locale from '../locale/locale';
import Store from '../store';
import luckysheetConfigsetting from './luckysheetConfigsetting';
@ -109,6 +109,13 @@ function showsheetconfigmenu() {
}
$("#luckysheetsheetconfigcolorur").parent().find("span, div, button, input, a").addClass("luckysheet-mousedown-cancel");
// 如果全部按钮设置了隐藏,则不显示
const config = luckysheetConfigsetting.sheetRightClickConfig;
if(!config.delete && !config.copy && !config.rename && !config.color && !config.hide && !config.move){
return;
}
setTimeout(function(){
mouseclickposition($("#luckysheet-rightclick-sheet-menu"), luckysheetcurrentSheetitem.offset().left + luckysheetcurrentSheetitem.width(), luckysheetcurrentSheetitem.offset().top - 18, "leftbottom");
},1);

42
src/controllers/sheetmanage.js

@ -19,6 +19,7 @@ import luckysheetsizeauto from './resize';
import luckysheetPostil from './postil';
import imageCtrl from './imageCtrl';
import dataVerificationCtrl from './dataVerificationCtrl';
import hyperlinkCtrl from './hyperlinkCtrl';
import luckysheetFreezen from './freezen';
import { createFilterOptions, labelFilterOptionState } from './filter';
import { selectHightlightShow, selectionCopyShow } from './select';
@ -28,6 +29,7 @@ import { renderChartShow } from '../expendPlugins/chart/plugin';
import {changeSheetContainerSize, menuToolBarWidth} from './resize';
import {zoomNumberDomBind} from './zoom';
import menuButton from './menuButton';
import method from '../global/method';
const sheetmanage = {
generateRandomSheetIndex: function(prefix) {
@ -314,6 +316,24 @@ const sheetmanage = {
});
server.saveParam("shr", null, orders);
Store.luckysheetfile.sort((x, y) => {
let order_x = x.order;
let order_y = y.order;
if(order_x != null && order_y != null){
return order_x - order_y;
}
else if(order_x != null){
return -1;
}
else if(order_y != null){
return 1;
}
else{
return 1;
}
})
},
createSheet: function() { //修复拖动sheet更新后台后,重新打开显示错误
let _this = this;
@ -372,8 +392,11 @@ const sheetmanage = {
$c.scrollLeft(scrollLeftpx - 10);
if (c_width >= winW * 0.7) {
$("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block");
$("#luckysheet-sheet-container .docs-sheet-fade-left").show();
if(luckysheetConfigsetting.showsheetbarConfig.sheet){
$("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block");
$("#luckysheet-sheet-container .docs-sheet-fade-left").show();
}
}
}, 1)
},
@ -701,7 +724,7 @@ const sheetmanage = {
Store.luckysheetTableContentHW = [
$("#luckysheet-cell-main").width() + Store.rowHeaderWidth - Store.cellMainSrollBarSize,
$("#luckysheet-cell-main").height() + Store.columeHeaderHeight - Store.cellMainSrollBarSize
$("#luckysheet-cell-main").height() + Store.columnHeaderHeight - Store.cellMainSrollBarSize
];
$("#luckysheetTableContent, #luckysheetTableContentF").attr({
width: Math.ceil(Store.luckysheetTableContentHW[0] * Store.devicePixelRatio),
@ -912,6 +935,10 @@ const sheetmanage = {
//数据验证
dataVerificationCtrl.dataVerification = file.dataVerification;
dataVerificationCtrl.init();
//链接
hyperlinkCtrl.hyperlink = file.hyperlink;
hyperlinkCtrl.init();
createFilterOptions(file["filter_select"], file["filter"]);
},
@ -1314,7 +1341,7 @@ const sheetmanage = {
$("#luckysheet-cols-h-cells_0").css("width", Store.ch_width); //width更新
$("#luckysheet-scrollbar-x div").width(Store.ch_width);
$("#luckysheet-scrollbar-y div").height(Store.rh_height + Store.columeHeaderHeight - Store.cellMainSrollBarSize - 3);
$("#luckysheet-scrollbar-y div").height(Store.rh_height + Store.columnHeaderHeight - Store.cellMainSrollBarSize - 3);
//等待滚动条dom宽高计算完成后 初始化该表格滚动位置
let index = this.getSheetIndex(Store.currentSheetIndex);
@ -1391,8 +1418,11 @@ const sheetmanage = {
});
if (c_width >= containerW) {
$("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block");
$("#luckysheet-sheet-container .docs-sheet-fade-left").show();
if(luckysheetConfigsetting.showsheetbarConfig.sheet){
$("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block");
$("#luckysheet-sheet-container .docs-sheet-fade-left").show();
}
}
else{
$("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "none");

49
src/controllers/updateCell.js

@ -17,7 +17,6 @@ import {isInlineStringCell} from './inlineString';
import Store from '../store';
export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocus) {
if(!checkProtectionLocked(row_index1, col_index1, Store.currentSheetIndex)){
$("#luckysheet-functionbox-cell").blur();
return;
@ -27,8 +26,6 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
return;
}
//数据验证
if(dataVerificationCtrl.dataVerification != null && dataVerificationCtrl.dataVerification[row_index1 + '_' + col_index1] != null){
let dataVerificationItem = dataVerificationCtrl.dataVerification[row_index1 + '_' + col_index1];
@ -41,7 +38,12 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
}
let size = getColumnAndRowSize(row_index1, col_index1, d);
let row = size.row, row_pre = size.row_pre, col = size.col, col_pre = size.col_pre, row_index = size.row_index, col_index = size.col_index;
let row = size.row,
row_pre = size.row_pre,
col = size.col,
col_pre = size.col_pre,
row_index = size.row_index,
col_index = size.col_index;
if($("#luckysheet-dropCell-icon").is(":visible")){
$("#luckysheet-dropCell-icon").remove();
@ -56,14 +58,24 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
return;
}
let left = col_pre + container_offset.left + Store.rowHeaderWidth - scrollLeft - 2;
if(luckysheetFreezen.freezenverticaldata != null && col_index1 <= luckysheetFreezen.freezenverticaldata[1]){
left = col_pre + container_offset.left + Store.rowHeaderWidth - 2;
}
let top = row_pre + container_offset.top + Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight - scrollTop - 2;
if(luckysheetFreezen.freezenhorizontaldata != null && row_index1 <= luckysheetFreezen.freezenhorizontaldata[1]){
top = row_pre + container_offset.top + Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight - 2;
}
let input_postition = {
"min-width": col - col_pre+ 1- 8,
"min-height": row - row_pre + 1- 4,
"max-width":winW + scrollLeft - col_pre - 20 - Store.rowHeaderWidth,
"max-width": winW + scrollLeft - col_pre - 20 - Store.rowHeaderWidth,
"max-height": winH + scrollTop - row_pre - 20 - 15 - Store.toolbarHeight - Store.infobarHeight - Store.calculatebarHeight - Store.sheetBarHeight - Store.statisticBarHeight,
"left": col_pre + container_offset.left + Store.rowHeaderWidth - scrollLeft - 2,
"top": row_pre + container_offset.top + Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columeHeaderHeight - scrollTop - 2,
"left": left,
"top": top,
}
let inputContentScale = {
@ -110,7 +122,7 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
"max-width": winW*2/3,
"max-height": winH + scrollTop - row_pre - 20 - 15 - Store.toolbarHeight - Store.infobarHeight - Store.calculatebarHeight - Store.sheetBarHeight - Store.statisticBarHeight,
"left": col_pre + container_offset.left + Store.rowHeaderWidth - scrollLeft - 2,
"top": row_pre + container_offset.top + Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columeHeaderHeight - scrollTop - 2,
"top": row_pre + container_offset.top + Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight - scrollTop - 2,
}
if(Store.zoomRatio<1){
@ -128,7 +140,7 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
"max-width": col + container_offset.left - scrollLeft - 8,
"max-height": winH + scrollTop - row_pre - 20 - 15 - Store.toolbarHeight - Store.infobarHeight - Store.calculatebarHeight - Store.sheetBarHeight - Store.statisticBarHeight,
"right": winW - (container_offset.left + (Store.rowHeaderWidth-1) - scrollLeft) - col,
"top": row_pre + container_offset.top + Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columeHeaderHeight - scrollTop - 2,
"top": row_pre + container_offset.top + Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight - scrollTop - 2,
}
if(Store.zoomRatio<1){
@ -193,8 +205,6 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
if(input_postition["min-width"] > input_postition["max-width"]){
input_postition["min-width"] = input_postition["max-width"];
}
if((value == null || value.toString() == "") && !cover){
value = "<br/>";
@ -242,7 +252,6 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
cleargridelement();
}
export function setCenterInputPosition(row_index, col_index, d){
if(row_index==null ||col_index==null){
return;
@ -294,9 +303,11 @@ export function getColumnAndRowSize(row_index, col_index, d){
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1];
let col = Store.visibledatacolumn[col_index],
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1];
if(d==null){
if(d == null){
d = Store.flowdata;
}
let margeset = menuButton.mergeborer(d, row_index, col_index);
if(!!margeset){
row = margeset.row[1];
@ -308,11 +319,11 @@ export function getColumnAndRowSize(row_index, col_index, d){
}
return {
row:row,
row_pre:row_pre,
row_index:row_index,
col:col,
col_pre:col_pre,
col_index:col_index
row: row,
row_pre: row_pre,
row_index: row_index,
col: col,
col_pre: col_pre,
col_index: col_index
}
}

23
src/core.js

@ -47,6 +47,15 @@ luckysheet = common_extend(api,luckysheet);
//创建luckysheet表格
luckysheet.create = function (setting) {
// Store original parameters for api: toJson
Store.toJsonOptions = {}
for(let c in setting){
if(c !== 'data'){
Store.toJsonOptions[c] = setting[c];
}
}
let extendsetting = common_extend(defaultSetting, setting);
let loadurl = extendsetting.loadUrl,
@ -62,7 +71,6 @@ luckysheet.create = function (setting) {
Store.lang = extendsetting.lang; //language
Store.allowEdit = extendsetting.allowEdit;
Store.fontList = extendsetting.fontList;
Store.defaultFontSize = extendsetting.defaultFontSize;
server.gridKey = extendsetting.gridKey;
server.loadUrl = extendsetting.loadUrl;
server.updateUrl = extendsetting.updateUrl;
@ -77,9 +85,15 @@ luckysheet.create = function (setting) {
luckysheetConfigsetting.allowCopy = extendsetting.allowCopy;
luckysheetConfigsetting.showtoolbar = extendsetting.showtoolbar;
luckysheetConfigsetting.showtoolbarConfig = extendsetting.showtoolbarConfig;
luckysheetConfigsetting.showinfobar = extendsetting.showinfobar;
luckysheetConfigsetting.showsheetbar = extendsetting.showsheetbar;
luckysheetConfigsetting.showsheetbarConfig = extendsetting.showsheetbarConfig;
luckysheetConfigsetting.showstatisticBar = extendsetting.showstatisticBar;
luckysheetConfigsetting.showstatisticBarConfig = extendsetting.showstatisticBarConfig;
luckysheetConfigsetting.sheetFormulaBar = extendsetting.sheetFormulaBar;
luckysheetConfigsetting.cellRightClickConfig = extendsetting.cellRightClickConfig;
luckysheetConfigsetting.sheetRightClickConfig = extendsetting.sheetRightClickConfig;
luckysheetConfigsetting.pointEdit = extendsetting.pointEdit;
luckysheetConfigsetting.pointEditUpdate = extendsetting.pointEditUpdate;
luckysheetConfigsetting.pointEditZoom = extendsetting.pointEditZoom;
@ -91,7 +105,7 @@ luckysheet.create = function (setting) {
luckysheetConfigsetting.showConfigWindowResize = extendsetting.showConfigWindowResize;
luckysheetConfigsetting.enableAddRow = extendsetting.enableAddRow;
luckysheetConfigsetting.enableAddCol = extendsetting.enableAddCol;
luckysheetConfigsetting.enableAddBackTop = extendsetting.enableAddBackTop;
luckysheetConfigsetting.enablePage = extendsetting.enablePage;
luckysheetConfigsetting.pageInfo = extendsetting.pageInfo;
@ -105,15 +119,14 @@ luckysheet.create = function (setting) {
luckysheetConfigsetting.plugins = extendsetting.plugins;
luckysheetConfigsetting.rowHeaderWidth = extendsetting.rowHeaderWidth;
Store.rowHeaderWidth = extendsetting.rowHeaderWidth;
luckysheetConfigsetting.columeHeaderHeight = extendsetting.columeHeaderHeight;
Store.columeHeaderHeight = extendsetting.columeHeaderHeight;
luckysheetConfigsetting.columnHeaderHeight = extendsetting.columnHeaderHeight;
luckysheetConfigsetting.defaultColWidth = extendsetting.defaultColWidth;
luckysheetConfigsetting.defaultRowHeight = extendsetting.defaultRowHeight;
luckysheetConfigsetting.title = extendsetting.title;
luckysheetConfigsetting.container = extendsetting.container;
luckysheetConfigsetting.hook = extendsetting.hook;
// Register plugins
initPlugins(extendsetting.plugins , extendsetting.data);

43
src/css/luckysheet-core.css

@ -979,9 +979,9 @@
}
.luckysheet-sta-c .luckysheet-sta-content {
position: absolute;
left: 0px;
right: 358px;
/* position: absolute; */
/* left: 0px; */
/* right: 358px; */
height: 22px;
line-height: 22px;
text-align: right;
@ -1055,7 +1055,8 @@ div.luckysheet-sheets-m:hover {
top: 0;
width: 6px;
height: 100%;
z-index: 1005;
/* z-index: 1005; */
z-index: 1;/*因为会覆盖右击菜单,改为1*/
}
.docs-sheet-fade div {
@ -7065,6 +7066,40 @@ fieldset[disabled] .btn-danger.focus {
position: absolute;
display: none;
}
/* 插入链接 */
#luckysheet-insertLink-dialog{
user-select: none;
}
#luckysheet-insertLink-dialog .box{
font-size: 12px;
}
#luckysheet-insertLink-dialog .box-item{
height: 30px;
line-height: 30px;
margin-bottom: 10px;
}
#luckysheet-insertLink-dialog .box-item label{
display: inline-block;
width: 80px;
text-align: right;
margin-right: 10px;
}
#luckysheet-insertLink-dialog .box-item input{
width: 200px;
height: 30px;
padding: 0 10px;
border: 1px solid #d4d4d4;
outline-style: none;
box-sizing: border-box;
}
#luckysheet-insertLink-dialog .box-item select{
width: 200px;
height: 30px;
padding: 0 5px;
border: 1px solid #d4d4d4;
outline-style: none;
box-sizing: border-box;
}
/* 数据验证 */
#luckysheet-dataVerification-dialog{
user-select: none;

5
src/css/luckysheet-print.css

@ -1,7 +1,8 @@
.luckysheet-print-viewList{
position: absolute;
position: relative;
float: right;
width:126px;
right: 222px;
/* right: 222px; */
height: 22px;
line-height: 22px;
text-align: center;

5
src/css/luckysheet-zoom.css

@ -1,7 +1,8 @@
.luckysheet-zoom-content{
position: absolute;
position: relative;
float: right;
width:210px;
right: 0px;
/* right: 0px; */
height: 22px;
line-height: 22px;
text-align: right;

65
src/global/api.js

@ -323,10 +323,32 @@ export function setCellFormat(row, column, attr, value, options = {}) {
// 特殊格式
if (attr == 'ct' && (!value || !value.hasOwnProperty('fa') || !value.hasOwnProperty('t'))) {
return new TypeError('While set attribute \'ct\' to cell, the value must have property \'fa\' and \'t\'')
cellData.m = update(value.fa, cellData.v)
}
cellData[attr] = value;
if (attr == 'bd') {
let cfg = $.extend(true, {}, Store.config);
if(cfg["borderInfo"] == null){
cfg["borderInfo"] = [];
}
let borderInfo = {
rangeType: "range",
borderType: "border-all",
color: "#000",
style: "1",
range: [{
column: [column, column],
row: [row, row]
}],
...value,
}
cfg["borderInfo"].push(borderInfo);
Store.config = cfg;
} else {
cellData[attr] = value;
}
// refresh
jfrefreshgrid(targetSheetData, {
row: [row],
@ -470,7 +492,7 @@ export function frozenFirstRow(order) {
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [
Store.visibledatarow[row_st],
row_st + 1,
@ -571,7 +593,7 @@ export function frozenRowRange(range, order) {
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [
Store.visibledatarow[row_st],
row_st + 1,
@ -769,7 +791,7 @@ export function setBothFrozen(isRange, options = {}) {
if(row_st == -1){
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [
Store.visibledatarow[row_st],
row_st + 1,
@ -837,7 +859,7 @@ export function setBothFrozen(isRange, options = {}) {
row_st = 0;
}
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [
Store.visibledatarow[row_st],
row_st + 1,
@ -901,6 +923,8 @@ export function insertRowOrColumn(type, index = 0, options = {}) {
success
} = {...options}
let _locale = locale();
let locale_info = _locale.info;
if (!isRealNum(number)) {
if(isEditMode()){
alert(locale_info.tipInputNumber);
@ -4709,6 +4733,9 @@ export function setSheetActive(order, options = {}) {
success
} = {...options}
$("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active");
$("#luckysheet-sheets-item" + file.index).addClass("luckysheet-sheets-item-active");
sheetmanage.changeSheet(file.index);
setTimeout(() => {
@ -5370,6 +5397,8 @@ export function getAllSheets() {
}
delete item.load;
delete item.freezen;
})
return data;
@ -5841,3 +5870,27 @@ export function transToData(celldata, options = {}){
celldata: celldata
})
}
/**
* 导出的json字符串可以直接当作`luckysheet.create(options)`初始化工作簿时的参数`options`使用
*
*/
export function toJson(){
const toJsonOptions = Store.toJsonOptions;
// Workbook name
toJsonOptions.title = $("#luckysheet_info_detail_input").val();
toJsonOptions.data = getAllSheets();
// row and column
getluckysheetfile().forEach((file,index)=>{
toJsonOptions.data[index].row = file.data.length;
toJsonOptions.data[index].column = file.data[0].length;
})
return toJsonOptions;
}

41
src/global/border.js

@ -3,7 +3,7 @@ import { getObjType } from '../utils/util';
import Store from '../store';
//获取表格边框数据计算值
function getBorderInfoCompute(sheetIndex) {
function getBorderInfoComputeRange(dataset_row_st,dataset_row_ed,dataset_col_st,dataset_col_ed,sheetIndex) {
let borderInfoCompute = {};
let cfg, data;
@ -33,6 +33,22 @@ function getBorderInfoCompute(sheetIndex) {
let bd_r1 = borderRange[j].row[0], bd_r2 = borderRange[j].row[1];
let bd_c1 = borderRange[j].column[0], bd_c2 = borderRange[j].column[1];
if(bd_r1<dataset_row_st){
bd_r1 = dataset_row_st;
}
if(bd_r2>dataset_row_ed){
bd_r2 = dataset_row_ed;
}
if(bd_c1<dataset_col_st){
bd_c1 = dataset_col_st;
}
if(bd_c2>dataset_col_ed){
bd_c2 = dataset_col_ed;
}
if(borderType == "border-left"){
for(let bd_r = bd_r1; bd_r <= bd_r2; bd_r++){
if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r] != null) {
@ -812,6 +828,10 @@ function getBorderInfoCompute(sheetIndex) {
let bd_r = value.row_index, bd_c = value.col_index;
if(bd_r < dataset_row_st || bd_r > dataset_row_ed || bd_c < dataset_col_st || bd_c > dataset_col_ed){
continue;
}
if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r] != null) {
continue;
}
@ -1029,6 +1049,25 @@ function getBorderInfoCompute(sheetIndex) {
return borderInfoCompute;
}
function getBorderInfoCompute(sheetIndex) {
let borderInfoCompute = {};
let cfg, data;
if(sheetIndex == null){
cfg = Store.config;
data = Store.flowdata;
}
else{
cfg = Store.luckysheetfile[getSheetIndex(sheetIndex)].config;
data = Store.luckysheetfile[getSheetIndex(sheetIndex)].data;
}
getBorderInfoComputeRange(0, data.length,0, data[0].length, sheetIndex);
return borderInfoCompute;
}
export {
getBorderInfoCompute,
getBorderInfoComputeRange
}

10
src/global/createdom.js

@ -86,7 +86,9 @@ export default function luckysheetcreatedom(colwidth, rowheight, data, menu, tit
}
}
bottomControll += backControll;
if(luckysheetConfigsetting.enableAddBackTop){
bottomControll += backControll;
}
let flowstr = replaceHtml('<div id="luckysheetcoltable_0" class="luckysheet-cell-flow-col"> <div id ="luckysheet-sheettable_0" class="luckysheet-cell-sheettable" style="height:${height}px;width:${width}px;"></div><div id="luckysheet-bottom-controll-row" class="luckysheet-bottom-controll-row"> '+ bottomControll +' </div> </div>', { "height": Store.rh_height, "width": Store.ch_width - 1 });
@ -99,7 +101,7 @@ export default function luckysheetcreatedom(colwidth, rowheight, data, menu, tit
$("#" + Store.container).append(gh);
$("#luckysheet-scrollbar-x div").width(Store.ch_width);
$("#luckysheet-scrollbar-y div").height(Store.rh_height + Store.columeHeaderHeight - Store.cellMainSrollBarSize - 3);
$("#luckysheet-scrollbar-y div").height(Store.rh_height + Store.columnHeaderHeight - Store.cellMainSrollBarSize - 3);
//新建行菜单
$("body").append(maskHTML);
@ -111,8 +113,8 @@ export default function luckysheetcreatedom(colwidth, rowheight, data, menu, tit
$("body").append(sheetconfigHTML());
$("#luckysheet-rows-h").width((Store.rowHeaderWidth-1.5));
$("#luckysheet-cols-h-c").height((Store.columeHeaderHeight-1.5));
$("#luckysheet-left-top").css({width:Store.rowHeaderWidth-1.5, height:Store.columeHeaderHeight-1.5});
$("#luckysheet-cols-h-c").height((Store.columnHeaderHeight-1.5));
$("#luckysheet-left-top").css({width:Store.rowHeaderWidth-1.5, height:Store.columnHeaderHeight-1.5});
// //批注
// luckysheetPostil.buildAllPs(Store.flowdata);

181
src/global/draw.js

@ -11,12 +11,14 @@ import browser from './browser';
import { isRealNull, isRealNum } from './validate';
import { getCellTextSplitArr,getMeasureText,getCellTextInfo } from './getRowlen';
import { getcellvalue,getRealCellValue } from './getdata';
import { getBorderInfoCompute } from './border';
import { getBorderInfoComputeRange } from './border';
import { getSheetIndex } from '../methods/get';
import { getObjType, chatatABC, luckysheetfontformat } from '../utils/util';
import { isInlineStringCell } from '../controllers/inlineString';
import method from './method';
import Store from '../store';
import locale from '../locale/locale';
import sheetmanage from '../controllers/sheetmanage';
function luckysheetDrawgridRowTitle(scrollHeight, drawHeight, offsetTop) {
if (scrollHeight == null) {
@ -28,7 +30,7 @@ function luckysheetDrawgridRowTitle(scrollHeight, drawHeight, offsetTop) {
}
if (offsetTop == null) {
offsetTop = Store.columeHeaderHeight;
offsetTop = Store.columnHeaderHeight;
}
let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
@ -79,14 +81,21 @@ function luckysheetDrawgridRowTitle(scrollHeight, drawHeight, offsetTop) {
// if(end_r > scrollHeight + drawHeight){
// break;
// }
let firstOffset = (dataset_row_st==r)?-2:0;
let lastOffset = (dataset_row_ed==r)?-2:0;
//列标题单元格渲染前触发,return false 则不渲染该单元格
if(!method.createHookFunction("rowTitleCellRenderBefore", r+1, {
r:r,
top:(start_r + offsetTop + firstOffset),
width:Store.rowHeaderWidth -1,
height:(end_r - start_r + 1+lastOffset-firstOffset)
}, luckysheetTableContent)){ continue; }
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) {
}
else {
luckysheetTableContent.fillStyle = "#ffffff";
let firstOffset = (dataset_row_st==r)?-2:0;
let lastOffset = (dataset_row_ed==r)?-2:0;
luckysheetTableContent.fillRect(
0,
(start_r + offsetTop + firstOffset) ,
@ -174,6 +183,14 @@ function luckysheetDrawgridRowTitle(scrollHeight, drawHeight, offsetTop) {
preEndR = end_r;
//列标题单元格渲染前触发,return false 则不渲染该单元格
method.createHookFunction("rowTitleCellRenderAfter", r+1, {
r:r,
top:(start_r + offsetTop + firstOffset),
width:Store.rowHeaderWidth -1,
height:(end_r - start_r + 1+lastOffset-firstOffset)
}, luckysheetTableContent)
}
//行标题栏竖线
@ -193,7 +210,7 @@ function luckysheetDrawgridRowTitle(scrollHeight, drawHeight, offsetTop) {
//清除canvas左上角区域 防止列标题栏序列号溢出显示
// luckysheetTableContent.clearRect(0, 0, Store.rowHeaderWidth , Store.columeHeaderHeight );
// luckysheetTableContent.clearRect(0, 0, Store.rowHeaderWidth , Store.columnHeaderHeight );
luckysheetTableContent.restore();
@ -220,7 +237,7 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
offsetLeft ,
0,
drawWidth ,
(Store.columeHeaderHeight - 1)
(Store.columnHeaderHeight - 1)
);
@ -241,10 +258,10 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
luckysheetTableContent.save();
luckysheetTableContent.beginPath();
luckysheetTableContent.rect(offsetLeft-1, 0, drawWidth, Store.columeHeaderHeight -1);
luckysheetTableContent.rect(offsetLeft-1, 0, drawWidth, Store.columnHeaderHeight -1);
luckysheetTableContent.clip();
// console.log(offsetLeft, 0, drawWidth, Store.columeHeaderHeight -1);
// console.log(offsetLeft, 0, drawWidth, Store.columnHeaderHeight -1);
let end_c, start_c;
let bodrder05 = 0.5;//Default 0.5
@ -262,6 +279,14 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
// if(end_c > scrollWidth + drawWidth+1){
// break;
// }
let abc = chatatABC(c);
//列标题单元格渲染前触发,return false 则不渲染该单元格
if(!method.createHookFunction("columnTitleCellRenderBefore", abc, {
c:c,
left:(start_c + offsetLeft - 1),
width:(end_c - start_c),
height:Store.columnHeaderHeight -1
}, luckysheetTableContent)){ continue; }
if (Store.config["colhidden"] != null && Store.config["colhidden"][c] != null) {
@ -272,19 +297,19 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
(start_c + offsetLeft - 1) ,
0,
(end_c - start_c) ,
Store.columeHeaderHeight -1
Store.columnHeaderHeight -1
)
luckysheetTableContent.fillStyle = "#000000";
//列标题栏序列号
luckysheetTableContent.save();//save scale before draw text
luckysheetTableContent.scale(Store.zoomRatio,Store.zoomRatio);
let abc = chatatABC(c);
let textMetrics = getMeasureText(abc, luckysheetTableContent);
//luckysheetTableContent.measureText(abc);
let horizonAlignPos = Math.round((start_c + (end_c - start_c) / 2 + offsetLeft) - textMetrics.width / 2);
let verticalAlignPos = Math.round(Store.columeHeaderHeight / 2 );
let verticalAlignPos = Math.round(Store.columnHeaderHeight / 2 );
luckysheetTableContent.fillText(abc, horizonAlignPos/Store.zoomRatio, verticalAlignPos/Store.zoomRatio);
luckysheetTableContent.restore();//restore scale after draw text
@ -299,7 +324,7 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
);
luckysheetTableContent.lineTo(
(end_c + offsetLeft - 4 + bodrder05) ,
(Store.columeHeaderHeight - 2)
(Store.columnHeaderHeight - 2)
);
luckysheetTableContent.lineWidth = 1;
luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
@ -314,7 +339,7 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
);
luckysheetTableContent.lineTo(
(end_c + offsetLeft - 2 + bodrder05) ,
(Store.columeHeaderHeight - 2)
(Store.columnHeaderHeight - 2)
);
luckysheetTableContent.lineWidth = 1;
@ -331,7 +356,7 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
);
luckysheetTableContent.lineTo(
(preEndC + offsetLeft + bodrder05) ,
(Store.columeHeaderHeight - 2)
(Store.columnHeaderHeight - 2)
);
// luckysheetTableContent.lineWidth = 1;
// luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
@ -344,11 +369,11 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
(start_c + offsetLeft - 1),
(Store.columeHeaderHeight - 2 + bodrder05)
(Store.columnHeaderHeight - 2 + bodrder05)
);
luckysheetTableContent.lineTo(
(end_c + offsetLeft - 1),
(Store.columeHeaderHeight - 2 + bodrder05)
(Store.columnHeaderHeight - 2 + bodrder05)
);
// luckysheetTableContent.lineWidth = 1;
@ -357,17 +382,24 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
luckysheetTableContent.closePath();
preEndC = end_c;
method.createHookFunction("columnTitleCellRenderAfter", abc, {
c:c,
left:(start_c + offsetLeft - 1),
width:(end_c - start_c),
height:Store.columnHeaderHeight -1
}, luckysheetTableContent)
}
//列标题栏横线
// luckysheetTableContent.beginPath();
// luckysheetTableContent.moveTo(
// (offsetLeft - 1) ,
// (Store.columeHeaderHeight - 2 + 0.5)
// (Store.columnHeaderHeight - 2 + 0.5)
// );
// luckysheetTableContent.lineTo(
// (Store.ch_width + offsetLeft - 2) ,
// (Store.columeHeaderHeight - 2 + 0.5)
// (Store.columnHeaderHeight - 2 + 0.5)
// );
// luckysheetTableContent.lineWidth = 1;
// luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
@ -375,7 +407,7 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
// luckysheetTableContent.stroke();
//清除canvas左上角区域 防止列标题栏序列号溢出显示
// luckysheetTableContent.clearRect(0, 0, Store.rowHeaderWidth , Store.columeHeaderHeight );
// luckysheetTableContent.clearRect(0, 0, Store.rowHeaderWidth , Store.columnHeaderHeight );
luckysheetTableContent.restore();
luckysheetTableContent.restore();
@ -387,6 +419,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
return;
}
let sheetFile = sheetmanage.getSheetByIndex();
// console.trace();
clearTimeout(Store.measureTextCacheTimeOut);
@ -410,7 +443,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
offsetLeft = Store.rowHeaderWidth;
}
if (offsetTop == null) {
offsetTop = Store.columeHeaderHeight;
offsetTop = Store.columnHeaderHeight;
}
if (columnOffsetCell == null) {
@ -571,6 +604,8 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
firstcolumnlen = Store.config["columnlen"][c];
}
if (Store.flowdata[r] != null && Store.flowdata[r][c] != null) {
let value = Store.flowdata[r][c];
@ -617,6 +652,18 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
}
}
}
else{
//空单元格渲染前
if(!method.createHookFunction("cellRenderBefore", Store.flowdata[r][c], {
r:r,
c:c,
"start_r": start_r,
"start_c": start_c,
"end_r": end_r,
"end_c": end_c
}, sheetFile,luckysheetTableContent)){ continue; }
}
cellupdate.push({
"r": r,
@ -663,6 +710,16 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
if(Store.flowdata[r] == null){
continue;
}
//有值单元格渲染前
if(!method.createHookFunction("cellRenderBefore", Store.flowdata[r][c], {
r:r,
c:c,
"start_r": start_r,
"start_c": start_c,
"end_r": end_r,
"end_c": end_c
}, sheetFile,luckysheetTableContent)){ continue; }
if(Store.flowdata[r][c] == null){ //空单元格
nullCellRender(r, c, start_r, start_c, end_r, end_c,luckysheetTableContent,af_compute, cf_compute,offsetLeft,offsetTop,dynamicArray_compute,cellOverflowMap, dataset_col_st, dataset_col_ed,scrollHeight,scrollWidth,bodrder05);
@ -700,6 +757,15 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
cellRender(r, c, start_r, start_c, end_r, end_c, value,luckysheetTableContent,af_compute, cf_compute,offsetLeft,offsetTop,dynamicArray_compute,cellOverflowMap, dataset_col_st, dataset_col_ed,scrollHeight,scrollWidth,bodrder05);
}
}
method.createHookFunction("cellRenderAfter", Store.flowdata[r][c], {
r:r,
c:c,
"start_r": start_r,
"start_c": start_c,
"end_r": end_r,
"end_c": end_c
}, sheetFile,luckysheetTableContent)
}
//合并单元格再处理
@ -944,7 +1010,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
canvas.restore();
}
let borderInfoCompute = getBorderInfoCompute();
let borderInfoCompute = getBorderInfoComputeRange(dataset_row_st,dataset_row_ed,dataset_col_st,dataset_col_ed);
for(let x in borderInfoCompute){
//let bd_r = x.split("_")[0], bd_c = x.split("_")[1];
@ -952,6 +1018,10 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
let bd_r = x.substr(0, x.indexOf('_'));
let bd_c = x.substr(x.indexOf('_') + 1);
// if(bd_r < dataset_row_st || bd_r > dataset_row_ed || bd_c < dataset_col_st || bd_c > dataset_col_ed){
// continue;
// }
if(borderOffset[bd_r + "_" + bd_c]){
let start_r = borderOffset[bd_r + "_" + bd_c].start_r;
let start_c = borderOffset[bd_r + "_" + bd_c].start_c;
@ -998,6 +1068,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
Store.measureTextCacheTimeOut = setTimeout(() => {
Store.measureTextCache = {};
Store.measureTextCellInfoCache = {};
Store.cellOverflowMapCache = {};
}, 2000);
}
@ -1894,9 +1965,22 @@ function getCellOverflowMap(canvas, col_st, col_ed, row_st, row_end){
if(data[r]==null){
continue;
}
if(Store.cellOverflowMapCache[r]!=null){
map[r] = Store.cellOverflowMapCache[r];
continue;
}
let hasCellOver = false;
for(let c = 0; c < data[r].length; c++){
let cell = data[r][c];
// if(Store.cellOverflowMapCache[r + '_' + c]!=null){
// map[r + '_' + c] = Store.cellOverflowMapCache[r + '_' + c];
// continue;
// }
if (Store.config["colhidden"] != null && Store.config["colhidden"][c] != null) {
continue
}
@ -1979,14 +2063,29 @@ function getCellOverflowMap(canvas, col_st, col_ed, row_st, row_end){
// if(((stc >= col_st && stc <= col_ed) || (edc >= col_st && edc <= col_ed)) && stc < edc){
if(((stc <= col_ed) || (edc >= col_st)) && stc < edc){
map[r + '_' + c] = {
let item = {
r: r,
stc: stc,
edc: edc
}
if(map[r]==null){
map[r] = {};
}
map[r][c] = item;
// Store.cellOverflowMapCache[r + '_' + c] = item;
hasCellOver = true;
}
}
}
if(hasCellOver){
Store.cellOverflowMapCache[r] = map[r];
}
}
return map;
@ -2090,25 +2189,31 @@ function cellOverflow_colIn(map, r, c, col_st, col_ed){
stc,
edc;
for(let key in map){
// rowIndex = key.split('_')[0];
// colIndex = key.split('_')[1];
rowIndex = key.substr(0, key.indexOf('_'));
colIndex = key.substr(key.indexOf('_') + 1);
stc = map[key].stc;
edc = map[key].edc;
if(rowIndex == r){
if(c >= stc && c <= edc){
colIn = true;
if(c == edc || c == col_ed){
colLast = true;
break;
for(let rkey in map){
for(let ckey in map[rkey]){
rowIndex = rkey;
colIndex = ckey;
// rowIndex = key.substr(0, key.indexOf('_'));
// colIndex = key.substr(key.indexOf('_') + 1);
let mapItem = map[rkey][ckey];
stc = mapItem.stc;
edc = mapItem.edc;
if(rowIndex == r){
if(c >= stc && c <= edc){
colIn = true;
if(c == edc || c == col_ed){
colLast = true;
break;
}
}
}
}
if(colLast){
break;
}
}
return {

158
src/global/extend.js

@ -427,7 +427,7 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) {
freezen_row_st += value;
}
let freezen_top = Store.visibledatarow[freezen_row_st] - 2 - freezen_scrollTop + Store.columeHeaderHeight;
let freezen_top = Store.visibledatarow[freezen_row_st] - 2 - freezen_scrollTop + Store.columnHeaderHeight;
newFreezen.freezenhorizontaldata = [
Store.visibledatarow[freezen_row_st],
@ -482,9 +482,17 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) {
else if(index == r){
if(direction == "lefttop"){
newDataVerification[(r + value) + "_" + c] = item;
for(let i = 0; i < value; i++){
newDataVerification[(r + i) + "_" + c] = item;
}
}
else{
newDataVerification[r + "_" + c] = item;
for(let i = 0; i < value; i++){
newDataVerification[(r + i + 1) + "_" + c] = item;
}
}
}
else{
@ -498,9 +506,17 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) {
else if(index == c){
if(direction == "lefttop"){
newDataVerification[r + "_" + (c + value)] = item;
for(let i = 0; i < value; i++){
newDataVerification[r + "_" + (c + i)] = item;
}
}
else{
newDataVerification[r + "_" + c] = item;
for(let i = 0; i < value; i++){
newDataVerification[r + "_" + (c + i + 1)] = item;
}
}
}
else{
@ -510,6 +526,50 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) {
}
}
//超链接配置变动
let hyperlink = file.hyperlink;
let newHyperlink = {};
if(hyperlink != null){
for(let key in hyperlink){
let r = Number(key.split('_')[0]),
c = Number(key.split('_')[1]);
let item = hyperlink[key];
if(type == "row"){
if(index < r){
newHyperlink[(r + value) + "_" + c] = item;
}
else if(index == r){
if(direction == "lefttop"){
newHyperlink[(r + value) + "_" + c] = item;
}
else{
newHyperlink[r + "_" + c] = item;
}
}
else{
newHyperlink[r + "_" + c] = item;
}
}
else if(type == "column"){
if(index < c){
newHyperlink[r + "_" + (c + value)] = item;
}
else if(index == c){
if(direction == "lefttop"){
newHyperlink[r + "_" + (c + value)] = item;
}
else{
newHyperlink[r + "_" + c] = item;
}
}
else{
newHyperlink[r + "_" + c] = item;
}
}
}
}
let type1;
if (type == "row") {
type1 = "r";
@ -829,7 +889,8 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) {
newCFarr,
newAFarr,
newFreezen,
newDataVerification
newDataVerification,
newHyperlink
);
}
else{
@ -841,6 +902,7 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) {
file.luckysheet_conditionformat_save = newCFarr;
file.luckysheet_alternateformat_save = newAFarr;
file.dataVerification = newDataVerification;
file.hyperlink = newHyperlink;
}
let range = null;
@ -1356,7 +1418,7 @@ function luckysheetdeletetable(type, st, ed, sheetIndex) {
freezen_row_st = freezen_st;
}
let freezen_top = Store.visibledatarow[freezen_row_st] - 2 - freezen_scrollTop + Store.columeHeaderHeight;
let freezen_top = Store.visibledatarow[freezen_row_st] - 2 - freezen_scrollTop + Store.columnHeaderHeight;
newFreezen.freezenhorizontaldata = [
Store.visibledatarow[freezen_row_st],
@ -1434,6 +1496,34 @@ function luckysheetdeletetable(type, st, ed, sheetIndex) {
}
}
//超链接配置变动
let hyperlink = file.hyperlink;
let newHyperlink = {};
if(hyperlink != null){
for(let key in hyperlink){
let r = Number(key.split('_')[0]),
c = Number(key.split('_')[1]);
let item = hyperlink[key];
if(type == "row"){
if(r < st){
newHyperlink[r + "_" + c] = item;
}
else if(r > ed){
newHyperlink[(r - slen) + "_" + c] = item;
}
}
else if(type == "column"){
if(c < st){
newHyperlink[r + "_" + c] = item;
}
else if(c > ed){
newHyperlink[r + "_" + (c - slen)] = item;
}
}
}
}
//主逻辑
let type1;
if (type == "row") {
@ -1670,7 +1760,8 @@ function luckysheetdeletetable(type, st, ed, sheetIndex) {
newCFarr,
newAFarr,
newFreezen,
newDataVerification
newDataVerification,
newHyperlink
);
}
else{
@ -1682,6 +1773,7 @@ function luckysheetdeletetable(type, st, ed, sheetIndex) {
file.luckysheet_conditionformat_save = newCFarr;
file.luckysheet_alternateformat_save = newAFarr;
file.dataVerification = newDataVerification;
file.hyperlink = newHyperlink;
}
}
@ -2073,6 +2165,36 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, sheetIndex) {
}
}
//超链接配置变动
let hyperlink = file.hyperlink;
let newHyperlink = {};
if(hyperlink != null){
for(let key in hyperlink){
let r = Number(key.split('_')[0]),
c = Number(key.split('_')[1]);
let item = hyperlink[key];
if(r < str || r > edr || c < stc || c > edc){
if(type == "moveLeft"){
if(c > edc && r >= str && r <= edr){
newHyperlink[r + "_" + (c - clen)] = item;
}
else{
newHyperlink[r + "_" + c] = item;
}
}
else if(type == "moveUp"){
if(r > edr && c >= stc && c <= edc){
newHyperlink[(r - rlen) + "_" + c] = item;
}
else{
newHyperlink[r + "_" + c] = item;
}
}
}
}
}
//边框配置变动
if(cfg["borderInfo"] && cfg["borderInfo"].length > 0){
let borderInfo = [];
@ -2112,20 +2234,20 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, sheetIndex) {
let row_index = cfg["borderInfo"][i].value.row_index;
let col_index = cfg["borderInfo"][i].value.col_index;
if(row_index < str || col_index < stc){
borderInfo.push(cfg["borderInfo"][i]);
}
else if(row_index > edr || col_index > edc){
if(row_index > edr){
row_index -= rlen;
cfg["borderInfo"][i].value.row_index = row_index;
if(row_index < str || row_index > edr || col_index < stc || col_index > edc){
if(type == 'moveLeft'){
if(col_index > edc && row_index >= str && row_index <= edr){
col_index -= clen;
cfg["borderInfo"][i].value.col_index = col_index;
}
}
if(col_index > edc){
col_index -= clen;
cfg["borderInfo"][i].value.col_index = col_index;
else if(type == 'moveUp'){
if(row_index > edr && col_index >= stc && col_index <= edc){
row_index -= rlen;
cfg["borderInfo"][i].value.row_index = row_index;
}
}
borderInfo.push(cfg["borderInfo"][i]);
}
}
@ -2184,7 +2306,8 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, sheetIndex) {
newCalcChain,
newFilterObj,
newCFarr,
newDataVerification
newDataVerification,
newHyperlink
);
}
else{
@ -2195,6 +2318,7 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, sheetIndex) {
file.filter_select = newFilterObj.filter_select;
file.luckysheet_conditionformat_save = newCFarr;
file.dataVerification = newDataVerification;
file.hyperlink = newHyperlink;
}
}

2
src/global/location.js

@ -59,7 +59,7 @@ function mouseposition(x, y) {
let container_offset = $("#" + Store.container).offset();
let newX = x - container_offset.left - Store.rowHeaderWidth,
newY = y - container_offset.top - Store.infobarHeight - Store.toolbarHeight - Store.calculatebarHeight - Store.columeHeaderHeight;
newY = y - container_offset.top - Store.infobarHeight - Store.toolbarHeight - Store.calculatebarHeight - Store.columnHeaderHeight;
return [newX, newY];
}

26
src/global/method.js

@ -38,7 +38,7 @@ const defaultConfig = {
infobarHeight: 0,
calculatebarHeight: 0,
rowHeaderWidth: 46,
columeHeaderHeight: 20,
columnHeaderHeight: 20,
cellMainSrollBarSize: 12,
sheetBarHeight: 31,
statisticBarHeight: 23,
@ -135,6 +135,7 @@ const defaultConfig = {
measureTextCache:{},
measureTextCellInfoCache:{},
measureTextCacheTimeOut:null,
cellOverflowMapCache:{},
zoomRatio:1,
@ -321,7 +322,6 @@ const method = {
let dataset = d.data;
// rptapp
let newData = dataset.celldata;
luckysheetextendData(dataset["row"], newData);
@ -506,7 +506,29 @@ const method = {
luckysheet.insertChartTosheet(c.sheetIndex, c.dataSheetIndex, c.option, c.chartType, c.selfOption, c.defaultOption, c.row, c.column, chart_selection_color, chart_id, chart_selection_id, c.chartStyle, c.rangeConfigCheck, c.rangeRowCheck, c.rangeColCheck, c.chartMarkConfig, c.chartTitleConfig, c.winWidth, c.winHeight, c.scrollLeft, c.scrollTop, chartTheme, c.myWidth, c.myHeight, c.myLeft!=null?parseFloat(c.myLeft):null, c.myTop!=null?parseFloat(c.myTop):null, c.myindexrank, true);
$("#"+chart_id).find(".luckysheet-modal-controll-update").click();
},
/**
* 获取单元格的值
* @param {name} 函数名称
* @param {arguments} 函数参数
*/
createHookFunction:function(){
let hookName = arguments[0];
if(luckysheetConfigsetting.hook && luckysheetConfigsetting.hook[hookName]!=null && (typeof luckysheetConfigsetting.hook[hookName] == "function")){
var args = Array.prototype.slice.apply(arguments);
args.shift();
let ret = luckysheetConfigsetting.hook[hookName].apply(this, args);
if(ret===false){
return false;
}
else{
return true;
}
}
return true;
}
}
export default method;

41
src/global/refresh.js

@ -14,6 +14,7 @@ import server from '../controllers/server';
import sheetmanage from '../controllers/sheetmanage';
import luckysheetPostil from '../controllers/postil';
import dataVerificationCtrl from '../controllers/dataVerificationCtrl';
import hyperlinkCtrl from '../controllers/hyperlinkCtrl';
import { selectHightlightShow, selectionCopyShow } from '../controllers/select';
import { createFilterOptions } from '../controllers/filter';
import { getSheetIndex } from '../methods/get';
@ -375,7 +376,7 @@ function jfrefreshrange(data, range, cdformat) {
}
//删除、增加行列 刷新表格
function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf, af, freezen, dataVerification){
function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf, af, freezen, dataVerification, hyperlink){
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
//merge改变对应的单元格值改变
@ -443,7 +444,9 @@ function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf,
"freezen": { "freezenhorizontaldata": luckysheetFreezen.freezenhorizontaldata, "freezenverticaldata": luckysheetFreezen.freezenverticaldata },
"curFreezen": freezen,
"dataVerification": $.extend(true, {}, file.dataVerification),
"curDataVerification": dataVerification
"curDataVerification": dataVerification,
"hyperlink": $.extend(true, {}, file.hyperlink),
"curHyperlink": hyperlink
});
}
@ -567,12 +570,17 @@ function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf,
file.dataVerification = dataVerification;
server.saveParam("all", Store.currentSheetIndex, file.dataVerification, { "k": "dataVerification" });
//超链接
hyperlinkCtrl.hyperlink = hyperlink;
file.hyperlink = hyperlink;
server.saveParam("all", Store.currentSheetIndex, file.hyperlink, { "k": "hyperlink" });
//行高、列宽刷新
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
}
//删除单元格 刷新表格
function jfrefreshgrid_deleteCell(data, cfg, ctrl, calc, filterObj, cf, dataVerification){
function jfrefreshgrid_deleteCell(data, cfg, ctrl, calc, filterObj, cf, dataVerification, hyperlink){
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
clearTimeout(refreshCanvasTimeOut);
//merge改变对应的单元格值改变
@ -650,7 +658,9 @@ function jfrefreshgrid_deleteCell(data, cfg, ctrl, calc, filterObj, cf, dataVeri
"cf": $.extend(true, [], file.luckysheet_conditionformat_save),
"curCf": cf,
"dataVerification": $.extend(true, {}, file.dataVerification),
"curDataVerification": dataVerification
"curDataVerification": dataVerification,
"hyperlink": $.extend(true, {}, file.hyperlink),
"curHyperlink": hyperlink
});
}
@ -729,6 +739,11 @@ function jfrefreshgrid_deleteCell(data, cfg, ctrl, calc, filterObj, cf, dataVeri
file.dataVerification = dataVerification;
server.saveParam("all", Store.currentSheetIndex, file.dataVerification, { "k": "dataVerification" });
//超链接
hyperlinkCtrl.hyperlink = hyperlink;
file.hyperlink = hyperlink;
server.saveParam("all", Store.currentSheetIndex, file.hyperlink, { "k": "hyperlink" });
refreshCanvasTimeOut = setTimeout(function () {
luckysheetrefreshgrid();
}, 1);
@ -955,7 +970,7 @@ function jfrefreshgrid_rhcw(rowheight, colwidth, isRefreshCanvas=true){
let scrollTop = luckysheetFreezen.freezenhorizontaldata[2];
let scrollLeft = luckysheetFreezen.freezenverticaldata[2];
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [
Store.visibledatarow[row_st],
row_st + 1,
@ -981,7 +996,7 @@ function jfrefreshgrid_rhcw(rowheight, colwidth, isRefreshCanvas=true){
let row_st = luckysheetFreezen.freezenhorizontaldata[1] - 1;
let scrollTop = luckysheetFreezen.freezenhorizontaldata[2];
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columeHeaderHeight;
let top = Store.visibledatarow[row_st] - 2 - scrollTop + Store.columnHeaderHeight;
let freezenhorizontaldata = [
Store.visibledatarow[row_st],
row_st + 1,
@ -1127,7 +1142,7 @@ function luckysheetrefreshgrid(scrollWidth, scrollHeight) {
drawWidth - freezen_vertical_px + freezen_vertical_scrollTop,
drawHeight - freezen_horizon_px + freezen_horizon_scrollTop,
freezen_vertical_px - freezen_vertical_scrollTop + Store.rowHeaderWidth,
freezen_horizon_px - freezen_horizon_scrollTop + Store.columeHeaderHeight
freezen_horizon_px - freezen_horizon_scrollTop + Store.columnHeaderHeight
);
//标题
@ -1138,11 +1153,11 @@ function luckysheetrefreshgrid(scrollWidth, scrollHeight) {
freezen_vertical_px - freezen_vertical_scrollTop + Store.rowHeaderWidth
);
luckysheetDrawgridRowTitle(freezen_horizon_scrollTop, freezen_horizon_px, Store.columeHeaderHeight);
luckysheetDrawgridRowTitle(freezen_horizon_scrollTop, freezen_horizon_px, Store.columnHeaderHeight);
luckysheetDrawgridRowTitle(
scrollHeight + freezen_horizon_px - freezen_horizon_scrollTop,
drawHeight - freezen_horizon_px + freezen_horizon_scrollTop,
freezen_horizon_px - freezen_horizon_scrollTop + Store.columeHeaderHeight
freezen_horizon_px - freezen_horizon_scrollTop + Store.columnHeaderHeight
);
}
@ -1168,16 +1183,16 @@ function luckysheetrefreshgrid(scrollWidth, scrollHeight) {
drawWidth,
drawHeight - freezen_horizon_px + freezen_horizon_scrollTop,
null,
freezen_horizon_px - freezen_horizon_scrollTop + Store.columeHeaderHeight
freezen_horizon_px - freezen_horizon_scrollTop + Store.columnHeaderHeight
);
luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, null);
luckysheetDrawgridRowTitle(freezen_horizon_scrollTop, freezen_horizon_px, Store.columeHeaderHeight);
luckysheetDrawgridRowTitle(freezen_horizon_scrollTop, freezen_horizon_px, Store.columnHeaderHeight);
luckysheetDrawgridRowTitle(
scrollHeight + freezen_horizon_px - freezen_horizon_scrollTop,
drawHeight - freezen_horizon_px + freezen_horizon_scrollTop,
freezen_horizon_px - freezen_horizon_scrollTop + Store.columeHeaderHeight
freezen_horizon_px - freezen_horizon_scrollTop + Store.columnHeaderHeight
);
}
@ -1231,7 +1246,7 @@ function luckysheetrefreshgrid(scrollWidth, scrollHeight) {
//清除canvas左上角区域 防止列标题栏序列号溢出显示
luckysheetTableContent.clearRect(0, 0, (Store.rowHeaderWidth* Store.devicePixelRatio-1) , (Store.columeHeaderHeight* Store.devicePixelRatio-1) );
luckysheetTableContent.clearRect(0, 0, (Store.rowHeaderWidth* Store.devicePixelRatio-1) , (Store.columnHeaderHeight* Store.devicePixelRatio-1) );
}
}

6
src/global/rhchInit.js

@ -83,8 +83,8 @@ export default function rhchInit(rowheight, colwidth) {
export function zoomSetting(){
//zoom
Store.rowHeaderWidth = luckysheetConfigsetting.rowHeaderWidth * Store.zoomRatio;
Store.columeHeaderHeight = luckysheetConfigsetting.columeHeaderHeight *Store.zoomRatio;
Store.columnHeaderHeight = luckysheetConfigsetting.columnHeaderHeight *Store.zoomRatio;
$("#luckysheet-rows-h").width((Store.rowHeaderWidth-1.5));
$("#luckysheet-cols-h-c").height((Store.columeHeaderHeight-1.5));
$("#luckysheet-left-top").css({width:Store.rowHeaderWidth-1.5, height:Store.columeHeaderHeight-1.5});
$("#luckysheet-cols-h-c").height((Store.columnHeaderHeight-1.5));
$("#luckysheet-left-top").css({width:Store.rowHeaderWidth-1.5, height:Store.columnHeaderHeight-1.5});
}

35
src/index.html

@ -62,6 +62,39 @@
"url":"./assets/iconfont/Pacifico-Regular.ttf"
}
],
hook:{
rowTitleCellRenderBefore:function(rowNum,postion,ctx){
// console.log(rowNum);
},
rowTitleCellRenderAfter:function(rowNum,postion,ctx){
// console.log(ctx);
},
columnTitleCellRenderBefore:function(columnAbc,postion,ctx){
// console.log(columnAbc);
},
columnTitleCellRenderAfter:function(columnAbc,postion,ctx){
// console.log(postion);
},
cellRenderBefore:function(cell,postion,sheetFile,ctx){
// console.log(cell,postion,sheetFile,ctx);
},
cellRenderAfter:function(cell,postion,sheetFile,ctx){
// console.log(postion);
},
cellMousedownBefore:function(cell,postion,sheetFile,ctx){
// console.log(postion);
},
cellMousedown:function(cell,postion,sheetFile,ctx){
// console.log(sheetFile);
},
sheetMousemove:function(cell,postion,sheetFile,moveState,ctx){
// console.log(cell,postion,sheetFile,moveState,ctx);
},
sheetMouseup:function(cell,postion,sheetFile,moveState,ctx){
// console.log(cell,postion,sheetFile,moveState,ctx);
},
},
data:
[sheetCell,sheetFormula,sheetConditionFormat,sheetSparkline,sheetTable,sheetComment,sheetPivotTableData,sheetPivotTable,sheetChart,sheetPicture,sheetDataVerification]
/*[{"name":"Sheet1","config":{"columnlen":{"0":241},"rowlen":{"0":81}},"index":"1","status":"1","order":"0","luckysheet_select_save":[{"row":[0,0],"column":[4,4],"sheetIndex":1}],"zoomRatio":1,"showGridLines":"1","defaultColWidth":72,"defaultRowHeight":18,"celldata":[
@ -1793,7 +1826,7 @@
"scrollTop": 0
}]*/
})
})
</script>

16
src/locale/en.js

@ -8860,6 +8860,7 @@ export default {
screenshot: 'Screenshot',
splitColumn: 'Split text',
insertImage: 'Insert image',
insertLink: 'Insert link',
dataVerification: 'Data verification',
protection:"Protect the sheet",
@ -9690,6 +9691,21 @@ export default {
fiveQuadrantDiagram: 'Five-quadrant diagram',
fiveBoxes: '5 Boxes',
},
insertLink: {
linkText: "Text",
linkType: "Link type",
external: "External link",
internal: "Internal link",
linkAddress: "Link address",
linkSheet: "Worksheet",
linkCell: "Cell reference",
linkTooltip: "Tooltip",
placeholder1: "Please enter the web link address",
placeholder2: "Please enter the cell to be quoted, example A1",
placeholder3: "Please enter the prompt content",
tooltipInfo1: "Please enter a valid link",
tooltipInfo2: "Please enter the correct cell reference",
},
dataVerification: {
cellRange: 'Cell range',
selectCellRange: 'Click to select a cell range',

16
src/locale/zh.js

@ -9086,6 +9086,7 @@ export default {
screenshot: '截图',
splitColumn: '分列',
insertImage: '插入图片',
insertLink: '插入链接',
dataVerification: '数据验证',
protection:"保护工作表内容",
@ -9934,6 +9935,21 @@ export default {
fiveQuadrantDiagram: '五象限图',
fiveBoxes: '5个框',
},
insertLink: {
linkText: "文本",
linkType: "链接类型",
external: "外部链接",
internal: "内部链接",
linkAddress: "链接地址",
linkSheet: "工作表",
linkCell: "单元格引用",
linkTooltip: "提示",
placeholder1: "请输入网页链接地址",
placeholder2: "请输入要引用的单元格,例A1",
placeholder3: "请输入提示内容",
tooltipInfo1: "请输入有效的链接",
tooltipInfo2: "请输入正确的单元格引用",
},
dataVerification: {
cellRange: '单元格范围',
selectCellRange: '点击选择单元格范围',

3
src/store/index.js

@ -22,7 +22,7 @@ const Store = {
infobarHeight: 0,
calculatebarHeight: 0,
rowHeaderWidth: 46,
columeHeaderHeight: 20,
columnHeaderHeight: 20,
cellMainSrollBarSize: 12,
sheetBarHeight: 31,
statisticBarHeight: 23,
@ -119,6 +119,7 @@ const Store = {
measureTextCache:{},
measureTextCellInfoCache:{},
measureTextCacheTimeOut:null,
cellOverflowMapCache:{},
zoomRatio:1,

2
src/utils/util.js

@ -357,7 +357,7 @@ function luckysheetfontformat(format) {
//font-size/line-height
if (!format.fs) {
font += Store.luckysheetfontformat + "pt ";
font += Store.defaultFontSize + "pt ";
}
else {
font += Math.ceil(format.fs) + "pt ";

Loading…
Cancel
Save