wbfsa 5 years ago
parent
commit
254081f7e4
  1. 19
      README-zh.md
  2. 20
      README.md
  3. 8
      docs/guide/data.md
  4. 2
      docs/zh/guide/README.md
  5. 9
      docs/zh/guide/cell.md
  6. 268
      docs/zh/guide/config.md
  7. 192
      docs/zh/guide/operate.md
  8. 544
      docs/zh/guide/sheet.md
  9. 55
      src/controllers/constant.js
  10. 169
      src/controllers/handler.js
  11. 283
      src/controllers/imageCtrl.js
  12. 2
      src/controllers/server.js
  13. 14
      src/controllers/sheetmanage.js
  14. 218
      src/css/luckysheet-core.css
  15. 8
      src/expendPlugins/chart/plugin.js
  16. 2
      src/global/createdom.js
  17. 2
      src/global/draw.js
  18. 2
      src/index.html

19
README-zh.md

@ -150,11 +150,17 @@ npm run build
```
## 加入共建
如果你想为 Luckysheet 实现一个重要功能,需要先撰写 RFC 文档,按照Luckysheet的 [RFC](https://github.com/mengshukeji/Luckysheet-rfcs) 机制进行操作,在经过社区讨论完善后才可以进行代码的提交。
## 联系
- 欢迎提交 PR 或者 [Issues](https://github.com/mengshukeji/Luckysheet/issues/new/choose)
- Email: mengshu@office2.cn
1. 任何疑问或者建议,欢迎提交[Issues](https://github.com/mengshukeji/Luckysheet/issues/new/choose)
2. 如果您想为 Luckysheet 实现一个重要功能,需要先撰写 RFC 文档,按照Luckysheet的 [RFC](https://github.com/mengshukeji/Luckysheet-rfcs) 机制进行操作,在经过社区讨论完善后才可以进行代码的提交。
3. 如果您对Luckysheet感兴趣,非常欢迎加入开发组,一起来完善这个插件(下方扫码添加小编微信备注:共建),有4类任务可以认领
- BUG修复
- 新功能添加
- 文档
- 推广
您将收获:
- Luckysheet官方readme文档贡献者链接
- 参与大型开源项目,技术和视野提升
## 交流
@ -171,7 +177,10 @@ npm run build
[英文社群](./README.md)
## 贡献者和感谢
- [@wbfsa](https://github.com/wbfsa)
- [@wpxp123456](https://github.com/wpxp123456)
- [@swen-xiong](https://github.com/swen-xiong)
- [@tonytonychopper123](https://github.com/tonytonychopper123)
- [@Dushusir](https://github.com/Dushusir)
## 版权信息

20
README.md

@ -154,13 +154,20 @@ Create a table
})
</script>
```
## Join the co-construction
If you want to implement an important function for Luckysheet, you need to write an RFC document first, follow Luckysheet's [RFC](https://github.com/mengshukeji/Luckysheet-rfcs) to operate, and submit the code after community discussion and improvement.
## Co-construction
## Contact
- Welcome to submit PR or [Issues](https://github.com/mengshukeji/Luckysheet/issues/new/choose)
- Email: mengshu@office2.cn
1. Any questions or suggestions are welcome to submit [Issues](https://github.com/mengshukeji/Luckysheet/issues/new/choose)
2. If you want to implement an important function for Luckysheet, you need to write an RFC document first, follow Luckysheet's [RFC](https://github.com/mengshukeji/Luckysheet-rfcs) mechanism to operate, and only after community discussion and improvement, you can submit the code.
3. If you are interested in Luckysheet, you are very welcome to join the development team to improve this plugin together (Email: alexads@foxmail.com), there are 4 types of tasks that can be claimed
- BUG
- New features
- Documentation
- Popularize
You will gain:
- Luckysheet official readme document contributor link
- Participate in large open source projects, improve technology and vision
## Communication
@ -169,7 +176,10 @@ If you want to implement an important function for Luckysheet, you need to write
[Chinese community](./README-zh.md)
## Authors and acknowledgment
- [@wbfsa](https://github.com/wbfsa)
- [@wpxp123456](https://github.com/wpxp123456)
- [@swen-xiong](https://github.com/swen-xiong)
- [@tonytonychopper123](https://github.com/tonytonychopper123)
- [@Dushusir](https://github.com/Dushusir)
## License

8
docs/guide/data.md

@ -26,7 +26,7 @@
"rowlen":{}, //Table row height
"columnlen":{}, //Table column width
"rowhidden":{}, //hidden rows
"columnhidden":{}, //hidden columns
"colhidden":{}, //hidden columns
"borderInfo":{}, //borders
},
"celldata": [], //initialize the cell data used
@ -204,15 +204,15 @@
}
```
### config.columnhidden
### config.colhidden
- Type:Object
- Default:{}
- Usage:Hidden column information, Columns:`columnhidden[Columns]: 0`,
- Usage:Hidden column information, Columns:`colhidden[Columns]: 0`,
`key` specify the number of columns,`value` is always `0`
- example:
```js
"columnhidden": {
"colhidden": {
"30": 0,
"31": 0
}

2
docs/zh/guide/README.md

@ -171,7 +171,7 @@ luckysheetfile = [ {sheet1设置}, {sheet2设置}, {sheet3设置} ]`
"rowlen":{}, //表格行高
"columnlen":{}, //表格列宽
"rowhidden":{}, //隐藏行
"columnhidden":{}, //隐藏列
"colhidden":{}, //隐藏列
"borderInfo":{}, //边框
},
"celldata": [], //初始化使用的单元格数据

9
docs/zh/guide/cell.md

@ -147,6 +147,15 @@
</td>
<td></td>
</tr>
<tr>
<td>ae</td>
<td>allowEdit</td>
<td>是否允许编辑</td>
<td>
0: 只读,不可编辑 1:可以编辑,默认为 1
</td>
<td></td>
</tr>
</table>
一个规范的单元格对象如下:

268
docs/zh/guide/config.md

@ -22,48 +22,59 @@ luckysheet.create(options)
这里的`options`配置项会作用于整个表格,特别的,单个sheet的配置则需要在`options.data`数组中,分别设置对应更详细的参数,参考[工作表配置](/zh/guide/sheet.html)
针对个性化的需求,除了允许配置名称栏([showinfobar](#showinfobar))、工具栏([showtoolbar](#showtoolbar))、底部sheet页([showsheetbar](#showsheetbar))、底部计数栏([showstatisticBar](#showstatisticBar))之外,
Luckysheet开放了更细致的自定义配置选项,分别有
- 自定义工具栏([showtoolbarConfig](#showtoolbarConfig))
- 自定义底部sheet页([showsheetbarConfig](#showsheetbarConfig))
- 自定义计数栏([showstatisticBarConfig](#showstatisticBarConfig))
- 自定义添加行和回到顶部([sheetBottomConfig](#sheetBottomConfig))
- 自定义单元格右键菜单([cellRightClickConfig](#cellRightClickConfig))
- 自定义sheet页右击菜单([sheetRightClickConfig](#sheetRightClickConfig))
## 配置项
以下为所有支持的设置参数
- [container](#container)
- [title](#title)
- [lang](#lang)
- [gridKey](#gridKey)
- [loadUrl](#loadUrl)
- [loadSheetUrl](#loadSheetUrl)
- [allowUpdate](#allowUpdate)
- [updateUrl](#updateUrl)
- [updateImageUrl](#updateImageUrl)
- [data](#data)
- [plugins](#plugins)
- [column](#column)
- [row](#row)
- [autoFormatw](#autoFormatw)
- [accuracy](#accuracy)
- [allowCopy](#allowCopy)
- [showtoolbar](#showtoolbar)
- [showtoolbarConfig](#showtoolbarConfig)
- [showinfobar](#showinfobar)
- [showsheetbar](#showsheetbar)
- [showsheetbarConfig](#showsheetbarConfig)
- [showstatisticBar](#showstatisticBar)
- [showstatisticBarConfig](#showstatisticBarConfig)
- [allowEdit](#allowEdit)
- [enableAddRow](#enableAddRow)
- [enableAddCol](#enableAddCol)
- [userInfo](#userInfo)
- [userMenuItem](#userMenuItem)
- [myFolderUrl](#myFolderUrl)
- [devicePixelRatio](#devicePixelRatio)
- [functionButton](#functionButton)
- [showConfigWindowResize](#showConfigWindowResize)
- [enablePage](#enablePage)
- [fullscreenmode](#fullscreenmode)
- [beforeCreateDom](#beforeCreateDom)
- [fireMousedown](#fireMousedown)
- [forceCalculation](#forceCalculation)
- [rightClickConfig](#rightClickConfig)
- 容器ID [container](#container)
- 工作簿名称 [title](#title)
- 语言 [lang](#lang)
- 唯一key [gridKey](#gridKey)
- 加载整个工作簿 [loadUrl](#loadUrl)
- 加载其它页celldata [loadSheetUrl](#loadSheetUrl)
- 允许更新 [allowUpdate](#allowUpdate)
- 更新地址 [updateUrl](#updateUrl)
- 缩略图更新地址 [updateImageUrl](#updateImageUrl)
- 工作表配置 [data](#data)
- 插件 [plugins](#plugins)
- 列数 [column](#column)
- 行数 [row](#row)
- 亿万格式 [autoFormatw](#autoFormatw)
- 精度 [accuracy](#accuracy)
- 允许复制 [allowCopy](#allowCopy)
- 工具栏 [showtoolbar](#showtoolbar)
- 自定义工具栏[showtoolbarConfig](#showtoolbarConfig)
- 名称栏 [showinfobar](#showinfobar)
- 底部sheet页 [showsheetbar](#showsheetbar)
- 自定义底部sheet页 [showsheetbarConfig](#showsheetbarConfig)
- 底部计数栏 [showstatisticBar](#showstatisticBar)
- 自定义计数栏 [showstatisticBarConfig](#showstatisticBarConfig)
- 自定义添加行和回到顶部 [sheetBottomConfig](#sheetBottomConfig)
- 允许编辑 [allowEdit](#allowEdit)
- 允许增加行 [enableAddRow](#enableAddRow)
- 允许增加列 [enableAddCol](#enableAddCol)
- 用户信息 [userInfo](#userInfo)
- 用户信息菜单 [userMenuItem](#userMenuItem)
- 返回按钮链接 [myFolderUrl](#myFolderUrl)
- 比例 [devicePixelRatio](#devicePixelRatio)
- 功能按钮 [functionButton](#functionButton)
- 自动缩进界面 [showConfigWindowResize](#showConfigWindowResize)
- 加载下一页 [enablePage](#enablePage)
- 全屏模式 [fullscreenmode](#fullscreenmode)
- 刷新公式 [forceCalculation](#forceCalculation)
- 自定义单元格右键菜单 [cellRightClickConfig](#cellRightClickConfig)
- 自定义sheet页右击菜单 [sheetRightClickConfig](#sheetRightClickConfig)
### container
- 类型:String
@ -74,7 +85,7 @@ luckysheet.create(options)
### title
- 类型:String
- 默认值:"Luckysheet Demo"
- 作用:表格的名称
- 作用:工作簿名称
------------
### lang
@ -167,7 +178,7 @@ luckysheet.create(options)
- 作用:是否第二列显示工具栏
------------
#### showtoolbarConfig
### showtoolbarConfig
- 类型:Object
- 默认值:{}
- 作用:自定义配置工具栏
@ -218,13 +229,13 @@ luckysheet.create(options)
### showsheetbar
- 类型:Boolean
- 默认值:true
- 作用:是否显示底部表格名称区域
- 作用:是否显示底部sheet页按钮
------------
### showsheetbarConfig
- 类型:Object
- 默认值:{}
- 作用:自定义配置底部表格名称区域
- 作用:自定义配置底部sheet页按钮
- 格式:
```json
{
@ -252,6 +263,18 @@ luckysheet.create(options)
zoom: false // 缩放
}
------------
### sheetBottomConfig
- 类型:Object
- 默认值:{}
- 作用:sheet页下方的添加行按钮和回到顶部按钮配置
- 格式:
```json
{
addRow: false, // 添加行按钮
backTop: false // 回到顶部
}
------------
### allowEdit
- 类型:Boolean
@ -318,18 +341,6 @@ luckysheet.create(options)
- 默认值:true
- 作用:是否全屏模式。非全屏模式下,标记框不会强制选中
------------
### beforeCreateDom
- 类型:Function
- 默认值:null
- 作用:表格创建之前自定义方法
------------
### fireMousedown
- 类型:Function
- 默认值:null
- 作用:单元格数据下钻自定义方法
------------
### forceCalculation
- 类型:Boolean
@ -343,33 +354,54 @@ luckysheet.create(options)
⚠️提醒,公式较多时会有性能问题,慎用!
------------
### rightClickConfig
### cellRightClickConfig
- 类型:Object
- 默认值:{}
- 作用:自定义配置右击菜单
- 作用:自定义配置单元格右击菜单
- 格式:
```json
{
copy:false, // '复制'
copyAs:false, // '复制为'
paste:false, // '粘贴',
insert:false, // '插入',
delete:false, // '删除',
hide:false, // '隐藏',
deleteCell:false, // '删除单元格',
clear:false, // '清除内容',
matrix:false, // '矩阵操作选区',
sort:false, // '排序选区',
filter:false, //'筛选选区',
chart:false, // '图表生成',
copy: false, // '复制'
copyAs: false, // '复制为'
paste: false, // '粘贴'
insert: false, // '插入'
delete: false, // '删除'
hide: false, // '隐藏'
deleteCell: false, // '删除单元格'
clear: false, // '清除内容'
matrix: false, // '矩阵操作选区'
sort: false, // '排序选区'
filter: false, //'筛选选区'
chart: false // '图表生成'
}
## 钩子函数
------------
### sheetRightClickConfig
- 类型:Object
- 默认值:{}
- 作用:自定义配置sheet页右击菜单
- 格式:
```json
{
delete: false, // '删除'
copy: false, // '复制'
rename: false, //重命名
color: false, //更改颜色
hide: false, //隐藏
show: false, //取消隐藏
left: false, //向左移
right: false //向右移
}
------------
## 钩子函数(TODO)
钩子函数应用于二次开发时,会在各个常用鼠标或者键盘操作时植入钩子,调用开发者传入的函数,起到扩展Luckysheet功能的作用。
钩子函数统一配置在`options.hook`下,可以分别针对单元格、sheet页、表格创建配置hook
钩子函数统一配置在`options.hook`下,可以分别针对单元格、sheet页、表格创建配置hook
------------
### cellHover
- 类型:Function
- 默认值:null
@ -380,38 +412,116 @@ luckysheet.create(options)
- {Object} [v]: 单元格对象
------------
### cellClickBefore
- 类型:Function
- 默认值:null
- 作用:点击单元格前触发,即在点击单元格的时候,最先触发这个方法
- 参数:
- {Number} [r]: 单元格所在行数
- {Number} [c]: 单元格所在列数
- {Object} [v]: 单元格对象
------------
### cellClickAfter
### cellClicked
- 类型:Function
- 默认值:null
- 作用:点击单元格后触发,即在点击单元格的时候,最后触发这个方法
- 参数:
- {Number} [r]: 单元格所在行数
- {Number} [c]: 单元格所在列数
- {Object} [v]: 单元格对象
------------
### cellEditBefore
- 类型:Function
- 默认值:null
- 作用:双击单元格后触发,即在双击单元格编辑内容的时候,最先触发这个方法
- 参数:
- {Number} [r]: 单元格所在行数
- {Number} [c]: 单元格所在列数
- {Object} [v]: 单元格对象
------------
### cellEdited
- 类型:Function
- 默认值:null
- 作用:双击单元格后触发,即在双击单元格编辑内容的时候,最后触发这个方法
- 参数:
- {Number} [r]: 单元格所在行数
- {Number} [c]: 单元格所在列数
- {Object} [oldV]: 修改前单元格对象
- {Object} [newV]: 修改后单元格对象
------------
### sheetClickBefore
- 类型:Function
- 默认值:null
- 作用:点击sheet页前触发
- 参数:
- {Number} [i]: sheet页的index
- {Object} [sheet]: sheet页的配置
------------
### sheetClickAfter
### sheetClicked
- 类型:Function
- 默认值:null
- 作用:点击sheet页后触发
- 参数:
- {Number} [i]: sheet页的index
- {Object} [sheet]: sheet页的配置
------------
### sheetClickAfter
### workbookCreateBefore
- 类型:Function
- 默认值:null
- 作用:点击sheet页后触发
- 作用:表格创建之前触发。旧的钩子函数叫做`beforeCreateDom`
- 参数:
- {Object} [book]: 整个工作簿的配置(options)
------------
### workbookCreated
- 类型:Function
- 默认值:null
- 作用:表格创建之后触发
- 参数:
- {Object} [book]: 整个工作簿的配置(options)
------------
### workbookUpdated
- 类型:Function
- 默认值:null
- 作用:表格创建之后触发
- 参数:
- {Object} [book]: 整个工作簿的配置(options)
------------
### workbookDestroyBefore
- 类型:Function
- 默认值:null
- 作用:表格创建之后触发
- 参数:
- {Object} [book]: 整个工作簿的配置(options)
------------
### workbookDestroyed
- 类型:Function
- 默认值:null
- 作用:表格创建之后触发
- 参数:
- {Object} [book]: 整个工作簿的配置(options)
------------
### updated
- 类型:Function
- 默认值:null
- 作用:每次操作更新后执行的方法,即客户端每执行一次表格操作,Luckysheet将这次操作存到历史记录中后触发,撤销时因为也算一次操作,当然也会触发此钩子函数。
- 参数:
- {Object} [operate]: 本次操作的历史记录信息,根据不同的操作,会有不同的历史记录,参考源码 [历史记录](https://github.com/mengshukeji/Luckysheet/blob/master/src/controllers/controlHistory.js)
------------
### fireMousedown
- 类型:Function
- 默认值:null
- 作用:单元格数据下钻自定义方法
------------

192
docs/zh/guide/operate.md

@ -8,6 +8,8 @@
以下为所有的支持传输到后台的操作类型,并且以MongoDB做存储示例,讲解如何做前后端交互。
注意一点,对象中的i为当前sheet的index值,而不是order。
## 单元格刷新
### 单个单元格刷新
@ -33,7 +35,7 @@
|参数|说明|
| ------------ | ------------ |
|t|操作类型表示符号|
|i|当前sheet的索引值|
|i|当前sheet的index值|
|v|单元格的值,数字、字符串或着对象格式,对象参考 [单元格属性表](/zh/guide/cell.html#基本单元格)|
|r|单元格的行号|
|c|单元格的列号|
@ -113,7 +115,7 @@
|t|操作类型表示符号|
|i|当前sheet的index值|
|v|需要更新value值|
|k|操作的key值,可选 边框:`'borderInfo'` / :行隐藏:`'rowhidden'` / 列隐藏:`'columnhidden'` / 行高:`'rowlen'` / 列宽:`'columnlen'` |
|k|操作的key值,可选 边框:`'borderInfo'` / :行隐藏:`'rowhidden'` / 列隐藏:`'colhidden'` / 行高:`'rowlen'` / 列宽:`'columnlen'` |
- **后台更新**
@ -1079,4 +1081,188 @@
- **后台更新**
Luckysheet配置,修改title为`"Luckysheet Demo1"`
Luckysheet配置,修改title为`"Luckysheet Demo1"`
## 图表(TODO)
图表操作类型有4种,分别为新增图表"add"、移动图表位置"xy"、缩放图表"wh"、修改图表配置"update"
### 新增图表
- **格式**
```json
{
"t": "c",
"i": 0,
"op":"add",
"v": {
"chart_id": "chart_p145W6i73otw_1596209943446",
"width": 400,
"height": 250,
"left": 20,
"top": 120,
"sheetIndex": "Sheet_6az6nei65t1i_1596209937084",
"needRangeShow": true,
"chartOptions": {
"chart_id": "chart_p145W6i73otw_1596209943446",
"chartAllType": "echarts|line|default",
"rangeArray": [ { "row": [ 0, 4 ], "column": [ 0, 7 ] } ],
"rangeColCheck": { "exits": true, "range": [ 0, 0 ] },
"rangeRowCheck": { "exits": true, "range": [ 0, 0 ] },
"rangeConfigCheck": false,
"defaultOption": {
"title": {
"show": true,
"text": "默认标题"
}
}
},
"isShow": true
}
}
```
- **说明**
|参数|说明|
| ------------ | ------------ |
|t|操作类型表示符号|
|i|当前sheet的index值|
|op|操作选项|
|v|图表的配置信息|
- **后台更新**
更新对应sheet页中的图表设置,如果`luckysheetfile[i].chart`为null,则初始化为空数组 `[]`
```json
luckysheetfile[0].chart.push(v)
```
### 移动图表位置
- **格式**
```json
{
"t": "c",
"i": 0,
"op":"xy",
"v": {
"chart_id": "chart_p145W6i73otw_1596209943446",
"left": 20,
"top": 120
}
}
```
- **说明**
|参数|说明|
| ------------ | ------------ |
|t|操作类型表示符号|
|i|当前sheet的index值|
|op|操作选项|
|v|图表的配置信息|
- **后台更新**
更新对应sheet页中的图表设置
```js
luckysheetfile[0].chart[v.chart_id].left = v.left;
luckysheetfile[0].chart[v.chart_id].top = v.top;
```
### 缩放图表
- **格式**
```json
{
"t": "c",
"i": 0,
"op":"wh",
"v": {
"chart_id": "chart_p145W6i73otw_1596209943446",
"width": 400,
"height": 250,
"left": 20,
"top": 120
}
}
```
- **说明**
|参数|说明|
| ------------ | ------------ |
|t|操作类型表示符号|
|i|当前sheet的index值|
|op|操作选项|
|v|图表的配置信息|
- **后台更新**
更新对应sheet页中的图表设置
```js
luckysheetfile[0].chart[v.chart_id].left = v.left;
luckysheetfile[0].chart[v.chart_id].top = v.top;
luckysheetfile[0].chart[v.chart_id].width = v.width;
luckysheetfile[0].chart[v.chart_id].height = v.height;
```
### 修改图表配置
- **格式**
```json
{
"t": "c",
"i": 0,
"op":"update",
"v": {
"chart_id": "chart_p145W6i73otw_1596209943446",
"width": 400,
"height": 250,
"left": 20,
"top": 120,
"sheetIndex": "Sheet_6az6nei65t1i_1596209937084",
"needRangeShow": true,
"chartOptions": {
"chart_id": "chart_p145W6i73otw_1596209943446",
"chartAllType": "echarts|line|default",
"rangeArray": [ { "row": [ 0, 4 ], "column": [ 0, 7 ] } ],
"rangeColCheck": { "exits": true, "range": [ 0, 0 ] },
"rangeRowCheck": { "exits": true, "range": [ 0, 0 ] },
"rangeConfigCheck": false,
"defaultOption": {
"title": {
"show": true,
"text": "默认标题"
}
}
},
"isShow": true
}
}
```
- **说明**
|参数|说明|
| ------------ | ------------ |
|t|操作类型表示符号|
|i|当前sheet的index值|
|op|操作选项|
|v|图表的配置信息|
- **后台更新**
更新对应sheet页中的图表设置
```js
luckysheetfile[0].chart[v.chart_id] = v;
```

544
docs/zh/guide/sheet.md

@ -23,7 +23,7 @@ options.data示例如下:
"rowlen":{}, //表格行高
"columnlen":{}, //表格列宽
"rowhidden":{}, //隐藏行
"columnhidden":{}, //隐藏列
"colhidden":{}, //隐藏列
"borderInfo":{}, //边框
},
"scrollLeft": 0, //左右滚动条位置
@ -37,8 +37,10 @@ options.data示例如下:
"luckysheet_alternateformat_save": [], //交替颜色
"luckysheet_alternateformat_save_modelCustom": [], //自定义交替颜色
"luckysheet_conditionformat_save": {},//条件格式
"frozen": {}, //冻结行列
"frozen": {}, //冻结行列配置
"chart": [], //图表配置
"allowEdit": true, //是否允许编辑
"zoomRatio":1, // 缩放比例
},
{
"name": "Sheet2",
@ -219,16 +221,16 @@ options.data示例如下:
}
```
#### config.columnhidden
#### config.colhidden
- 类型:Object
- 默认值:{}
- 作用:隐藏列
格式为:`columnhidden[列数]: 0`,
格式为:`colhidden[列数]: 0`,
`key`指定列数即可,`value`总是为`0`
- 示例:
```js
"columnhidden": {
"colhidden": {
"30": 0,
"31": 0
}
@ -383,11 +385,11 @@ options.data示例如下:
- 示例:
```js
[{
"r": 6,
"c": 3,
"index": 1,
"func": [true, 23.75, "=AVERAGE(D3:D6)"],
"color": "w",
"r": 6, //行数
"c": 3, //列数
"index": 1, //工作表id
"func": [true, 23.75, "=AVERAGE(D3:D6)"], //公式信息,包含公式计算结果和公式字符串
"color": "w", //"w":采用深度优先算法 "b":普通计算
"parent": null,
"chidren": {},
"times": 0
@ -421,7 +423,7 @@ options.data示例如下:
"row": [0, 12],
"column": [0, 4]
},
"pivotDataSheetIndex": 6, //The sheet index where the source data is located
"pivotDataSheetIndex": 6, //源数据所在的sheet页
"column": [{
"index": 3,
"name": "subject",
@ -441,7 +443,7 @@ options.data示例如下:
"nameindex": 0
}],
"showType": "column",
"pivotDatas": [
"pivotDatas": [ //数据透视表的源数据
["count:score", "science", "mathematics", "foreign language", "English", "total"],
["Alex", 1, 1, 1, 1, 4],
["Joy", 1, 1, 1, 1, 4],
@ -510,30 +512,30 @@ options.data示例如下:
- 示例:
```js
[{
"cellrange": {
"cellrange": { //单元格范围
"row": [1, 6],
"column": [1, 5]
},
"format": {
"head": {
"head": { //页眉颜色
"fc": "#000",
"bc": "#5ed593"
},
"one": {
"one": { //第一种颜色
"fc": "#000",
"bc": "#ffffff"
},
"two": {
"two": { //第二种颜色
"fc": "#000",
"bc": "#e5fbee"
},
"foot": {
"foot": { //页脚颜色
"fc": "#000",
"bc": "#a5efcc"
}
},
"hasRowHeader": false,
"hasRowFooter": false
"hasRowHeader": false, //含有页眉
"hasRowFooter": false //含有页脚
}, {
"cellrange": {
"row": [1, 6],
@ -570,19 +572,19 @@ options.data示例如下:
- 示例:
```js
[{
"head": {
"head": { //页眉颜色
"fc": "#6aa84f",
"bc": "#ffffff"
},
"one": {
"one": { //第一种颜色
"fc": "#000",
"bc": "#ffffff"
},
"two": {
"two": { //第二种颜色
"fc": "#000",
"bc": "#e5fbee"
},
"foot": {
"foot": { //页脚颜色
"fc": "#000",
"bc": "#a5efcc"
}
@ -603,22 +605,23 @@ options.data示例如下:
"colorGradation": 色阶
API中对此设置也有介绍[API setRangeConditionalFormat](/zh/guide/api.html)
- 示例:
```js
[
{
"type": "default",
"cellrange": [
"cellrange": [ //应用的范围
{
"row": [ 2, 7 ],
"column": [ 2, 2 ]
}
],
"format": {
"format": { //type 为 default 时 应设置文本颜色和单元格颜色
"textColor": "#000000",
"cellColor": "#ff0000"
},
"conditionName": "betweenness",
"conditionName": "betweenness", //类型
"conditionRange": [
{
"row": [ 4, 4 ],
@ -721,7 +724,486 @@ options.data示例如下:
### chart
- 类型:Array
- 默认值:[]
- 作用: 图表配置
- 作用: 图表配置,参照chartMix的配置格式,允许只设置想要的图表属性,一个完整的配置案例如下。
- 示例:
:::::: details
```json
{
"chart_id": "chart_p145W6i73otw_1596209943446",
"width": 400,
"height": 250,
"left": 20,
"top": 120,
"sheetIndex": "Sheet_6az6nei65t1i_1596209937084",
"needRangeShow": true,
"chartOptions": {
"chart_id": "chart_p145W6i73otw_1596209943446",
"chartAllType": "echarts|line|default",
"rangeArray": [ { "row": [ 0, 4 ], "column": [ 0, 7 ] } ],
"rangeColCheck": { "exits": true, "range": [ 0, 0 ] },
"rangeRowCheck": { "exits": true, "range": [ 0, 0 ] },
"rangeConfigCheck": false,
"defaultOption": {
"title": {
"show": false,
"text": "默认标题",
"label": {
"fontSize": 12,
"color": "#333",
"fontFamily": "sans-serif",
"fontGroup": [],
"cusFontSize": 12
},
"position": {
"value": "left-top",
"offsetX": 40,
"offsetY": 50
}
},
"subtitle": {
"show": false,
"text": "",
"label": {
"fontSize": 12,
"color": "#333",
"fontFamily": "sans-serif",
"fontGroup": [],
"cusFontSize": 12
},
"distance": {
"value": "auto",
"cusGap": 40
}
},
"config": {
"color": "transparent",
"fontFamily": "Sans-serif",
"grid": {
"value": "normal",
"top": 5,
"left": 10,
"right": 20,
"bottom": 10
}
},
"legend": {
"show": true,
"selectMode": "multiple",
"selected": [
{
"seriesName": "衣服",
"isShow": true
},
{
"seriesName": "食材",
"isShow": true
},
{
"seriesName": "图书",
"isShow": true
}
],
"label": {
"fontSize": 12,
"color": "#333",
"fontFamily": "sans-serif",
"fontGroup": [],
"cusFontSize": 12
},
"position": {
"value": "left-top",
"offsetX": 40,
"offsetY": 50,
"direction": "horizontal"
},
"width": {
"value": "auto",
"cusSize": 25
},
"height": {
"value": "auto",
"cusSize": 14
},
"distance": {
"value": "auto",
"cusGap": 10
},
"itemGap": 10,
"data": [
"Mon",
"Tues",
"Wed",
"Thur",
"Fri",
"Sat",
"Sun"
]
},
"tooltip": {
"show": true,
"label": {
"fontSize": 12,
"color": "#333",
"fontFamily": "sans-serif",
"fontGroup": [],
"cusFontSize": 12
},
"backgroundColor": "rgba(50,50,50,0.7)",
"triggerOn": "mousemove",
"triggerType": "item",
"axisPointer": {
"type": "line",
"style": {
"color": "#555",
"width": "normal",
"type": "solid"
}
},
"format": [
{
"seriesName": "衣服",
"prefix": "",
"suffix": "",
"ratio": 1,
"digit": "auto"
},
{
"seriesName": "食材",
"prefix": "",
"suffix": "",
"ratio": 1,
"digit": "auto"
},
{
"seriesName": "图书",
"prefix": "",
"suffix": "",
"ratio": 1,
"digit": "auto"
}
],
"position": "auto"
},
"axis": {
"axisType": "xAxisDown",
"xAxisUp": {
"show": false,
"title": {
"showTitle": false,
"text": "",
"nameGap": 15,
"rotate": 0,
"label": {
"fontSize": 12,
"color": "#333",
"fontFamily": "sans-serif",
"fontGroup": [],
"cusFontSize": 12
},
"fzPosition": "end"
},
"name": "显示X轴",
"inverse": false,
"tickLine": {
"show": true,
"width": 1,
"color": "auto"
},
"tick": {
"show": true,
"position": "outside",
"length": 5,
"width": 1,
"color": "auto"
},
"tickLabel": {
"show": true,
"label": {
"fontSize": 12,
"color": "#333",
"fontFamily": "sans-serif",
"fontGroup": [],
"cusFontSize": 12
},
"rotate": 0,
"prefix": "",
"suffix": "",
"optimize": 0,
"distance": 0,
"min": "auto",
"max": "auto",
"ratio": 1,
"digit": "auto"
},
"netLine": {
"show": false,
"width": 1,
"type": "solid",
"color": "auto",
"interval": {
"value": "auto",
"cusNumber": 0
}
},
"netArea": {
"show": false,
"interval": {
"value": "auto",
"cusNumber": 0
},
"colorOne": "auto",
"colorTwo": "auto"
},
"axisLine": {
"onZero": false
}
},
"xAxisDown": {
"show": true,
"title": {
"showTitle": false,
"text": "",
"nameGap": 15,
"rotate": 0,
"label": {
"fontSize": 12,
"color": "#333",
"fontFamily": "sans-serif",
"fontGroup": [],
"cusFontSize": 12
},
"fzPosition": "end"
},
"name": "显示X轴",
"inverse": false,
"tickLine": {
"show": true,
"width": 1,
"color": "auto"
},
"tick": {
"show": true,
"position": "outside",
"length": 5,
"width": 1,
"color": "auto"
},
"tickLabel": {
"show": true,
"label": {
"fontSize": 12,
"color": "#333",
"fontFamily": "sans-serif",
"fontGroup": [],
"cusFontSize": 12
},
"rotate": 0,
"prefix": "",
"suffix": "",
"optimize": 0,
"distance": 0,
"min": null,
"max": null,
"ratio": 1,
"digit": "auto"
},
"netLine": {
"show": false,
"width": 1,
"type": "solid",
"color": "auto",
"interval": {
"value": "auto",
"cusNumber": 0
}
},
"netArea": {
"show": false,
"interval": {
"value": "auto",
"cusNumber": 0
},
"colorOne": "auto",
"colorTwo": "auto"
},
"data": [
"BUS",
"UBER",
"TAXI",
"SUBWAY"
],
"type": "category"
},
"yAxisLeft": {
"show": true,
"title": {
"showTitle": false,
"text": "",
"nameGap": 15,
"rotate": 0,
"label": {
"fontSize": 12,
"color": "#333",
"fontFamily": "sans-serif",
"fontGroup": [],
"cusFontSize": 12
},
"fzPosition": "end"
},
"name": "显示Y轴",
"inverse": false,
"tickLine": {
"show": true,
"width": 1,
"color": "auto"
},
"tick": {
"show": true,
"position": "outside",
"length": 5,
"width": 1,
"color": "auto"
},
"tickLabel": {
"show": true,
"label": {
"fontSize": 12,
"color": "#333",
"fontFamily": "sans-serif",
"fontGroup": [],
"cusFontSize": 12
},
"rotate": 0,
"formatter": {
"prefix": "",
"suffix": "",
"ratio": 1,
"digit": "auto"
},
"split": 5,
"min": null,
"max": null,
"prefix": "",
"suffix": "",
"ratio": 1,
"digit": "auto",
"distance": 0
},
"netLine": {
"show": false,
"width": 1,
"type": "solid",
"color": "auto",
"interval": {
"value": "auto",
"cusNumber": 0
}
},
"netArea": {
"show": false,
"interval": {
"value": "auto",
"cusNumber": 0
},
"colorOne": "auto",
"colorTwo": "auto"
},
"type": "value"
},
"yAxisRight": {
"show": false,
"title": {
"showTitle": false,
"text": "",
"nameGap": 15,
"rotate": 0,
"label": {
"fontSize": 12,
"color": "#333",
"fontFamily": "sans-serif",
"fontGroup": [],
"cusFontSize": 12
},
"fzPosition": "end"
},
"name": "显示Y轴",
"inverse": false,
"tickLine": {
"show": true,
"width": 1,
"color": "auto"
},
"tick": {
"show": true,
"position": "outside",
"length": 5,
"width": 1,
"color": "auto"
},
"tickLabel": {
"show": true,
"label": {
"fontSize": 12,
"color": "#333",
"fontFamily": "sans-serif",
"fontGroup": [],
"cusFontSize": 12
},
"rotate": 0,
"formatter": {
"prefix": "",
"suffix": "",
"ratio": 1,
"digit": "auto"
},
"split": 5,
"min": null,
"max": null,
"prefix": "",
"suffix": "",
"ratio": 1,
"digit": "auto",
"distance": 0
},
"netLine": {
"show": false,
"width": 1,
"type": "solid",
"color": "auto",
"interval": {
"value": "auto",
"cusNumber": 0
}
},
"netArea": {
"show": false,
"interval": {
"value": "auto",
"cusNumber": 0
},
"colorOne": "auto",
"colorTwo": "auto"
}
}
}
}
},
"isShow": true
}
```
:::
------------
### allowEdit
- 类型:Boolean
- 默认值:true
- 作用: 此sheet页是否允许编辑
------------
### zoomRatio
- 类型:Number
- 默认值:1
- 作用: 此sheet页的缩放比例,为0~1之间的二位小数数字。比如`0.1`、`0.56`
------------
@ -751,7 +1233,7 @@ Luckysheet在初始化完成之后进行的一系列操作,会将更多本地
"rowlen":{}, //表格行高
"columnlen":{}, //表格列宽
"rowhidden":{}, //隐藏行
"columnhidden":{}, //隐藏列
"colhidden":{}, //隐藏列
"borderInfo":{}, //边框
},
"scrollLeft": 0, //左右滚动条位置
@ -765,8 +1247,12 @@ Luckysheet在初始化完成之后进行的一系列操作,会将更多本地
"luckysheet_alternateformat_save": [], //交替颜色
"luckysheet_alternateformat_save_modelCustom": [], //自定义交替颜色
"luckysheet_conditionformat_save": {},//条件格式
"freezen": {}, //冻结行列
"frozen": {}, //冻结行列配置
"freezen": {}, //冻结行列的渲染数据存储
"chart": [], //图表配置
"allowEdit": true, //是否允许编辑
"zoomRatio":1, // 缩放比例
"visibledatarow": [], //所有行的位置
"visibledatacolumn": [], //所有列的位置

55
src/controllers/constant.js

@ -127,6 +127,57 @@ const gridHTML = function(){
<div id="luckysheet-postil-showBoxs"></div>
<div id="luckysheet-multipleRange-show"></div>
<div id="luckysheet-dynamicArray-hightShow"></div>
<div id="luckysheet-image-showBoxs">
<div id="luckysheet-modal-dialog-activeImage" class="luckysheet-modal-dialog" style="display:none;padding:0;position:absolute;z-index:300;">
<div class="luckysheet-modal-dialog-content"></div>
<div class="luckysheet-modal-dialog-resize">
<div class="luckysheet-modal-dialog-resize-item luckysheet-modal-dialog-resize-item-lt" data-type="lt"></div>
<div class="luckysheet-modal-dialog-resize-item luckysheet-modal-dialog-resize-item-mt" data-type="mt"></div>
<div class="luckysheet-modal-dialog-resize-item luckysheet-modal-dialog-resize-item-lm" data-type="lm"></div>
<div class="luckysheet-modal-dialog-resize-item luckysheet-modal-dialog-resize-item-rm" data-type="rm"></div>
<div class="luckysheet-modal-dialog-resize-item luckysheet-modal-dialog-resize-item-rt" data-type="rt"></div>
<div class="luckysheet-modal-dialog-resize-item luckysheet-modal-dialog-resize-item-lb" data-type="lb"></div>
<div class="luckysheet-modal-dialog-resize-item luckysheet-modal-dialog-resize-item-mb" data-type="mb"></div>
<div class="luckysheet-modal-dialog-resize-item luckysheet-modal-dialog-resize-item-rb" data-type="rb"></div>
</div>
<div class="luckysheet-modal-dialog-controll">
<span class="luckysheet-modal-controll-btn luckysheet-modal-controll-crop" role="button" tabindex="0" aria-label="裁剪" title="裁剪">
<i class="fa fa-pencil" aria-hidden="true"></i>
</span>
<span class="luckysheet-modal-controll-btn luckysheet-modal-controll-restore" role="button" tabindex="0" aria-label="恢复原图" title="恢复原图">
<i class="fa fa-window-maximize" aria-hidden="true"></i>
</span>
<span class="luckysheet-modal-controll-btn luckysheet-modal-controll-del" role="button" tabindex="0" aria-label="删除" title="删除">
<i class="fa fa-trash" aria-hidden="true"></i>
</span>
</div>
</div>
<div id="luckysheet-modal-dialog-cropping" class="luckysheet-modal-dialog" style="display:none;padding:0;position:absolute;z-index:300;">
<div class="cropping-mask"></div>
<div class="cropping-content"></div>
<div class="luckysheet-modal-dialog-resize">
<div class="resize-item lt" data-type="lt"></div>
<div class="resize-item mt" data-type="mt"></div>
<div class="resize-item lm" data-type="lm"></div>
<div class="resize-item rm" data-type="rm"></div>
<div class="resize-item rt" data-type="rt"></div>
<div class="resize-item lb" data-type="lb"></div>
<div class="resize-item mb" data-type="mb"></div>
<div class="resize-item rb" data-type="rb"></div>
</div>
<div class="luckysheet-modal-dialog-controll">
<span class="luckysheet-modal-controll-btn luckysheet-modal-controll-crop" role="button" tabindex="0" aria-label="裁剪" title="裁剪">
<i class="fa fa-pencil" aria-hidden="true"></i>
</span>
<span class="luckysheet-modal-controll-btn luckysheet-modal-controll-restore" role="button" tabindex="0" aria-label="恢复原图" title="恢复原图">
<i class="fa fa-window-maximize" aria-hidden="true"></i>
</span>
<span class="luckysheet-modal-controll-btn luckysheet-modal-controll-del" role="button" tabindex="0" aria-label="删除" title="删除">
<i class="fa fa-trash" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
<div class="luckysheet-cell-copy"></div>
<div class="luckysheet-grdblkflowpush"></div> \${flow}
</div>
@ -1209,6 +1260,10 @@ function menuToolBar (){
<i class="fa fa-gg">
</i>
${toolbar.splitColumn}
</div>
<div class="luckysheetfulltoolbar" id="luckysheet-insertImg-btn-title">
插入图片
<input id="luckysheet-imgUpload" type="file" accept="image/*" style="display:none;">
</div>`;
}

169
src/controllers/handler.js

@ -4,6 +4,7 @@ import luckysheetFreezen from './freezen';
import pivotTable from './pivotTable';
import luckysheetDropCell from './dropCell';
import luckysheetPostil from './postil';
import imageCtrl from './imageCtrl';
import menuButton from './menuButton';
import conditionformat from './conditionformat';
import alternateformat from './alternateformat';
@ -1945,6 +1946,119 @@ export default function luckysheetHandler() {
// resize chart
Store.resizeChart(Store.chartparam.luckysheetCurrentChart)
}
//image move
else if (imageCtrl.move) {
let mouse = mouseposition(event.pageX, event.pageY);
let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
let myh = $("#luckysheet-modal-dialog-activeImage").outerHeight(),
myw = $("#luckysheet-modal-dialog-activeImage").outerWidth();
let top = y - imageCtrl.moveXY[1],
left = x - imageCtrl.moveXY[0];
if (top < 0) {
top = 0;
}
if (top + myh + 42 + 6 > imageCtrl.currentWinH) {
top = imageCtrl.currentWinH - myh - 42 - 6;
}
if (left < 0) {
left = 0;
}
if (left + myw + 22 + 36 > imageCtrl.currentWinW) {
left = imageCtrl.currentWinW - myw - 22 - 36;
}
$("#luckysheet-modal-dialog-activeImage").css({ "left": left, "top": top });
}
//image resize
else if (!!imageCtrl.resize) {
let mouse = mouseposition(event.pageX, event.pageY);
let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
if (x < 0 || y < 0) {
return false;
}
let resizeXY = imageCtrl.resizeXY;
let topchange = y - resizeXY[1],
leftchange = x - resizeXY[0];
let top = resizeXY[5],
height = resizeXY[3],
left = resizeXY[4],
width = resizeXY[2];
let resize = imageCtrl.resize;
if (resize == "lm" || resize == "lt" || resize == "lb") {
left = x;
width = resizeXY[2] - leftchange;
if (left > resizeXY[2] + resizeXY[4] - 60) {
left = resizeXY[2] + resizeXY[4] - 60;
width = resizeXY[2] - (resizeXY[2] + resizeXY[4] - 60 - resizeXY[0]);
}
else if (left <= 0) {
left = 0;
width = resizeXY[2] + resizeXY[0];
}
}
if (resize == "rm" || resize == "rt" || resize == "rb") {
width = resizeXY[2] + leftchange;
if (width < 60) {
width = 60;
}
else if (width >= imageCtrl.currentWinW - resizeXY[4] - 22 - 36) {
width = imageCtrl.currentWinW - resizeXY[4] - 22 - 36;
}
}
if (resize == "mt" || resize == "lt" || resize == "rt") {
top = y;
height = resizeXY[3] - topchange;
if (top > resizeXY[3] + resizeXY[5] - 60) {
top = resizeXY[3] + resizeXY[5] - 60;
height = resizeXY[3] - (resizeXY[3] + resizeXY[5] - 60 - resizeXY[1]);
}
else if (top <= 0) {
top = 0;
height = resizeXY[3] + resizeXY[1];
}
}
if (resize == "mb" || resize == "lb" || resize == "rb") {
height = resizeXY[3] + topchange;
if (height < 60) {
height = 60;
}
else if (height >= imageCtrl.currentWinH - resizeXY[5] - 42 - 6) {
height = imageCtrl.currentWinH - resizeXY[5] - 42 - 6;
}
}
$("#luckysheet-modal-dialog-activeImage").css({
"width": width,
"height": height,
"left": left,
"top": top
});
$("#luckysheet-modal-dialog-activeImage .luckysheet-modal-dialog-content").css({
"background-size": width + "px " + height + "px",
"background-position": "0px 0px"
})
}
else if (luckysheetPostil.move) {
let mouse = mouseposition(event.pageX, event.pageY);
let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
@ -2052,7 +2166,8 @@ export default function luckysheetHandler() {
}
else if (!!formula.rangeMove) {
formula.rangeMoveDraging(event, formula.rangeMovexy, formula.rangeMoveObj.data("range"), formula.rangeMoveObj, Store.sheetBarHeight, Store.statisticBarHeight);
} else if (!!Store.chart_selection.rangeResize) {
}
else if (!!Store.chart_selection.rangeResize) {
Store.chart_selection.rangeResizeDraging(event, Store.sheetBarHeight, Store.statisticBarHeight);
}
else if (!!Store.chart_selection.rangeMove) {
@ -2231,6 +2346,16 @@ export default function luckysheetHandler() {
formula.rangeResizeDragged(event, formula.rangeResizeObj, formula.rangeResize, formula.rangeResizexy, formula.rangeResizeWinW, formula.rangeResizeWinH);
}
//image move
if (imageCtrl.move) {
imageCtrl.moveImgItem();
}
//image resize
if (imageCtrl.resize) {
imageCtrl.resizeImgItem();
}
//批注框 移动
if (luckysheetPostil.move) {
luckysheetPostil.move = false;
@ -3437,6 +3562,48 @@ export default function luckysheetHandler() {
splitColumn.init();
});
//菜单栏 插入图片按钮
$("#luckysheet-insertImg-btn-title").click(function () {
$("#luckysheet-imgUpload").click();
});
$("#luckysheet-imgUpload").click(function (e) {
e.stopPropagation();
});
$("#luckysheet-imgUpload").on("change", function(e){
let file = e.currentTarget.files[0];
let render = new FileReader();
render.readAsDataURL(file);
render.onload = function(event){
let src = event.target.result;
let rowIndex = Store.luckysheet_select_save[0].row_focus;
let colIndex = Store.luckysheet_select_save[0].column_focus;
let left = colIndex == 0 ? 0 : Store.visibledatacolumn[colIndex - 1];
let top = rowIndex == 0 ? 0 : Store.visibledatarow[rowIndex - 1];
let image = new Image();
image.onload = function(){
let width = image.width,
height = image.height;
let img = {
src: src,
left: left,
top: top,
originWidth: width,
originHeight: height
}
imageCtrl.addImgItem(img);
$("#luckysheet-imgUpload").val("");
}
image.src = src;
}
});
//冻结行列
$("#luckysheet-freezen-btn-horizontal").click(function () {
if ($.trim($(this).text()) == locale().freezen.freezenCancel) {

283
src/controllers/imageCtrl.js

@ -0,0 +1,283 @@
import {
rowLocation,
colLocation,
mouseposition
} from '../global/location';
import { setluckysheet_scroll_status } from '../methods/set';
const imageCtrl = {
imgItem: {
src: '', //图片url
originWidth: null, //图片原始宽度
originHeight: null, //图片原始高度
default: {
width: null, //图片 宽度
height: null, //图片 高度
left: null, //图片离表格左边的 位置
top: null, //图片离表格顶部的 位置
},
crop: {
width: null, //图片裁剪后 宽度
height: null, //图片裁剪后 高度
offsetLeft: 0, //图片裁剪后离未裁剪时 左边的位移
offsetTop: 0, //图片裁剪后离未裁剪时 顶部的位移
}
},
images: null,
currentImgId: null,
currentWinW: null,
currentWinH: null,
resize: null,
resizeXY: null,
move: false,
moveXY: null,
generateRandomId: function(prefix) {
if(prefix == null){
prefix = "img";
}
let userAgent = window.navigator.userAgent.replace(/[^a-zA-Z0-9]/g, "").split("");
let mid = "";
for(let i = 0; i < 12; i++){
mid += userAgent[Math.round(Math.random() * (userAgent.length - 1))];
}
let time = new Date().getTime();
return prefix + "_" + mid + "_" + time;
},
modelHtml: function(id, imgItem) {
let src = imgItem.src;
let width = imgItem.default.width,
height = imgItem.default.height,
left = imgItem.default.left,
top = imgItem.default.top;
return `<div id="${id}" class="luckysheet-modal-dialog luckysheet-modal-dialog-image" style="width:${width}px;height:${height}px;padding:0;position:absolute;left:${left}px;top:${top}px;z-index:200;">
<div class="luckysheet-modal-dialog-content">
<img src="${src}" style="width:100%;height:100%;" />
</div>
</div>`;
},
init: function() {
let _this = this;
//image active
$("#luckysheet-image-showBoxs").off("mousedown.active").on("mousedown.active", ".luckysheet-modal-dialog-image", function(e) {
$(this).hide();
let id = $(this).attr("id");
_this.currentImgId = id;
let item = _this.images[id];
let width = item.default.width,
height = item.default.height,
left = item.default.left,
top = item.default.top;
if(item.crop.width != width || item.crop.height != height){
width = item.crop.width;
height = item.crop.height;
left = left + item.crop.offsetLeft;
top = top + item.crop.offsetTop;
}
$("#luckysheet-modal-dialog-activeImage").show().css({
"width": width,
"height": height,
"left": left,
"top": top
});
$("#luckysheet-modal-dialog-activeImage .luckysheet-modal-dialog-content").css({
"background-image": "url(" + item.src + ")",
"background-size": item.default.width + "px " + item.default.height + "px",
"background-position": -item.crop.offsetLeft + "px " + -item.crop.offsetTop + "px"
})
e.stopPropagation();
})
//image move
$("#luckysheet-modal-dialog-activeImage").off("mousedown.move").on("mousedown.move", ".luckysheet-modal-dialog-content", function(e) {
_this.move = true;
_this.currentWinW = $("#luckysheet-cell-main")[0].scrollWidth;
_this.currentWinH = $("#luckysheet-cell-main")[0].scrollHeight;
let scrollTop = $("#luckysheet-cell-main").scrollTop(),
scrollLeft = $("#luckysheet-cell-main").scrollLeft();
let offset = $("#luckysheet-modal-dialog-activeImage").offset();
let position = $("#luckysheet-modal-dialog-activeImage").position();
_this.moveXY = [
e.pageX - offset.left,
e.pageY - offset.top,
position.left,
position.top,
scrollLeft,
scrollTop
];
setluckysheet_scroll_status(true);
e.stopPropagation();
})
//image resize
$("#luckysheet-modal-dialog-activeImage").off("mousedown.resize").on("mousedown.resize", ".luckysheet-modal-dialog-resize-item", function(e) {
_this.currentWinW = $("#luckysheet-cell-main")[0].scrollWidth;
_this.currentWinH = $("#luckysheet-cell-main")[0].scrollHeight;
_this.resize = $(this).data("type");
let scrollTop = $("#luckysheet-cell-main").scrollTop(),
scrollLeft = $("#luckysheet-cell-main").scrollLeft();
let mouse = mouseposition(e.pageX, e.pageY);
let x = mouse[0] + scrollLeft;
let y = mouse[1] + scrollTop;
let position = $("#luckysheet-modal-dialog-activeImage").position();
let width = $("#luckysheet-modal-dialog-activeImage").width();
let height = $("#luckysheet-modal-dialog-activeImage").height();
_this.resizeXY = [
x,
y,
width,
height,
position.left + scrollLeft,
position.top + scrollTop,
scrollLeft,
scrollTop
];
setluckysheet_scroll_status(true);
e.stopPropagation();
})
//image crop
$("#luckysheet-modal-dialog-activeImage").off("mousedown.crop").on("mousedown.crop", ".luckysheet-modal-controll-crop", function(e) {
$("#luckysheet-modal-dialog-activeImage").hide();
let item = _this.images[_this.currentImgId];
let width = item.default.width,
height = item.default.height,
left = item.default.left,
top = item.default.top;
if(item.crop.width != width || item.crop.height != height){
width = item.crop.width;
height = item.crop.height;
left = left + item.crop.offsetLeft;
top = top + item.crop.offsetTop;
}
$("#luckysheet-modal-dialog-cropping").show().css({
"width": width,
"height": height,
"left": left,
"top": top
});
$("#luckysheet-modal-dialog-cropping .cropping-mask").css({
"width": item.default.width,
"height": item.default.height,
"background-image": "url(" + item.src + ")",
"left": -item.crop.offsetLeft,
"top": -item.crop.offsetTop
})
$("#luckysheet-modal-dialog-cropping .cropping-content").css({
"background-image": "url(" + item.src + ")",
"background-size": item.default.width + "px " + item.default.height + "px",
"background-position": -item.crop.offsetLeft + "px " + -item.crop.offsetTop + "px"
})
e.stopPropagation();
})
//image delete
$("#luckysheet-modal-dialog-activeImage").off("mousedown.delete").on("mousedown.delete", ".luckysheet-modal-controll-del", function(e) {
_this.removeImgItem();
})
},
addImgItem: function(img) {
let _this = this;
let width, height;
let max = 400;
if(img.originHeight < img.originWidth){
height = Math.round(img.originHeight * (max / img.originWidth));
width = max;
}
else{
width = Math.round(img.originWidth * (max / img.originHeight));
height = max;
}
if(_this.images == null){
_this.images = {};
}
let imgItem = $.extend(true, {}, _this.imgItem);
imgItem.src = img.src;
imgItem.originWidth = img.originWidth;
imgItem.originHeight = img.originHeight;
imgItem.default.width = width;
imgItem.default.height = height;
imgItem.default.left = img.left;
imgItem.default.top = img.top;
imgItem.crop.width = width;
imgItem.crop.height = height;
let id = _this.generateRandomId();
let modelHtml = _this.modelHtml(id, imgItem);
$("#luckysheet-image-showBoxs").append(modelHtml);
_this.images[id] = imgItem;
_this.init();
},
moveImgItem: function() {
let _this = this;
_this.move = false;
let position = $("#luckysheet-modal-dialog-activeImage").position();
_this.images[_this.currentImgId].left = position.left;
_this.images[_this.currentImgId].top = position.top;
},
resizeImgItem: function() {
let _this = this;
_this.resize = null;
let position = $("#luckysheet-modal-dialog-activeImage").position();
let width = $("#luckysheet-modal-dialog-activeImage").outerWidth();
let height = $("#luckysheet-modal-dialog-activeImage").outerHeight();
_this.images[_this.currentImgId].width = width;
_this.images[_this.currentImgId].height = height;
_this.images[_this.currentImgId].left = position.left;
_this.images[_this.currentImgId].top = position.top;
},
removeImgItem: function() {
let _this = this;
delete _this.images[_this.currentImgId];
$("#luckysheet-modal-dialog-activeImage").hide();
},
}
export default imageCtrl;

2
src/controllers/server.js

@ -660,7 +660,7 @@ const server = {
$("#luckysheet-sheets-item" + index).show();
}
}
else if(type == "c"){ //图表操作
else if(type == "c"){ //图表操作 TODO
let op = item.op, cid = item.cid;
if(op == "add"){ //插入

14
src/controllers/sheetmanage.js

@ -695,6 +695,7 @@ const sheetmanage = {
let execF = function(){
_this.mergeCalculation(file["index"]);
editor.webWorkerFlowDataCache(Store.flowdata);//worker存数据
_this.storeSheetParam();
_this.restoreselect();
_this.CacheNotLoadControll = [];
@ -981,10 +982,11 @@ const sheetmanage = {
}
let load = file["load"];
if (load != null) {
if (load != null) {
_this.mergeCalculation(index);
_this.setSheetParam(true);
_this.showSheet();
_this.mergeCalculation(index);
setTimeout(function () {
formula.execFunctionGroup();
luckysheetrefreshgrid();
@ -998,10 +1000,10 @@ const sheetmanage = {
file["data"] = data;
file["load"] = "1";
_this.mergeCalculation(index);
_this.setSheetParam();
_this.showSheet();
_this.mergeCalculation(index);
setTimeout(function () {
_this.restoreCache();
formula.execFunctionGroupForce(luckysheetConfigsetting.forceCalculation);
@ -1041,10 +1043,10 @@ const sheetmanage = {
file["data"] = data;
file["load"] = "1";
_this.mergeCalculation(index);
_this.setSheetParam();
_this.showSheet();
_this.mergeCalculation(index);
setTimeout(function () {
_this.restoreCache();
formula.execFunctionGroupForce(luckysheetConfigsetting.forceCalculation);

218
src/css/luckysheet-core.css

@ -6397,3 +6397,221 @@ fieldset[disabled] a.btn {
background: #FC6666;
cursor: pointer;
}
/* 图片 */
#luckysheet-modal-dialog-activeImage .luckysheet-modal-dialog-content{
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
cursor: move;
}
#luckysheet-modal-dialog-cropping::before{
content: "";
outline: 1px solid #fff;
position: absolute;
left: 33.3%;
right: 33.3%;
top: 0;
bottom: 0;
z-index: 1;
pointer-events: none;
}
#luckysheet-modal-dialog-cropping::after{
content: "";
outline: 1px solid #fff;
position: absolute;
left: 0;
right: 0;
top: 33.3%;
bottom: 33.3%;
z-index: 1;
pointer-events: none;
}
#luckysheet-modal-dialog-cropping .cropping-mask{
filter: brightness(.5);
position: absolute;
background-size: 100% 100%;
left: 0;
top: 0;
}
#luckysheet-modal-dialog-cropping .cropping-content{
position: absolute;
overflow: hidden;
background-position: 0 0;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
#luckysheet-modal-dialog-cropping .luckysheet-modal-dialog-resize{
border: none;
position: absolute;
margin: 0px;
padding: 0px;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
#luckysheet-modal-dialog-cropping .resize-item{
width: 0;
height: 0;
background: none;
border: none;
position: absolute;
z-index: 3;
}
#luckysheet-modal-dialog-cropping .resize-item::before{
content: "";
display: block;
position: absolute;
background: #000;
}
#luckysheet-modal-dialog-cropping .resize-item::after{
content: "";
display: block;
position: absolute;
background: #000;
}
#luckysheet-modal-dialog-cropping .lt{
left: 0;
top: 0;
cursor: nwse-resize;
}
#luckysheet-modal-dialog-cropping .lt::before{
width: 18px;
height: 4px;
left: 0;
top: 0;
border-right: 2px solid #fff;
border-bottom: 2px solid #fff;
}
#luckysheet-modal-dialog-cropping .lt::after{
width: 4px;
height: 14px;
left: 0;
top: 4px;
border-right: 2px solid #fff;
border-bottom: 2px solid #fff;
}
#luckysheet-modal-dialog-cropping .mt{
left: 50%;
top: 0;
cursor: ns-resize;
}
#luckysheet-modal-dialog-cropping .mt::before{
width: 18px;
height: 4px;
left: -11px;
top: 0;
border-left: 2px solid #fff;
border-right: 2px solid #fff;
border-bottom: 2px solid #fff;
}
#luckysheet-modal-dialog-cropping .rt{
right: 0;
top: 0;
cursor: nesw-resize;
}
#luckysheet-modal-dialog-cropping .rt::before{
width: 18px;
height: 4px;
right: 0;
top: 0;
border-left: 2px solid #fff;
border-bottom: 2px solid #fff;
}
#luckysheet-modal-dialog-cropping .rt::after{
width: 4px;
height: 14px;
right: 0;
top: 4px;
border-left: 2px solid #fff;
border-bottom: 2px solid #fff;
}
#luckysheet-modal-dialog-cropping .lm{
left: 0;
top: 50%;
cursor: ew-resize;
}
#luckysheet-modal-dialog-cropping .lm::before{
width: 4px;
height: 18px;
left: 0;
top: -11px;
border-right: 2px solid #fff;
border-top: 2px solid #fff;
border-bottom: 2px solid #fff;
}
#luckysheet-modal-dialog-cropping .rm{
right: 0;
top: 50%;
cursor: ew-resize;
}
#luckysheet-modal-dialog-cropping .rm::before{
width: 4px;
height: 18px;
right: 0;
top: -11px;
border-left: 2px solid #fff;
border-top: 2px solid #fff;
border-bottom: 2px solid #fff;
}
#luckysheet-modal-dialog-cropping .lb{
left: 0;
bottom: 0;
cursor: nesw-resize;
}
#luckysheet-modal-dialog-cropping .lb::before{
width: 18px;
height: 4px;
left: 0;
bottom: 0;
border-right: 2px solid #fff;
border-top: 2px solid #fff;
}
#luckysheet-modal-dialog-cropping .lb::after{
width: 4px;
height: 14px;
left: 0;
bottom: 4px;
border-right: 2px solid #fff;
border-top: 2px solid #fff;
}
#luckysheet-modal-dialog-cropping .rb{
right: 0;
bottom: 0;
cursor: nwse-resize;
}
#luckysheet-modal-dialog-cropping .rb::before{
width: 18px;
height: 4px;
right: 0;
bottom: 0;
border-left: 2px solid #fff;
border-top: 2px solid #fff;
}
#luckysheet-modal-dialog-cropping .rb::after{
width: 4px;
height: 14px;
right: 0;
bottom: 4px;
border-left: 2px solid #fff;
border-top: 2px solid #fff;
}
#luckysheet-modal-dialog-cropping .mb{
left: 50%;
bottom: 0;
cursor: ns-resize;
}
#luckysheet-modal-dialog-cropping .mb::before{
width: 18px;
height: 4px;
left: -11px;
bottom: 0;
border-left: 2px solid #fff;
border-right: 2px solid #fff;
border-top: 2px solid #fff;
}

8
src/expendPlugins/chart/plugin.js

@ -1387,10 +1387,10 @@ function selectRangeBorderShow(chart_id) {
//luckysheet取cell-main,后续扩展到其他的用户自定义元素
$('#luckysheet-cell-main')
.find('.luckysheet-modal-dialog-resize')
.find('.luckysheet-modal-dialog-chart .luckysheet-modal-dialog-resize')
.hide()
$('#luckysheet-cell-main')
.find('.luckysheet-modal-dialog-controll')
.find('.luckysheet-modal-dialog-chart .luckysheet-modal-dialog-controll')
.hide()
$t.css('z-index', chartInfo.chartparam.luckysheetCurrentChartZIndexRank++)
@ -1413,7 +1413,7 @@ function selectRangeBorderShow(chart_id) {
//选择区域高亮隐藏
function selectRangeBorderHide(settingShow) {
$('#luckysheet-cell-main .luckysheet-modal-dialog-resize, #luckysheet-cell-main .luckysheet-modal-dialog-controll').hide()
$('#luckysheet-cell-main .luckysheet-modal-dialog-chart .luckysheet-modal-dialog-resize, #luckysheet-cell-main .luckysheet-modal-dialog-chart .luckysheet-modal-dialog-controll').hide()
$('#luckysheet-cell-main').find('.luckysheet-datavisual-selection-set div').remove()
chartInfo.chartparam.luckysheetCurrentChartActive = false
@ -1447,7 +1447,7 @@ function hideChartSettingComponent(refresh) {
//隐藏设置界面
$('.chartSetting').hide();
//.luckysheet-modal-dialog-resize为图表显示框的缩放框,.luckysheet-modal-dialog-controll为显示框右边的控制按钮
$('#luckysheet-cell-main .luckysheet-modal-dialog-resize, #luckysheet-cell-main .luckysheet-modal-dialog-controll').hide()
$('#luckysheet-cell-main .luckysheet-modal-dialog-chart .luckysheet-modal-dialog-resize, #luckysheet-cell-main .luckysheet-modal-dialog-chart .luckysheet-modal-dialog-controll').hide()
$('#luckysheet-cell-main').find('.luckysheet-datavisual-selection-set div').remove()

2
src/global/createdom.js

@ -50,8 +50,6 @@ export default function luckysheetcreatedom(colwidth, rowheight, data, menu, tit
else {
Store.flowdata = data;
}
editor.webWorkerFlowDataCache(Store.flowdata);//worker存数据
let flowHTML = flow;
if(Store.config == null){

2
src/global/draw.js

@ -716,7 +716,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
let end_c = Store.visibledatacolumn[c] - scrollWidth;
//数据透视表\
//数据透视表
if (!!Store.luckysheetcurrentisPivotTable && pivotTable.drawPivotTable) {
if ((c == 0 || c == 5) && r <= 11) {
luckysheetTableContent.beginPath();

2
src/index.html

@ -33,7 +33,7 @@
luckysheet.create({
container: 'luckysheet',
lang: 'zh',
lang: 'en',
allowEdit:true,
forceCalculation:false,
plugins: ['chart'],

Loading…
Cancel
Save