@leankylin-sheet/react 5.1.15 → 5.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +3 -49
- package/dist/index.js +2 -48
- package/dist/index.umd.js +579 -524
- package/dist/index.umd.min.js +1 -1
- package/package.json +3 -3
package/dist/index.umd.js
CHANGED
|
@@ -86813,13 +86813,14 @@
|
|
|
86813
86813
|
var f = (data === null || data === void 0 ? void 0 : data.f) || "";
|
|
86814
86814
|
var rowspan = (_data$mc$rs = data === null || data === void 0 ? void 0 : (_data$mc = data.mc) === null || _data$mc === void 0 ? void 0 : _data$mc.rs) !== null && _data$mc$rs !== void 0 ? _data$mc$rs : 1;
|
|
86815
86815
|
var colspan = (_data$mc$cs = data === null || data === void 0 ? void 0 : (_data$mc2 = data.mc) === null || _data$mc2 === void 0 ? void 0 : _data$mc2.cs) !== null && _data$mc$cs !== void 0 ? _data$mc$cs : 1;
|
|
86816
|
+
var allV = JSON.stringify(data);
|
|
86816
86817
|
if (!(data === null || data === void 0 ? void 0 : data.mc) || (data === null || data === void 0 ? void 0 : data.mc) && (data === null || data === void 0 ? void 0 : data.mc.r) === r && data.mc.c === c) {
|
|
86817
86818
|
var _Object$keys;
|
|
86818
86819
|
var style = cellAttrToDomStyle(data, borderInfo["".concat(r, "_").concat(c)]);
|
|
86819
86820
|
var styleStr = (_Object$keys = Object.keys(style)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.map(function (item) {
|
|
86820
86821
|
return "".concat(item, ":").concat(style[item], ";");
|
|
86821
86822
|
}).join("");
|
|
86822
|
-
cpString += "<td x:num='".concat(realValue, "' f='").concat(f, "' style='").concat(styleStr, "' rowspan=").concat(rowspan, " colspan=").concat(colspan, ">").concat(value, "</td>");
|
|
86823
|
+
cpString += "<td _v='".concat(allV, "' x:num='").concat(realValue, "' f='").concat(f, "' style='").concat(styleStr, "' rowspan=").concat(rowspan, " colspan=").concat(colspan, ">").concat(value, "</td>");
|
|
86823
86824
|
}
|
|
86824
86825
|
};
|
|
86825
86826
|
for (var c = columns[0]; c <= columns[1]; c += 1) {
|
|
@@ -86830,7 +86831,41 @@
|
|
|
86830
86831
|
var result = "<table border=\"1\" style=\"border-collapse:collapse\" data-type=\"leankylin-copy-action-table\">".concat(cpString, "</table>");
|
|
86831
86832
|
clipboard.writeHtml(result);
|
|
86832
86833
|
}
|
|
86833
|
-
function
|
|
86834
|
+
function deepClear(ctx) {
|
|
86835
|
+
var allowEdit = isAllowEdit(ctx);
|
|
86836
|
+
if (allowEdit === false) {
|
|
86837
|
+
return "allowEdit";
|
|
86838
|
+
}
|
|
86839
|
+
var selection = ctx.luckysheet_select_save;
|
|
86840
|
+
if (selection && !lodash.isEmpty(selection)) {
|
|
86841
|
+
var d = getFlowdata(ctx);
|
|
86842
|
+
var hyperlinkMap = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].hyperlink;
|
|
86843
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
86844
|
+
var r1 = selection[s].row[0];
|
|
86845
|
+
var r2 = selection[s].row[1];
|
|
86846
|
+
var c1 = selection[s].column[0];
|
|
86847
|
+
var c2 = selection[s].column[1];
|
|
86848
|
+
for (var r = r1; r <= r2; r += 1) {
|
|
86849
|
+
for (var c = c1; c <= c2; c += 1) {
|
|
86850
|
+
var _d$r2;
|
|
86851
|
+
var cell = d === null || d === void 0 ? void 0 : (_d$r2 = d[r]) === null || _d$r2 === void 0 ? void 0 : _d$r2[c];
|
|
86852
|
+
d[r][c] = null;
|
|
86853
|
+
if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
|
|
86854
|
+
delFunctionGroup(ctx, r, c, ctx.currentSheetId);
|
|
86855
|
+
}
|
|
86856
|
+
if (hyperlinkMap && hyperlinkMap["".concat(r, "_").concat(c)]) {
|
|
86857
|
+
delete hyperlinkMap["".concat(r, "_").concat(c)];
|
|
86858
|
+
}
|
|
86859
|
+
}
|
|
86860
|
+
}
|
|
86861
|
+
}
|
|
86862
|
+
}
|
|
86863
|
+
return "success";
|
|
86864
|
+
}
|
|
86865
|
+
function deleteSelectedCellText(ctx, deep) {
|
|
86866
|
+
if (deep) {
|
|
86867
|
+
return deepClear(ctx);
|
|
86868
|
+
}
|
|
86834
86869
|
var allowEdit = isAllowEdit(ctx);
|
|
86835
86870
|
if (allowEdit === false) {
|
|
86836
86871
|
return "allowEdit";
|
|
@@ -90955,98 +90990,339 @@
|
|
|
90955
90990
|
}
|
|
90956
90991
|
console.timeEnd("calculateSheetByCellsTime");
|
|
90957
90992
|
}
|
|
90958
|
-
|
|
90959
|
-
|
|
90993
|
+
function generateRandomId(prefix) {
|
|
90994
|
+
if (prefix == null) {
|
|
90995
|
+
prefix = "img";
|
|
90996
|
+
}
|
|
90997
|
+
var userAgent = window.navigator.userAgent.replace(/[^a-zA-Z0-9]/g, "").split("");
|
|
90998
|
+
var mid = "";
|
|
90999
|
+
for (var i = 0; i < 12; i += 1) {
|
|
91000
|
+
mid += userAgent[Math.round(Math.random() * (userAgent.length - 1))];
|
|
91001
|
+
}
|
|
91002
|
+
var time = new Date().getTime();
|
|
91003
|
+
return "".concat(prefix, "_").concat(mid, "_").concat(time);
|
|
91004
|
+
}
|
|
91005
|
+
function showImgChooser() {
|
|
91006
|
+
var chooser = document.getElementById("leankylin-img-upload");
|
|
91007
|
+
if (chooser) chooser.click();
|
|
91008
|
+
}
|
|
91009
|
+
function saveImage(ctx) {
|
|
90960
91010
|
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
90961
91011
|
if (index == null) return;
|
|
90962
91012
|
var file = ctx.luckysheetfile[index];
|
|
90963
|
-
file.
|
|
90964
|
-
file.luckysheet_select_save = ctx.luckysheet_select_save;
|
|
90965
|
-
file.luckysheet_selection_range = ctx.luckysheet_selection_range;
|
|
90966
|
-
file.zoomRatio = ctx.zoomRatio;
|
|
91013
|
+
file.images = ctx.insertedImgs;
|
|
90967
91014
|
}
|
|
90968
|
-
function
|
|
90969
|
-
|
|
90970
|
-
|
|
90971
|
-
|
|
90972
|
-
ctx.
|
|
91015
|
+
function removeActiveImage(ctx) {
|
|
91016
|
+
ctx.insertedImgs = lodash.filter(ctx.insertedImgs, function (image) {
|
|
91017
|
+
return image.id !== ctx.activeImg;
|
|
91018
|
+
});
|
|
91019
|
+
ctx.activeImg = undefined;
|
|
91020
|
+
saveImage(ctx);
|
|
90973
91021
|
}
|
|
90974
|
-
function
|
|
90975
|
-
|
|
90976
|
-
|
|
90977
|
-
|
|
90978
|
-
|
|
90979
|
-
|
|
90980
|
-
|
|
90981
|
-
|
|
90982
|
-
|
|
90983
|
-
|
|
90984
|
-
|
|
90985
|
-
|
|
90986
|
-
|
|
90987
|
-
|
|
90988
|
-
|
|
90989
|
-
|
|
90990
|
-
|
|
90991
|
-
|
|
90992
|
-
|
|
90993
|
-
|
|
90994
|
-
|
|
91022
|
+
function insertImage(ctx, image) {
|
|
91023
|
+
try {
|
|
91024
|
+
var _ctx$luckysheet_selec;
|
|
91025
|
+
var last = (_ctx$luckysheet_selec = ctx.luckysheet_select_save) === null || _ctx$luckysheet_selec === void 0 ? void 0 : _ctx$luckysheet_selec[ctx.luckysheet_select_save.length - 1];
|
|
91026
|
+
var rowIndex = last === null || last === void 0 ? void 0 : last.row_focus;
|
|
91027
|
+
var colIndex = last === null || last === void 0 ? void 0 : last.column_focus;
|
|
91028
|
+
if (!last) {
|
|
91029
|
+
rowIndex = 0;
|
|
91030
|
+
colIndex = 0;
|
|
91031
|
+
} else {
|
|
91032
|
+
if (rowIndex == null) {
|
|
91033
|
+
var _last$row = _slicedToArray$2(last.row, 1);
|
|
91034
|
+
rowIndex = _last$row[0];
|
|
91035
|
+
}
|
|
91036
|
+
if (colIndex == null) {
|
|
91037
|
+
var _last$column = _slicedToArray$2(last.column, 1);
|
|
91038
|
+
colIndex = _last$column[0];
|
|
91039
|
+
}
|
|
91040
|
+
}
|
|
91041
|
+
var flowdata = getFlowdata(ctx);
|
|
91042
|
+
var left = colIndex === 0 ? 0 : ctx.visibledatacolumn[colIndex - 1];
|
|
91043
|
+
var top = rowIndex === 0 ? 0 : ctx.visibledatarow[rowIndex - 1];
|
|
91044
|
+
if (flowdata) {
|
|
91045
|
+
var margeset = mergeBorder(ctx, flowdata, rowIndex, colIndex);
|
|
91046
|
+
if (margeset) {
|
|
91047
|
+
var _margeset$row = _slicedToArray$2(margeset.row, 1);
|
|
91048
|
+
top = _margeset$row[0];
|
|
91049
|
+
var _margeset$column = _slicedToArray$2(margeset.column, 1);
|
|
91050
|
+
left = _margeset$column[0];
|
|
91051
|
+
}
|
|
91052
|
+
}
|
|
91053
|
+
var width = image.width;
|
|
91054
|
+
var height = image.height;
|
|
91055
|
+
var img = {
|
|
91056
|
+
id: generateRandomId("img"),
|
|
91057
|
+
src: image.src,
|
|
91058
|
+
left: left,
|
|
91059
|
+
top: top,
|
|
91060
|
+
width: width * 0.5,
|
|
91061
|
+
height: height * 0.5,
|
|
91062
|
+
originWidth: width,
|
|
91063
|
+
originHeight: height
|
|
91064
|
+
};
|
|
91065
|
+
ctx.insertedImgs = (ctx.insertedImgs || []).concat(img);
|
|
91066
|
+
saveImage(ctx);
|
|
91067
|
+
} catch (err) {
|
|
91068
|
+
console.info(err);
|
|
90995
91069
|
}
|
|
90996
91070
|
}
|
|
90997
|
-
function
|
|
90998
|
-
var
|
|
90999
|
-
|
|
91000
|
-
var
|
|
91001
|
-
|
|
91002
|
-
|
|
91003
|
-
|
|
91004
|
-
|
|
91005
|
-
|
|
91006
|
-
|
|
91007
|
-
|
|
91008
|
-
|
|
91009
|
-
|
|
91010
|
-
|
|
91011
|
-
|
|
91012
|
-
|
|
91013
|
-
|
|
91071
|
+
function getImagePosition() {
|
|
91072
|
+
var box = document.getElementById("luckysheet-modal-dialog-activeImage");
|
|
91073
|
+
if (!box) return undefined;
|
|
91074
|
+
var _box$getBoundingClien = box.getBoundingClientRect(),
|
|
91075
|
+
width = _box$getBoundingClien.width,
|
|
91076
|
+
height = _box$getBoundingClien.height;
|
|
91077
|
+
var left = box.offsetLeft;
|
|
91078
|
+
var top = box.offsetTop;
|
|
91079
|
+
return {
|
|
91080
|
+
left: left,
|
|
91081
|
+
top: top,
|
|
91082
|
+
width: width,
|
|
91083
|
+
height: height
|
|
91084
|
+
};
|
|
91085
|
+
}
|
|
91086
|
+
function cancelActiveImgItem(ctx, globalCache) {
|
|
91087
|
+
ctx.activeImg = undefined;
|
|
91088
|
+
globalCache.image = undefined;
|
|
91089
|
+
}
|
|
91090
|
+
function onImageMoveStart(ctx, globalCache, e) {
|
|
91091
|
+
var position = getImagePosition();
|
|
91092
|
+
if (position) {
|
|
91093
|
+
var top = position.top,
|
|
91094
|
+
left = position.left;
|
|
91095
|
+
lodash.set(globalCache, "image", {
|
|
91096
|
+
cursorMoveStartPosition: {
|
|
91097
|
+
x: e.pageX,
|
|
91098
|
+
y: e.pageY
|
|
91099
|
+
},
|
|
91100
|
+
imgInitialPosition: {
|
|
91101
|
+
left: left,
|
|
91102
|
+
top: top
|
|
91103
|
+
}
|
|
91014
91104
|
});
|
|
91015
91105
|
}
|
|
91016
|
-
|
|
91017
|
-
|
|
91018
|
-
|
|
91019
|
-
|
|
91020
|
-
|
|
91021
|
-
|
|
91022
|
-
|
|
91023
|
-
|
|
91024
|
-
|
|
91025
|
-
|
|
91026
|
-
|
|
91027
|
-
|
|
91028
|
-
|
|
91029
|
-
|
|
91030
|
-
|
|
91031
|
-
|
|
91106
|
+
}
|
|
91107
|
+
function onImageMove(ctx, globalCache, e) {
|
|
91108
|
+
if (ctx.allowEdit === false) return false;
|
|
91109
|
+
var image = globalCache === null || globalCache === void 0 ? void 0 : globalCache.image;
|
|
91110
|
+
var img = document.getElementById("luckysheet-modal-dialog-activeImage");
|
|
91111
|
+
if (img && image && !image.resizingSide) {
|
|
91112
|
+
var _image$cursorMoveStar = image.cursorMoveStartPosition,
|
|
91113
|
+
startX = _image$cursorMoveStar.x,
|
|
91114
|
+
startY = _image$cursorMoveStar.y;
|
|
91115
|
+
var _image$imgInitialPosi = image.imgInitialPosition,
|
|
91116
|
+
top = _image$imgInitialPosi.top,
|
|
91117
|
+
left = _image$imgInitialPosi.left;
|
|
91118
|
+
left += e.pageX - startX;
|
|
91119
|
+
top += e.pageY - startY;
|
|
91120
|
+
if (top < 0) top = 0;
|
|
91121
|
+
img.style.left = "".concat(left, "px");
|
|
91122
|
+
img.style.top = "".concat(top, "px");
|
|
91123
|
+
return true;
|
|
91032
91124
|
}
|
|
91033
|
-
|
|
91034
|
-
|
|
91035
|
-
|
|
91125
|
+
return false;
|
|
91126
|
+
}
|
|
91127
|
+
function onImageMoveEnd(ctx, globalCache) {
|
|
91128
|
+
var _globalCache$image;
|
|
91129
|
+
var position = getImagePosition();
|
|
91130
|
+
if (!((_globalCache$image = globalCache.image) === null || _globalCache$image === void 0 ? void 0 : _globalCache$image.resizingSide)) {
|
|
91131
|
+
globalCache.image = undefined;
|
|
91132
|
+
if (position) {
|
|
91133
|
+
var img = lodash.find(ctx.insertedImgs, function (v) {
|
|
91134
|
+
return v.id === ctx.activeImg;
|
|
91135
|
+
});
|
|
91136
|
+
if (img) {
|
|
91137
|
+
img.left = position.left / ctx.zoomRatio;
|
|
91138
|
+
img.top = position.top / ctx.zoomRatio;
|
|
91139
|
+
saveImage(ctx);
|
|
91140
|
+
}
|
|
91141
|
+
}
|
|
91036
91142
|
}
|
|
91037
|
-
|
|
91038
|
-
|
|
91039
|
-
|
|
91040
|
-
|
|
91143
|
+
}
|
|
91144
|
+
function onImageResizeStart(globalCache, e, resizingSide) {
|
|
91145
|
+
var position = getImagePosition();
|
|
91146
|
+
if (position) {
|
|
91147
|
+
lodash.set(globalCache, "image", {
|
|
91148
|
+
cursorMoveStartPosition: {
|
|
91149
|
+
x: e.pageX,
|
|
91150
|
+
y: e.pageY
|
|
91151
|
+
},
|
|
91152
|
+
resizingSide: resizingSide,
|
|
91153
|
+
imgInitialPosition: position
|
|
91041
91154
|
});
|
|
91042
91155
|
}
|
|
91043
91156
|
}
|
|
91044
|
-
function
|
|
91045
|
-
|
|
91046
|
-
|
|
91047
|
-
|
|
91048
|
-
|
|
91049
|
-
|
|
91157
|
+
function onImageResize(ctx, globalCache, e) {
|
|
91158
|
+
if (ctx.allowEdit === false) return false;
|
|
91159
|
+
var image = globalCache === null || globalCache === void 0 ? void 0 : globalCache.image;
|
|
91160
|
+
if (image === null || image === void 0 ? void 0 : image.resizingSide) {
|
|
91161
|
+
var imgContainer = document.getElementById("luckysheet-modal-dialog-activeImage");
|
|
91162
|
+
var img = imgContainer === null || imgContainer === void 0 ? void 0 : imgContainer.querySelector(".luckysheet-modal-dialog-content");
|
|
91163
|
+
if (img == null) return false;
|
|
91164
|
+
var _image$cursorMoveStar2 = image.cursorMoveStartPosition,
|
|
91165
|
+
startX = _image$cursorMoveStar2.x,
|
|
91166
|
+
startY = _image$cursorMoveStar2.y;
|
|
91167
|
+
var _image$imgInitialPosi2 = image.imgInitialPosition,
|
|
91168
|
+
top = _image$imgInitialPosi2.top,
|
|
91169
|
+
left = _image$imgInitialPosi2.left,
|
|
91170
|
+
width = _image$imgInitialPosi2.width,
|
|
91171
|
+
height = _image$imgInitialPosi2.height;
|
|
91172
|
+
var dx = e.pageX - startX;
|
|
91173
|
+
var dy = e.pageY - startY;
|
|
91174
|
+
var minHeight = 60 * ctx.zoomRatio;
|
|
91175
|
+
var minWidth = 1.5 * 60 * ctx.zoomRatio;
|
|
91176
|
+
if (["lm", "lt", "lb"].includes(image.resizingSide)) {
|
|
91177
|
+
if (width - dx < minWidth) {
|
|
91178
|
+
left += width - minWidth;
|
|
91179
|
+
width = minWidth;
|
|
91180
|
+
} else {
|
|
91181
|
+
left += dx;
|
|
91182
|
+
width -= dx;
|
|
91183
|
+
}
|
|
91184
|
+
if (left < 0) left = 0;
|
|
91185
|
+
img.style.left = "".concat(left, "px");
|
|
91186
|
+
imgContainer.style.left = "".concat(left, "px");
|
|
91187
|
+
}
|
|
91188
|
+
if (["rm", "rt", "rb"].includes(image.resizingSide)) {
|
|
91189
|
+
width = width + dx < minWidth ? minWidth : width + dx;
|
|
91190
|
+
}
|
|
91191
|
+
if (["mt", "lt", "rt"].includes(image.resizingSide)) {
|
|
91192
|
+
if (height - dy < minHeight) {
|
|
91193
|
+
top += height - minHeight;
|
|
91194
|
+
height = minHeight;
|
|
91195
|
+
} else {
|
|
91196
|
+
top += dy;
|
|
91197
|
+
height -= dy;
|
|
91198
|
+
}
|
|
91199
|
+
if (top < 0) top = 0;
|
|
91200
|
+
img.style.top = "".concat(top, "px");
|
|
91201
|
+
imgContainer.style.top = "".concat(top, "px");
|
|
91202
|
+
}
|
|
91203
|
+
if (["mb", "lb", "rb"].includes(image.resizingSide)) {
|
|
91204
|
+
height = height + dy < minHeight ? minHeight : height + dy;
|
|
91205
|
+
}
|
|
91206
|
+
img.style.width = "".concat(width, "px");
|
|
91207
|
+
imgContainer.style.width = "".concat(width, "px");
|
|
91208
|
+
img.style.height = "".concat(height, "px");
|
|
91209
|
+
imgContainer.style.height = "".concat(height, "px");
|
|
91210
|
+
img.style.backgroundSize = "".concat(width, "px ").concat(height, "px");
|
|
91211
|
+
return true;
|
|
91212
|
+
}
|
|
91213
|
+
return false;
|
|
91214
|
+
}
|
|
91215
|
+
function onImageResizeEnd(ctx, globalCache) {
|
|
91216
|
+
var _globalCache$image2;
|
|
91217
|
+
if ((_globalCache$image2 = globalCache.image) === null || _globalCache$image2 === void 0 ? void 0 : _globalCache$image2.resizingSide) {
|
|
91218
|
+
globalCache.image = undefined;
|
|
91219
|
+
var position = getImagePosition();
|
|
91220
|
+
if (position) {
|
|
91221
|
+
var img = lodash.find(ctx.insertedImgs, function (v) {
|
|
91222
|
+
return v.id === ctx.activeImg;
|
|
91223
|
+
});
|
|
91224
|
+
if (img) {
|
|
91225
|
+
img.left = position.left / ctx.zoomRatio;
|
|
91226
|
+
img.top = position.top / ctx.zoomRatio;
|
|
91227
|
+
img.width = position.width / ctx.zoomRatio;
|
|
91228
|
+
img.height = position.height / ctx.zoomRatio;
|
|
91229
|
+
saveImage(ctx);
|
|
91230
|
+
}
|
|
91231
|
+
}
|
|
91232
|
+
}
|
|
91233
|
+
}
|
|
91234
|
+
|
|
91235
|
+
function storeSheetParam(ctx) {
|
|
91236
|
+
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
91237
|
+
if (index == null) return;
|
|
91238
|
+
var file = ctx.luckysheetfile[index];
|
|
91239
|
+
file.config = ctx.config;
|
|
91240
|
+
file.luckysheet_select_save = ctx.luckysheet_select_save;
|
|
91241
|
+
file.luckysheet_selection_range = ctx.luckysheet_selection_range;
|
|
91242
|
+
file.zoomRatio = ctx.zoomRatio;
|
|
91243
|
+
}
|
|
91244
|
+
function storeSheetParamALL(ctx) {
|
|
91245
|
+
storeSheetParam(ctx);
|
|
91246
|
+
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
91247
|
+
if (index == null) return;
|
|
91248
|
+
ctx.luckysheetfile[index].config = ctx.config;
|
|
91249
|
+
}
|
|
91250
|
+
function changeSheet(ctx, id, isPivotInitial, isNewSheet, isCopySheet) {
|
|
91251
|
+
var _ctx$hooks$beforeActi, _ctx$hooks;
|
|
91252
|
+
if (id === ctx.currentSheetId) {
|
|
91253
|
+
return;
|
|
91254
|
+
}
|
|
91255
|
+
var file = ctx.luckysheetfile[getSheetIndex(ctx, id)];
|
|
91256
|
+
if (((_ctx$hooks$beforeActi = (_ctx$hooks = ctx.hooks).beforeActivateSheet) === null || _ctx$hooks$beforeActi === void 0 ? void 0 : _ctx$hooks$beforeActi.call(_ctx$hooks, id)) === false) {
|
|
91257
|
+
return;
|
|
91258
|
+
}
|
|
91259
|
+
storeSheetParamALL(ctx);
|
|
91260
|
+
ctx.currentSheetId = id;
|
|
91261
|
+
if (file.isPivotTable) {
|
|
91262
|
+
ctx.luckysheetcurrentisPivotTable = true;
|
|
91263
|
+
} else {
|
|
91264
|
+
ctx.luckysheetcurrentisPivotTable = false;
|
|
91265
|
+
}
|
|
91266
|
+
if (ctx.hooks.afterActivateSheet) {
|
|
91267
|
+
setTimeout(function () {
|
|
91268
|
+
var _ctx$hooks$afterActiv, _ctx$hooks2;
|
|
91269
|
+
(_ctx$hooks$afterActiv = (_ctx$hooks2 = ctx.hooks).afterActivateSheet) === null || _ctx$hooks$afterActiv === void 0 ? void 0 : _ctx$hooks$afterActiv.call(_ctx$hooks2, id);
|
|
91270
|
+
});
|
|
91271
|
+
}
|
|
91272
|
+
}
|
|
91273
|
+
function addSheet(ctx, settings) {
|
|
91274
|
+
var _ctx$hooks$beforeAddS, _ctx$hooks3;
|
|
91275
|
+
var newSheetID = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
91276
|
+
var isPivotTable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
91277
|
+
var sheetName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
|
|
91278
|
+
var sheetData = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : undefined;
|
|
91279
|
+
if (ctx.allowEdit === false) {
|
|
91280
|
+
return;
|
|
91281
|
+
}
|
|
91282
|
+
var order = ctx.luckysheetfile.length;
|
|
91283
|
+
var id = newSheetID !== null && newSheetID !== void 0 ? newSheetID : settings === null || settings === void 0 ? void 0 : settings.generateSheetId();
|
|
91284
|
+
var sheetname = sheetName || generateRandomSheetName(ctx.luckysheetfile, isPivotTable, ctx);
|
|
91285
|
+
if (!lodash.isNil(sheetData)) {
|
|
91286
|
+
delete sheetData.data;
|
|
91287
|
+
ctx.luckysheetfile.forEach(function (sheet) {
|
|
91288
|
+
sheet.order = sheet.order < sheetData.order ? sheet.order : sheet.order + 1;
|
|
91289
|
+
return sheet;
|
|
91290
|
+
});
|
|
91291
|
+
}
|
|
91292
|
+
var sheetconfig = lodash.isNil(sheetData) ? {
|
|
91293
|
+
name: sheetName === undefined ? sheetname : sheetName,
|
|
91294
|
+
status: 0,
|
|
91295
|
+
order: order,
|
|
91296
|
+
id: id,
|
|
91297
|
+
row: ctx.defaultrowNum,
|
|
91298
|
+
column: ctx.defaultcolumnNum,
|
|
91299
|
+
config: {},
|
|
91300
|
+
pivotTable: null,
|
|
91301
|
+
isPivotTable: !!isPivotTable,
|
|
91302
|
+
zoomRatio: 1
|
|
91303
|
+
} : sheetData;
|
|
91304
|
+
if (sheetName !== undefined) sheetconfig.name = sheetName;
|
|
91305
|
+
if (sheetconfig.id === undefined) sheetconfig.id = v4();
|
|
91306
|
+
if (((_ctx$hooks$beforeAddS = (_ctx$hooks3 = ctx.hooks).beforeAddSheet) === null || _ctx$hooks$beforeAddS === void 0 ? void 0 : _ctx$hooks$beforeAddS.call(_ctx$hooks3, sheetconfig)) === false) {
|
|
91307
|
+
return;
|
|
91308
|
+
}
|
|
91309
|
+
ctx.luckysheetfile.push(sheetconfig);
|
|
91310
|
+
if (!newSheetID) {
|
|
91311
|
+
changeSheet(ctx, id);
|
|
91312
|
+
}
|
|
91313
|
+
if (ctx.hooks.afterAddSheet) {
|
|
91314
|
+
setTimeout(function () {
|
|
91315
|
+
var _ctx$hooks$afterAddSh, _ctx$hooks4;
|
|
91316
|
+
(_ctx$hooks$afterAddSh = (_ctx$hooks4 = ctx.hooks).afterAddSheet) === null || _ctx$hooks$afterAddSh === void 0 ? void 0 : _ctx$hooks$afterAddSh.call(_ctx$hooks4, sheetconfig);
|
|
91317
|
+
});
|
|
91318
|
+
}
|
|
91319
|
+
}
|
|
91320
|
+
function deleteSheet(ctx, id) {
|
|
91321
|
+
var _ctx$hooks$beforeDele, _ctx$hooks5;
|
|
91322
|
+
if (ctx.allowEdit === false) {
|
|
91323
|
+
return;
|
|
91324
|
+
}
|
|
91325
|
+
var arrIndex = getSheetIndex(ctx, id);
|
|
91050
91326
|
if (arrIndex == null) {
|
|
91051
91327
|
return;
|
|
91052
91328
|
}
|
|
@@ -91167,6 +91443,54 @@
|
|
|
91167
91443
|
});
|
|
91168
91444
|
}
|
|
91169
91445
|
}
|
|
91446
|
+
function setNextSheet(draftCtx, nextSheetId, refs) {
|
|
91447
|
+
var _draftCtx$luckysheetf, _luckysheetCellUpdate;
|
|
91448
|
+
var sheet = draftCtx.luckysheetfile.find(function (_sheet) {
|
|
91449
|
+
return _sheet.id === nextSheetId;
|
|
91450
|
+
}) || ((_draftCtx$luckysheetf = draftCtx.luckysheetfile) === null || _draftCtx$luckysheetf === void 0 ? void 0 : _draftCtx$luckysheetf[0]);
|
|
91451
|
+
draftCtx.sheetScrollRecord[draftCtx.currentSheetId] = {
|
|
91452
|
+
scrollLeft: draftCtx.scrollLeft,
|
|
91453
|
+
scrollTop: draftCtx.scrollTop,
|
|
91454
|
+
luckysheet_select_status: draftCtx.luckysheet_select_status,
|
|
91455
|
+
luckysheet_select_save: draftCtx.luckysheet_select_save,
|
|
91456
|
+
luckysheet_selection_range: draftCtx.luckysheet_selection_range
|
|
91457
|
+
};
|
|
91458
|
+
var isBack = false;
|
|
91459
|
+
var luckysheetCellUpdate = [];
|
|
91460
|
+
if ((israngeseleciton(draftCtx) || draftCtx.formulaCache.rangestart) && !draftCtx.active_f) {
|
|
91461
|
+
var _refs$fxInput$current, _draftCtx$sheetScroll;
|
|
91462
|
+
draftCtx.active_f = {
|
|
91463
|
+
r: draftCtx.luckysheet_select_save[0].row_focus,
|
|
91464
|
+
c: draftCtx.luckysheet_select_save[0].column_focus,
|
|
91465
|
+
sheetId: draftCtx.currentSheetId,
|
|
91466
|
+
text: (_refs$fxInput$current = refs.fxInput.current) === null || _refs$fxInput$current === void 0 ? void 0 : _refs$fxInput$current.innerText
|
|
91467
|
+
};
|
|
91468
|
+
if ((_draftCtx$sheetScroll = draftCtx.sheetScrollRecord[nextSheetId]) === null || _draftCtx$sheetScroll === void 0 ? void 0 : _draftCtx$sheetScroll.luckysheet_select_save) {
|
|
91469
|
+
draftCtx.sheetScrollRecord[nextSheetId].luckysheet_select_save = undefined;
|
|
91470
|
+
}
|
|
91471
|
+
moveToEnd(refs.fxInput.current);
|
|
91472
|
+
} else if (draftCtx.active_f && draftCtx.active_f.sheetId === nextSheetId) {
|
|
91473
|
+
var _refs$fxInput$current2;
|
|
91474
|
+
luckysheetCellUpdate = [draftCtx.active_f.r, draftCtx.active_f.c];
|
|
91475
|
+
isBack = true;
|
|
91476
|
+
if ((_refs$fxInput$current2 = refs.fxInput.current) === null || _refs$fxInput$current2 === void 0 ? void 0 : _refs$fxInput$current2.innerHTML) {
|
|
91477
|
+
var _refs$fxInput$current3;
|
|
91478
|
+
refs.cellInput.current.innerHTML = ((_refs$fxInput$current3 = refs.fxInput.current) === null || _refs$fxInput$current3 === void 0 ? void 0 : _refs$fxInput$current3.innerHTML) || "";
|
|
91479
|
+
}
|
|
91480
|
+
moveToEnd(refs.cellInput.current);
|
|
91481
|
+
}
|
|
91482
|
+
var _update = ((_luckysheetCellUpdate = luckysheetCellUpdate) === null || _luckysheetCellUpdate === void 0 ? void 0 : _luckysheetCellUpdate.length) > 0 ? luckysheetCellUpdate : draftCtx.luckysheetCellUpdate;
|
|
91483
|
+
draftCtx.currentSheetId = nextSheetId;
|
|
91484
|
+
if ((_update === null || _update === void 0 ? void 0 : _update.length) > 0) ;
|
|
91485
|
+
draftCtx.dataVerificationDropDownList = false;
|
|
91486
|
+
draftCtx.zoomRatio = sheet.zoomRatio || 1;
|
|
91487
|
+
cancelActiveImgItem(draftCtx, refs.globalCache);
|
|
91488
|
+
cancelNormalSelected(draftCtx);
|
|
91489
|
+
if (isBack) {
|
|
91490
|
+
draftCtx.luckysheetCellUpdate = luckysheetCellUpdate;
|
|
91491
|
+
draftCtx.active_f = undefined;
|
|
91492
|
+
}
|
|
91493
|
+
}
|
|
91170
91494
|
|
|
91171
91495
|
function mergeCells(ctx, sheetId, ranges, type) {
|
|
91172
91496
|
var idx = getSheetIndex(ctx, sheetId);
|
|
@@ -92217,6 +92541,7 @@
|
|
|
92217
92541
|
continue;
|
|
92218
92542
|
}
|
|
92219
92543
|
for (var c = col_st; c <= col_ed; c += 1) {
|
|
92544
|
+
var _foucsStatus;
|
|
92220
92545
|
var cell = d[r][c];
|
|
92221
92546
|
var value = void 0;
|
|
92222
92547
|
if (lodash.isPlainObject(cell)) {
|
|
@@ -92229,7 +92554,9 @@
|
|
|
92229
92554
|
}
|
|
92230
92555
|
var mask = update(foucsStatus, value);
|
|
92231
92556
|
var type = "n";
|
|
92232
|
-
if (
|
|
92557
|
+
if ((_foucsStatus = foucsStatus) === null || _foucsStatus === void 0 ? void 0 : _foucsStatus.includes("leanky_")) {
|
|
92558
|
+
type = "n";
|
|
92559
|
+
} else if (is_date(foucsStatus) || foucsStatus === 14 || foucsStatus === 15 || foucsStatus === 16 || foucsStatus === 17 || foucsStatus === 18 || foucsStatus === 19 || foucsStatus === 20 || foucsStatus === 21 || foucsStatus === 22 || foucsStatus === 45 || foucsStatus === 46 || foucsStatus === 47) {
|
|
92233
92560
|
type = "d";
|
|
92234
92561
|
} else if (foucsStatus === "@" || foucsStatus === 49) {
|
|
92235
92562
|
type = "s";
|
|
@@ -93509,280 +93836,12 @@
|
|
|
93509
93836
|
width: width,
|
|
93510
93837
|
height: height,
|
|
93511
93838
|
size: size,
|
|
93512
|
-
value: value,
|
|
93513
|
-
autoFocus: false
|
|
93514
|
-
};
|
|
93515
|
-
}
|
|
93516
|
-
function getCommentBoxPosition(commentId) {
|
|
93517
|
-
var box = document.getElementById(commentId);
|
|
93518
|
-
if (!box) return undefined;
|
|
93519
|
-
var _box$getBoundingClien = box.getBoundingClientRect(),
|
|
93520
|
-
width = _box$getBoundingClien.width,
|
|
93521
|
-
height = _box$getBoundingClien.height;
|
|
93522
|
-
var left = box.offsetLeft;
|
|
93523
|
-
var top = box.offsetTop;
|
|
93524
|
-
return {
|
|
93525
|
-
left: left,
|
|
93526
|
-
top: top,
|
|
93527
|
-
width: width,
|
|
93528
|
-
height: height
|
|
93529
|
-
};
|
|
93530
|
-
}
|
|
93531
|
-
function onCommentBoxResizeStart(ctx, globalCache, e, _ref3, resizingId, resizingSide) {
|
|
93532
|
-
var r = _ref3.r,
|
|
93533
|
-
c = _ref3.c,
|
|
93534
|
-
rc = _ref3.rc;
|
|
93535
|
-
var position = getCommentBoxPosition(resizingId);
|
|
93536
|
-
if (position) {
|
|
93537
|
-
lodash.set(globalCache, "commentBox", {
|
|
93538
|
-
cursorMoveStartPosition: {
|
|
93539
|
-
x: e.pageX,
|
|
93540
|
-
y: e.pageY
|
|
93541
|
-
},
|
|
93542
|
-
resizingId: resizingId,
|
|
93543
|
-
resizingSide: resizingSide,
|
|
93544
|
-
commentRC: {
|
|
93545
|
-
r: r,
|
|
93546
|
-
c: c,
|
|
93547
|
-
rc: rc
|
|
93548
|
-
},
|
|
93549
|
-
boxInitialPosition: position
|
|
93550
|
-
});
|
|
93551
|
-
}
|
|
93552
|
-
}
|
|
93553
|
-
function onCommentBoxResize(ctx, globalCache, e) {
|
|
93554
|
-
if (ctx.allowEdit === false) return false;
|
|
93555
|
-
var commentBox = globalCache === null || globalCache === void 0 ? void 0 : globalCache.commentBox;
|
|
93556
|
-
if ((commentBox === null || commentBox === void 0 ? void 0 : commentBox.resizingId) && commentBox.resizingSide) {
|
|
93557
|
-
var box = document.getElementById(commentBox.resizingId);
|
|
93558
|
-
var _commentBox$cursorMov = commentBox.cursorMoveStartPosition,
|
|
93559
|
-
startX = _commentBox$cursorMov.x,
|
|
93560
|
-
startY = _commentBox$cursorMov.y;
|
|
93561
|
-
var _commentBox$boxInitia = commentBox.boxInitialPosition,
|
|
93562
|
-
top = _commentBox$boxInitia.top,
|
|
93563
|
-
left = _commentBox$boxInitia.left,
|
|
93564
|
-
width = _commentBox$boxInitia.width,
|
|
93565
|
-
height = _commentBox$boxInitia.height;
|
|
93566
|
-
var dx = e.pageX - startX;
|
|
93567
|
-
var dy = e.pageY - startY;
|
|
93568
|
-
var minHeight = 60 * ctx.zoomRatio;
|
|
93569
|
-
var minWidth = 1.5 * 60 * ctx.zoomRatio;
|
|
93570
|
-
if (["lm", "lt", "lb"].includes(commentBox.resizingSide)) {
|
|
93571
|
-
if (width - dx < minWidth) {
|
|
93572
|
-
left += width - minWidth;
|
|
93573
|
-
width = minWidth;
|
|
93574
|
-
} else {
|
|
93575
|
-
left += dx;
|
|
93576
|
-
width -= dx;
|
|
93577
|
-
}
|
|
93578
|
-
if (left < 0) left = 0;
|
|
93579
|
-
box.style.left = "".concat(left, "px");
|
|
93580
|
-
}
|
|
93581
|
-
if (["rm", "rt", "rb"].includes(commentBox.resizingSide)) {
|
|
93582
|
-
width = width + dx < minWidth ? minWidth : width + dx;
|
|
93583
|
-
}
|
|
93584
|
-
if (["mt", "lt", "rt"].includes(commentBox.resizingSide)) {
|
|
93585
|
-
if (height - dy < minHeight) {
|
|
93586
|
-
top += height - minHeight;
|
|
93587
|
-
height = minHeight;
|
|
93588
|
-
} else {
|
|
93589
|
-
top += dy;
|
|
93590
|
-
height -= dy;
|
|
93591
|
-
}
|
|
93592
|
-
if (top < 0) top = 0;
|
|
93593
|
-
box.style.top = "".concat(top, "px");
|
|
93594
|
-
}
|
|
93595
|
-
if (["mb", "lb", "rb"].includes(commentBox.resizingSide)) {
|
|
93596
|
-
height = height + dy < minHeight ? minHeight : height + dy;
|
|
93597
|
-
}
|
|
93598
|
-
box.style.width = "".concat(width, "px");
|
|
93599
|
-
box.style.height = "".concat(height, "px");
|
|
93600
|
-
return true;
|
|
93601
|
-
}
|
|
93602
|
-
return false;
|
|
93603
|
-
}
|
|
93604
|
-
function onCommentBoxResizeEnd(ctx, globalCache) {
|
|
93605
|
-
var _globalCache$commentB;
|
|
93606
|
-
if ((_globalCache$commentB = globalCache.commentBox) === null || _globalCache$commentB === void 0 ? void 0 : _globalCache$commentB.resizingId) {
|
|
93607
|
-
var _globalCache$commentB2 = globalCache.commentBox,
|
|
93608
|
-
resizingId = _globalCache$commentB2.resizingId,
|
|
93609
|
-
_globalCache$commentB3 = _globalCache$commentB2.commentRC,
|
|
93610
|
-
r = _globalCache$commentB3.r,
|
|
93611
|
-
c = _globalCache$commentB3.c;
|
|
93612
|
-
globalCache.commentBox.resizingId = undefined;
|
|
93613
|
-
var position = getCommentBoxPosition(resizingId);
|
|
93614
|
-
if (position) {
|
|
93615
|
-
var top = position.top,
|
|
93616
|
-
left = position.left,
|
|
93617
|
-
width = position.width,
|
|
93618
|
-
height = position.height;
|
|
93619
|
-
var flowdata = getFlowdata(ctx);
|
|
93620
|
-
var cell = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r][c];
|
|
93621
|
-
if (!flowdata || !(cell === null || cell === void 0 ? void 0 : cell.ps)) return;
|
|
93622
|
-
cell.ps.left = left / ctx.zoomRatio;
|
|
93623
|
-
cell.ps.top = top / ctx.zoomRatio;
|
|
93624
|
-
cell.ps.width = width / ctx.zoomRatio;
|
|
93625
|
-
cell.ps.height = height / ctx.zoomRatio;
|
|
93626
|
-
setEditingComment(ctx, flowdata, r, c);
|
|
93627
|
-
if (ctx.hooks.afterUpdateComment) {
|
|
93628
|
-
var _ctx$hooks$afterUpdat5, _ctx$hooks10;
|
|
93629
|
-
(_ctx$hooks$afterUpdat5 = (_ctx$hooks10 = ctx.hooks).afterUpdateComment) === null || _ctx$hooks$afterUpdat5 === void 0 ? void 0 : _ctx$hooks$afterUpdat5.call(_ctx$hooks10, r, c, _objectSpread2$1({}, cell.ps), true);
|
|
93630
|
-
}
|
|
93631
|
-
}
|
|
93632
|
-
}
|
|
93633
|
-
}
|
|
93634
|
-
function onCommentBoxMoveStart(ctx, globalCache, e, _ref4, movingId) {
|
|
93635
|
-
var r = _ref4.r,
|
|
93636
|
-
c = _ref4.c,
|
|
93637
|
-
rc = _ref4.rc;
|
|
93638
|
-
var position = getCommentBoxPosition(movingId);
|
|
93639
|
-
if (position) {
|
|
93640
|
-
var top = position.top,
|
|
93641
|
-
left = position.left;
|
|
93642
|
-
lodash.set(globalCache, "commentBox", {
|
|
93643
|
-
cursorMoveStartPosition: {
|
|
93644
|
-
x: e.pageX,
|
|
93645
|
-
y: e.pageY
|
|
93646
|
-
},
|
|
93647
|
-
movingId: movingId,
|
|
93648
|
-
commentRC: {
|
|
93649
|
-
r: r,
|
|
93650
|
-
c: c,
|
|
93651
|
-
rc: rc
|
|
93652
|
-
},
|
|
93653
|
-
boxInitialPosition: {
|
|
93654
|
-
left: left,
|
|
93655
|
-
top: top
|
|
93656
|
-
}
|
|
93657
|
-
});
|
|
93658
|
-
}
|
|
93659
|
-
}
|
|
93660
|
-
function onCommentBoxMove(ctx, globalCache, e) {
|
|
93661
|
-
var commentBox = globalCache === null || globalCache === void 0 ? void 0 : globalCache.commentBox;
|
|
93662
|
-
if (commentBox === null || commentBox === void 0 ? void 0 : commentBox.movingId) {
|
|
93663
|
-
var box = document.getElementById(commentBox.movingId);
|
|
93664
|
-
var _commentBox$cursorMov2 = commentBox.cursorMoveStartPosition,
|
|
93665
|
-
startX = _commentBox$cursorMov2.x,
|
|
93666
|
-
startY = _commentBox$cursorMov2.y;
|
|
93667
|
-
var _commentBox$boxInitia2 = commentBox.boxInitialPosition,
|
|
93668
|
-
top = _commentBox$boxInitia2.top,
|
|
93669
|
-
left = _commentBox$boxInitia2.left;
|
|
93670
|
-
left += e.pageX - startX;
|
|
93671
|
-
top += e.pageY - startY;
|
|
93672
|
-
if (top < 0) top = 0;
|
|
93673
|
-
if (left < 0) left = 0;
|
|
93674
|
-
box.style.left = "".concat(left, "px");
|
|
93675
|
-
box.style.top = "".concat(top, "px");
|
|
93676
|
-
return true;
|
|
93677
|
-
}
|
|
93678
|
-
return false;
|
|
93679
|
-
}
|
|
93680
|
-
function onCommentBoxMoveEnd(ctx, globalCache) {
|
|
93681
|
-
var _globalCache$commentB4;
|
|
93682
|
-
if ((_globalCache$commentB4 = globalCache.commentBox) === null || _globalCache$commentB4 === void 0 ? void 0 : _globalCache$commentB4.movingId) {
|
|
93683
|
-
var _globalCache$commentB5 = globalCache.commentBox,
|
|
93684
|
-
movingId = _globalCache$commentB5.movingId,
|
|
93685
|
-
_globalCache$commentB6 = _globalCache$commentB5.commentRC,
|
|
93686
|
-
r = _globalCache$commentB6.r,
|
|
93687
|
-
c = _globalCache$commentB6.c;
|
|
93688
|
-
globalCache.commentBox.movingId = undefined;
|
|
93689
|
-
var position = getCommentBoxPosition(movingId);
|
|
93690
|
-
if (position) {
|
|
93691
|
-
var top = position.top,
|
|
93692
|
-
left = position.left;
|
|
93693
|
-
var flowdata = getFlowdata(ctx);
|
|
93694
|
-
var cell = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r][c];
|
|
93695
|
-
if (!flowdata || !(cell === null || cell === void 0 ? void 0 : cell.ps)) return;
|
|
93696
|
-
cell.ps.left = left / ctx.zoomRatio;
|
|
93697
|
-
cell.ps.top = top / ctx.zoomRatio;
|
|
93698
|
-
setEditingComment(ctx, flowdata, r, c);
|
|
93699
|
-
if (ctx.hooks.afterUpdateComment) {
|
|
93700
|
-
var _ctx$hooks$afterUpdat6, _ctx$hooks11;
|
|
93701
|
-
(_ctx$hooks$afterUpdat6 = (_ctx$hooks11 = ctx.hooks).afterUpdateComment) === null || _ctx$hooks$afterUpdat6 === void 0 ? void 0 : _ctx$hooks$afterUpdat6.call(_ctx$hooks11, r, c, _objectSpread2$1({}, cell.ps), true);
|
|
93702
|
-
}
|
|
93703
|
-
}
|
|
93704
|
-
}
|
|
93705
|
-
}
|
|
93706
|
-
function generateRandomId(prefix) {
|
|
93707
|
-
if (prefix == null) {
|
|
93708
|
-
prefix = "img";
|
|
93709
|
-
}
|
|
93710
|
-
var userAgent = window.navigator.userAgent.replace(/[^a-zA-Z0-9]/g, "").split("");
|
|
93711
|
-
var mid = "";
|
|
93712
|
-
for (var i = 0; i < 12; i += 1) {
|
|
93713
|
-
mid += userAgent[Math.round(Math.random() * (userAgent.length - 1))];
|
|
93714
|
-
}
|
|
93715
|
-
var time = new Date().getTime();
|
|
93716
|
-
return "".concat(prefix, "_").concat(mid, "_").concat(time);
|
|
93717
|
-
}
|
|
93718
|
-
function showImgChooser() {
|
|
93719
|
-
var chooser = document.getElementById("leankylin-img-upload");
|
|
93720
|
-
if (chooser) chooser.click();
|
|
93721
|
-
}
|
|
93722
|
-
function saveImage(ctx) {
|
|
93723
|
-
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
93724
|
-
if (index == null) return;
|
|
93725
|
-
var file = ctx.luckysheetfile[index];
|
|
93726
|
-
file.images = ctx.insertedImgs;
|
|
93727
|
-
}
|
|
93728
|
-
function removeActiveImage(ctx) {
|
|
93729
|
-
ctx.insertedImgs = lodash.filter(ctx.insertedImgs, function (image) {
|
|
93730
|
-
return image.id !== ctx.activeImg;
|
|
93731
|
-
});
|
|
93732
|
-
ctx.activeImg = undefined;
|
|
93733
|
-
saveImage(ctx);
|
|
93734
|
-
}
|
|
93735
|
-
function insertImage(ctx, image) {
|
|
93736
|
-
try {
|
|
93737
|
-
var _ctx$luckysheet_selec;
|
|
93738
|
-
var last = (_ctx$luckysheet_selec = ctx.luckysheet_select_save) === null || _ctx$luckysheet_selec === void 0 ? void 0 : _ctx$luckysheet_selec[ctx.luckysheet_select_save.length - 1];
|
|
93739
|
-
var rowIndex = last === null || last === void 0 ? void 0 : last.row_focus;
|
|
93740
|
-
var colIndex = last === null || last === void 0 ? void 0 : last.column_focus;
|
|
93741
|
-
if (!last) {
|
|
93742
|
-
rowIndex = 0;
|
|
93743
|
-
colIndex = 0;
|
|
93744
|
-
} else {
|
|
93745
|
-
if (rowIndex == null) {
|
|
93746
|
-
var _last$row = _slicedToArray$2(last.row, 1);
|
|
93747
|
-
rowIndex = _last$row[0];
|
|
93748
|
-
}
|
|
93749
|
-
if (colIndex == null) {
|
|
93750
|
-
var _last$column = _slicedToArray$2(last.column, 1);
|
|
93751
|
-
colIndex = _last$column[0];
|
|
93752
|
-
}
|
|
93753
|
-
}
|
|
93754
|
-
var flowdata = getFlowdata(ctx);
|
|
93755
|
-
var left = colIndex === 0 ? 0 : ctx.visibledatacolumn[colIndex - 1];
|
|
93756
|
-
var top = rowIndex === 0 ? 0 : ctx.visibledatarow[rowIndex - 1];
|
|
93757
|
-
if (flowdata) {
|
|
93758
|
-
var margeset = mergeBorder(ctx, flowdata, rowIndex, colIndex);
|
|
93759
|
-
if (margeset) {
|
|
93760
|
-
var _margeset$row = _slicedToArray$2(margeset.row, 1);
|
|
93761
|
-
top = _margeset$row[0];
|
|
93762
|
-
var _margeset$column = _slicedToArray$2(margeset.column, 1);
|
|
93763
|
-
left = _margeset$column[0];
|
|
93764
|
-
}
|
|
93765
|
-
}
|
|
93766
|
-
var width = image.width;
|
|
93767
|
-
var height = image.height;
|
|
93768
|
-
var img = {
|
|
93769
|
-
id: generateRandomId("img"),
|
|
93770
|
-
src: image.src,
|
|
93771
|
-
left: left,
|
|
93772
|
-
top: top,
|
|
93773
|
-
width: width * 0.5,
|
|
93774
|
-
height: height * 0.5,
|
|
93775
|
-
originWidth: width,
|
|
93776
|
-
originHeight: height
|
|
93777
|
-
};
|
|
93778
|
-
ctx.insertedImgs = (ctx.insertedImgs || []).concat(img);
|
|
93779
|
-
saveImage(ctx);
|
|
93780
|
-
} catch (err) {
|
|
93781
|
-
console.info(err);
|
|
93782
|
-
}
|
|
93839
|
+
value: value,
|
|
93840
|
+
autoFocus: false
|
|
93841
|
+
};
|
|
93783
93842
|
}
|
|
93784
|
-
function
|
|
93785
|
-
var box = document.getElementById(
|
|
93843
|
+
function getCommentBoxPosition(commentId) {
|
|
93844
|
+
var box = document.getElementById(commentId);
|
|
93786
93845
|
if (!box) return undefined;
|
|
93787
93846
|
var _box$getBoundingClien = box.getBoundingClientRect(),
|
|
93788
93847
|
width = _box$getBoundingClien.width,
|
|
@@ -93796,97 +93855,46 @@
|
|
|
93796
93855
|
height: height
|
|
93797
93856
|
};
|
|
93798
93857
|
}
|
|
93799
|
-
function
|
|
93800
|
-
|
|
93801
|
-
|
|
93802
|
-
|
|
93803
|
-
|
|
93804
|
-
var position = getImagePosition();
|
|
93805
|
-
if (position) {
|
|
93806
|
-
var top = position.top,
|
|
93807
|
-
left = position.left;
|
|
93808
|
-
lodash.set(globalCache, "image", {
|
|
93809
|
-
cursorMoveStartPosition: {
|
|
93810
|
-
x: e.pageX,
|
|
93811
|
-
y: e.pageY
|
|
93812
|
-
},
|
|
93813
|
-
imgInitialPosition: {
|
|
93814
|
-
left: left,
|
|
93815
|
-
top: top
|
|
93816
|
-
}
|
|
93817
|
-
});
|
|
93818
|
-
}
|
|
93819
|
-
}
|
|
93820
|
-
function onImageMove(ctx, globalCache, e) {
|
|
93821
|
-
if (ctx.allowEdit === false) return false;
|
|
93822
|
-
var image = globalCache === null || globalCache === void 0 ? void 0 : globalCache.image;
|
|
93823
|
-
var img = document.getElementById("luckysheet-modal-dialog-activeImage");
|
|
93824
|
-
if (img && image && !image.resizingSide) {
|
|
93825
|
-
var _image$cursorMoveStar = image.cursorMoveStartPosition,
|
|
93826
|
-
startX = _image$cursorMoveStar.x,
|
|
93827
|
-
startY = _image$cursorMoveStar.y;
|
|
93828
|
-
var _image$imgInitialPosi = image.imgInitialPosition,
|
|
93829
|
-
top = _image$imgInitialPosi.top,
|
|
93830
|
-
left = _image$imgInitialPosi.left;
|
|
93831
|
-
left += e.pageX - startX;
|
|
93832
|
-
top += e.pageY - startY;
|
|
93833
|
-
if (top < 0) top = 0;
|
|
93834
|
-
img.style.left = "".concat(left, "px");
|
|
93835
|
-
img.style.top = "".concat(top, "px");
|
|
93836
|
-
return true;
|
|
93837
|
-
}
|
|
93838
|
-
return false;
|
|
93839
|
-
}
|
|
93840
|
-
function onImageMoveEnd(ctx, globalCache) {
|
|
93841
|
-
var _globalCache$image;
|
|
93842
|
-
var position = getImagePosition();
|
|
93843
|
-
if (!((_globalCache$image = globalCache.image) === null || _globalCache$image === void 0 ? void 0 : _globalCache$image.resizingSide)) {
|
|
93844
|
-
globalCache.image = undefined;
|
|
93845
|
-
if (position) {
|
|
93846
|
-
var img = lodash.find(ctx.insertedImgs, function (v) {
|
|
93847
|
-
return v.id === ctx.activeImg;
|
|
93848
|
-
});
|
|
93849
|
-
if (img) {
|
|
93850
|
-
img.left = position.left / ctx.zoomRatio;
|
|
93851
|
-
img.top = position.top / ctx.zoomRatio;
|
|
93852
|
-
saveImage(ctx);
|
|
93853
|
-
}
|
|
93854
|
-
}
|
|
93855
|
-
}
|
|
93856
|
-
}
|
|
93857
|
-
function onImageResizeStart(globalCache, e, resizingSide) {
|
|
93858
|
-
var position = getImagePosition();
|
|
93858
|
+
function onCommentBoxResizeStart(ctx, globalCache, e, _ref3, resizingId, resizingSide) {
|
|
93859
|
+
var r = _ref3.r,
|
|
93860
|
+
c = _ref3.c,
|
|
93861
|
+
rc = _ref3.rc;
|
|
93862
|
+
var position = getCommentBoxPosition(resizingId);
|
|
93859
93863
|
if (position) {
|
|
93860
|
-
lodash.set(globalCache, "
|
|
93864
|
+
lodash.set(globalCache, "commentBox", {
|
|
93861
93865
|
cursorMoveStartPosition: {
|
|
93862
93866
|
x: e.pageX,
|
|
93863
93867
|
y: e.pageY
|
|
93864
93868
|
},
|
|
93869
|
+
resizingId: resizingId,
|
|
93865
93870
|
resizingSide: resizingSide,
|
|
93866
|
-
|
|
93871
|
+
commentRC: {
|
|
93872
|
+
r: r,
|
|
93873
|
+
c: c,
|
|
93874
|
+
rc: rc
|
|
93875
|
+
},
|
|
93876
|
+
boxInitialPosition: position
|
|
93867
93877
|
});
|
|
93868
93878
|
}
|
|
93869
93879
|
}
|
|
93870
|
-
function
|
|
93880
|
+
function onCommentBoxResize(ctx, globalCache, e) {
|
|
93871
93881
|
if (ctx.allowEdit === false) return false;
|
|
93872
|
-
var
|
|
93873
|
-
if (
|
|
93874
|
-
var
|
|
93875
|
-
var
|
|
93876
|
-
|
|
93877
|
-
|
|
93878
|
-
|
|
93879
|
-
|
|
93880
|
-
|
|
93881
|
-
|
|
93882
|
-
|
|
93883
|
-
width = _image$imgInitialPosi2.width,
|
|
93884
|
-
height = _image$imgInitialPosi2.height;
|
|
93882
|
+
var commentBox = globalCache === null || globalCache === void 0 ? void 0 : globalCache.commentBox;
|
|
93883
|
+
if ((commentBox === null || commentBox === void 0 ? void 0 : commentBox.resizingId) && commentBox.resizingSide) {
|
|
93884
|
+
var box = document.getElementById(commentBox.resizingId);
|
|
93885
|
+
var _commentBox$cursorMov = commentBox.cursorMoveStartPosition,
|
|
93886
|
+
startX = _commentBox$cursorMov.x,
|
|
93887
|
+
startY = _commentBox$cursorMov.y;
|
|
93888
|
+
var _commentBox$boxInitia = commentBox.boxInitialPosition,
|
|
93889
|
+
top = _commentBox$boxInitia.top,
|
|
93890
|
+
left = _commentBox$boxInitia.left,
|
|
93891
|
+
width = _commentBox$boxInitia.width,
|
|
93892
|
+
height = _commentBox$boxInitia.height;
|
|
93885
93893
|
var dx = e.pageX - startX;
|
|
93886
93894
|
var dy = e.pageY - startY;
|
|
93887
93895
|
var minHeight = 60 * ctx.zoomRatio;
|
|
93888
93896
|
var minWidth = 1.5 * 60 * ctx.zoomRatio;
|
|
93889
|
-
if (["lm", "lt", "lb"].includes(
|
|
93897
|
+
if (["lm", "lt", "lb"].includes(commentBox.resizingSide)) {
|
|
93890
93898
|
if (width - dx < minWidth) {
|
|
93891
93899
|
left += width - minWidth;
|
|
93892
93900
|
width = minWidth;
|
|
@@ -93895,13 +93903,12 @@
|
|
|
93895
93903
|
width -= dx;
|
|
93896
93904
|
}
|
|
93897
93905
|
if (left < 0) left = 0;
|
|
93898
|
-
|
|
93899
|
-
imgContainer.style.left = "".concat(left, "px");
|
|
93906
|
+
box.style.left = "".concat(left, "px");
|
|
93900
93907
|
}
|
|
93901
|
-
if (["rm", "rt", "rb"].includes(
|
|
93908
|
+
if (["rm", "rt", "rb"].includes(commentBox.resizingSide)) {
|
|
93902
93909
|
width = width + dx < minWidth ? minWidth : width + dx;
|
|
93903
93910
|
}
|
|
93904
|
-
if (["mt", "lt", "rt"].includes(
|
|
93911
|
+
if (["mt", "lt", "rt"].includes(commentBox.resizingSide)) {
|
|
93905
93912
|
if (height - dy < minHeight) {
|
|
93906
93913
|
top += height - minHeight;
|
|
93907
93914
|
height = minHeight;
|
|
@@ -93910,36 +93917,115 @@
|
|
|
93910
93917
|
height -= dy;
|
|
93911
93918
|
}
|
|
93912
93919
|
if (top < 0) top = 0;
|
|
93913
|
-
|
|
93914
|
-
imgContainer.style.top = "".concat(top, "px");
|
|
93920
|
+
box.style.top = "".concat(top, "px");
|
|
93915
93921
|
}
|
|
93916
|
-
if (["mb", "lb", "rb"].includes(
|
|
93922
|
+
if (["mb", "lb", "rb"].includes(commentBox.resizingSide)) {
|
|
93917
93923
|
height = height + dy < minHeight ? minHeight : height + dy;
|
|
93918
93924
|
}
|
|
93919
|
-
|
|
93920
|
-
|
|
93921
|
-
img.style.height = "".concat(height, "px");
|
|
93922
|
-
imgContainer.style.height = "".concat(height, "px");
|
|
93923
|
-
img.style.backgroundSize = "".concat(width, "px ").concat(height, "px");
|
|
93925
|
+
box.style.width = "".concat(width, "px");
|
|
93926
|
+
box.style.height = "".concat(height, "px");
|
|
93924
93927
|
return true;
|
|
93925
93928
|
}
|
|
93926
93929
|
return false;
|
|
93927
93930
|
}
|
|
93928
|
-
function
|
|
93929
|
-
var _globalCache$
|
|
93930
|
-
if ((_globalCache$
|
|
93931
|
-
|
|
93932
|
-
|
|
93931
|
+
function onCommentBoxResizeEnd(ctx, globalCache) {
|
|
93932
|
+
var _globalCache$commentB;
|
|
93933
|
+
if ((_globalCache$commentB = globalCache.commentBox) === null || _globalCache$commentB === void 0 ? void 0 : _globalCache$commentB.resizingId) {
|
|
93934
|
+
var _globalCache$commentB2 = globalCache.commentBox,
|
|
93935
|
+
resizingId = _globalCache$commentB2.resizingId,
|
|
93936
|
+
_globalCache$commentB3 = _globalCache$commentB2.commentRC,
|
|
93937
|
+
r = _globalCache$commentB3.r,
|
|
93938
|
+
c = _globalCache$commentB3.c;
|
|
93939
|
+
globalCache.commentBox.resizingId = undefined;
|
|
93940
|
+
var position = getCommentBoxPosition(resizingId);
|
|
93933
93941
|
if (position) {
|
|
93934
|
-
var
|
|
93935
|
-
|
|
93936
|
-
|
|
93937
|
-
|
|
93938
|
-
|
|
93939
|
-
|
|
93940
|
-
|
|
93941
|
-
|
|
93942
|
-
|
|
93942
|
+
var top = position.top,
|
|
93943
|
+
left = position.left,
|
|
93944
|
+
width = position.width,
|
|
93945
|
+
height = position.height;
|
|
93946
|
+
var flowdata = getFlowdata(ctx);
|
|
93947
|
+
var cell = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r][c];
|
|
93948
|
+
if (!flowdata || !(cell === null || cell === void 0 ? void 0 : cell.ps)) return;
|
|
93949
|
+
cell.ps.left = left / ctx.zoomRatio;
|
|
93950
|
+
cell.ps.top = top / ctx.zoomRatio;
|
|
93951
|
+
cell.ps.width = width / ctx.zoomRatio;
|
|
93952
|
+
cell.ps.height = height / ctx.zoomRatio;
|
|
93953
|
+
setEditingComment(ctx, flowdata, r, c);
|
|
93954
|
+
if (ctx.hooks.afterUpdateComment) {
|
|
93955
|
+
var _ctx$hooks$afterUpdat5, _ctx$hooks10;
|
|
93956
|
+
(_ctx$hooks$afterUpdat5 = (_ctx$hooks10 = ctx.hooks).afterUpdateComment) === null || _ctx$hooks$afterUpdat5 === void 0 ? void 0 : _ctx$hooks$afterUpdat5.call(_ctx$hooks10, r, c, _objectSpread2$1({}, cell.ps), true);
|
|
93957
|
+
}
|
|
93958
|
+
}
|
|
93959
|
+
}
|
|
93960
|
+
}
|
|
93961
|
+
function onCommentBoxMoveStart(ctx, globalCache, e, _ref4, movingId) {
|
|
93962
|
+
var r = _ref4.r,
|
|
93963
|
+
c = _ref4.c,
|
|
93964
|
+
rc = _ref4.rc;
|
|
93965
|
+
var position = getCommentBoxPosition(movingId);
|
|
93966
|
+
if (position) {
|
|
93967
|
+
var top = position.top,
|
|
93968
|
+
left = position.left;
|
|
93969
|
+
lodash.set(globalCache, "commentBox", {
|
|
93970
|
+
cursorMoveStartPosition: {
|
|
93971
|
+
x: e.pageX,
|
|
93972
|
+
y: e.pageY
|
|
93973
|
+
},
|
|
93974
|
+
movingId: movingId,
|
|
93975
|
+
commentRC: {
|
|
93976
|
+
r: r,
|
|
93977
|
+
c: c,
|
|
93978
|
+
rc: rc
|
|
93979
|
+
},
|
|
93980
|
+
boxInitialPosition: {
|
|
93981
|
+
left: left,
|
|
93982
|
+
top: top
|
|
93983
|
+
}
|
|
93984
|
+
});
|
|
93985
|
+
}
|
|
93986
|
+
}
|
|
93987
|
+
function onCommentBoxMove(ctx, globalCache, e) {
|
|
93988
|
+
var commentBox = globalCache === null || globalCache === void 0 ? void 0 : globalCache.commentBox;
|
|
93989
|
+
if (commentBox === null || commentBox === void 0 ? void 0 : commentBox.movingId) {
|
|
93990
|
+
var box = document.getElementById(commentBox.movingId);
|
|
93991
|
+
var _commentBox$cursorMov2 = commentBox.cursorMoveStartPosition,
|
|
93992
|
+
startX = _commentBox$cursorMov2.x,
|
|
93993
|
+
startY = _commentBox$cursorMov2.y;
|
|
93994
|
+
var _commentBox$boxInitia2 = commentBox.boxInitialPosition,
|
|
93995
|
+
top = _commentBox$boxInitia2.top,
|
|
93996
|
+
left = _commentBox$boxInitia2.left;
|
|
93997
|
+
left += e.pageX - startX;
|
|
93998
|
+
top += e.pageY - startY;
|
|
93999
|
+
if (top < 0) top = 0;
|
|
94000
|
+
if (left < 0) left = 0;
|
|
94001
|
+
box.style.left = "".concat(left, "px");
|
|
94002
|
+
box.style.top = "".concat(top, "px");
|
|
94003
|
+
return true;
|
|
94004
|
+
}
|
|
94005
|
+
return false;
|
|
94006
|
+
}
|
|
94007
|
+
function onCommentBoxMoveEnd(ctx, globalCache) {
|
|
94008
|
+
var _globalCache$commentB4;
|
|
94009
|
+
if ((_globalCache$commentB4 = globalCache.commentBox) === null || _globalCache$commentB4 === void 0 ? void 0 : _globalCache$commentB4.movingId) {
|
|
94010
|
+
var _globalCache$commentB5 = globalCache.commentBox,
|
|
94011
|
+
movingId = _globalCache$commentB5.movingId,
|
|
94012
|
+
_globalCache$commentB6 = _globalCache$commentB5.commentRC,
|
|
94013
|
+
r = _globalCache$commentB6.r,
|
|
94014
|
+
c = _globalCache$commentB6.c;
|
|
94015
|
+
globalCache.commentBox.movingId = undefined;
|
|
94016
|
+
var position = getCommentBoxPosition(movingId);
|
|
94017
|
+
if (position) {
|
|
94018
|
+
var top = position.top,
|
|
94019
|
+
left = position.left;
|
|
94020
|
+
var flowdata = getFlowdata(ctx);
|
|
94021
|
+
var cell = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r][c];
|
|
94022
|
+
if (!flowdata || !(cell === null || cell === void 0 ? void 0 : cell.ps)) return;
|
|
94023
|
+
cell.ps.left = left / ctx.zoomRatio;
|
|
94024
|
+
cell.ps.top = top / ctx.zoomRatio;
|
|
94025
|
+
setEditingComment(ctx, flowdata, r, c);
|
|
94026
|
+
if (ctx.hooks.afterUpdateComment) {
|
|
94027
|
+
var _ctx$hooks$afterUpdat6, _ctx$hooks11;
|
|
94028
|
+
(_ctx$hooks$afterUpdat6 = (_ctx$hooks11 = ctx.hooks).afterUpdateComment) === null || _ctx$hooks$afterUpdat6 === void 0 ? void 0 : _ctx$hooks$afterUpdat6.call(_ctx$hooks11, r, c, _objectSpread2$1({}, cell.ps), true);
|
|
93943
94029
|
}
|
|
93944
94030
|
}
|
|
93945
94031
|
}
|
|
@@ -100654,13 +100740,9 @@
|
|
|
100654
100740
|
ctx.luckysheet_paste_iscut = false;
|
|
100655
100741
|
}
|
|
100656
100742
|
|
|
100657
|
-
function handleGlobalEnter(ctx, cellInput, e, canvas) {
|
|
100658
|
-
|
|
100659
|
-
|
|
100660
|
-
var last = (_ctx$luckysheet_selec = ctx.luckysheet_select_save) === null || _ctx$luckysheet_selec === void 0 ? void 0 : _ctx$luckysheet_selec[ctx.luckysheet_select_save.length - 1];
|
|
100661
|
-
if (last && !lodash.isNil(last.row_focus) && !lodash.isNil(last.column_focus)) ;
|
|
100662
|
-
e.preventDefault();
|
|
100663
|
-
} else if (ctx.luckysheetCellUpdate.length > 0) {
|
|
100743
|
+
function handleGlobalEnter(ctx, cellInput, e, canvas, refs) {
|
|
100744
|
+
var _ctx$active_f;
|
|
100745
|
+
function setValue() {
|
|
100664
100746
|
var lastCellUpdate = lodash.clone(ctx.luckysheetCellUpdate);
|
|
100665
100747
|
updateCell(ctx, ctx.luckysheetCellUpdate[0], ctx.luckysheetCellUpdate[1], cellInput, undefined, canvas);
|
|
100666
100748
|
ctx.luckysheet_select_save = [{
|
|
@@ -100671,6 +100753,18 @@
|
|
|
100671
100753
|
}];
|
|
100672
100754
|
moveHighlightCell(ctx, "down", 1, "rangeOfSelect");
|
|
100673
100755
|
e.preventDefault();
|
|
100756
|
+
}
|
|
100757
|
+
if ((e.altKey || e.metaKey) && ctx.luckysheetCellUpdate.length > 0) {
|
|
100758
|
+
var _ctx$luckysheet_selec;
|
|
100759
|
+
var last = (_ctx$luckysheet_selec = ctx.luckysheet_select_save) === null || _ctx$luckysheet_selec === void 0 ? void 0 : _ctx$luckysheet_selec[ctx.luckysheet_select_save.length - 1];
|
|
100760
|
+
if (last && !lodash.isNil(last.row_focus) && !lodash.isNil(last.column_focus)) ;
|
|
100761
|
+
e.preventDefault();
|
|
100762
|
+
} else if (ctx.luckysheetCellUpdate.length > 0) {
|
|
100763
|
+
setValue();
|
|
100764
|
+
} else if ((_ctx$active_f = ctx.active_f) === null || _ctx$active_f === void 0 ? void 0 : _ctx$active_f.sheetId) {
|
|
100765
|
+
var _ctx$active_f2;
|
|
100766
|
+
setNextSheet(ctx, (_ctx$active_f2 = ctx.active_f) === null || _ctx$active_f2 === void 0 ? void 0 : _ctx$active_f2.sheetId, refs);
|
|
100767
|
+
setValue();
|
|
100674
100768
|
} else {
|
|
100675
100769
|
var _ctx$luckysheet_selec2, _ctx$luckysheet_selec3;
|
|
100676
100770
|
if (((_ctx$luckysheet_selec2 = (_ctx$luckysheet_selec3 = ctx.luckysheet_select_save) === null || _ctx$luckysheet_selec3 === void 0 ? void 0 : _ctx$luckysheet_selec3.length) !== null && _ctx$luckysheet_selec2 !== void 0 ? _ctx$luckysheet_selec2 : 0) > 0) {
|
|
@@ -100815,7 +100909,7 @@
|
|
|
100815
100909
|
break;
|
|
100816
100910
|
}
|
|
100817
100911
|
}
|
|
100818
|
-
function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas) {
|
|
100912
|
+
function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas, refs) {
|
|
100819
100913
|
ctx.luckysheet_select_status = false;
|
|
100820
100914
|
var kcode = e.keyCode;
|
|
100821
100915
|
var kstr = e.key;
|
|
@@ -100831,7 +100925,7 @@
|
|
|
100831
100925
|
}
|
|
100832
100926
|
if (kstr === "Enter") {
|
|
100833
100927
|
if (!allowEdit) return;
|
|
100834
|
-
handleGlobalEnter(ctx, cellInput, e, canvas);
|
|
100928
|
+
handleGlobalEnter(ctx, cellInput, e, canvas, refs);
|
|
100835
100929
|
} else if (kstr === "Tab") {
|
|
100836
100930
|
if (ctx.luckysheetCellUpdate.length > 0) {
|
|
100837
100931
|
return;
|
|
@@ -101312,7 +101406,7 @@
|
|
|
101312
101406
|
var col_location = colLocation(x, ctx.visibledatacolumn);
|
|
101313
101407
|
var col_pre = col_location[0];
|
|
101314
101408
|
var col_index = col_location[2];
|
|
101315
|
-
var currentCellValue = JSON.parse(JSON.stringify((_flowdata$row_index4 = flowdata[row_index]) === null || _flowdata$row_index4 === void 0 ? void 0 : _flowdata$row_index4[col_index]));
|
|
101409
|
+
var currentCellValue = JSON.parse(JSON.stringify(((_flowdata$row_index4 = flowdata[row_index]) === null || _flowdata$row_index4 === void 0 ? void 0 : _flowdata$row_index4[col_index]) || null));
|
|
101316
101410
|
var box = document.querySelector(".leankylin-cell-area");
|
|
101317
101411
|
if (box) {
|
|
101318
101412
|
var _currentCellValue$cu;
|
|
@@ -101433,7 +101527,7 @@
|
|
|
101433
101527
|
var col_location = colLocation(x, ctx.visibledatacolumn);
|
|
101434
101528
|
var col_pre = col_location[0];
|
|
101435
101529
|
var col_index = col_location[2];
|
|
101436
|
-
var currentCellValue = JSON.parse(JSON.stringify((_flowdata$row_index6 = flowdata[row_index]) === null || _flowdata$row_index6 === void 0 ? void 0 : _flowdata$row_index6[col_index]));
|
|
101530
|
+
var currentCellValue = JSON.parse(JSON.stringify(((_flowdata$row_index6 = flowdata[row_index]) === null || _flowdata$row_index6 === void 0 ? void 0 : _flowdata$row_index6[col_index]) || null));
|
|
101437
101531
|
var box = document.querySelector(".leankylin-cell-area");
|
|
101438
101532
|
if (box) {
|
|
101439
101533
|
var _currentCellValue$cu3;
|
|
@@ -101720,7 +101814,7 @@
|
|
|
101720
101814
|
}
|
|
101721
101815
|
}
|
|
101722
101816
|
function mouseRender(ctx, globalCache, e, cellInput, scrollX, scrollY, container, fxInput) {
|
|
101723
|
-
var _ctx$rangeDialog;
|
|
101817
|
+
var _ctx$rangeDialog, _ctx$rangeDialog2;
|
|
101724
101818
|
var rect = container.getBoundingClientRect();
|
|
101725
101819
|
if (ctx.luckysheet_scroll_status && !ctx.luckysheet_cols_change_size && !ctx.luckysheet_rows_change_size) {
|
|
101726
101820
|
var left = ctx.scrollLeft;
|
|
@@ -101748,7 +101842,8 @@
|
|
|
101748
101842
|
scrollX.scrollLeft = sleft;
|
|
101749
101843
|
}
|
|
101750
101844
|
}
|
|
101751
|
-
|
|
101845
|
+
console.log('ctx.rangeDialog?.singleSelect', (_ctx$rangeDialog = ctx.rangeDialog) === null || _ctx$rangeDialog === void 0 ? void 0 : _ctx$rangeDialog.singleSelect);
|
|
101846
|
+
if ((_ctx$rangeDialog2 = ctx.rangeDialog) === null || _ctx$rangeDialog2 === void 0 ? void 0 : _ctx$rangeDialog2.singleSelect) {
|
|
101752
101847
|
return;
|
|
101753
101848
|
}
|
|
101754
101849
|
if (ctx.luckysheet_select_status) {
|
|
@@ -102886,21 +102981,23 @@
|
|
|
102886
102981
|
};
|
|
102887
102982
|
}
|
|
102888
102983
|
function getClipboardData(ctx, e, copyRich, startRow, startCol) {
|
|
102889
|
-
var _ctx$luckysheetfile, _currentSheet$data, _currentSheet$data2, _currentSheet$data2
|
|
102984
|
+
var _ctx$luckysheetfile, _currentSheet$data, _currentSheet$data2, _currentSheet$data2$;
|
|
102890
102985
|
var clipboardData = e.clipboardData;
|
|
102891
102986
|
var currentSheet = (_ctx$luckysheetfile = ctx.luckysheetfile) === null || _ctx$luckysheetfile === void 0 ? void 0 : _ctx$luckysheetfile.find(function (item) {
|
|
102892
102987
|
return item.id === ctx.currentSheetId;
|
|
102893
102988
|
});
|
|
102894
102989
|
var currentRowLen = (currentSheet === null || currentSheet === void 0 ? void 0 : (_currentSheet$data = currentSheet.data) === null || _currentSheet$data === void 0 ? void 0 : _currentSheet$data.length) || 1000;
|
|
102895
102990
|
var currentColLen = (currentSheet === null || currentSheet === void 0 ? void 0 : (_currentSheet$data2 = currentSheet.data) === null || _currentSheet$data2 === void 0 ? void 0 : (_currentSheet$data2$ = _currentSheet$data2[0]) === null || _currentSheet$data2$ === void 0 ? void 0 : _currentSheet$data2$.length) || 200;
|
|
102896
|
-
var txtdata = clipboardData.getData("text/html");
|
|
102991
|
+
var txtdata = clipboardData.getData("text/html") || clipboardData.getData("text/plain");
|
|
102897
102992
|
var iframe = document.createElement("iframe");
|
|
102898
102993
|
iframe.style.display = "none";
|
|
102899
102994
|
document.body.appendChild(iframe);
|
|
102900
102995
|
var iframeDoc = iframe.contentDocument;
|
|
102901
102996
|
iframeDoc.documentElement.innerHTML = txtdata;
|
|
102902
102997
|
var htmlDoc = iframeDoc === null || iframeDoc === void 0 ? void 0 : iframeDoc.documentElement;
|
|
102903
|
-
var
|
|
102998
|
+
var headerRows = Array.from(htmlDoc.querySelectorAll("thead tr")) || [];
|
|
102999
|
+
var bodyRows = Array.from(htmlDoc.querySelectorAll("tbody tr")).slice(0, currentRowLen);
|
|
103000
|
+
var rows = [].concat(_toConsumableArray$2(headerRows), _toConsumableArray$2(bodyRows));
|
|
102904
103001
|
if (!rows || rows.length < 1) {
|
|
102905
103002
|
return {
|
|
102906
103003
|
data: [[clipboardData.getData("text")]],
|
|
@@ -102913,7 +103010,10 @@
|
|
|
102913
103010
|
var merge = {};
|
|
102914
103011
|
for (var index = 0; index < (rows === null || rows === void 0 ? void 0 : rows.length); index += 1) {
|
|
102915
103012
|
var row = rows[index];
|
|
102916
|
-
var
|
|
103013
|
+
var tds = row.querySelectorAll("td");
|
|
103014
|
+
var ths = row.querySelectorAll("th");
|
|
103015
|
+
var tCells = (tds === null || tds === void 0 ? void 0 : tds.length) > 0 ? tds : ths;
|
|
103016
|
+
var cells = Array.from(tCells).slice(0, currentColLen);
|
|
102917
103017
|
if (!result[index]) {
|
|
102918
103018
|
result[index] = [];
|
|
102919
103019
|
}
|
|
@@ -102934,13 +103034,14 @@
|
|
|
102934
103034
|
continue;
|
|
102935
103035
|
}
|
|
102936
103036
|
var m = cell === null || cell === void 0 ? void 0 : cell.textContent;
|
|
103037
|
+
var allV = JSON.parse(cell.getAttribute("_v") || "{}");
|
|
102937
103038
|
var v = cell.getAttribute("x:num");
|
|
102938
103039
|
var f = cell.getAttribute("f");
|
|
102939
103040
|
if (copyRich) {
|
|
102940
103041
|
var style = iframe.contentWindow.getComputedStyle(cell);
|
|
102941
103042
|
var rowspan = Number(cell.getAttribute("rowspan")) || 1;
|
|
102942
103043
|
var colspan = Number(cell.getAttribute("colspan")) || 1;
|
|
102943
|
-
var mainCell = _objectSpread2$1({
|
|
103044
|
+
var mainCell = _objectSpread2$1(_objectSpread2$1({}, allV || {}), {}, {
|
|
102944
103045
|
v: v || m,
|
|
102945
103046
|
m: m || v,
|
|
102946
103047
|
f: f || undefined
|
|
@@ -111989,53 +112090,7 @@
|
|
|
111989
112090
|
var onChangeSheet = useMemoizedFn(function () {
|
|
111990
112091
|
if (isDropPlaceholder) return;
|
|
111991
112092
|
setContext(function (draftCtx) {
|
|
111992
|
-
|
|
111993
|
-
draftCtx.sheetScrollRecord[draftCtx.currentSheetId] = {
|
|
111994
|
-
scrollLeft: draftCtx.scrollLeft,
|
|
111995
|
-
scrollTop: draftCtx.scrollTop,
|
|
111996
|
-
luckysheet_select_status: draftCtx.luckysheet_select_status,
|
|
111997
|
-
luckysheet_select_save: draftCtx.luckysheet_select_save,
|
|
111998
|
-
luckysheet_selection_range: draftCtx.luckysheet_selection_range
|
|
111999
|
-
};
|
|
112000
|
-
var isBack = false;
|
|
112001
|
-
var luckysheetCellUpdate = [];
|
|
112002
|
-
var sheetId = sheet.id;
|
|
112003
|
-
if ((israngeseleciton(draftCtx) || draftCtx.formulaCache.rangestart) && !draftCtx.active_f) {
|
|
112004
|
-
var _refs$fxInput$current, _draftCtx$sheetScroll;
|
|
112005
|
-
draftCtx.active_f = {
|
|
112006
|
-
r: draftCtx.luckysheet_select_save[0].row_focus,
|
|
112007
|
-
c: draftCtx.luckysheet_select_save[0].column_focus,
|
|
112008
|
-
sheetId: draftCtx.currentSheetId,
|
|
112009
|
-
text: (_refs$fxInput$current = refs.fxInput.current) === null || _refs$fxInput$current === void 0 ? void 0 : _refs$fxInput$current.innerText
|
|
112010
|
-
};
|
|
112011
|
-
if ((_draftCtx$sheetScroll = draftCtx.sheetScrollRecord[sheet.id]) === null || _draftCtx$sheetScroll === void 0 ? void 0 : _draftCtx$sheetScroll.luckysheet_select_save) {
|
|
112012
|
-
draftCtx.sheetScrollRecord[sheet.id].luckysheet_select_save = undefined;
|
|
112013
|
-
}
|
|
112014
|
-
moveToEnd(refs.fxInput.current);
|
|
112015
|
-
} else if (draftCtx.active_f && draftCtx.active_f.sheetId === sheet.id) {
|
|
112016
|
-
var _refs$fxInput$current2;
|
|
112017
|
-
luckysheetCellUpdate = [draftCtx.active_f.r, draftCtx.active_f.c];
|
|
112018
|
-
isBack = true;
|
|
112019
|
-
if ((_refs$fxInput$current2 = refs.fxInput.current) === null || _refs$fxInput$current2 === void 0 ? void 0 : _refs$fxInput$current2.innerHTML) {
|
|
112020
|
-
var _refs$fxInput$current3;
|
|
112021
|
-
refs.cellInput.current.innerHTML = ((_refs$fxInput$current3 = refs.fxInput.current) === null || _refs$fxInput$current3 === void 0 ? void 0 : _refs$fxInput$current3.innerHTML) || "";
|
|
112022
|
-
}
|
|
112023
|
-
moveToEnd(refs.cellInput.current);
|
|
112024
|
-
}
|
|
112025
|
-
if (draftCtx.active_f) {
|
|
112026
|
-
sheetId = draftCtx.active_f.sheetId;
|
|
112027
|
-
}
|
|
112028
|
-
var _update = ((_luckysheetCellUpdate = luckysheetCellUpdate) === null || _luckysheetCellUpdate === void 0 ? void 0 : _luckysheetCellUpdate.length) > 0 ? luckysheetCellUpdate : draftCtx.luckysheetCellUpdate;
|
|
112029
|
-
draftCtx.currentSheetId = sheet.id;
|
|
112030
|
-
if ((_update === null || _update === void 0 ? void 0 : _update.length) > 0) ;
|
|
112031
|
-
draftCtx.dataVerificationDropDownList = false;
|
|
112032
|
-
draftCtx.zoomRatio = sheet.zoomRatio || 1;
|
|
112033
|
-
cancelActiveImgItem(draftCtx, refs.globalCache);
|
|
112034
|
-
cancelNormalSelected(draftCtx);
|
|
112035
|
-
if (isBack) {
|
|
112036
|
-
draftCtx.luckysheetCellUpdate = luckysheetCellUpdate;
|
|
112037
|
-
draftCtx.active_f = undefined;
|
|
112038
|
-
}
|
|
112093
|
+
setNextSheet(draftCtx, sheet.id, refs);
|
|
112039
112094
|
});
|
|
112040
112095
|
});
|
|
112041
112096
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
@@ -112995,7 +113050,7 @@
|
|
|
112995
113050
|
if (draftCtx.activeImg != null) {
|
|
112996
113051
|
removeActiveImage(draftCtx);
|
|
112997
113052
|
} else {
|
|
112998
|
-
var msg = deleteSelectedCellText(draftCtx);
|
|
113053
|
+
var msg = deleteSelectedCellText(draftCtx, true);
|
|
112999
113054
|
if (msg === "partMC") {
|
|
113000
113055
|
showDialog(generalDialog.partiallyError, "ok");
|
|
113001
113056
|
} else if (msg === "allowEdit") {
|
|
@@ -116228,7 +116283,7 @@
|
|
|
116228
116283
|
return;
|
|
116229
116284
|
}
|
|
116230
116285
|
setContextWithProduce(function (draftCtx) {
|
|
116231
|
-
handleGlobalKeyDown(draftCtx, cellInput.current, fxInput.current, nativeEvent, globalCache.current, handleUndo, handleRedo, canvas.current.getContext("2d"));
|
|
116286
|
+
handleGlobalKeyDown(draftCtx, cellInput.current, fxInput.current, nativeEvent, globalCache.current, handleUndo, handleRedo, canvas.current.getContext("2d"), refs);
|
|
116232
116287
|
});
|
|
116233
116288
|
}, [handleRedo, handleUndo, setContextWithProduce, mergedSettings.disabledKeyboardCodes]);
|
|
116234
116289
|
var onPaste = React.useCallback(function (e) {
|