@leankylin-sheet/react 5.2.77 → 6.0.1
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/components/Workbook/api.d.ts +1 -0
- package/dist/components/Workbook/index.d.ts +1 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/index.esm.js +284 -85
- package/dist/index.js +283 -84
- package/dist/index.umd.js +15533 -15334
- package/dist/index.umd.min.js +1 -1
- package/package.json +3 -3
|
@@ -93,6 +93,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
93
93
|
hyperlink?: Record<string, {
|
|
94
94
|
linkType: string;
|
|
95
95
|
linkAddress: string;
|
|
96
|
+
payload?: Record<string, any> | undefined;
|
|
96
97
|
}> | undefined;
|
|
97
98
|
dynamicArray_compute?: any;
|
|
98
99
|
dynamicArray?: any[] | undefined;
|
|
@@ -101,6 +101,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
101
101
|
hyperlink?: Record<string, {
|
|
102
102
|
linkType: string;
|
|
103
103
|
linkAddress: string;
|
|
104
|
+
payload?: Record<string, any> | undefined;
|
|
104
105
|
}> | undefined;
|
|
105
106
|
dynamicArray_compute?: any;
|
|
106
107
|
dynamicArray?: any[] | undefined;
|
package/dist/context/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type SetContextOptions = {
|
|
|
17
17
|
declare const WorkbookContext: React.Context<{
|
|
18
18
|
context: Context;
|
|
19
19
|
setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void;
|
|
20
|
+
setScrollContext: (recipe: (ctx: Context) => void) => void;
|
|
20
21
|
settings: Required<Settings>;
|
|
21
22
|
refs: RefValues;
|
|
22
23
|
handleUndo: () => void;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleContextMenu, selectTitlesMap, selectTitlesRange, fixColumnStyleOverflowInFreeze, rowLocationByIndex, rowLocation, handleRowHeaderMouseDown, handleRowSizeHandleMouseDown, handleRowFreezeHandleMouseDown, fixRowStyleOverflowInFreeze, functionHTMLGenerate, locale, getCellValue, createRangeHightlight, isInlineStringCell, getInlineStringHTML, valueShowEs, escapeHTMLTag, escapeScriptTag, isShowHidenCR, cancelNormalSelected, moveHighlightCell, updateCell, israngeseleciton, handleFormulaInput, onSearchDialogMoveStart, replaceAll, replace, searchAll, searchNext, changeSheet, normalizeSelection, scrollToHighlightCell, chatatABC, isLinkValid, getRangetxt, goToLink, replaceHtml, removeHyperlink, onRangeSelectionModalMoveStart, saveHyperlink, createFilterOptions, onImageMoveStart, onImageResizeStart, showComments, setEditingComment, onCommentBoxMoveStart, onCommentBoxResizeStart, confirmMessage, getRangeByTxt, getDropdownList, setCellValue, setConditionRules, mergeBorder, setDropcownValue, handleCellAreaMouseDown, handleCellAreaMouseMove, handleCellAreaDragOver, handleCellDrop, handleCellAreaDoubleClick, selectAll, showLinkCard, getCellRowColumn,
|
|
1
|
+
import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleContextMenu, selectTitlesMap, selectTitlesRange, fixColumnStyleOverflowInFreeze, rowLocationByIndex, rowLocation, handleRowHeaderMouseDown, handleRowSizeHandleMouseDown, handleRowFreezeHandleMouseDown, fixRowStyleOverflowInFreeze, functionHTMLGenerate, locale, getCellValue, createRangeHightlight, isInlineStringCell, getInlineStringHTML, valueShowEs, escapeHTMLTag, escapeScriptTag, isShowHidenCR, cancelNormalSelected, moveHighlightCell, updateCell, israngeseleciton, handleFormulaInput, onSearchDialogMoveStart, replaceAll, replace, searchAll, searchNext, changeSheet, normalizeSelection, scrollToHighlightCell, chatatABC, getCellHyperlink, isLinkValid, getRangetxt, goToLink, replaceHtml, removeHyperlink, onRangeSelectionModalMoveStart, saveHyperlink, createFilterOptions, onImageMoveStart, onImageResizeStart, showComments, setEditingComment, onCommentBoxMoveStart, onCommentBoxResizeStart, confirmMessage, getRangeByTxt, getDropdownList, setCellValue, setConditionRules, mergeBorder, setDropcownValue, handleCellAreaMouseDown, handleCellAreaMouseMove, handleCellAreaDragOver, handleCellDrop, handleCellAreaDoubleClick, selectAll, showLinkCard, getCellRowColumn, handleOverlayMouseMove, handleOverlayMouseUp, handleKeydownForZoom, handleOverlayTouchStart, handleOverlayTouchMove, handleOverlayTouchEnd, onCellsMoveStart, createDropCellRange, handleDropCellDoubleClick, updateContextWithSheetData, updateContextWithCanvas, initFreeze, Canvas, handleGlobalWheel, setCaretPosition, getDataArr, updateMoreCell, getRegStr, getOptionValue, getSelectRange, applyLocation, updateItem, update, normalizedCellAttr, updateFormat, handleTextSize, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, showImgChooser, insertImage, editComment, deleteComment, showHideComment, showHideAllComments, newComment, handleSum, autoSelectionFormula, handleMerge, handleBorder, handleFreeze, handleSort, createFilter, clearFilter, toolbarItemSelectedFunc, toolbarItemClickHandler, handleTextColor, handleTextBackground, getDataBySelectionNoCopy, getInlineStringNoStyle, rangeHightlightselected, editSheetName, setNextSheet, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, addSheet, indexToColumnChar, sortSelection, handleCopy, insertRowCol, deleteRowCol, hideSelected, showSelected, api, removeActiveImage, deleteSelectedCellText, jfrefreshgrid, handleLink, deleteSheet, opToPatch, orderbydatafiler, getFilterColumnValues, getFilterColumnColors, saveFilter, cancelActiveImgItem, patchToOp, filterPatch, inverseRowColOptions, ensureSheetIndex, initSheetIndex, handleGlobalKeyDown, handlePasteByLeanklin, groupValuesRefresh } from '@leankylin-sheet/core';
|
|
2
|
+
import { useInViewport, useMemoizedFn, useThrottleFn } from 'ahooks';
|
|
2
3
|
import React, { useContext, useRef, useState, useMemo, useCallback, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
|
|
3
4
|
import produce, { applyPatches, enablePatches, produceWithPatches } from 'immer';
|
|
4
5
|
import _ from 'lodash';
|
|
5
|
-
import { useInViewport, useMemoizedFn, useThrottleFn } from 'ahooks';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
|
|
8
8
|
function _iterableToArrayLimit(r, l) {
|
|
@@ -556,6 +556,7 @@ var defaultRefs = {
|
|
|
556
556
|
var WorkbookContext = /*#__PURE__*/React.createContext({
|
|
557
557
|
context: defaultContext(defaultRefs),
|
|
558
558
|
setContext: function setContext() {},
|
|
559
|
+
setScrollContext: function setScrollContext() {},
|
|
559
560
|
settings: defaultSettings,
|
|
560
561
|
handleUndo: function handleUndo() {},
|
|
561
562
|
handleRedo: function handleRedo() {},
|
|
@@ -1670,7 +1671,7 @@ var ScrollBar = function ScrollBar(_ref) {
|
|
|
1670
1671
|
var _useContext = useContext(WorkbookContext),
|
|
1671
1672
|
context = _useContext.context,
|
|
1672
1673
|
refs = _useContext.refs,
|
|
1673
|
-
|
|
1674
|
+
setScrollContext = _useContext.setScrollContext;
|
|
1674
1675
|
var ref = axis === "x" ? refs.scrollbarX : refs.scrollbarY;
|
|
1675
1676
|
var _useInViewport = useInViewport(ref),
|
|
1676
1677
|
_useInViewport2 = _slicedToArray(_useInViewport, 1),
|
|
@@ -1703,11 +1704,11 @@ var ScrollBar = function ScrollBar(_ref) {
|
|
|
1703
1704
|
className: "luckysheet-scrollbars luckysheet-scrollbar-ltr luckysheet-scrollbar-".concat(axis),
|
|
1704
1705
|
onScroll: function onScroll() {
|
|
1705
1706
|
if (axis === "x") {
|
|
1706
|
-
|
|
1707
|
+
setScrollContext(function (draftCtx) {
|
|
1707
1708
|
draftCtx.scrollLeft = refs.scrollbarX.current.scrollLeft;
|
|
1708
1709
|
});
|
|
1709
1710
|
} else {
|
|
1710
|
-
|
|
1711
|
+
setScrollContext(function (draftCtx) {
|
|
1711
1712
|
draftCtx.scrollTop = refs.scrollbarY.current.scrollTop;
|
|
1712
1713
|
});
|
|
1713
1714
|
}
|
|
@@ -2262,7 +2263,7 @@ var LinkEditCard = function LinkEditCard(_ref) {
|
|
|
2262
2263
|
c = _ref.c,
|
|
2263
2264
|
rc = _ref.rc,
|
|
2264
2265
|
originText = _ref.originText,
|
|
2265
|
-
|
|
2266
|
+
_originType = _ref.originType,
|
|
2266
2267
|
originAddress = _ref.originAddress,
|
|
2267
2268
|
isEditing = _ref.isEditing,
|
|
2268
2269
|
position = _ref.position,
|
|
@@ -2270,7 +2271,8 @@ var LinkEditCard = function LinkEditCard(_ref) {
|
|
|
2270
2271
|
var _useContext = useContext(WorkbookContext),
|
|
2271
2272
|
context = _useContext.context,
|
|
2272
2273
|
setContext = _useContext.setContext,
|
|
2273
|
-
refs = _useContext.refs
|
|
2274
|
+
refs = _useContext.refs,
|
|
2275
|
+
settings = _useContext.settings;
|
|
2274
2276
|
var _useState = useState(originText),
|
|
2275
2277
|
_useState2 = _slicedToArray(_useState, 2),
|
|
2276
2278
|
linkText = _useState2[0],
|
|
@@ -2279,10 +2281,19 @@ var LinkEditCard = function LinkEditCard(_ref) {
|
|
|
2279
2281
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
2280
2282
|
linkAddress = _useState4[0],
|
|
2281
2283
|
setLinkAddress = _useState4[1];
|
|
2284
|
+
var originType = _originType || settings.detailLinkType || "webpage";
|
|
2282
2285
|
var _useState5 = useState(originType),
|
|
2283
2286
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
2284
2287
|
linkType = _useState6[0],
|
|
2285
2288
|
setLinkType = _useState6[1];
|
|
2289
|
+
var _useState7 = useState(function () {
|
|
2290
|
+
var _origin$payload;
|
|
2291
|
+
var origin = getCellHyperlink(context, r, c);
|
|
2292
|
+
return (_origin$payload = origin === null || origin === void 0 ? void 0 : origin.payload) !== null && _origin$payload !== void 0 ? _origin$payload : {};
|
|
2293
|
+
}),
|
|
2294
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
2295
|
+
customPayload = _useState8[0],
|
|
2296
|
+
setCustomPayload = _useState8[1];
|
|
2286
2297
|
var _locale = locale(context),
|
|
2287
2298
|
insertLink = _locale.insertLink,
|
|
2288
2299
|
linkTypeList = _locale.linkTypeList,
|
|
@@ -2293,9 +2304,65 @@ var LinkEditCard = function LinkEditCard(_ref) {
|
|
|
2293
2304
|
}]));
|
|
2294
2305
|
var skipCellRangeSet = useRef(true);
|
|
2295
2306
|
var isLinkAddressValid = isLinkValid(context, linkType, linkAddress);
|
|
2296
|
-
var
|
|
2297
|
-
|
|
2298
|
-
|
|
2307
|
+
var mergedLinkTypeList = useMemo(function () {
|
|
2308
|
+
var _settings$customLinkT;
|
|
2309
|
+
var customs = (_settings$customLinkT = settings === null || settings === void 0 ? void 0 : settings.customLinkTypes) !== null && _settings$customLinkT !== void 0 ? _settings$customLinkT : [];
|
|
2310
|
+
if (customs.length === 0) return linkTypeList;
|
|
2311
|
+
var builtinTypes = new Set(linkTypeList.map(function (it) {
|
|
2312
|
+
return it.value;
|
|
2313
|
+
}));
|
|
2314
|
+
var extra = customs.filter(function (it) {
|
|
2315
|
+
return it.type && !builtinTypes.has(it.type);
|
|
2316
|
+
}).map(function (it) {
|
|
2317
|
+
return {
|
|
2318
|
+
text: it.text,
|
|
2319
|
+
value: it.type
|
|
2320
|
+
};
|
|
2321
|
+
});
|
|
2322
|
+
return [].concat(_toConsumableArray(extra), _toConsumableArray(linkTypeList));
|
|
2323
|
+
}, [settings === null || settings === void 0 ? void 0 : settings.customLinkTypes, linkTypeList]);
|
|
2324
|
+
var customLinkTypeMap = useMemo(function () {
|
|
2325
|
+
var _settings$customLinkT2;
|
|
2326
|
+
var m = {};
|
|
2327
|
+
((_settings$customLinkT2 = settings === null || settings === void 0 ? void 0 : settings.customLinkTypes) !== null && _settings$customLinkT2 !== void 0 ? _settings$customLinkT2 : []).forEach(function (it) {
|
|
2328
|
+
if (it.type) m[it.type] = it;
|
|
2329
|
+
});
|
|
2330
|
+
return m;
|
|
2331
|
+
}, [settings === null || settings === void 0 ? void 0 : settings.customLinkTypes]);
|
|
2332
|
+
var currentCustomConfig = customLinkTypeMap[linkType];
|
|
2333
|
+
var isCustomTypeValid = useMemo(function () {
|
|
2334
|
+
if (!currentCustomConfig) return true;
|
|
2335
|
+
if (!currentCustomConfig.onSave) return true;
|
|
2336
|
+
var next = currentCustomConfig.onSave({
|
|
2337
|
+
linkText: linkText,
|
|
2338
|
+
linkAddress: linkAddress,
|
|
2339
|
+
position: {
|
|
2340
|
+
r: r,
|
|
2341
|
+
c: c
|
|
2342
|
+
},
|
|
2343
|
+
origin: function () {
|
|
2344
|
+
var o = getCellHyperlink(context, r, c);
|
|
2345
|
+
return o ? {
|
|
2346
|
+
linkType: o.linkType,
|
|
2347
|
+
linkAddress: o.linkAddress,
|
|
2348
|
+
payload: o.payload
|
|
2349
|
+
} : undefined;
|
|
2350
|
+
}()
|
|
2351
|
+
});
|
|
2352
|
+
return next !== undefined;
|
|
2353
|
+
}, [currentCustomConfig, linkText, linkAddress, r, c, context]);
|
|
2354
|
+
var canSubmit = !currentCustomConfig || isCustomTypeValid ? isLinkAddressValid.isValid : false;
|
|
2355
|
+
var tooltip = function () {
|
|
2356
|
+
var text;
|
|
2357
|
+
if (currentCustomConfig) {
|
|
2358
|
+
text = isCustomTypeValid ? "" : insertLink.tooltipInfo1 || "";
|
|
2359
|
+
} else {
|
|
2360
|
+
text = isLinkAddressValid.tooltip;
|
|
2361
|
+
}
|
|
2362
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2363
|
+
className: "validation-input-tip"
|
|
2364
|
+
}, text);
|
|
2365
|
+
}();
|
|
2299
2366
|
var hideLinkCard = useCallback(function () {
|
|
2300
2367
|
_.set(refs.globalCache, "linkCard.mouseEnter", false);
|
|
2301
2368
|
setContext(function (draftCtx) {
|
|
@@ -2357,10 +2424,13 @@ var LinkEditCard = function LinkEditCard(_ref) {
|
|
|
2357
2424
|
}));
|
|
2358
2425
|
}, []);
|
|
2359
2426
|
useLayoutEffect(function () {
|
|
2427
|
+
var _origin$payload2;
|
|
2360
2428
|
setLinkAddress(originAddress);
|
|
2361
2429
|
setLinkText(originText);
|
|
2362
2430
|
setLinkType(originType);
|
|
2363
|
-
|
|
2431
|
+
var origin = getCellHyperlink(context, r, c);
|
|
2432
|
+
setCustomPayload((_origin$payload2 = origin === null || origin === void 0 ? void 0 : origin.payload) !== null && _origin$payload2 !== void 0 ? _origin$payload2 : {});
|
|
2433
|
+
}, [rc, originAddress, originText, originType, r, c, context]);
|
|
2364
2434
|
useLayoutEffect(function () {
|
|
2365
2435
|
if (selectingCellRange) {
|
|
2366
2436
|
skipCellRangeSet.current = true;
|
|
@@ -2379,6 +2449,7 @@ var LinkEditCard = function LinkEditCard(_ref) {
|
|
|
2379
2449
|
}
|
|
2380
2450
|
}, [context, selectingCellRange]);
|
|
2381
2451
|
if (!isEditing) {
|
|
2452
|
+
var toolbarCustomConfig = customLinkTypeMap[originType];
|
|
2382
2453
|
return /*#__PURE__*/React.createElement("div", _objectSpread2(_objectSpread2({}, containerEvent), {}, {
|
|
2383
2454
|
onKeyDown: function onKeyDown(e) {
|
|
2384
2455
|
e.stopPropagation();
|
|
@@ -2390,16 +2461,35 @@ var LinkEditCard = function LinkEditCard(_ref) {
|
|
|
2390
2461
|
}
|
|
2391
2462
|
}), /*#__PURE__*/React.createElement("div", {
|
|
2392
2463
|
className: "link-content",
|
|
2393
|
-
onClick: function onClick() {
|
|
2464
|
+
onClick: function onClick(reactEvent) {
|
|
2465
|
+
var _getCellHyperlink, _toolbarCustomConfig$, _settings$hooks, _settings$hooks$onHyp;
|
|
2466
|
+
var payload = (_getCellHyperlink = getCellHyperlink(context, r, c)) === null || _getCellHyperlink === void 0 ? void 0 : _getCellHyperlink.payload;
|
|
2467
|
+
var clickInfo = {
|
|
2468
|
+
linkType: originType,
|
|
2469
|
+
linkAddress: originAddress,
|
|
2470
|
+
payload: payload,
|
|
2471
|
+
position: {
|
|
2472
|
+
r: r,
|
|
2473
|
+
c: c,
|
|
2474
|
+
sheetId: context.currentSheetId
|
|
2475
|
+
},
|
|
2476
|
+
event: reactEvent
|
|
2477
|
+
};
|
|
2478
|
+
var userResult = toolbarCustomConfig === null || toolbarCustomConfig === void 0 ? void 0 : (_toolbarCustomConfig$ = toolbarCustomConfig.onClick) === null || _toolbarCustomConfig$ === void 0 ? void 0 : _toolbarCustomConfig$.call(toolbarCustomConfig, clickInfo);
|
|
2479
|
+
settings === null || settings === void 0 ? void 0 : (_settings$hooks = settings.hooks) === null || _settings$hooks === void 0 ? void 0 : (_settings$hooks$onHyp = _settings$hooks.onHyperlinkClick) === null || _settings$hooks$onHyp === void 0 ? void 0 : _settings$hooks$onHyp.call(_settings$hooks, clickInfo);
|
|
2480
|
+
if (userResult === false) {
|
|
2481
|
+
hideLinkCard();
|
|
2482
|
+
return;
|
|
2483
|
+
}
|
|
2394
2484
|
setContext(function (draftCtx) {
|
|
2395
|
-
return goToLink(draftCtx, r, c,
|
|
2485
|
+
return goToLink(draftCtx, r, c, originType, originAddress, refs.scrollbarX.current, refs.scrollbarY.current);
|
|
2396
2486
|
});
|
|
2397
2487
|
}
|
|
2398
|
-
},
|
|
2399
|
-
linkAddress:
|
|
2488
|
+
}, originType === "webpage" ? insertLink.openLink : replaceHtml(insertLink.goTo, {
|
|
2489
|
+
linkAddress: originAddress
|
|
2400
2490
|
})), context.allowEdit === true && /*#__PURE__*/React.createElement("div", {
|
|
2401
2491
|
className: "divider"
|
|
2402
|
-
}), context.allowEdit === true &&
|
|
2492
|
+
}), context.allowEdit === true && originType === "webpage" && renderToolbarButton("copy", function () {
|
|
2403
2493
|
navigator.clipboard.writeText(originAddress);
|
|
2404
2494
|
hideLinkCard();
|
|
2405
2495
|
}), context.allowEdit === true && renderToolbarButton("pencil", function () {
|
|
@@ -2478,18 +2568,23 @@ var LinkEditCard = function LinkEditCard(_ref) {
|
|
|
2478
2568
|
className: "leankylin-link-modify-select",
|
|
2479
2569
|
value: linkType,
|
|
2480
2570
|
onChange: function onChange(e) {
|
|
2481
|
-
|
|
2571
|
+
var next = e.target.value;
|
|
2572
|
+
var nextCustomConfig = customLinkTypeMap[next];
|
|
2573
|
+
if (next === "sheet") {
|
|
2482
2574
|
if (!linkText) {
|
|
2483
2575
|
setLinkText(context.luckysheetfile[0].name);
|
|
2484
2576
|
}
|
|
2485
2577
|
setLinkAddress(context.luckysheetfile[0].name);
|
|
2578
|
+
} else if (nextCustomConfig) {
|
|
2579
|
+
setLinkAddress("");
|
|
2580
|
+
setCustomPayload({});
|
|
2486
2581
|
} else {
|
|
2487
2582
|
setLinkAddress("");
|
|
2488
2583
|
}
|
|
2489
|
-
if (
|
|
2490
|
-
setLinkType(
|
|
2584
|
+
if (next === "cellrange") setRangeModalVisible(true);
|
|
2585
|
+
setLinkType(next);
|
|
2491
2586
|
}
|
|
2492
|
-
},
|
|
2587
|
+
}, mergedLinkTypeList.map(function (type) {
|
|
2493
2588
|
return /*#__PURE__*/React.createElement("option", {
|
|
2494
2589
|
key: type.value,
|
|
2495
2590
|
value: type.value
|
|
@@ -2535,11 +2630,63 @@ var LinkEditCard = function LinkEditCard(_ref) {
|
|
|
2535
2630
|
key: sheet.id,
|
|
2536
2631
|
value: sheet.name
|
|
2537
2632
|
}, sheet.name);
|
|
2633
|
+
})), tooltip)), currentCustomConfig && ( /*#__PURE__*/React.createElement(React.Fragment, null, currentCustomConfig.render ? currentCustomConfig.render({
|
|
2634
|
+
value: linkAddress,
|
|
2635
|
+
position: {
|
|
2636
|
+
r: r,
|
|
2637
|
+
c: c
|
|
2638
|
+
},
|
|
2639
|
+
onChange: function onChange(v) {
|
|
2640
|
+
return setLinkAddress(v);
|
|
2641
|
+
},
|
|
2642
|
+
setPayload: function setPayload(next) {
|
|
2643
|
+
setCustomPayload(function (prev) {
|
|
2644
|
+
return typeof next === "function" ? next(prev) : next;
|
|
2645
|
+
});
|
|
2646
|
+
},
|
|
2647
|
+
payload: customPayload,
|
|
2648
|
+
ctx: {
|
|
2649
|
+
context: context,
|
|
2650
|
+
setContext: setContext,
|
|
2651
|
+
settings: settings
|
|
2652
|
+
}
|
|
2653
|
+
}) : ( /*#__PURE__*/React.createElement("input", {
|
|
2654
|
+
className: "leankylin-link-modify-input ".concat(canSubmit ? "" : "error-input"),
|
|
2655
|
+
spellCheck: "false",
|
|
2656
|
+
value: linkAddress,
|
|
2657
|
+
onChange: function onChange(e) {
|
|
2658
|
+
return setLinkAddress(e.target.value);
|
|
2659
|
+
}
|
|
2538
2660
|
})), tooltip))), /*#__PURE__*/React.createElement("div", {
|
|
2539
2661
|
className: "modal-footer"
|
|
2540
2662
|
}, renderBottomButton(function () {
|
|
2541
|
-
if (!
|
|
2663
|
+
if (!canSubmit) return;
|
|
2542
2664
|
_.set(refs.globalCache, "linkCard.mouseEnter", false);
|
|
2665
|
+
if (currentCustomConfig === null || currentCustomConfig === void 0 ? void 0 : currentCustomConfig.onSave) {
|
|
2666
|
+
var origin = function () {
|
|
2667
|
+
var o = getCellHyperlink(context, r, c);
|
|
2668
|
+
return o ? {
|
|
2669
|
+
linkType: o.linkType,
|
|
2670
|
+
linkAddress: o.linkAddress,
|
|
2671
|
+
payload: o.payload
|
|
2672
|
+
} : undefined;
|
|
2673
|
+
}();
|
|
2674
|
+
var saved = currentCustomConfig.onSave({
|
|
2675
|
+
linkText: linkText,
|
|
2676
|
+
linkAddress: linkAddress,
|
|
2677
|
+
position: {
|
|
2678
|
+
r: r,
|
|
2679
|
+
c: c
|
|
2680
|
+
},
|
|
2681
|
+
origin: origin
|
|
2682
|
+
});
|
|
2683
|
+
if (!saved) return;
|
|
2684
|
+
setContext(function (draftCtx) {
|
|
2685
|
+
var _saved$payload;
|
|
2686
|
+
return saveHyperlink(draftCtx, r, c, linkText || saved.linkAddress, saved.linkType, saved.linkAddress, _objectSpread2(_objectSpread2({}, customPayload), (_saved$payload = saved.payload) !== null && _saved$payload !== void 0 ? _saved$payload : {}));
|
|
2687
|
+
});
|
|
2688
|
+
return;
|
|
2689
|
+
}
|
|
2543
2690
|
setContext(function (draftCtx) {
|
|
2544
2691
|
return saveHyperlink(draftCtx, r, c, linkText, linkType, linkAddress);
|
|
2545
2692
|
});
|
|
@@ -4350,9 +4497,7 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
4350
4497
|
}, [setContext, refs.globalCache, refs.cellInput, refs.cellArea, refs.fxInput, refs.canvas]);
|
|
4351
4498
|
var debounceMouseMove = useMemoizedFn(function (e) {
|
|
4352
4499
|
var nativeEvent = e.nativeEvent;
|
|
4353
|
-
|
|
4354
|
-
handleCellAreaMouseMove(draftCtx, refs.globalCache, nativeEvent, refs.cellArea.current);
|
|
4355
|
-
});
|
|
4500
|
+
handleCellAreaMouseMove(context, refs.globalCache, nativeEvent, refs.cellArea.current);
|
|
4356
4501
|
});
|
|
4357
4502
|
var debounceDragOver = useMemoizedFn(function (e) {
|
|
4358
4503
|
var nativeEvent = e.nativeEvent;
|
|
@@ -4418,16 +4563,53 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
4418
4563
|
if (link == null) {
|
|
4419
4564
|
debouncedShowLinkCard(globalCache, rc.r, rc.c, false);
|
|
4420
4565
|
} else {
|
|
4566
|
+
var _settings$customLinkT, _customConfig$onHover, _settings$hooks, _settings$hooks$onHyp;
|
|
4421
4567
|
showLinkCard(ctx, rc.r, rc.c, false);
|
|
4422
4568
|
debouncedShowLinkCard(globalCache, rc.r, rc.c, false, true);
|
|
4569
|
+
var payload = link.payload;
|
|
4570
|
+
var customConfigMap = ((_settings$customLinkT = settings === null || settings === void 0 ? void 0 : settings.customLinkTypes) !== null && _settings$customLinkT !== void 0 ? _settings$customLinkT : []).reduce(function (acc, it) {
|
|
4571
|
+
if (it.type) acc[it.type] = it;
|
|
4572
|
+
return acc;
|
|
4573
|
+
}, {});
|
|
4574
|
+
var customConfig = customConfigMap[link.linkType];
|
|
4575
|
+
var hoverInfo = {
|
|
4576
|
+
linkType: link.linkType,
|
|
4577
|
+
linkAddress: link.linkAddress,
|
|
4578
|
+
payload: payload,
|
|
4579
|
+
position: {
|
|
4580
|
+
r: rc.r,
|
|
4581
|
+
c: rc.c,
|
|
4582
|
+
sheetId: ctx.currentSheetId
|
|
4583
|
+
},
|
|
4584
|
+
event: e
|
|
4585
|
+
};
|
|
4586
|
+
customConfig === null || customConfig === void 0 ? void 0 : (_customConfig$onHover = customConfig.onHover) === null || _customConfig$onHover === void 0 ? void 0 : _customConfig$onHover.call(customConfig, hoverInfo);
|
|
4587
|
+
settings === null || settings === void 0 ? void 0 : (_settings$hooks = settings.hooks) === null || _settings$hooks === void 0 ? void 0 : (_settings$hooks$onHyp = _settings$hooks.onHyperlinkHover) === null || _settings$hooks$onHyp === void 0 ? void 0 : _settings$hooks$onHyp.call(_settings$hooks, hoverInfo);
|
|
4423
4588
|
}
|
|
4424
|
-
}, [debouncedShowLinkCard]);
|
|
4589
|
+
}, [debouncedShowLinkCard, settings]);
|
|
4590
|
+
var lastHoverCellRef = useRef(null);
|
|
4425
4591
|
var onMouseMove = useCallback(function (nativeEvent) {
|
|
4592
|
+
var _gc$commentBox, _gc$commentBox2, _gc$searchDialog, _gc$linkCard;
|
|
4593
|
+
var container = containerRef.current;
|
|
4594
|
+
var scrollX = refs.scrollbarX.current;
|
|
4595
|
+
var scrollY = refs.scrollbarY.current;
|
|
4596
|
+
if (!container || !scrollX || !scrollY) return;
|
|
4597
|
+
var gc = refs.globalCache;
|
|
4598
|
+
var isInteracting = !!context.luckysheet_scroll_status || !!context.luckysheet_select_status || !!context.luckysheet_rows_selected_status || !!context.luckysheet_cols_selected_status || !!context.luckysheet_cell_selected_move || !!context.luckysheet_cell_selected_extend || !!context.luckysheet_cols_change_size || !!context.luckysheet_rows_change_size || ((_gc$commentBox = gc.commentBox) === null || _gc$commentBox === void 0 ? void 0 : _gc$commentBox.movingId) != null || ((_gc$commentBox2 = gc.commentBox) === null || _gc$commentBox2 === void 0 ? void 0 : _gc$commentBox2.resizingId) != null || gc.image != null || ((_gc$searchDialog = gc.searchDialog) === null || _gc$searchDialog === void 0 ? void 0 : _gc$searchDialog.moveProps) != null || ((_gc$linkCard = gc.linkCard) === null || _gc$linkCard === void 0 ? void 0 : _gc$linkCard.rangeSelectionModal) != null;
|
|
4599
|
+
if (!isInteracting) {
|
|
4600
|
+
var rc = getCellRowColumn(context, nativeEvent, container, scrollX, scrollY);
|
|
4601
|
+
var last = lastHoverCellRef.current;
|
|
4602
|
+
var hoverChanged = rc == null ? last != null : last == null || last.r !== rc.r || last.c !== rc.c;
|
|
4603
|
+
if (!hoverChanged) {
|
|
4604
|
+
return;
|
|
4605
|
+
}
|
|
4606
|
+
lastHoverCellRef.current = rc !== null && rc !== void 0 ? rc : null;
|
|
4607
|
+
}
|
|
4426
4608
|
setContext(function (draftCtx) {
|
|
4427
|
-
overShowLinkCard(draftCtx, refs.globalCache, nativeEvent,
|
|
4428
|
-
handleOverlayMouseMove(draftCtx, refs.globalCache, nativeEvent, refs.cellInput.current,
|
|
4609
|
+
overShowLinkCard(draftCtx, refs.globalCache, nativeEvent, container, scrollX, scrollY);
|
|
4610
|
+
handleOverlayMouseMove(draftCtx, refs.globalCache, nativeEvent, refs.cellInput.current, scrollX, scrollY, container, refs.fxInput.current);
|
|
4429
4611
|
});
|
|
4430
|
-
}, [overShowLinkCard, refs.cellInput, refs.fxInput, refs.globalCache, refs.scrollbarX, refs.scrollbarY, setContext]);
|
|
4612
|
+
}, [overShowLinkCard, context, refs.cellInput, refs.fxInput, refs.globalCache, refs.scrollbarX, refs.scrollbarY, setContext]);
|
|
4431
4613
|
var onMouseUp = useCallback(function (nativeEvent) {
|
|
4432
4614
|
setContext(function (draftCtx) {
|
|
4433
4615
|
try {
|
|
@@ -5014,9 +5196,7 @@ var Sheet = function Sheet(_ref) {
|
|
|
5014
5196
|
return false;
|
|
5015
5197
|
}
|
|
5016
5198
|
var onWheel = useCallback(function (e) {
|
|
5017
|
-
|
|
5018
|
-
handleGlobalWheel(draftCtx, e, refs.globalCache, refs.scrollbarX.current, refs.scrollbarY.current);
|
|
5019
|
-
});
|
|
5199
|
+
handleGlobalWheel(context, e, refs.globalCache, refs.scrollbarX.current, refs.scrollbarY.current);
|
|
5020
5200
|
if (e.deltaY === 0 && e.deltaX === 0) {
|
|
5021
5201
|
return;
|
|
5022
5202
|
}
|
|
@@ -5037,7 +5217,7 @@ var Sheet = function Sheet(_ref) {
|
|
|
5037
5217
|
e.preventDefault();
|
|
5038
5218
|
}
|
|
5039
5219
|
}
|
|
5040
|
-
}, [refs.globalCache, refs.scrollbarX, refs.scrollbarY
|
|
5220
|
+
}, [context, refs.globalCache, refs.scrollbarX, refs.scrollbarY]);
|
|
5041
5221
|
useEffect(function () {
|
|
5042
5222
|
var container = containerRef.current;
|
|
5043
5223
|
container === null || container === void 0 ? void 0 : container.addEventListener("wheel", onWheel);
|
|
@@ -11958,6 +12138,7 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
11958
12138
|
_useState2 = _slicedToArray(_useState, 2),
|
|
11959
12139
|
context = _useState2[0],
|
|
11960
12140
|
setContext = _useState2[1];
|
|
12141
|
+
var contextRef = useRef(context);
|
|
11961
12142
|
var _useState3 = useState(null),
|
|
11962
12143
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
11963
12144
|
moreToolbarItems = _useState4[0],
|
|
@@ -12062,64 +12243,81 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
12062
12243
|
}
|
|
12063
12244
|
return cellData;
|
|
12064
12245
|
}
|
|
12065
|
-
var setContextWithProduce =
|
|
12246
|
+
var setContextWithProduce = useMemoizedFn(function (recipe) {
|
|
12066
12247
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
});
|
|
12086
|
-
if (target) {
|
|
12087
|
-
var index = getSheetIndex(ctx_, options.deleteSheetOp.id);
|
|
12088
|
-
options.deletedSheet = {
|
|
12089
|
-
id: options.deleteSheetOp.id,
|
|
12090
|
-
index: index,
|
|
12091
|
-
value: _.cloneDeep(ctx_.luckysheetfile[index])
|
|
12092
|
-
};
|
|
12093
|
-
options.deletedSheet.value.celldata = dataToCelldata(options.deletedSheet.value.data);
|
|
12094
|
-
delete options.deletedSheet.value.data;
|
|
12095
|
-
options.deletedSheet.value.status = 0;
|
|
12096
|
-
filteredInversePatches = [{
|
|
12097
|
-
op: "add",
|
|
12098
|
-
path: ["luckysheetfile", 0],
|
|
12099
|
-
value: options.deletedSheet.value
|
|
12100
|
-
}];
|
|
12101
|
-
}
|
|
12102
|
-
} else if (options.addSheetOp) {
|
|
12103
|
-
options.addSheet = {};
|
|
12104
|
-
options.addSheet.id = result.luckysheetfile[result.luckysheetfile.length - 1].id;
|
|
12105
|
-
}
|
|
12106
|
-
globalCache.current.undoList.push({
|
|
12107
|
-
patches: filteredPatches,
|
|
12108
|
-
inversePatches: filteredInversePatches,
|
|
12109
|
-
options: options
|
|
12248
|
+
var ctx_ = contextRef.current;
|
|
12249
|
+
var _produceWithPatches = produceWithPatches(ctx_, concatProducer(recipe, triggerGroupValuesRefresh)),
|
|
12250
|
+
_produceWithPatches2 = _slicedToArray(_produceWithPatches, 3),
|
|
12251
|
+
result = _produceWithPatches2[0],
|
|
12252
|
+
patches = _produceWithPatches2[1],
|
|
12253
|
+
inversePatches = _produceWithPatches2[2];
|
|
12254
|
+
if (patches.length > 0 && !options.noHistory) {
|
|
12255
|
+
if (options.logPatch) {
|
|
12256
|
+
console.info("patch", patches);
|
|
12257
|
+
}
|
|
12258
|
+
var filteredPatches = filterPatch(patches);
|
|
12259
|
+
var filteredInversePatches = filterPatch(inversePatches);
|
|
12260
|
+
if (filteredInversePatches.length > 0) {
|
|
12261
|
+
options.id = ctx_.currentSheetId;
|
|
12262
|
+
if (options.deleteSheetOp) {
|
|
12263
|
+
var target = ctx_.luckysheetfile.filter(function (sheet) {
|
|
12264
|
+
var _options$deleteSheetO;
|
|
12265
|
+
return sheet.id === ((_options$deleteSheetO = options.deleteSheetOp) === null || _options$deleteSheetO === void 0 ? void 0 : _options$deleteSheetO.id);
|
|
12110
12266
|
});
|
|
12111
|
-
|
|
12112
|
-
|
|
12113
|
-
|
|
12114
|
-
|
|
12115
|
-
|
|
12116
|
-
|
|
12117
|
-
|
|
12267
|
+
if (target) {
|
|
12268
|
+
var index = getSheetIndex(ctx_, options.deleteSheetOp.id);
|
|
12269
|
+
options.deletedSheet = {
|
|
12270
|
+
id: options.deleteSheetOp.id,
|
|
12271
|
+
index: index,
|
|
12272
|
+
value: _.cloneDeep(ctx_.luckysheetfile[index])
|
|
12273
|
+
};
|
|
12274
|
+
options.deletedSheet.value.celldata = dataToCelldata(options.deletedSheet.value.data);
|
|
12275
|
+
delete options.deletedSheet.value.data;
|
|
12276
|
+
options.deletedSheet.value.status = 0;
|
|
12277
|
+
filteredInversePatches = [{
|
|
12278
|
+
op: "add",
|
|
12279
|
+
path: ["luckysheetfile", 0],
|
|
12280
|
+
value: options.deletedSheet.value
|
|
12281
|
+
}];
|
|
12282
|
+
}
|
|
12283
|
+
} else if (options.addSheetOp) {
|
|
12284
|
+
options.addSheet = {};
|
|
12285
|
+
options.addSheet.id = result.luckysheetfile[result.luckysheetfile.length - 1].id;
|
|
12118
12286
|
}
|
|
12287
|
+
globalCache.current.undoList.push({
|
|
12288
|
+
patches: filteredPatches,
|
|
12289
|
+
inversePatches: filteredInversePatches,
|
|
12290
|
+
options: options
|
|
12291
|
+
});
|
|
12292
|
+
globalCache.current.redoList = [];
|
|
12293
|
+
emitOp(result, filteredPatches, options);
|
|
12119
12294
|
}
|
|
12295
|
+
} else {
|
|
12296
|
+
var _patches$, _patches$$value, _ctx_$luckysheetfile;
|
|
12297
|
+
if ((patches === null || patches === void 0 ? void 0 : (_patches$ = patches[0]) === null || _patches$ === void 0 ? void 0 : (_patches$$value = _patches$.value) === null || _patches$$value === void 0 ? void 0 : _patches$$value.length) < (ctx_ === null || ctx_ === void 0 ? void 0 : (_ctx_$luckysheetfile = ctx_.luckysheetfile) === null || _ctx_$luckysheetfile === void 0 ? void 0 : _ctx_$luckysheetfile.length)) {
|
|
12298
|
+
reduceUndoList(result, ctx_);
|
|
12299
|
+
}
|
|
12300
|
+
}
|
|
12301
|
+
contextRef.current = result;
|
|
12302
|
+
setContext(function (prev) {
|
|
12303
|
+
if (prev === ctx_) {
|
|
12304
|
+
return result;
|
|
12305
|
+
}
|
|
12306
|
+
var merged = applyPatches(prev, patches);
|
|
12307
|
+
contextRef.current = merged;
|
|
12308
|
+
return merged;
|
|
12309
|
+
});
|
|
12310
|
+
});
|
|
12311
|
+
var setScrollContext = useMemoizedFn(function (recipe) {
|
|
12312
|
+
setContext(function (ctx_) {
|
|
12313
|
+
var result = produce(ctx_, recipe);
|
|
12314
|
+
if (result === ctx_) {
|
|
12315
|
+
return ctx_;
|
|
12316
|
+
}
|
|
12317
|
+
contextRef.current = result;
|
|
12120
12318
|
return result;
|
|
12121
12319
|
});
|
|
12122
|
-
}
|
|
12320
|
+
});
|
|
12123
12321
|
var handleUndo = useCallback(function () {
|
|
12124
12322
|
var history = globalCache.current.undoList.pop();
|
|
12125
12323
|
if (history) {
|
|
@@ -12192,12 +12390,13 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
12192
12390
|
return {
|
|
12193
12391
|
context: context,
|
|
12194
12392
|
setContext: setContextWithProduce,
|
|
12393
|
+
setScrollContext: setScrollContext,
|
|
12195
12394
|
settings: mergedSettings,
|
|
12196
12395
|
handleUndo: handleUndo,
|
|
12197
12396
|
handleRedo: handleRedo,
|
|
12198
12397
|
refs: refs
|
|
12199
12398
|
};
|
|
12200
|
-
}, [context, handleRedo, handleUndo, mergedSettings, refs, setContextWithProduce]);
|
|
12399
|
+
}, [context, handleRedo, handleUndo, mergedSettings, refs, setContextWithProduce, setScrollContext]);
|
|
12201
12400
|
useEffect(function () {
|
|
12202
12401
|
if (!_.isEmpty(context.luckysheetfile)) {
|
|
12203
12402
|
onChange === null || onChange === void 0 ? void 0 : onChange(context.luckysheetfile);
|