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

Dev #1393

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Dev #1393

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
export default {
container: "luckysheet", //容器的ID
loading:{}, //自定义loading
column: 60, //空表格默认的列数量
row: 84, //空表格默认的行数据量
column: 15, //空表格默认的列数量
row: 30, //空表格默认的行数据量
allowCopy: true, //是否允许拷贝
showtoolbar: true, //是否第二列显示工具栏
showinfobar: true, //是否显示顶部名称栏
Expand Down Expand Up @@ -55,9 +55,9 @@ export default {
forceCalculation:false,//强制刷新公式,公式较多会有性能问题,慎用
rowHeaderWidth: 46,
columnHeaderHeight: 20,
defaultColWidth:73,
defaultRowHeight:19,
defaultFontSize:10,
defaultColWidth:120,
defaultRowHeight:40,
defaultFontSize:12,
limitSheetNameLength:true, //是否限制工作表名的长度
defaultSheetNameMaxLength:31, //默认工作表名称的最大长度
sheetFormulaBar:true, //是否显示公式栏
Expand All @@ -67,4 +67,13 @@ export default {
cellRightClickConfig:{}, //自定义单元格右键菜单
sheetRightClickConfig:{}, //自定义底部sheet页右击菜单
imageUpdateMethodConfig:{}, //自定义图片同步方式
// defaultstyle: {
// fillStyle: "#000000",
// textBaseline: "middle",
// strokeStyle: "#dfdfdf",
// rowFillStyle: "#5e5e5e",
// textAlign: "center",
// whiteSpace: "normal" // 添加自动换行属性
// },
defaultBorder:{},
}
2 changes: 1 addition & 1 deletion src/controllers/freezen.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { rowLocationByIndex, colLocationByIndex } from '../global/location';
import Store from '../store';
import locale from '../locale/locale';
import { luckysheetrefreshgrid } from '../global/refresh';

import imageCtrl from './imageCtrl';

const luckysheetFreezen = {
freezenHorizontalHTML: '<div id="luckysheet-freezebar-horizontal" class="luckysheet-freezebar" tabindex="0"><div class="luckysheet-freezebar-handle luckysheet-freezebar-horizontal-handle" ><div class="luckysheet-freezebar-handle-bar luckysheet-freezebar-horizontal-handle-title" ></div><div class="luckysheet-freezebar-handle-bar luckysheet-freezebar-horizontal-handle-bar" ></div></div><div class="luckysheet-freezebar-drop luckysheet-freezebar-horizontal-drop" ><div class="luckysheet-freezebar-drop-bar luckysheet-freezebar-horizontal-drop-title" ></div><div class="luckysheet-freezebar-drop-bar luckysheet-freezebar-horizontal-drop-bar" >&nbsp;</div></div></div>',
Expand Down
34 changes: 19 additions & 15 deletions src/controllers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,12 @@ export default function luckysheetHandler() {
}

let $span = $editor.find("span[rangeindex='" + formula.rangechangeindex + "']");
if ($span && $span != undefined && $span != null && $span && $span.html().length) {
formula.setCaretPosition($span.get(0), 0, $span.html().length);
if ($span && $span != undefined && $span != null && $span ) {
if($span.html()){
if($span.html().length){
formula.setCaretPosition($span.get(0), 0, $span.html().length);
}
}
}
}, 1);
return;
Expand Down Expand Up @@ -1363,15 +1367,15 @@ export default function luckysheetHandler() {
}
}

if (isSame) {
$("#luckysheet-cols-rows-add")
.find("input[type='number'].rcsize")
.val(first_collen);
} else {
$("#luckysheet-cols-rows-add")
.find("input[type='number'].rcsize")
.val("");
}
// if (isSame) {
// $("#luckysheet-cols-rows-add")
// .find("input[type='number'].rcsize")
// .val(first_collen);
// } else {
// $("#luckysheet-cols-rows-add")
// .find("input[type='number'].rcsize")
// .val("");
// }
} else if (
obj_s["column"] != null &&
obj_s["column"][0] == 0 &&
Expand Down Expand Up @@ -1558,7 +1562,7 @@ export default function luckysheetHandler() {
// 备注:在mousedown中发送光标信息会漏处理部分(选区)范围
server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
})
.dblclick(function(event) {
.dblclick(function(event) { // 双击进入单元格执行的是这个方法
if ($(event.target).hasClass("luckysheet-mousedown-cancel")) {
return;
}
Expand Down Expand Up @@ -5135,7 +5139,7 @@ export default function luckysheetHandler() {
value = $("#luckysheet-bottom-add-row-input").val();

if (value == "") {
value = luckysheetConfigsetting.addRowCount || 100;
value = luckysheetConfigsetting.addRowCount || 5;
}

if (isNaN(parseInt(value))) {
Expand All @@ -5148,7 +5152,7 @@ export default function luckysheetHandler() {
}

value = parseInt(value);
if (value < 1 || value > 100) {
if (value < 1 || value > 10) { // 1-10 行数据
if (isEditMode()) {
alert(locale_info.tipInputNumberLimit);
} else {
Expand Down Expand Up @@ -6041,7 +6045,7 @@ export default function luckysheetHandler() {
}

const locale_fontjson = locale().fontjson;

debugger;
// hook
if (!method.createHookFunction("rangePasteBefore", Store.luckysheet_select_save, txtdata)) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/luckysheetConfigsetting.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const luckysheetConfigsetting = {

showConfigWindowResize: true,
enableAddRow: true,
addRowCount: 100,
addRowCount: 5,//默认为5
enableAddBackTop: true,
enablePage: true,
pageInfo: null,
Expand All @@ -34,8 +34,8 @@ const luckysheetConfigsetting = {
plugins:[],
forceCalculation:false,//强制刷新公式,公式较多会有性能问题,慎用

defaultColWidth:73,
defaultRowHeight:19,
defaultColWidth:120,
defaultRowHeight:40,

defaultTextColor: '#000',
defaultCellColor: '#fff',
Expand Down
28 changes: 15 additions & 13 deletions src/controllers/menuButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,7 @@ const menuButton = {
let menu = replaceHtml(_this.menu, { id: "align-menu", item: itemset, subclass: "", sub: "" });

$("body").append(menu);
$menuButton = $("#" + menuButtonId).width(120);
$menuButton = $("#" + menuButtonId).width(140);
_this.focus($menuButton);

$menuButton.find(".luckysheet-cols-menuitem").click(function() {
Expand Down Expand Up @@ -1928,7 +1928,7 @@ const menuButton = {
let menu = replaceHtml(_this.menu, { id: "valign-menu", item: itemset, subclass: "", sub: "" });

$("body").append(menu);
$menuButton = $("#" + menuButtonId).width(120);
$menuButton = $("#" + menuButtonId).width(140);
_this.focus($menuButton, "bottom");

$menuButton.find(".luckysheet-cols-menuitem").click(function() {
Expand Down Expand Up @@ -2004,15 +2004,17 @@ const menuButton = {
let menu = replaceHtml(_this.menu, { id: "textwrap-menu", item: itemset, subclass: "", sub: "" });

$("body").append(menu);
$menuButton = $("#" + menuButtonId).width(120);
$menuButton = $("#" + menuButtonId).width(140);
_this.focus($menuButton, "clip");

//点击换行方式时触发
$menuButton.find(".luckysheet-cols-menuitem").click(function() {

$menuButton.find(".luckysheet-cols-menuitem").click(function() { // 处理自动换行
$menuButton.hide();
luckysheetContainerFocus();

let $t = $(this),
itemvalue = $t.attr("itemvalue");
itemvalue = $t.attr("itemvalue"); // 当前选中的换行方式
_this.focus($menuButton, itemvalue);

let $icon = $("#luckysheet-icon-textwrap")
Expand Down Expand Up @@ -2309,10 +2311,9 @@ const menuButton = {
}
let scrollTop = $("#luckysheet-cell-main").scrollTop();
let row_st = luckysheet_searcharray(Store.visibledatarow, scrollTop);

let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
let row_focus = last["row_focus"] == null ? last["row"][0] : last["row_focus"];
row_st = Math.max(row_st - 1, row_focus - 1, 0);
row_st = Math.max(row_st, row_focus, 0);

let top, freezenhorizontaldata;
if (luckysheetFreezen.freezenRealFirstRowColumn) {
Expand Down Expand Up @@ -2369,7 +2370,7 @@ const menuButton = {

let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
let column_focus = last["column_focus"] == null ? last["column"][0] : last["column_focus"];
col_st = Math.max(col_st - 1, column_focus - 1, 0);
col_st = Math.max(col_st, column_focus, 0);

let left, freezenverticaldata;
if (luckysheetFreezen.freezenRealFirstRowColumn) {
Expand Down Expand Up @@ -2430,7 +2431,7 @@ const menuButton = {

let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
let row_focus = last["row_focus"] == null ? last["row"][0] : last["row_focus"];
row_st = Math.max(row_st - 1, row_focus - 1, 0);
row_st = Math.max(row_st, row_focus , 0);

let top, freezenhorizontaldata;
if (luckysheetFreezen.freezenRealFirstRowColumn) {
Expand Down Expand Up @@ -2461,7 +2462,7 @@ const menuButton = {
let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);

let column_focus = last["column_focus"] == null ? last["column"][0] : last["column_focus"];
col_st = Math.max(col_st - 1, column_focus - 1, 0);
col_st = Math.max(col_st, column_focus, 0);

let left, freezenverticaldata;
if (luckysheetFreezen.freezenRealFirstRowColumn) {
Expand Down Expand Up @@ -3929,15 +3930,17 @@ const menuButton = {
cfg["rowlen"] = {};
}

for (let s = 0; s < Store.luckysheet_select_save.length; s++) {
for (let s = 0; s < Store.luckysheet_select_save.length; s++) { // 调整了行高和列宽
let row_st = Store.luckysheet_select_save[s]["row"][0],
row_ed = Store.luckysheet_select_save[s]["row"][1];
let col_st = Store.luckysheet_select_save[s]["column"][0],
col_ed = Store.luckysheet_select_save[s]["column"][1];

this.updateFormatCell(d, attr, foucsStatus, row_st, row_ed, col_st, col_ed);

if (attr == "tb" || attr == "tr" || attr == "fs") {
if (attr == "tr" || attr == "fs") {
// if (attr == "tb" || attr == "tr" || attr == "fs") {
// 处理行高的,我需要tb 的去掉行高
cfg = rowlenByRange(d, row_st, row_ed, cfg);
}
}
Expand Down Expand Up @@ -4335,7 +4338,6 @@ const menuButton = {
let $menuButton = $("#luckysheet-icon-textwrap-menu-menuButton");
let $t = $("luckysheet-icon-textwrap"),
itemvalue = "clip";

if (foucsStatus == "1") {
itemvalue = "overflow";
} else if (foucsStatus == "2") {
Expand Down
45 changes: 28 additions & 17 deletions src/controllers/protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ export function initialEvent(file){

inputRangeProtectionPassword = {};

//确定工作表保护的确定事件,触发updated钩子函数
if(Store.clearjfundo){
let redo = {};
redo["type"] = 'update_protect';
redo["sheetIndex"] = file.index;
redo["config"] = $.extend(true, {}, file.config);
Store. jfundo.length = 0;
Store.jfredo.push(redo);
}
closeProtectionModal();

});
Expand Down Expand Up @@ -495,15 +504,15 @@ function initialProtectionRangeModal(file){
</div>
</div>
</div>
<div class="luckysheet-slider-protection-row">
<div class="luckysheet-slider-protection-row" style="display:none">
<div class="luckysheet-slider-protection-column luckysheet-protection-column-3x">
${local_protection.allowRangeAddTitlePassword}
</div>
<div class="luckysheet-slider-protection-column luckysheet-protection-column-7x" style="left:30%">
<input class="luckysheet-protection-rangeItemiInput" id="protection-allowRangeAdd-password" placeHolder="${local_protection.enterPassword}">
</div>
</div>
<div class="luckysheet-slider-protection-row">
<div class="luckysheet-slider-protection-row" style="display:none" >
<div class="luckysheet-slider-protection-column luckysheet-protection-column-3x">
${local_protection.allowRangeAddTitleHint}
</div>
Expand Down Expand Up @@ -549,24 +558,24 @@ function initialProtectionRIghtBar(file){
<label for="protection-swichProtectionState"><input id="protection-swichProtectionState" name="protection-swichProtectionState" type="checkbox">${local_protection.swichProtectionTip}</label>
</div>
</div>
<div class="luckysheet-slider-protection-row" style="height:23px;">
<div class="luckysheet-slider-protection-row" style="height:23px; display:none;">
<div class="luckysheet-slider-protection-column" style="width:98%;">
<input class="luckysheet-protection-input" id="protection-password" placeHolder="${local_protection.enterPassword}">
</div>
</div>
<div class="luckysheet-slider-protection-row" style="height:47px;margin-top:4px;">
<div class="luckysheet-slider-protection-row" style="height:47px;margin-top:4px;display:none;">
<div class="luckysheet-slider-protection-column" style="width:98%;">
<textarea class="luckysheet-protection-textarea" id="protection-hint" placeHolder="${local_protection.enterHint}"></textarea>
</div>
</div>
</div>
<div class="luckysheet-slider-protection-config" style="top:130px;height:290px;border-top:1px solid #c5c5c5">
<div class="luckysheet-slider-protection-config" style="top:60px;height:290px;border-top:1px solid #c5c5c5">
<div class="luckysheet-slider-protection-row" style="height:20px;">
${local_protection.authorityTitle}
</div>
${authorityItemHtml}
</div>
<div class="luckysheet-slider-protection-config" style="top:440px;bottom:45px;border-top:1px solid #c5c5c5">
<div class="luckysheet-slider-protection-config" style="top:375px;bottom:45px;border-top:1px solid #c5c5c5">
<div class="luckysheet-slider-protection-row" style="height:25px;">
<div class="luckysheet-slider-protection-column luckysheet-protection-column-7x" style="left:0px;line-height: 25px;">
${local_protection.allowRangeTitle}
Expand Down Expand Up @@ -686,24 +695,24 @@ function restoreProtectionConfig(aut){
export function openProtectionModal(file){
if(!isInitialProtection){
initialProtectionRIghtBar(file);
initialEvent(file);
isInitialProtection = true;
}
initialProtectionRIghtBar(file);

updatingSheetFile = file;

initialEvent(file);
isInitialProtection = true;

if(file!=null && file.config!=null && file.config.authority!=null){
let aut = file.config.authority;
if(firstInputSheetProtectionPassword && aut.sheet==1 && aut.password!=null && aut.password.length>0){
validationAuthority = aut;
$("#luckysheet-protection-sheet-validation input").val("");
openSelfModel("luckysheet-protection-sheet-validation");
return;
}
else{//retore protection config
// if(firstInputSheetProtectionPassword && aut.sheet==1 && aut.password!=null && aut.password.length>0){
// validationAuthority = aut;
// $("#luckysheet-protection-sheet-validation input").val("");
// openSelfModel("luckysheet-protection-sheet-validation");
// return;
// }
// else{//retore protection config
restoreProtectionConfig(aut);
}
// }
}
else{//protection initial config //没有设置可编辑区域
//默认全选
Expand Down Expand Up @@ -883,6 +892,7 @@ function openRangePasswordModal(rangeAut) {

//protection state
export function checkProtectionNotEnable(sheetIndex){
//删除 单元格格式化 合并单元格等都会走这个方法。
let sheetFile = sheetmanage.getSheetByIndex(sheetIndex);
if(sheetFile==null){
return true;
Expand All @@ -901,6 +911,7 @@ export function checkProtectionNotEnable(sheetIndex){
const _locale = locale();
const local_protection = _locale.protection;

// 如果是垂直
let ht;
if(aut.hintText != null && aut.hintText.length>0){
ht = aut.hintText;
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) {
else {
$("#" + Store.container).find(".luckysheet-wa-editor").show();
// Store.toolbarHeight = 72;
Store.toolbarHeight = document.querySelector('#' + Store.container +' .luckysheet-wa-editor').offsetHeight;
if (document.querySelector('#' + Store.container + ' .luckysheet-wa-editor')) {
Store.toolbarHeight = document.querySelector('#' + Store.container + ' .luckysheet-wa-editor').offsetHeight;
}
}

// if (!luckysheetConfigsetting.showsheetbar) {
Expand Down
Loading