Browse Source

feat(config): sheetRightClickConfig

Support sheetRightClickConfig
master
mengshukeji 5 years ago
parent
commit
59c7cb34a3
  1. 12
      docs/guide/config.md
  2. 13
      docs/zh/guide/config.md
  3. 68
      src/controllers/constant.js
  4. 21
      src/controllers/handler.js
  5. 15
      src/controllers/rowColumnOperation.js
  6. 9
      src/controllers/sheetBar.js
  7. 1
      src/core.js

12
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
}
------------

13
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, //向左移,向右移
}
------------

68
src/controllers/constant.js

@ -623,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>
@ -663,6 +685,8 @@ function sheetconfigHTML(){
</div>
</div>
</div>`;
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,

21
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) {

15
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';

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);

1
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;

Loading…
Cancel
Save