diff --git a/docs/guide/config.md b/docs/guide/config.md index d1ea88f22..10f49580f 100644 --- a/docs/guide/config.md +++ b/docs/guide/config.md @@ -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|-| @@ -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 @@ -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 } ------------ diff --git a/docs/zh/guide/config.md b/docs/zh/guide/config.md index 40494e6c9..3fdfa2ed8 100644 --- a/docs/zh/guide/config.md +++ b/docs/zh/guide/config.md @@ -551,8 +551,9 @@ Luckysheet开放了更细致的自定义配置选项,分别有 |insertColumn|插入列|-|向左增加N列,向右增加N列|向左增加N列,向右增加N列| |deleteRow|删除选中行|删除选中行|-|-| |deleteColumn|删除选中列|-|删除选中列|删除选中列| - |hideRow|隐藏选中行和显示选中行|隐藏选中行和显示选中行|-|-| - |hideColumn|隐藏选中列和显示选中列|-|隐藏选中列和显示选中列|隐藏选中列和显示选中列| + |deleteCell|删除单元格|-|-|-| + |hideRow|-|隐藏选中行和显示选中行|-|-| + |hideColumn|-|-|隐藏选中列和显示选中列|隐藏选中列和显示选中列| |rowHeight|-|行高|-|-| |columnWidth|-|-|列宽|列宽| |clear|清除内容|清除内容|清除内容|-| @@ -569,8 +570,6 @@ Luckysheet开放了更细致的自定义配置选项,分别有 ------------ ### sheetRightClickConfig -[todo] - - 类型:Object - 默认值:{} - 作用:自定义配置sheet页右击菜单 @@ -581,10 +580,8 @@ Luckysheet开放了更细致的自定义配置选项,分别有 copy: false, // 复制 rename: false, //重命名 color: false, //更改颜色 - hide: false, //隐藏 - show: false, //取消隐藏 - left: false, //向左移 - right: false //向右移 + hide: false, //隐藏,取消隐藏 + move: false, //向左移,向右移 } ------------ diff --git a/src/controllers/constant.js b/src/controllers/constant.js index 9f755cd90..f1e018634 100644 --- a/src/controllers/constant.js +++ b/src/controllers/constant.js @@ -623,33 +623,55 @@ const sheetHTML = '
-
+ 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 = `
+
${sheetconfig.delete}
-
+
${sheetconfig.copy}
-
+
${sheetconfig.rename}
-
+
${sheetconfig.changeColor}
- -
+ +
${sheetconfig.hide}
-
+
${sheetconfig.unhide}
- -
+ +
${sheetconfig.moveLeft}
-
+
${sheetconfig.moveRight}
@@ -663,6 +685,8 @@ function sheetconfigHTML(){
`; + + return sheetconfigModel; } const luckysheetPivotTableHTML = function(){ @@ -1703,6 +1727,28 @@ function customCellRightClickConfig() { 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, diff --git a/src/controllers/handler.js b/src/controllers/handler.js index 8bf28b2d7..b4073f14b 100644 --- a/src/controllers/handler.js +++ b/src/controllers/handler.js @@ -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); @@ -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); @@ -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'; @@ -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) { diff --git a/src/controllers/rowColumnOperation.js b/src/controllers/rowColumnOperation.js index 57448b137..32f137030 100644 --- a/src/controllers/rowColumnOperation.js +++ b/src/controllers/rowColumnOperation.js @@ -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'; @@ -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'; @@ -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'; diff --git a/src/controllers/sheetBar.js b/src/controllers/sheetBar.js index 9df8d6706..4ecc87cc2 100644 --- a/src/controllers/sheetBar.js +++ b/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); diff --git a/src/core.js b/src/core.js index 5b322207d..be85a221f 100644 --- a/src/core.js +++ b/src/core.js @@ -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;