@univerjs/sheets-ui 1.2.0 → 1.3.0
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/lib/cjs/index.js +176 -123
- package/lib/es/index.js +178 -125
- package/lib/index.css +4 -0
- package/lib/index.js +178 -125
- package/lib/types/controllers/mobile/ui-mobile.controller.d.ts +0 -1
- package/lib/types/controllers/render-controllers/header-unhide.render-controller.d.ts +1 -1
- package/lib/types/controllers/render-controllers/mobile/mobile-header-resize.render-controller.d.ts +4 -7
- package/lib/types/menu/menu.d.ts +1 -1
- package/lib/types/menu/sheet.menu.d.ts +1 -1
- package/lib/types/mobile-plugin.d.ts +1 -1
- package/lib/umd/index.js +3 -3
- package/package.json +13 -13
package/lib/cjs/index.js
CHANGED
|
@@ -15917,7 +15917,7 @@ let HeaderResizeRenderController = class HeaderResizeRenderController extends _u
|
|
|
15917
15917
|
if (Math.abs(initialType === 0 ? moveChangeY : moveChangeX) >= MINIMAL_OFFSET$1) isStartMove = true;
|
|
15918
15918
|
if (initialType === 0) {
|
|
15919
15919
|
if (moveChangeY > canvasMaxHeight - scrollBarHorizontalHeight + scrollXY.y - cell.startY) moveChangeY = canvasMaxHeight - scrollBarHorizontalHeight + scrollXY.y - cell.startY;
|
|
15920
|
-
|
|
15920
|
+
moveChangeY = Math.max(moveChangeY, -(cell.endY - cell.startY));
|
|
15921
15921
|
if (isStartMove) {
|
|
15922
15922
|
var _this$_resizeHelperSh, _this$_rowResizeRect4, _this$_rowResizeRect5;
|
|
15923
15923
|
(_this$_resizeHelperSh = this._resizeHelperShape) === null || _this$_resizeHelperSh === void 0 || _this$_resizeHelperSh.transformByState({ top: currentOffsetY + moveChangeY });
|
|
@@ -15927,7 +15927,7 @@ let HeaderResizeRenderController = class HeaderResizeRenderController extends _u
|
|
|
15927
15927
|
}
|
|
15928
15928
|
} else {
|
|
15929
15929
|
if (moveChangeX > canvasMaxWidth - scrollBarVerticalWidth + scrollXY.x - cell.startX) moveChangeX = canvasMaxWidth - scrollBarVerticalWidth + scrollXY.x - cell.startX;
|
|
15930
|
-
|
|
15930
|
+
moveChangeX = Math.max(moveChangeX, -(cell.endX - cell.startX));
|
|
15931
15931
|
if (isStartMove) {
|
|
15932
15932
|
var _this$_resizeHelperSh2, _this$_columnResizeRe4, _this$_columnResizeRe5;
|
|
15933
15933
|
(_this$_resizeHelperSh2 = this._resizeHelperShape) === null || _this$_resizeHelperSh2 === void 0 || _this$_resizeHelperSh2.transformByState({ left: currentOffsetX + moveChangeX });
|
|
@@ -15937,7 +15937,7 @@ let HeaderResizeRenderController = class HeaderResizeRenderController extends _u
|
|
|
15937
15937
|
}
|
|
15938
15938
|
}
|
|
15939
15939
|
});
|
|
15940
|
-
this._scenePointerUpSub = scene.onPointerUp$.subscribeEvent((
|
|
15940
|
+
this._scenePointerUpSub = scene.onPointerUp$.subscribeEvent(() => {
|
|
15941
15941
|
var _this$_resizeHelperSh3;
|
|
15942
15942
|
const scene = this._context.scene;
|
|
15943
15943
|
this._clearObserverEvent();
|
|
@@ -16287,6 +16287,7 @@ let HeaderUnhideRenderController = class HeaderUnhideRenderController extends _u
|
|
|
16287
16287
|
dispose() {
|
|
16288
16288
|
super.dispose();
|
|
16289
16289
|
this._clearShapes();
|
|
16290
|
+
this.interceptor.dispose();
|
|
16290
16291
|
}
|
|
16291
16292
|
_init() {
|
|
16292
16293
|
let activeSheetId = "";
|
|
@@ -16315,18 +16316,54 @@ let HeaderUnhideRenderController = class HeaderUnhideRenderController extends _u
|
|
|
16315
16316
|
if (!skeleton) return;
|
|
16316
16317
|
const visibleCheck = this.interceptor.fetchThroughInterceptors(HEADER_UNHIDE_RANGE_VISIBLE_CHECK);
|
|
16317
16318
|
const shouldRenderRange = (payload) => this._headerUnhideRangeService.shouldRenderRange(visibleCheck(true, payload) ?? true, payload);
|
|
16318
|
-
const
|
|
16319
|
+
const zeroHeightRowRanges = [];
|
|
16320
|
+
const rowData = worksheet.getRowManager().getRowData();
|
|
16321
|
+
for (const rowIndex of Object.keys(rowData)) {
|
|
16322
|
+
const row = Number(rowIndex);
|
|
16323
|
+
if (row >= 0 && row < worksheet.getRowCount() && worksheet.getRowVisible(row) && worksheet.getRowHeight(row) === 0) zeroHeightRowRanges.push({
|
|
16324
|
+
startRow: row,
|
|
16325
|
+
endRow: row,
|
|
16326
|
+
startColumn: 0,
|
|
16327
|
+
endColumn: worksheet.getColumnCount() - 1
|
|
16328
|
+
});
|
|
16329
|
+
}
|
|
16330
|
+
const rowRanges = [...worksheet.getHiddenRows(), ..._univerjs_core.Rectangle.mergeRanges(zeroHeightRowRanges)].map((range) => ({
|
|
16331
|
+
...range,
|
|
16332
|
+
rangeType: _univerjs_core.RANGE_TYPE.ROW
|
|
16333
|
+
})).filter((range) => shouldRenderRange({
|
|
16319
16334
|
axis: "row",
|
|
16320
16335
|
range,
|
|
16321
16336
|
workbook,
|
|
16322
16337
|
worksheet
|
|
16323
16338
|
}));
|
|
16324
|
-
const
|
|
16339
|
+
const hiddenRowRanges = _univerjs_core.Rectangle.mergeRanges(rowRanges).map((range) => ({
|
|
16340
|
+
...range,
|
|
16341
|
+
rangeType: _univerjs_core.RANGE_TYPE.ROW
|
|
16342
|
+
}));
|
|
16343
|
+
const zeroWidthColRanges = [];
|
|
16344
|
+
const columnData = worksheet.getColumnManager().getColumnData();
|
|
16345
|
+
for (const columnIndex of Object.keys(columnData)) {
|
|
16346
|
+
const column = Number(columnIndex);
|
|
16347
|
+
if (column >= 0 && column < worksheet.getColumnCount() && worksheet.getColVisible(column) && worksheet.getColumnWidth(column) === 0) zeroWidthColRanges.push({
|
|
16348
|
+
startRow: 0,
|
|
16349
|
+
endRow: worksheet.getRowCount() - 1,
|
|
16350
|
+
startColumn: column,
|
|
16351
|
+
endColumn: column
|
|
16352
|
+
});
|
|
16353
|
+
}
|
|
16354
|
+
const columnRanges = [...worksheet.getHiddenCols(), ..._univerjs_core.Rectangle.mergeRanges(zeroWidthColRanges)].map((range) => ({
|
|
16355
|
+
...range,
|
|
16356
|
+
rangeType: _univerjs_core.RANGE_TYPE.COLUMN
|
|
16357
|
+
})).filter((range) => shouldRenderRange({
|
|
16325
16358
|
axis: "column",
|
|
16326
16359
|
range,
|
|
16327
16360
|
workbook,
|
|
16328
16361
|
worksheet
|
|
16329
16362
|
}));
|
|
16363
|
+
const hiddenColRanges = _univerjs_core.Rectangle.mergeRanges(columnRanges).map((range) => ({
|
|
16364
|
+
...range,
|
|
16365
|
+
rangeType: _univerjs_core.RANGE_TYPE.COLUMN
|
|
16366
|
+
}));
|
|
16330
16367
|
const { scene } = this._getSheetObject();
|
|
16331
16368
|
const rowCount = worksheet.getRowCount();
|
|
16332
16369
|
const rowShapes = hiddenRowRanges.map((range) => {
|
|
@@ -18393,11 +18430,7 @@ const MenuItemInput = (props) => {
|
|
|
18393
18430
|
if (compositionEndTimerRef.current !== null) clearTimeout(compositionEndTimerRef.current);
|
|
18394
18431
|
}, []);
|
|
18395
18432
|
const handleChange = (value) => {
|
|
18396
|
-
|
|
18397
|
-
setInputValue(min.toString());
|
|
18398
|
-
return;
|
|
18399
|
-
}
|
|
18400
|
-
const inputValue = value.toString();
|
|
18433
|
+
const inputValue = (value ?? min).toString();
|
|
18401
18434
|
setInputValue(inputValue);
|
|
18402
18435
|
onChange(inputValue);
|
|
18403
18436
|
};
|
|
@@ -19121,7 +19154,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
|
|
|
19121
19154
|
type: _univerjs_ui.MenuItemType.BUTTON_SELECTOR,
|
|
19122
19155
|
selections: [{
|
|
19123
19156
|
label: {
|
|
19124
|
-
name:
|
|
19157
|
+
name: _univerjs_docs_ui.EditorColorPicker.componentKey,
|
|
19125
19158
|
hoverable: false,
|
|
19126
19159
|
selectable: false
|
|
19127
19160
|
},
|
|
@@ -19175,7 +19208,7 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
|
19175
19208
|
icon: "PaintBucketDoubleIcon",
|
|
19176
19209
|
selections: [{
|
|
19177
19210
|
label: {
|
|
19178
|
-
name:
|
|
19211
|
+
name: _univerjs_docs_ui.EditorColorPicker.componentKey,
|
|
19179
19212
|
hoverable: false,
|
|
19180
19213
|
selectable: false
|
|
19181
19214
|
},
|
|
@@ -19783,7 +19816,7 @@ function SetRowHeightMenuItemFactory(accessor) {
|
|
|
19783
19816
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
19784
19817
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
19785
19818
|
const selectionManagerService = accessor.get(_univerjs_sheets.SheetsSelectionsService);
|
|
19786
|
-
const min =
|
|
19819
|
+
const min = 0;
|
|
19787
19820
|
return {
|
|
19788
19821
|
id: _univerjs_sheets.SetRowHeightCommand.id,
|
|
19789
19822
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
@@ -19822,7 +19855,7 @@ function SetColWidthMenuItemFactory(accessor) {
|
|
|
19822
19855
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
19823
19856
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
19824
19857
|
const selectionManagerService = accessor.get(_univerjs_sheets.SheetsSelectionsService);
|
|
19825
|
-
const min =
|
|
19858
|
+
const min = 0;
|
|
19826
19859
|
return {
|
|
19827
19860
|
id: _univerjs_sheets.SetColWidthCommand.id,
|
|
19828
19861
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
@@ -20374,15 +20407,35 @@ function RenameSheetMenuItemFactory(accessor) {
|
|
|
20374
20407
|
};
|
|
20375
20408
|
}
|
|
20376
20409
|
function ChangeColorSheetMenuItemFactory(accessor) {
|
|
20410
|
+
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
20411
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
20377
20412
|
return {
|
|
20378
20413
|
id: _univerjs_sheets.SetTabColorCommand.id,
|
|
20379
20414
|
title: "sheets-ui.sheetConfig.changeColor",
|
|
20380
20415
|
type: _univerjs_ui.MenuItemType.SELECTOR,
|
|
20381
|
-
selections: [{
|
|
20382
|
-
|
|
20383
|
-
|
|
20384
|
-
|
|
20385
|
-
}
|
|
20416
|
+
selections: [{
|
|
20417
|
+
label: "sheets-ui.toolbar.resetColor",
|
|
20418
|
+
icon: "NoColorDoubleIcon",
|
|
20419
|
+
value: ""
|
|
20420
|
+
}, {
|
|
20421
|
+
label: {
|
|
20422
|
+
name: _univerjs_docs_ui.EditorColorPicker.componentKey,
|
|
20423
|
+
hoverable: false,
|
|
20424
|
+
selectable: false
|
|
20425
|
+
},
|
|
20426
|
+
value$: new rxjs.Observable((subscriber) => {
|
|
20427
|
+
const updateColor = () => {
|
|
20428
|
+
var _workbook$getActiveSh;
|
|
20429
|
+
const workbook = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
20430
|
+
subscriber.next((workbook === null || workbook === void 0 || (_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getTabColor()) ?? "");
|
|
20431
|
+
};
|
|
20432
|
+
updateColor();
|
|
20433
|
+
const disposable = commandService.onCommandExecuted(({ id }) => {
|
|
20434
|
+
if (id === _univerjs_sheets.SetTabColorMutation.id || id === _univerjs_sheets.SetWorksheetActiveOperation.id) updateColor();
|
|
20435
|
+
});
|
|
20436
|
+
return () => disposable.dispose();
|
|
20437
|
+
})
|
|
20438
|
+
}],
|
|
20386
20439
|
hidden$: getWorkbookPermissionDisable$(accessor, [_univerjs_sheets.WorkbookEditablePermission])
|
|
20387
20440
|
};
|
|
20388
20441
|
}
|
|
@@ -22816,6 +22869,7 @@ function keepTextSelected(inputHtml) {
|
|
|
22816
22869
|
if (!selection) return;
|
|
22817
22870
|
const range = document.createRange();
|
|
22818
22871
|
range.selectNodeContents(inputHtml);
|
|
22872
|
+
if (!getEditorText(inputHtml)) range.collapse(true);
|
|
22819
22873
|
selection.removeAllRanges();
|
|
22820
22874
|
selection.addRange(range);
|
|
22821
22875
|
});
|
|
@@ -23715,7 +23769,7 @@ function SheetBarTabs() {
|
|
|
23715
23769
|
embedChildType != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmbedSheetTabProductIcon, { childType: embedChildType }),
|
|
23716
23770
|
hasProtection && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LockIcon, { className: "univer-shrink-0" }),
|
|
23717
23771
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
23718
|
-
className: "univer-truncate univer-outline-none",
|
|
23772
|
+
className: "univer-min-w-px univer-truncate univer-outline-none",
|
|
23719
23773
|
children: sheet.getName()
|
|
23720
23774
|
})
|
|
23721
23775
|
] }),
|
|
@@ -25092,7 +25146,7 @@ const useHighlightRange = (ranges = []) => {
|
|
|
25092
25146
|
//#endregion
|
|
25093
25147
|
//#region package.json
|
|
25094
25148
|
var name = "@univerjs/sheets-ui";
|
|
25095
|
-
var version = "1.
|
|
25149
|
+
var version = "1.3.0";
|
|
25096
25150
|
|
|
25097
25151
|
//#endregion
|
|
25098
25152
|
//#region src/views/cell-popup/config.ts
|
|
@@ -28737,7 +28791,7 @@ function SheetPermissionPanelListContent({ ActionRowComponent }) {
|
|
|
28737
28791
|
}).filter((r) => !!r).join(",") : ""})`;
|
|
28738
28792
|
} else if (rule.unitType === _univerjs_protocol.UnitObject.Worksheet) ruleName = targetName || "";
|
|
28739
28793
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
28740
|
-
className: (0, _univerjs_design.clsx)("univer-mt-3 univer-rounded-lg univer-p-3 hover:univer-bg-gray-50", _univerjs_design.borderClassName),
|
|
28794
|
+
className: (0, _univerjs_design.clsx)("univer-mt-3 univer-rounded-lg univer-p-3 hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-800", _univerjs_design.borderClassName),
|
|
28741
28795
|
onMouseMove: () => {
|
|
28742
28796
|
const { subUnitId, unitType } = rule;
|
|
28743
28797
|
const activeSheet = workbook.getActiveSheet();
|
|
@@ -28771,14 +28825,14 @@ function SheetPermissionPanelListContent({ ActionRowComponent }) {
|
|
|
28771
28825
|
children: [hasManagerPermission && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
28772
28826
|
title: localeService.t("sheets-ui.permission.panel.edit"),
|
|
28773
28827
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
28774
|
-
className: "univer-box-border univer-h-6 univer-rounded-sm univer-p-1 hover:univer-bg-gray-200",
|
|
28828
|
+
className: "univer-box-border univer-h-6 univer-rounded-sm univer-p-1 hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-700",
|
|
28775
28829
|
onClick: () => handleEdit(rule),
|
|
28776
28830
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.WriteIcon, {})
|
|
28777
28831
|
})
|
|
28778
28832
|
}), hasDeletePermission && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
28779
28833
|
title: localeService.t("sheets-ui.permission.panel.delete"),
|
|
28780
28834
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
28781
|
-
className: "univer-box-border univer-h-6 univer-rounded-sm univer-p-1 hover:univer-bg-gray-200",
|
|
28835
|
+
className: "univer-box-border univer-h-6 univer-rounded-sm univer-p-1 hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-700",
|
|
28782
28836
|
onClick: () => handleDelete(rule),
|
|
28783
28837
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteIcon, {})
|
|
28784
28838
|
})
|
|
@@ -32136,7 +32190,6 @@ let SheetUIMobileController = class SheetUIMobileController extends _univerjs_co
|
|
|
32136
32190
|
const visualViewport = window.visualViewport;
|
|
32137
32191
|
let stableHeight = Math.round(window.innerHeight);
|
|
32138
32192
|
let stableWidth = Math.round(window.innerWidth);
|
|
32139
|
-
let keyboardWasVisible = false;
|
|
32140
32193
|
const update = () => {
|
|
32141
32194
|
const width = Math.round(window.innerWidth);
|
|
32142
32195
|
const visibleBottom = visualViewport ? visualViewport.offsetTop + visualViewport.height : window.innerHeight;
|
|
@@ -32146,15 +32199,6 @@ let SheetUIMobileController = class SheetUIMobileController extends _univerjs_co
|
|
|
32146
32199
|
} else if (!isMobileKeyboardVisible(stableHeight, visibleBottom)) stableHeight = Math.round(Math.max(stableHeight, window.innerHeight, visibleBottom));
|
|
32147
32200
|
const keyboardVisible = isMobileKeyboardVisible(stableHeight, visibleBottom);
|
|
32148
32201
|
this._contextService.setContextValue(MOBILE_KEYBOARD_VISIBLE, keyboardVisible);
|
|
32149
|
-
if (shouldHideMobileEditorOnKeyboardClose(keyboardWasVisible && !keyboardVisible, this._contextService.getContextValue("MOBILE_FX_EDITOR_EXPANDED"), this._contextService.getContextValue("MOBILE_FORMULA_FUNCTION_PANEL_OPEN"), this._editorBridgeService.isForceKeepVisible())) {
|
|
32150
|
-
const visibleState = this._editorBridgeService.isVisible();
|
|
32151
|
-
if (visibleState.visible) this._commandService.executeCommand(SetCellEditVisibleOperation.id, {
|
|
32152
|
-
...visibleState,
|
|
32153
|
-
visible: false,
|
|
32154
|
-
eventType: _univerjs_engine_render.DeviceInputEventType.PointerDown
|
|
32155
|
-
});
|
|
32156
|
-
}
|
|
32157
|
-
keyboardWasVisible = keyboardVisible;
|
|
32158
32202
|
};
|
|
32159
32203
|
update();
|
|
32160
32204
|
window.addEventListener("resize", update);
|
|
@@ -32211,9 +32255,6 @@ SheetUIMobileController = __decorate([
|
|
|
32211
32255
|
function isMobileKeyboardVisible(stableHeight, visibleBottom) {
|
|
32212
32256
|
return stableHeight - visibleBottom > 80;
|
|
32213
32257
|
}
|
|
32214
|
-
function shouldHideMobileEditorOnKeyboardClose(keyboardClosed, editorExpanded, functionPanelOpen, forceKeepVisible) {
|
|
32215
|
-
return keyboardClosed && !editorExpanded && !functionPanelOpen && !forceKeepVisible;
|
|
32216
|
-
}
|
|
32217
32258
|
|
|
32218
32259
|
//#endregion
|
|
32219
32260
|
//#region src/controllers/move-range.controller.ts
|
|
@@ -32837,7 +32878,7 @@ let FormatPainterRenderController = class FormatPainterRenderController extends
|
|
|
32837
32878
|
getTarget: (event) => {
|
|
32838
32879
|
var _this$_selections$get, _this$_context$unit$g;
|
|
32839
32880
|
const picked = this._context.scene.pick(new _univerjs_engine_render.Vector2(event.offsetX, event.offsetY));
|
|
32840
|
-
if (picked && picked !== this._context.mainComponent) return null;
|
|
32881
|
+
if (picked && picked !== this._context.mainComponent && picked !== this._context.components.get("__SpreadsheetRowHeader__") && picked !== this._context.components.get("__SpreadsheetColumnHeader__")) return null;
|
|
32841
32882
|
const range = (_this$_selections$get = this._selections.getCurrentLastSelection()) === null || _this$_selections$get === void 0 ? void 0 : _this$_selections$get.range;
|
|
32842
32883
|
return range ? {
|
|
32843
32884
|
unitId: this._context.unitId,
|
|
@@ -33164,27 +33205,22 @@ let MobileHeaderResizeRenderController = class MobileHeaderResizeRenderControlle
|
|
|
33164
33205
|
_defineProperty(this, "_columnResizeButton", void 0);
|
|
33165
33206
|
_defineProperty(this, "_resizeHelperShape", void 0);
|
|
33166
33207
|
_defineProperty(this, "_isDragging", false);
|
|
33167
|
-
_defineProperty(this, "
|
|
33168
|
-
_defineProperty(this, "_touchStartY", 0);
|
|
33169
|
-
_defineProperty(this, "_touchMoveHandler", void 0);
|
|
33170
|
-
_defineProperty(this, "_touchEndHandler", void 0);
|
|
33208
|
+
_defineProperty(this, "_resizeListeners", void 0);
|
|
33171
33209
|
_defineProperty(this, "_selectionSubscription", void 0);
|
|
33172
33210
|
_defineProperty(this, "_scrollSubscription", void 0);
|
|
33173
33211
|
this._init();
|
|
33174
33212
|
}
|
|
33175
33213
|
dispose() {
|
|
33176
|
-
var _this$_rowResizeButto, _this$_columnResizeBu, _this$
|
|
33214
|
+
var _this$_rowResizeButto, _this$_columnResizeBu, _this$_selectionSubsc, _this$_scrollSubscrip;
|
|
33215
|
+
this._cancelResize();
|
|
33177
33216
|
(_this$_rowResizeButto = this._rowResizeButton) === null || _this$_rowResizeButto === void 0 || _this$_rowResizeButto.dispose();
|
|
33178
33217
|
this._rowResizeButton = null;
|
|
33179
33218
|
(_this$_columnResizeBu = this._columnResizeButton) === null || _this$_columnResizeBu === void 0 || _this$_columnResizeBu.dispose();
|
|
33180
33219
|
this._columnResizeButton = null;
|
|
33181
|
-
(_this$_resizeHelperSh = this._resizeHelperShape) === null || _this$_resizeHelperSh === void 0 || _this$_resizeHelperSh.dispose();
|
|
33182
|
-
this._resizeHelperShape = null;
|
|
33183
33220
|
(_this$_selectionSubsc = this._selectionSubscription) === null || _this$_selectionSubsc === void 0 || _this$_selectionSubsc.unsubscribe();
|
|
33184
33221
|
this._selectionSubscription = null;
|
|
33185
33222
|
(_this$_scrollSubscrip = this._scrollSubscription) === null || _this$_scrollSubscrip === void 0 || _this$_scrollSubscrip.unsubscribe();
|
|
33186
33223
|
this._scrollSubscription = null;
|
|
33187
|
-
this._cleanupTouchHandlers();
|
|
33188
33224
|
super.dispose();
|
|
33189
33225
|
}
|
|
33190
33226
|
_init() {
|
|
@@ -33205,8 +33241,8 @@ let MobileHeaderResizeRenderController = class MobileHeaderResizeRenderControlle
|
|
|
33205
33241
|
zIndex: 100
|
|
33206
33242
|
});
|
|
33207
33243
|
scene.addObjects([this._rowResizeButton, this._columnResizeButton], 10);
|
|
33208
|
-
this.
|
|
33209
|
-
this.
|
|
33244
|
+
this._bindPointerEventsToButton(this._rowResizeButton, "row");
|
|
33245
|
+
this._bindPointerEventsToButton(this._columnResizeButton, "column");
|
|
33210
33246
|
}
|
|
33211
33247
|
_initSelectionListener() {
|
|
33212
33248
|
this._selectionSubscription = this._selectionManagerService.selectionMoveEnd$.subscribe((selections) => {
|
|
@@ -33291,12 +33327,13 @@ let MobileHeaderResizeRenderController = class MobileHeaderResizeRenderControlle
|
|
|
33291
33327
|
});
|
|
33292
33328
|
}
|
|
33293
33329
|
}
|
|
33294
|
-
|
|
33295
|
-
button.onPointerDown$.subscribeEvent((evt) => {
|
|
33330
|
+
_bindPointerEventsToButton(button, type) {
|
|
33331
|
+
this.disposeWithMe(button.onPointerDown$.subscribeEvent((evt) => {
|
|
33332
|
+
if (evt.button !== 0) return;
|
|
33296
33333
|
if (this._contextService.getContextValue("MOBILE_PINCH_ZOOMING")) return;
|
|
33297
33334
|
if (this._contextService.getContextValue("MOBILE_EXPANDING_SELECTION")) return;
|
|
33298
33335
|
this._startResize(evt, type);
|
|
33299
|
-
});
|
|
33336
|
+
}));
|
|
33300
33337
|
}
|
|
33301
33338
|
_startResize(evt, type) {
|
|
33302
33339
|
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
@@ -33305,69 +33342,80 @@ let MobileHeaderResizeRenderController = class MobileHeaderResizeRenderControlle
|
|
|
33305
33342
|
const engine = scene.getEngine();
|
|
33306
33343
|
const canvasElement = engine === null || engine === void 0 ? void 0 : engine.getCanvasElement();
|
|
33307
33344
|
if (!canvasElement) return;
|
|
33308
|
-
this.
|
|
33309
|
-
this._touchStartY = evt.offsetY;
|
|
33310
|
-
this._isDragging = false;
|
|
33345
|
+
this._cancelResize();
|
|
33311
33346
|
const currentOffset = type === "row" ? skeleton.getOffsetByRow(this._currentRow) : skeleton.getOffsetByColumn(this._currentColumn);
|
|
33312
33347
|
this._createResizeHelper(type, currentOffset, skeleton);
|
|
33313
33348
|
scene.disableObjectsEvent();
|
|
33314
|
-
this.
|
|
33349
|
+
this._setupPointerHandlers(canvasElement, evt, type, currentOffset);
|
|
33315
33350
|
}
|
|
33316
|
-
|
|
33317
|
-
if (!this._sheetSkeletonManagerService.getCurrentSkeleton()) return;
|
|
33318
|
-
const scene = this._context.scene;
|
|
33351
|
+
_setupPointerHandlers(canvasElement, evt, type, initialOffset) {
|
|
33319
33352
|
const worksheet = this._context.unit.getActiveSheet();
|
|
33320
|
-
|
|
33353
|
+
if (!worksheet) {
|
|
33354
|
+
this._cancelResize();
|
|
33355
|
+
return;
|
|
33356
|
+
}
|
|
33357
|
+
const zoomRatio = worksheet.getZoomRatio() || 1;
|
|
33358
|
+
const initialSize = type === "row" ? worksheet.getRowHeight(this._currentRow) : worksheet.getColumnWidth(this._currentColumn);
|
|
33359
|
+
const anchor = type === "row" ? this._currentRow : this._currentColumn;
|
|
33360
|
+
const pointerId = "pointerId" in evt ? evt.pointerId : 0;
|
|
33361
|
+
const startX = evt.offsetX;
|
|
33362
|
+
const startY = evt.offsetY;
|
|
33321
33363
|
let totalDelta = 0;
|
|
33322
|
-
|
|
33364
|
+
const handlePointerMove = (e) => {
|
|
33365
|
+
if (e.pointerId !== pointerId) return;
|
|
33323
33366
|
if (this._contextService.getContextValue("MOBILE_PINCH_ZOOMING")) {
|
|
33324
33367
|
this._cancelResize();
|
|
33325
33368
|
return;
|
|
33326
33369
|
}
|
|
33327
|
-
if (e.touches.length !== 1) return;
|
|
33328
|
-
const touch = e.touches[0];
|
|
33329
33370
|
const rect = canvasElement.getBoundingClientRect();
|
|
33330
|
-
const offsetX =
|
|
33331
|
-
const offsetY =
|
|
33332
|
-
const adjustedDelta = (type === "row" ? offsetY -
|
|
33371
|
+
const offsetX = e.clientX - rect.left;
|
|
33372
|
+
const offsetY = e.clientY - rect.top;
|
|
33373
|
+
const adjustedDelta = (type === "row" ? offsetY - startY : offsetX - startX) / zoomRatio;
|
|
33333
33374
|
if (Math.abs(adjustedDelta) >= MINIMAL_OFFSET) this._isDragging = true;
|
|
33334
33375
|
if (this._isDragging) {
|
|
33335
|
-
totalDelta = adjustedDelta;
|
|
33336
|
-
this._updateResizeHelper(type, initialOffset +
|
|
33337
|
-
this._updateResizeButton(type, initialOffset +
|
|
33376
|
+
totalDelta = Math.max(adjustedDelta, -initialSize);
|
|
33377
|
+
this._updateResizeHelper(type, initialOffset + totalDelta);
|
|
33378
|
+
this._updateResizeButton(type, initialOffset + totalDelta);
|
|
33338
33379
|
}
|
|
33339
33380
|
e.preventDefault();
|
|
33340
33381
|
};
|
|
33341
|
-
|
|
33342
|
-
|
|
33343
|
-
|
|
33344
|
-
if (type === "row") this._commandService.executeCommand(_univerjs_sheets.DeltaRowHeightCommand.id, {
|
|
33345
|
-
deltaY: totalDelta,
|
|
33346
|
-
anchorRow: this._currentRow
|
|
33347
|
-
});
|
|
33348
|
-
else this._commandService.executeCommand(_univerjs_sheets.DeltaColumnWidthCommand.id, {
|
|
33349
|
-
deltaX: totalDelta,
|
|
33350
|
-
anchorCol: this._currentColumn
|
|
33351
|
-
});
|
|
33352
|
-
}
|
|
33382
|
+
const handlePointerUp = async (e) => {
|
|
33383
|
+
if (e.pointerId !== pointerId) return;
|
|
33384
|
+
const shouldResize = this._isDragging && totalDelta !== 0;
|
|
33353
33385
|
this._cleanupResize();
|
|
33354
|
-
if (this._touchMoveHandler) canvasElement.removeEventListener("touchmove", this._touchMoveHandler);
|
|
33355
|
-
if (this._touchEndHandler) {
|
|
33356
|
-
canvasElement.removeEventListener("touchend", this._touchEndHandler);
|
|
33357
|
-
canvasElement.removeEventListener("touchcancel", this._touchEndHandler);
|
|
33358
|
-
}
|
|
33359
33386
|
e.preventDefault();
|
|
33387
|
+
if (shouldResize) await this._commandService.executeCommand(type === "row" ? _univerjs_sheets.DeltaRowHeightCommand.id : _univerjs_sheets.DeltaColumnWidthCommand.id, type === "row" ? {
|
|
33388
|
+
deltaY: totalDelta,
|
|
33389
|
+
anchorRow: anchor
|
|
33390
|
+
} : {
|
|
33391
|
+
deltaX: totalDelta,
|
|
33392
|
+
anchorCol: anchor
|
|
33393
|
+
});
|
|
33360
33394
|
};
|
|
33361
|
-
|
|
33362
|
-
|
|
33363
|
-
|
|
33364
|
-
|
|
33365
|
-
|
|
33366
|
-
|
|
33367
|
-
|
|
33368
|
-
|
|
33369
|
-
|
|
33370
|
-
|
|
33395
|
+
this._bindResizeListeners(canvasElement, pointerId, handlePointerMove, handlePointerUp);
|
|
33396
|
+
}
|
|
33397
|
+
_bindResizeListeners(canvasElement, pointerId, handlePointerMove, handlePointerUp) {
|
|
33398
|
+
const ownerDocument = canvasElement.ownerDocument;
|
|
33399
|
+
const ownerWindow = ownerDocument.defaultView;
|
|
33400
|
+
const handlePointerCancel = (e) => {
|
|
33401
|
+
if (e.pointerId === pointerId) this._cancelResize();
|
|
33402
|
+
};
|
|
33403
|
+
const handlePointerDown = (e) => {
|
|
33404
|
+
if (e.pointerId !== pointerId) this._cancelResize();
|
|
33405
|
+
};
|
|
33406
|
+
const handleBlur = () => this._cancelResize();
|
|
33407
|
+
ownerDocument.addEventListener("pointermove", handlePointerMove, { passive: false });
|
|
33408
|
+
ownerDocument.addEventListener("pointerup", handlePointerUp);
|
|
33409
|
+
ownerDocument.addEventListener("pointercancel", handlePointerCancel);
|
|
33410
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown);
|
|
33411
|
+
ownerWindow === null || ownerWindow === void 0 || ownerWindow.addEventListener("blur", handleBlur);
|
|
33412
|
+
this._resizeListeners = (0, _univerjs_core.toDisposable)(() => {
|
|
33413
|
+
ownerDocument.removeEventListener("pointermove", handlePointerMove);
|
|
33414
|
+
ownerDocument.removeEventListener("pointerup", handlePointerUp);
|
|
33415
|
+
ownerDocument.removeEventListener("pointercancel", handlePointerCancel);
|
|
33416
|
+
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
|
|
33417
|
+
ownerWindow === null || ownerWindow === void 0 || ownerWindow.removeEventListener("blur", handleBlur);
|
|
33418
|
+
});
|
|
33371
33419
|
}
|
|
33372
33420
|
_createResizeHelper(type, offset, skeleton) {
|
|
33373
33421
|
const scene = this._context.scene;
|
|
@@ -33408,30 +33456,18 @@ let MobileHeaderResizeRenderController = class MobileHeaderResizeRenderControlle
|
|
|
33408
33456
|
else button.transformByState({ left: newOffset - buttonSize / 2 });
|
|
33409
33457
|
}
|
|
33410
33458
|
_cleanupResize() {
|
|
33411
|
-
var _this$
|
|
33412
|
-
(_this$
|
|
33459
|
+
var _this$_resizeListener, _this$_resizeHelperSh;
|
|
33460
|
+
(_this$_resizeListener = this._resizeListeners) === null || _this$_resizeListener === void 0 || _this$_resizeListener.dispose();
|
|
33461
|
+
this._resizeListeners = null;
|
|
33462
|
+
this._context.scene.enableObjectsEvent();
|
|
33463
|
+
(_this$_resizeHelperSh = this._resizeHelperShape) === null || _this$_resizeHelperSh === void 0 || _this$_resizeHelperSh.dispose();
|
|
33413
33464
|
this._resizeHelperShape = null;
|
|
33414
33465
|
this._isDragging = false;
|
|
33415
33466
|
}
|
|
33416
|
-
_cleanupTouchHandlers() {
|
|
33417
|
-
const engine = this._context.scene.getEngine();
|
|
33418
|
-
const canvasElement = engine === null || engine === void 0 ? void 0 : engine.getCanvasElement();
|
|
33419
|
-
if (canvasElement) {
|
|
33420
|
-
if (this._touchMoveHandler) {
|
|
33421
|
-
canvasElement.removeEventListener("touchmove", this._touchMoveHandler);
|
|
33422
|
-
this._touchMoveHandler = null;
|
|
33423
|
-
}
|
|
33424
|
-
if (this._touchEndHandler) {
|
|
33425
|
-
canvasElement.removeEventListener("touchend", this._touchEndHandler);
|
|
33426
|
-
canvasElement.removeEventListener("touchcancel", this._touchEndHandler);
|
|
33427
|
-
this._touchEndHandler = null;
|
|
33428
|
-
}
|
|
33429
|
-
}
|
|
33430
|
-
}
|
|
33431
33467
|
_cancelResize() {
|
|
33432
|
-
this.
|
|
33468
|
+
if (!this._resizeHelperShape && !this._resizeListeners) return;
|
|
33433
33469
|
this._cleanupResize();
|
|
33434
|
-
this.
|
|
33470
|
+
this._updateButtonPositionOnScroll();
|
|
33435
33471
|
}
|
|
33436
33472
|
};
|
|
33437
33473
|
MobileHeaderResizeRenderController = __decorate([
|
|
@@ -33445,6 +33481,7 @@ MobileHeaderResizeRenderController = __decorate([
|
|
|
33445
33481
|
//#endregion
|
|
33446
33482
|
//#region src/controllers/render-controllers/mobile/mobile-hover.render-controller.ts
|
|
33447
33483
|
const TAP_MOVE_THRESHOLD = 10;
|
|
33484
|
+
const DOUBLE_TAP_MOVE_THRESHOLD = 20;
|
|
33448
33485
|
const DOUBLE_TAP_DELAY = 500;
|
|
33449
33486
|
function getPointerId(event) {
|
|
33450
33487
|
return "pointerId" in event ? event.pointerId : void 0;
|
|
@@ -33520,6 +33557,7 @@ let MobileHoverRenderController = class MobileHoverRenderController extends _uni
|
|
|
33520
33557
|
next: ([event, state]) => {
|
|
33521
33558
|
state.stopPropagation();
|
|
33522
33559
|
state.skipNextObservers = true;
|
|
33560
|
+
if (event.deviceType === _univerjs_engine_render.DeviceType.Touch) return;
|
|
33523
33561
|
if (this._suppressEngineDoubleClick) {
|
|
33524
33562
|
this._clearEngineDoubleClickSuppression();
|
|
33525
33563
|
return;
|
|
@@ -33570,15 +33608,15 @@ let MobileHoverRenderController = class MobileHoverRenderController extends _uni
|
|
|
33570
33608
|
return;
|
|
33571
33609
|
}
|
|
33572
33610
|
this._tapState = {
|
|
33573
|
-
|
|
33574
|
-
|
|
33611
|
+
clientX: event.clientX,
|
|
33612
|
+
clientY: event.clientY,
|
|
33575
33613
|
pointerId: getPointerId(event)
|
|
33576
33614
|
};
|
|
33577
33615
|
}
|
|
33578
33616
|
_updateTapState(event) {
|
|
33579
33617
|
const pointerId = getPointerId(event);
|
|
33580
33618
|
if (!this._tapState || pointerId != null && pointerId !== this._tapState.pointerId) return;
|
|
33581
|
-
if (Math.abs(event.
|
|
33619
|
+
if (Math.abs(event.clientX - this._tapState.clientX) > TAP_MOVE_THRESHOLD || Math.abs(event.clientY - this._tapState.clientY) > TAP_MOVE_THRESHOLD) this._resetTapSequence();
|
|
33582
33620
|
}
|
|
33583
33621
|
_finishTap(event) {
|
|
33584
33622
|
const tapState = this._tapState;
|
|
@@ -33588,14 +33626,28 @@ let MobileHoverRenderController = class MobileHoverRenderController extends _uni
|
|
|
33588
33626
|
this._resetCompletedTap();
|
|
33589
33627
|
return false;
|
|
33590
33628
|
}
|
|
33591
|
-
const completed = Math.abs(event.
|
|
33629
|
+
const completed = Math.abs(event.clientX - tapState.clientX) <= TAP_MOVE_THRESHOLD && Math.abs(event.clientY - tapState.clientY) <= TAP_MOVE_THRESHOLD && !this._contextService.getContextValue("MOBILE_PINCH_ZOOMING") && !this._contextService.getContextValue("MOBILE_EXPANDING_SELECTION") && !this._contextService.getContextValue("MOBILE_TRIGGER_CONTEXT_MENU");
|
|
33592
33630
|
if (!completed) this._resetCompletedTap();
|
|
33593
33631
|
return completed;
|
|
33594
33632
|
}
|
|
33595
33633
|
_completeTap(unitId, event) {
|
|
33634
|
+
const skeletonParam = this._sheetSkeletonManagerService.getCurrentParam();
|
|
33635
|
+
const cellIndex = skeletonParam && getCellIndexByOffsetWithMerge(event.offsetX, event.offsetY, this._context.scene, skeletonParam.skeleton);
|
|
33636
|
+
if (!cellIndex || !skeletonParam) {
|
|
33637
|
+
this._resetCompletedTap();
|
|
33638
|
+
return;
|
|
33639
|
+
}
|
|
33640
|
+
const cell = {
|
|
33641
|
+
unitId,
|
|
33642
|
+
subUnitId: skeletonParam.sheetId,
|
|
33643
|
+
row: cellIndex.actualRow,
|
|
33644
|
+
col: cellIndex.actualCol
|
|
33645
|
+
};
|
|
33646
|
+
const timeStamp = Number.isFinite(event.timeStamp) ? event.timeStamp : performance.now();
|
|
33596
33647
|
const lastCompletedTap = this._lastCompletedTap;
|
|
33597
|
-
if (lastCompletedTap && Math.abs(event.
|
|
33648
|
+
if (lastCompletedTap && timeStamp >= lastCompletedTap.timeStamp && timeStamp - lastCompletedTap.timeStamp <= DOUBLE_TAP_DELAY && cell.unitId === lastCompletedTap.cell.unitId && cell.subUnitId === lastCompletedTap.cell.subUnitId && cell.row === lastCompletedTap.cell.row && cell.col === lastCompletedTap.cell.col && Math.abs(event.clientX - lastCompletedTap.clientX) <= DOUBLE_TAP_MOVE_THRESHOLD && Math.abs(event.clientY - lastCompletedTap.clientY) <= DOUBLE_TAP_MOVE_THRESHOLD) {
|
|
33598
33649
|
this._resetCompletedTap();
|
|
33650
|
+
this._clearEngineDoubleClickSuppression();
|
|
33599
33651
|
this._suppressEngineDoubleClick = true;
|
|
33600
33652
|
this._suppressEngineDoubleClickTimer = setTimeout(() => {
|
|
33601
33653
|
this._suppressEngineDoubleClick = false;
|
|
@@ -33606,9 +33658,10 @@ let MobileHoverRenderController = class MobileHoverRenderController extends _uni
|
|
|
33606
33658
|
}
|
|
33607
33659
|
this._resetCompletedTap();
|
|
33608
33660
|
this._lastCompletedTap = {
|
|
33609
|
-
|
|
33610
|
-
|
|
33611
|
-
|
|
33661
|
+
clientX: event.clientX,
|
|
33662
|
+
clientY: event.clientY,
|
|
33663
|
+
timeStamp,
|
|
33664
|
+
cell
|
|
33612
33665
|
};
|
|
33613
33666
|
this._completedTapTimer = setTimeout(() => this._resetCompletedTap(), DOUBLE_TAP_DELAY);
|
|
33614
33667
|
}
|
|
@@ -35441,7 +35494,7 @@ _defineProperty(UniverSheetsMobileUIPlugin, "packageName", name);
|
|
|
35441
35494
|
_defineProperty(UniverSheetsMobileUIPlugin, "version", version);
|
|
35442
35495
|
_defineProperty(UniverSheetsMobileUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
35443
35496
|
UniverSheetsMobileUIPlugin = __decorate([
|
|
35444
|
-
(0, _univerjs_core.DependentOn)(_univerjs_docs.UniverDocsPlugin, _univerjs_engine_formula.UniverFormulaEnginePlugin, _univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_ui.UniverMobileUIPlugin, _univerjs_docs_ui.
|
|
35497
|
+
(0, _univerjs_core.DependentOn)(_univerjs_docs.UniverDocsPlugin, _univerjs_engine_formula.UniverFormulaEnginePlugin, _univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_ui.UniverMobileUIPlugin, _univerjs_docs_ui.UniverDocsMobileUIPlugin),
|
|
35445
35498
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
35446
35499
|
__decorateParam(2, _univerjs_engine_render.IRenderManagerService),
|
|
35447
35500
|
__decorateParam(3, _univerjs_core.IConfigService),
|