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

Commit

Permalink
feat(config): sheetRightClickConfig
Browse files Browse the repository at this point in the history
Support sheetRightClickConfig
  • Loading branch information
mengshukeji committed Nov 4, 2020
1 parent 3e0b9a8 commit 59c7cb3
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 30 deletions.
12 changes: 4 additions & 8 deletions docs/guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,8 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect
|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|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|Hide the selected column and show the selected column|
|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|-|
Expand All @@ -481,8 +481,6 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect
------------
### sheetRightClickConfig

[todo]

- Type: Object
- Default: {}
- Usage: Customize the right-click menu of the bottom sheet bar
Expand All @@ -493,10 +491,8 @@ 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
}

------------
Expand Down
13 changes: 5 additions & 8 deletions docs/zh/guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,9 @@ Luckysheet开放了更细致的自定义配置选项,分别有
|insertColumn|插入列|-|向左增加N列,向右增加N列|向左增加N列,向右增加N列|
|deleteRow|删除选中行|删除选中行|-|-|
|deleteColumn|删除选中列|-|删除选中列|删除选中列|
|hideRow|隐藏选中行和显示选中行|隐藏选中行和显示选中行|-|-|
|hideColumn|隐藏选中列和显示选中列|-|隐藏选中列和显示选中列|隐藏选中列和显示选中列|
|deleteCell|删除单元格|-|-|-|
|hideRow|-|隐藏选中行和显示选中行|-|-|
|hideColumn|-|-|隐藏选中列和显示选中列|隐藏选中列和显示选中列|
|rowHeight|-|行高|-|-|
|columnWidth|-|-|列宽|列宽|
|clear|清除内容|清除内容|清除内容|-|
Expand All @@ -569,8 +570,6 @@ Luckysheet开放了更细致的自定义配置选项,分别有
------------
### sheetRightClickConfig

[todo]

- 类型:Object
- 默认值:{}
- 作用:自定义配置sheet页右击菜单
Expand All @@ -581,10 +580,8 @@ Luckysheet开放了更细致的自定义配置选项,分别有
copy: false, // 复制
rename: false, //重命名
color: false, //更改颜色
hide: false, //隐藏
show: false, //取消隐藏
left: false, //向左移
right: false //向右移
hide: false, //隐藏,取消隐藏
move: false, //向左移,向右移
}

------------
Expand Down
68 changes: 57 additions & 11 deletions src/controllers/constant.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 19 additions & 2 deletions src/controllers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,12 @@ export default function luckysheetHandler() {
$$('#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);
Expand Down Expand Up @@ -1234,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);
Expand Down Expand Up @@ -1301,6 +1313,11 @@ export default function luckysheetHandler() {
$("#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';
Expand All @@ -1319,8 +1336,8 @@ export default function luckysheetHandler() {
// 当一个功能菜单块内所有的按钮都隐藏的时候,它顶部的分割线也需要隐藏掉
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) {
Expand Down
15 changes: 15 additions & 0 deletions src/controllers/rowColumnOperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ export function rowColumnOperationInitial(){
// 自定义右键菜单:向上向下增加行,删除行,隐藏显示行,设置行高
const cellRightClickConfig = luckysheetConfigsetting.cellRightClickConfig;

// 如果全部按钮都隐藏,则整个菜单容器也要隐藏
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;
}

$$('#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';
Expand Down Expand Up @@ -830,6 +835,11 @@ export function rowColumnOperationInitial(){
// 自定义右键菜单:向左向右增加列,删除列,隐藏显示列,设置列宽
const cellRightClickConfig = luckysheetConfigsetting.cellRightClickConfig;

// 如果全部按钮都隐藏,则整个菜单容器也要隐藏
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;
}

$$('#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';
Expand Down Expand Up @@ -1004,6 +1014,11 @@ export function rowColumnOperationInitial(){
// 自定义右键菜单:向左向右增加列,删除列,隐藏显示列,设置列宽
const cellRightClickConfig = luckysheetConfigsetting.cellRightClickConfig;

// 如果全部按钮都隐藏,则整个菜单容器也要隐藏
if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste && !cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.hideColumn && !cellRightClickConfig.columnWidth && !cellRightClickConfig.sort){
return;
}

$$('#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';
Expand Down
9 changes: 8 additions & 1 deletion src/controllers/sheetBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';



Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ luckysheet.create = function (setting) {
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;
Expand Down

0 comments on commit 59c7cb3

Please sign in to comment.