@univerjs/sheets-ui 1.0.0-beta.0 → 1.0.0-beta.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/lib/cjs/facade.js +5 -5
- package/lib/cjs/index.js +1441 -1525
- package/lib/cjs/locale/ar-SA.js +14 -133
- package/lib/cjs/locale/ca-ES.js +14 -133
- package/lib/cjs/locale/de-DE.js +14 -133
- package/lib/cjs/locale/en-US.js +14 -133
- package/lib/cjs/locale/es-ES.js +14 -133
- package/lib/cjs/locale/fa-IR.js +14 -133
- package/lib/cjs/locale/fr-FR.js +14 -133
- package/lib/cjs/locale/id-ID.js +14 -133
- package/lib/cjs/locale/it-IT.js +14 -133
- package/lib/cjs/locale/ja-JP.js +14 -133
- package/lib/cjs/locale/ko-KR.js +14 -133
- package/lib/cjs/locale/pl-PL.js +14 -133
- package/lib/cjs/locale/pt-BR.js +14 -133
- package/lib/cjs/locale/ru-RU.js +14 -133
- package/lib/cjs/locale/sk-SK.js +14 -133
- package/lib/cjs/locale/vi-VN.js +14 -133
- package/lib/cjs/locale/zh-CN.js +14 -133
- package/lib/cjs/locale/zh-HK.js +14 -133
- package/lib/cjs/locale/zh-TW.js +14 -133
- package/lib/es/facade.js +6 -6
- package/lib/es/index.js +1446 -1531
- package/lib/es/locale/ar-SA.js +14 -133
- package/lib/es/locale/ca-ES.js +14 -133
- package/lib/es/locale/de-DE.js +14 -133
- package/lib/es/locale/en-US.js +14 -133
- package/lib/es/locale/es-ES.js +14 -133
- package/lib/es/locale/fa-IR.js +14 -133
- package/lib/es/locale/fr-FR.js +14 -133
- package/lib/es/locale/id-ID.js +14 -133
- package/lib/es/locale/it-IT.js +14 -133
- package/lib/es/locale/ja-JP.js +14 -133
- package/lib/es/locale/ko-KR.js +14 -133
- package/lib/es/locale/pl-PL.js +14 -133
- package/lib/es/locale/pt-BR.js +14 -133
- package/lib/es/locale/ru-RU.js +14 -133
- package/lib/es/locale/sk-SK.js +14 -133
- package/lib/es/locale/vi-VN.js +14 -133
- package/lib/es/locale/zh-CN.js +14 -133
- package/lib/es/locale/zh-HK.js +14 -133
- package/lib/es/locale/zh-TW.js +14 -133
- package/lib/facade.js +6 -6
- package/lib/index.css +54 -87
- package/lib/index.js +1446 -1531
- package/lib/locale/ar-SA.js +14 -133
- package/lib/locale/ca-ES.js +14 -133
- package/lib/locale/de-DE.js +14 -133
- package/lib/locale/en-US.js +14 -133
- package/lib/locale/es-ES.js +14 -133
- package/lib/locale/fa-IR.js +14 -133
- package/lib/locale/fr-FR.js +14 -133
- package/lib/locale/id-ID.js +14 -133
- package/lib/locale/it-IT.js +14 -133
- package/lib/locale/ja-JP.js +14 -133
- package/lib/locale/ko-KR.js +14 -133
- package/lib/locale/pl-PL.js +14 -133
- package/lib/locale/pt-BR.js +14 -133
- package/lib/locale/ru-RU.js +14 -133
- package/lib/locale/sk-SK.js +14 -133
- package/lib/locale/vi-VN.js +14 -133
- package/lib/locale/zh-CN.js +14 -133
- package/lib/locale/zh-HK.js +14 -133
- package/lib/locale/zh-TW.js +14 -133
- package/lib/types/controllers/editor/data-sync.controller.d.ts +4 -2
- package/lib/types/controllers/force-string-alert-render.controller.d.ts +9 -4
- package/lib/types/controllers/render-controllers/scroll.render-controller.d.ts +6 -0
- package/lib/types/controllers/utils/range-tools.d.ts +2 -0
- package/lib/types/embed-tab-anchor.d.ts +2 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/en-US.d.ts +1 -106
- package/lib/types/menu/header-menu-shape.d.ts +3 -3
- package/lib/types/services/cell-alert-manager.service.d.ts +6 -0
- package/lib/types/services/cell-popup-manager.service.d.ts +6 -7
- package/lib/types/services/sheet-embed-runtime.service.d.ts +2 -1
- package/lib/types/views/CellPopup.d.ts +2 -1
- package/lib/types/views/hook.d.ts +0 -4
- package/lib/types/views/status-bar/CopyableStatisticItem.d.ts +0 -2
- package/lib/types/views/status-bar/StatusBar.d.ts +1 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +14 -11
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +13 -13
- package/lib/types/services/sheet-loading-render.service.d.ts +0 -65
package/lib/cjs/index.js
CHANGED
|
@@ -10,9 +10,9 @@ let _univerjs_protocol = require("@univerjs/protocol");
|
|
|
10
10
|
let _univerjs_design = require("@univerjs/design");
|
|
11
11
|
let _univerjs_icons = require("@univerjs/icons");
|
|
12
12
|
let react = require("react");
|
|
13
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
14
|
let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
14
15
|
let _univerjs_telemetry = require("@univerjs/telemetry");
|
|
15
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
16
16
|
let rxjs_operators = require("rxjs/operators");
|
|
17
17
|
|
|
18
18
|
//#region src/basics/editor/get-editor-object.ts
|
|
@@ -93,6 +93,40 @@ function whenEditorDidNotInputFormulaActivated(contextService) {
|
|
|
93
93
|
|
|
94
94
|
//#endregion
|
|
95
95
|
//#region src/controllers/utils/range-tools.ts
|
|
96
|
+
function groupConsecutive(values, start, end) {
|
|
97
|
+
const groups = [];
|
|
98
|
+
for (let index = start; index <= end; index++) {
|
|
99
|
+
const value = values[index];
|
|
100
|
+
const previous = groups[groups.length - 1];
|
|
101
|
+
if (previous && value === previous.end + 1) previous.end = value;
|
|
102
|
+
else groups.push({
|
|
103
|
+
start: value,
|
|
104
|
+
end: value
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return groups;
|
|
108
|
+
}
|
|
109
|
+
function projectLine(values, start, end) {
|
|
110
|
+
let low = 0;
|
|
111
|
+
let high = values.length;
|
|
112
|
+
while (low < high) {
|
|
113
|
+
const middle = Math.floor((low + high) / 2);
|
|
114
|
+
if (values[middle] < start) low = middle + 1;
|
|
115
|
+
else high = middle;
|
|
116
|
+
}
|
|
117
|
+
const first = low;
|
|
118
|
+
if (first === values.length || values[first] > end) return null;
|
|
119
|
+
high = values.length;
|
|
120
|
+
while (low < high) {
|
|
121
|
+
const middle = Math.floor((low + high) / 2);
|
|
122
|
+
if (values[middle] <= end) low = middle + 1;
|
|
123
|
+
else high = middle;
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
start: first,
|
|
127
|
+
end: low - 1
|
|
128
|
+
};
|
|
129
|
+
}
|
|
96
130
|
function virtualizeDiscreteRanges(ranges) {
|
|
97
131
|
let totalRows = [];
|
|
98
132
|
let totalCols = [];
|
|
@@ -116,7 +150,27 @@ function virtualizeDiscreteRanges(ranges) {
|
|
|
116
150
|
mapFunc: (row, col) => ({
|
|
117
151
|
row: totalRows[row],
|
|
118
152
|
col: totalCols[col]
|
|
119
|
-
})
|
|
153
|
+
}),
|
|
154
|
+
mapRange: (range) => {
|
|
155
|
+
const rowGroups = groupConsecutive(totalRows, range.startRow, range.endRow);
|
|
156
|
+
const columnGroups = groupConsecutive(totalCols, range.startColumn, range.endColumn);
|
|
157
|
+
return rowGroups.flatMap((row) => columnGroups.map((column) => ({
|
|
158
|
+
startRow: row.start,
|
|
159
|
+
endRow: row.end,
|
|
160
|
+
startColumn: column.start,
|
|
161
|
+
endColumn: column.end
|
|
162
|
+
})));
|
|
163
|
+
},
|
|
164
|
+
projectRange: (range) => {
|
|
165
|
+
const row = projectLine(totalRows, range.startRow, range.endRow);
|
|
166
|
+
const column = projectLine(totalCols, range.startColumn, range.endColumn);
|
|
167
|
+
return row && column ? {
|
|
168
|
+
startRow: row.start,
|
|
169
|
+
endRow: row.end,
|
|
170
|
+
startColumn: column.start,
|
|
171
|
+
endColumn: column.end
|
|
172
|
+
} : null;
|
|
173
|
+
}
|
|
120
174
|
};
|
|
121
175
|
}
|
|
122
176
|
|
|
@@ -131,7 +185,7 @@ let SELECTION_SHAPE_DEPTH = /* @__PURE__ */ function(SELECTION_SHAPE_DEPTH) {
|
|
|
131
185
|
}({});
|
|
132
186
|
function genNormalSelectionStyle(themeService) {
|
|
133
187
|
const primaryColor = themeService.getColorFromTheme("primary.600");
|
|
134
|
-
const
|
|
188
|
+
const gray0Color = themeService.getColorFromTheme("gray.0");
|
|
135
189
|
const fill = new _univerjs_core.ColorKit(primaryColor).setAlpha(.07).toRgbString();
|
|
136
190
|
return {
|
|
137
191
|
strokeWidth: 1,
|
|
@@ -140,10 +194,10 @@ function genNormalSelectionStyle(themeService) {
|
|
|
140
194
|
widgets: {},
|
|
141
195
|
widgetSize: 6,
|
|
142
196
|
widgetStrokeWidth: 1,
|
|
143
|
-
widgetStroke:
|
|
197
|
+
widgetStroke: gray0Color,
|
|
144
198
|
autofillSize: 6,
|
|
145
199
|
autofillStrokeWidth: 1,
|
|
146
|
-
autofillStroke:
|
|
200
|
+
autofillStroke: gray0Color,
|
|
147
201
|
rowHeaderFill: fill,
|
|
148
202
|
rowHeaderStroke: primaryColor,
|
|
149
203
|
rowHeaderStrokeWidth: 1,
|
|
@@ -4010,6 +4064,10 @@ const IMAGE_MIME_TO_EXTENSION = {
|
|
|
4010
4064
|
[_univerjs_ui.FILE__BMP_CLIPBOARD_MIME_TYPE]: "bmp"
|
|
4011
4065
|
};
|
|
4012
4066
|
const FORMULA_CLIPBOARD_MIME_TYPE = "web application/x-univer-sheets-formula";
|
|
4067
|
+
function wrapHtmlForExcel(html) {
|
|
4068
|
+
var _html$match;
|
|
4069
|
+
return `<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Excel.Sheet"><meta name="Generator" content="Univer"></head><body><!--StartFragment-->${((_html$match = html.match(/<table[\s\S]*<\/table>/)) === null || _html$match === void 0 ? void 0 : _html$match[0]) ?? html}<!--EndFragment--></body></html>`;
|
|
4070
|
+
}
|
|
4013
4071
|
/**
|
|
4014
4072
|
* This service provide hooks for sheet features to supplement content or modify behavior of clipboard.
|
|
4015
4073
|
*/
|
|
@@ -4104,7 +4162,7 @@ let SheetClipboardService = class SheetClipboardService extends _univerjs_core.D
|
|
|
4104
4162
|
matrix: matrixFragment,
|
|
4105
4163
|
copyType
|
|
4106
4164
|
});
|
|
4107
|
-
await this._clipboardInterfaceService.write(plain, html, formulaClipboardPayload ? { [FORMULA_CLIPBOARD_MIME_TYPE]: formulaClipboardPayload } : void 0);
|
|
4165
|
+
await this._clipboardInterfaceService.write(plain, wrapHtmlForExcel(html), formulaClipboardPayload ? { [FORMULA_CLIPBOARD_MIME_TYPE]: formulaClipboardPayload } : void 0);
|
|
4108
4166
|
this._markSelectionService.removeAllShapes();
|
|
4109
4167
|
const style = createCopyPasteSelectionStyle(this._themeService);
|
|
4110
4168
|
this._copyMarkId = this._markSelectionService.addShape({
|
|
@@ -4124,7 +4182,9 @@ let SheetClipboardService = class SheetClipboardService extends _univerjs_core.D
|
|
|
4124
4182
|
const imageIndex = types.findIndex((type) => _univerjs_ui.imageMimeTypeSet.has(type));
|
|
4125
4183
|
const shouldUseHTMLPaste = imageIndex === -1 || !htmlContainsImage(html);
|
|
4126
4184
|
if (html && shouldUseHTMLPaste) {
|
|
4127
|
-
|
|
4185
|
+
const copyId = extractId(html);
|
|
4186
|
+
const isInternalCopy = Boolean(copyId && this._copyContentCache.get(copyId));
|
|
4187
|
+
if (this._platformService.isWindows && htmlIsFromExcel(html) && !isInternalCopy) this._notificationService.show({
|
|
4128
4188
|
type: "warning",
|
|
4129
4189
|
title: this._localeService.t("sheets-ui.clipboard.shortCutNotify.title"),
|
|
4130
4190
|
content: this._localeService.t("sheets-ui.clipboard.shortCutNotify.useShortCutInstead")
|
|
@@ -7233,6 +7293,9 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends _u
|
|
|
7233
7293
|
this._commandService = _commandService;
|
|
7234
7294
|
this._renderManagerService = _renderManagerService;
|
|
7235
7295
|
this._scrollManagerService = _scrollManagerService;
|
|
7296
|
+
_defineProperty(this, "_pendingWheelOffsetX", 0);
|
|
7297
|
+
_defineProperty(this, "_pendingWheelOffsetY", 0);
|
|
7298
|
+
_defineProperty(this, "_pendingWheelFrameId", null);
|
|
7236
7299
|
this._initCommandListener();
|
|
7237
7300
|
this._wheelEventListener();
|
|
7238
7301
|
this._scrollBarEventListener();
|
|
@@ -7243,6 +7306,12 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends _u
|
|
|
7243
7306
|
if (!scene) return;
|
|
7244
7307
|
const viewMain = scene.getViewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN);
|
|
7245
7308
|
if (!viewMain) return;
|
|
7309
|
+
this.disposeWithMe((0, _univerjs_core.toDisposable)(() => {
|
|
7310
|
+
if (this._pendingWheelFrameId != null) {
|
|
7311
|
+
cancelAnimationFrame(this._pendingWheelFrameId);
|
|
7312
|
+
this._pendingWheelFrameId = null;
|
|
7313
|
+
}
|
|
7314
|
+
}));
|
|
7246
7315
|
this.disposeWithMe(scene.onMouseWheel$.subscribeEvent((evt, state) => {
|
|
7247
7316
|
if (evt.ctrlKey || !this._contextService.getContextValue(_univerjs_core.FOCUSING_SHEET)) return;
|
|
7248
7317
|
let offsetX = 0;
|
|
@@ -7258,14 +7327,15 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends _u
|
|
|
7258
7327
|
if (absOffsetY >= absOffsetX * WHEEL_CROSS_AXIS_LOCK_RATIO) offsetX = 0;
|
|
7259
7328
|
else if (absOffsetX >= absOffsetY * WHEEL_CROSS_AXIS_LOCK_RATIO) offsetY = 0;
|
|
7260
7329
|
}
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
offsetY
|
|
7330
|
+
this._pendingWheelOffsetX += offsetX;
|
|
7331
|
+
this._pendingWheelOffsetY += offsetY;
|
|
7332
|
+
if (this._pendingWheelFrameId == null) this._pendingWheelFrameId = requestAnimationFrame(() => {
|
|
7333
|
+
this._pendingWheelFrameId = null;
|
|
7334
|
+
this._flushPendingWheelScroll();
|
|
7267
7335
|
});
|
|
7268
|
-
this.
|
|
7336
|
+
const targetViewportScrollX = viewMain.viewportScrollX + this._pendingWheelOffsetX;
|
|
7337
|
+
const targetViewportScrollY = viewMain.viewportScrollY + this._pendingWheelOffsetY;
|
|
7338
|
+
const { x: targetScrollX, y: targetScrollY } = viewMain.transViewportScroll2ScrollValue(targetViewportScrollX, targetViewportScrollY);
|
|
7269
7339
|
const isLimitedStore = viewMain.limitedScroll(targetScrollX, targetScrollY);
|
|
7270
7340
|
if (isLimitedStore && !isLimitedStore.isLimitedX && !isLimitedStore.isLimitedY) {
|
|
7271
7341
|
evt.preventDefault();
|
|
@@ -7274,6 +7344,30 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends _u
|
|
|
7274
7344
|
if (viewMain.isWheelPreventDefaultX && viewMain.isWheelPreventDefaultY) evt.preventDefault();
|
|
7275
7345
|
}));
|
|
7276
7346
|
}
|
|
7347
|
+
_flushPendingWheelScroll() {
|
|
7348
|
+
const offsetX = this._pendingWheelOffsetX;
|
|
7349
|
+
const offsetY = this._pendingWheelOffsetY;
|
|
7350
|
+
if (offsetX === 0 && offsetY === 0) return;
|
|
7351
|
+
this._pendingWheelOffsetX = 0;
|
|
7352
|
+
this._pendingWheelOffsetY = 0;
|
|
7353
|
+
const canUseScrollFastPath = this._canUseScrollFastPath();
|
|
7354
|
+
this._commandService.executeCommand(SetScrollRelativeCommand.id, {
|
|
7355
|
+
offsetX,
|
|
7356
|
+
offsetY
|
|
7357
|
+
});
|
|
7358
|
+
this._markSceneDirtyForScrolling(canUseScrollFastPath);
|
|
7359
|
+
}
|
|
7360
|
+
_canUseScrollFastPath() {
|
|
7361
|
+
var _this$_getSheetObject, _spreadsheet$getSkele;
|
|
7362
|
+
const { scene } = this._context;
|
|
7363
|
+
const spreadsheet = (_this$_getSheetObject = this._getSheetObject()) === null || _this$_getSheetObject === void 0 ? void 0 : _this$_getSheetObject.spreadsheet;
|
|
7364
|
+
return scene.getParent().classType === _univerjs_engine_render.RENDER_CLASS_TYPE.ENGINE && !scene.isDirty() && spreadsheet != null && !spreadsheet.isDirty() && !spreadsheet.isForceDirty() && ((_spreadsheet$getSkele = spreadsheet.getSkeleton()) === null || _spreadsheet$getSkele === void 0 ? void 0 : _spreadsheet$getSkele.worksheet.getMergeData().length) === 0 && scene.getViewports().every((viewport) => !viewport.shouldIntoRender() || !viewport.isDirty && !viewport.isForceDirty) && scene.getLayers().every((layer) => layer.getObjectsByOrder().every((object) => !object.isDirty()));
|
|
7365
|
+
}
|
|
7366
|
+
_markSceneDirtyForScrolling(canUseScrollFastPath) {
|
|
7367
|
+
const { scene } = this._context;
|
|
7368
|
+
if (canUseScrollFastPath) scene.makeDirtyForScrolling();
|
|
7369
|
+
else scene.makeDirty(true);
|
|
7370
|
+
}
|
|
7277
7371
|
_scrollBarEventListener() {
|
|
7278
7372
|
const { scene } = this._context;
|
|
7279
7373
|
if (scene == null) return;
|
|
@@ -7526,8 +7620,8 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends _u
|
|
|
7526
7620
|
return (0, _univerjs_sheets.getSelectionsService)(this._injector);
|
|
7527
7621
|
}
|
|
7528
7622
|
_getViewportBounding() {
|
|
7529
|
-
var _this$
|
|
7530
|
-
const scene = (_this$
|
|
7623
|
+
var _this$_getSheetObject2, _this$_sheetSkeletonM5;
|
|
7624
|
+
const scene = (_this$_getSheetObject2 = this._getSheetObject()) === null || _this$_getSheetObject2 === void 0 ? void 0 : _this$_getSheetObject2.scene;
|
|
7531
7625
|
if (scene == null) return;
|
|
7532
7626
|
const viewport = scene.getViewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN);
|
|
7533
7627
|
if (viewport == null) return;
|
|
@@ -7537,10 +7631,10 @@ let SheetsScrollRenderController = class SheetsScrollRenderController extends _u
|
|
|
7537
7631
|
return skeleton.getRangeByViewBound(vpInfo.viewBound);
|
|
7538
7632
|
}
|
|
7539
7633
|
_scrollToCell(row, column, forceTop = false, forceLeft = false) {
|
|
7540
|
-
var _this$
|
|
7634
|
+
var _this$_getSheetObject3, _this$_sheetSkeletonM6;
|
|
7541
7635
|
const { rowHeightAccumulation, columnWidthAccumulation } = this._sheetSkeletonManagerService.getCurrentSkeleton() ?? {};
|
|
7542
7636
|
if (rowHeightAccumulation == null || columnWidthAccumulation == null) return false;
|
|
7543
|
-
const scene = (_this$
|
|
7637
|
+
const scene = (_this$_getSheetObject3 = this._getSheetObject()) === null || _this$_getSheetObject3 === void 0 ? void 0 : _this$_getSheetObject3.scene;
|
|
7544
7638
|
if (scene == null) return false;
|
|
7545
7639
|
const viewport = scene.getViewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN);
|
|
7546
7640
|
if (viewport == null) return false;
|
|
@@ -9241,1057 +9335,382 @@ CellCustomRenderController = __decorate([
|
|
|
9241
9335
|
], CellCustomRenderController);
|
|
9242
9336
|
|
|
9243
9337
|
//#endregion
|
|
9244
|
-
//#region src/
|
|
9245
|
-
|
|
9246
|
-
|
|
9247
|
-
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
|
|
9259
|
-
|
|
9260
|
-
|
|
9261
|
-
|
|
9338
|
+
//#region src/views/hook.ts
|
|
9339
|
+
function useActiveWorkbook() {
|
|
9340
|
+
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
9341
|
+
return (0, _univerjs_ui.useObservable)(() => univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET), void 0, void 0, []) ?? null;
|
|
9342
|
+
}
|
|
9343
|
+
function useActiveWorksheet(workbook) {
|
|
9344
|
+
return (0, _univerjs_ui.useObservable)(() => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? (0, rxjs.of)(null), void 0, void 0, [workbook]);
|
|
9345
|
+
}
|
|
9346
|
+
function useWorkbooks() {
|
|
9347
|
+
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
9348
|
+
return (0, _univerjs_ui.useObservable)(() => {
|
|
9349
|
+
return (0, rxjs.merge)([univerInstanceService.getTypeOfUnitAdded$(_univerjs_core.UniverInstanceType.UNIVER_SHEET), univerInstanceService.getTypeOfUnitDisposed$(_univerjs_core.UniverInstanceType.UNIVER_SHEET)]).pipe((0, rxjs.map)(() => univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)), (0, rxjs.startWith)(univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)));
|
|
9350
|
+
}, [], void 0, [univerInstanceService]);
|
|
9351
|
+
}
|
|
9352
|
+
|
|
9353
|
+
//#endregion
|
|
9354
|
+
//#region src/views/clipboard/ClipboardPopupMenu.tsx
|
|
9355
|
+
const DEFAULT_PADDING = 2;
|
|
9356
|
+
const SheetPasteOptions = [
|
|
9357
|
+
{
|
|
9358
|
+
value: "DEFAULT_PASTE",
|
|
9359
|
+
label: "sheets-ui.rightClick.paste"
|
|
9360
|
+
},
|
|
9361
|
+
{
|
|
9362
|
+
value: "SPECIAL_PASTE_VALUE",
|
|
9363
|
+
label: "sheets-ui.rightClick.pasteValue"
|
|
9364
|
+
},
|
|
9365
|
+
{
|
|
9366
|
+
value: "SPECIAL_PASTE_FORMAT",
|
|
9367
|
+
label: "sheets-ui.rightClick.pasteFormat"
|
|
9368
|
+
},
|
|
9369
|
+
{
|
|
9370
|
+
value: "SPECIAL_PASTE_COL_WIDTH",
|
|
9371
|
+
label: "sheets-ui.rightClick.pasteColWidth"
|
|
9372
|
+
},
|
|
9373
|
+
{
|
|
9374
|
+
value: "SPECIAL_PASTE_BESIDES_BORDER",
|
|
9375
|
+
label: "sheets-ui.rightClick.pasteBesidesBorder"
|
|
9376
|
+
},
|
|
9377
|
+
{
|
|
9378
|
+
value: "SPECIAL_PASTE_FORMULA",
|
|
9379
|
+
label: "sheets-ui.rightClick.pasteFormula"
|
|
9262
9380
|
}
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
|
|
9267
|
-
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9381
|
+
];
|
|
9382
|
+
const useMenuPosition = (range) => {
|
|
9383
|
+
var _scene$getEngine;
|
|
9384
|
+
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
9385
|
+
const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
|
|
9386
|
+
const workbook = useActiveWorkbook();
|
|
9387
|
+
if (!range || !workbook) return null;
|
|
9388
|
+
const anchor = {
|
|
9389
|
+
startRow: range.rows[0],
|
|
9390
|
+
startCol: range.cols[0],
|
|
9391
|
+
endRow: range.rows[range.rows.length - 1],
|
|
9392
|
+
endCol: range.cols[range.cols.length - 1]
|
|
9393
|
+
};
|
|
9394
|
+
if (anchor.endRow < 0 || anchor.endCol < 0) return null;
|
|
9395
|
+
const ru = renderManagerService.getRenderUnitById(workbook.getUnitId());
|
|
9396
|
+
const sheetSkeletonManagerService = ru === null || ru === void 0 ? void 0 : ru.with(SheetSkeletonManagerService);
|
|
9397
|
+
const sheetObject = getSheetObject(univerInstanceService, renderManagerService);
|
|
9398
|
+
if (!sheetObject) return null;
|
|
9399
|
+
const { scene } = sheetObject;
|
|
9400
|
+
const skeleton = sheetSkeletonManagerService === null || sheetSkeletonManagerService === void 0 ? void 0 : sheetSkeletonManagerService.getCurrentSkeleton();
|
|
9401
|
+
const viewport = getViewportByCell(anchor.endRow, anchor.endCol, scene, workbook.getActiveSheet());
|
|
9402
|
+
if (!viewport) return null;
|
|
9403
|
+
const scaleX = scene === null || scene === void 0 ? void 0 : scene.scaleX;
|
|
9404
|
+
const scaleY = scene === null || scene === void 0 ? void 0 : scene.scaleY;
|
|
9405
|
+
const scrollXY = scene === null || scene === void 0 ? void 0 : scene.getViewportScrollXY(viewport);
|
|
9406
|
+
const canvas = (_scene$getEngine = scene.getEngine()) === null || _scene$getEngine === void 0 ? void 0 : _scene$getEngine.getCanvas();
|
|
9407
|
+
if (!scaleX || !scene || !scaleX || !scaleY || !scrollXY) return null;
|
|
9408
|
+
const endPosition = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getNoMergeCellWithCoordByIndex(anchor.endRow, anchor.endCol);
|
|
9409
|
+
const endX = (endPosition === null || endPosition === void 0 ? void 0 : endPosition.endX) ?? 0;
|
|
9410
|
+
const endY = (endPosition === null || endPosition === void 0 ? void 0 : endPosition.endY) ?? 0;
|
|
9411
|
+
const positionEndX = (0, _univerjs_engine_render.convertTransformToOffsetX)(endX, scaleX, scrollXY) ?? -9999;
|
|
9412
|
+
const positionEndY = (0, _univerjs_engine_render.convertTransformToOffsetY)(endY, scaleY, scrollXY) ?? -9999;
|
|
9413
|
+
const canvasWidth = canvas === null || canvas === void 0 ? void 0 : canvas.getWidth();
|
|
9414
|
+
const canvasHeight = canvas === null || canvas === void 0 ? void 0 : canvas.getHeight();
|
|
9415
|
+
if (!canvasWidth || !canvasHeight) return null;
|
|
9416
|
+
const XInSideView = positionEndX + 50 <= canvasWidth;
|
|
9417
|
+
const YInSideView = positionEndY + 50 <= canvasHeight;
|
|
9418
|
+
let positionX = positionEndX;
|
|
9419
|
+
let positionY = positionEndY;
|
|
9420
|
+
if (!XInSideView) positionX = canvasWidth - 100;
|
|
9421
|
+
if (!YInSideView) positionY = canvasHeight - 100;
|
|
9422
|
+
return {
|
|
9423
|
+
positionX,
|
|
9424
|
+
positionY
|
|
9425
|
+
};
|
|
9426
|
+
};
|
|
9427
|
+
const ClipboardPopupMenu = () => {
|
|
9428
|
+
const clipboardService = (0, _univerjs_ui.useDependency)(ISheetClipboardService);
|
|
9429
|
+
const showMenu = (0, _univerjs_ui.useObservable)(clipboardService.showMenu$, false);
|
|
9430
|
+
const pasteOptionsCache = (0, _univerjs_ui.useObservable)(clipboardService.pasteOptionsCache$, null);
|
|
9431
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
9432
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
9433
|
+
const [menuHovered, setMenuHovered] = (0, react.useState)(false);
|
|
9434
|
+
const [visible, setVisible] = (0, react.useState)(false);
|
|
9435
|
+
const range = pasteOptionsCache === null || pasteOptionsCache === void 0 ? void 0 : pasteOptionsCache.target.pastedRange;
|
|
9436
|
+
const relativePosition = useMenuPosition(range);
|
|
9437
|
+
if (!relativePosition || !showMenu) return null;
|
|
9438
|
+
if (relativePosition.positionX < 50 || relativePosition.positionY < 30) return null;
|
|
9439
|
+
const showMore = menuHovered || visible;
|
|
9440
|
+
const handleClick = (type) => {
|
|
9441
|
+
setVisible(false);
|
|
9442
|
+
commandService.executeCommand(SheetOptionalPasteCommand.id, { type });
|
|
9443
|
+
};
|
|
9444
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
9445
|
+
className: "univer-absolute univer-inset-0 univer-z-10 univer-size-0",
|
|
9446
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
9447
|
+
className: "univer-absolute",
|
|
9448
|
+
style: {
|
|
9449
|
+
left: relativePosition.positionX + DEFAULT_PADDING,
|
|
9450
|
+
top: relativePosition.positionY + DEFAULT_PADDING
|
|
9451
|
+
},
|
|
9452
|
+
onMouseEnter: () => setMenuHovered(true),
|
|
9453
|
+
onMouseLeave: () => setMenuHovered(false),
|
|
9454
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
9455
|
+
align: "start",
|
|
9456
|
+
items: SheetPasteOptions.map((item) => ({
|
|
9457
|
+
type: "checkbox",
|
|
9458
|
+
value: item.value,
|
|
9459
|
+
label: localeService.t(item.label),
|
|
9460
|
+
checked: (pasteOptionsCache === null || pasteOptionsCache === void 0 ? void 0 : pasteOptionsCache.pasteType) === PREDEFINED_HOOK_NAME_PASTE[item.value],
|
|
9461
|
+
onSelect: () => handleClick(item.value)
|
|
9462
|
+
})),
|
|
9463
|
+
open: visible,
|
|
9464
|
+
onOpenChange: setVisible,
|
|
9465
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
9466
|
+
className: (0, _univerjs_design.clsx)("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", _univerjs_design.borderClassName, {
|
|
9467
|
+
"univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
|
|
9468
|
+
"univer-bg-gray-0 dark:!univer-bg-gray-900": !visible
|
|
9469
|
+
}),
|
|
9470
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.PasteSpecialDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-gray-0" }), showMore && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "dark:!univer-text-gray-0" })]
|
|
9471
|
+
})
|
|
9472
|
+
})
|
|
9473
|
+
})
|
|
9474
|
+
});
|
|
9475
|
+
};
|
|
9476
|
+
|
|
9477
|
+
//#endregion
|
|
9478
|
+
//#region src/controllers/clipboard/const.ts
|
|
9479
|
+
/**
|
|
9480
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
9481
|
+
*
|
|
9482
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9483
|
+
* you may not use this file except in compliance with the License.
|
|
9484
|
+
* You may obtain a copy of the License at
|
|
9485
|
+
*
|
|
9486
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9487
|
+
*
|
|
9488
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
9489
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
9490
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9491
|
+
* See the License for the specific language governing permissions and
|
|
9492
|
+
* limitations under the License.
|
|
9493
|
+
*/
|
|
9494
|
+
const RemovePasteMenuCommands = [
|
|
9495
|
+
SetCellEditVisibleOperation.id,
|
|
9496
|
+
_univerjs_sheets.SetRangeValuesCommand.id,
|
|
9497
|
+
SetZoomRatioOperation.id,
|
|
9498
|
+
_univerjs_sheets.MoveRangeMutation.id,
|
|
9499
|
+
_univerjs_sheets.RemoveRowMutation.id,
|
|
9500
|
+
_univerjs_sheets.RemoveColMutation.id,
|
|
9501
|
+
_univerjs_sheets.InsertRowMutation.id,
|
|
9502
|
+
_univerjs_sheets.InsertColMutation.id,
|
|
9503
|
+
_univerjs_sheets.MoveRowsMutation.id,
|
|
9504
|
+
_univerjs_sheets.MoveColsMutation.id,
|
|
9505
|
+
_univerjs_sheets.SetWorksheetColWidthMutation.id,
|
|
9506
|
+
_univerjs_sheets.SetWorksheetRowHeightMutation.id,
|
|
9507
|
+
_univerjs_sheets.SetSelectionsOperation.id,
|
|
9508
|
+
_univerjs_core.UndoCommandId
|
|
9509
|
+
];
|
|
9510
|
+
|
|
9511
|
+
//#endregion
|
|
9512
|
+
//#region src/services/editor/cell-editor-manager.service.ts
|
|
9513
|
+
var CellEditorManagerService = class {
|
|
9514
|
+
constructor() {
|
|
9515
|
+
_defineProperty(this, "_state", null);
|
|
9516
|
+
_defineProperty(this, "_rect", null);
|
|
9517
|
+
_defineProperty(this, "_state$", new rxjs.BehaviorSubject(null));
|
|
9518
|
+
_defineProperty(this, "state$", this._state$.asObservable());
|
|
9519
|
+
_defineProperty(this, "_rect$", new rxjs.BehaviorSubject(null));
|
|
9520
|
+
_defineProperty(this, "rect$", this._rect$.asObservable());
|
|
9521
|
+
_defineProperty(this, "_focus", false);
|
|
9522
|
+
_defineProperty(this, "_focus$", new rxjs.BehaviorSubject(this._focus));
|
|
9523
|
+
_defineProperty(this, "focus$", this._focus$.asObservable());
|
|
9277
9524
|
}
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
this.
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
|
|
9292
|
-
|
|
9293
|
-
|
|
9294
|
-
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
this.
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9525
|
+
dispose() {
|
|
9526
|
+
this._state$.complete();
|
|
9527
|
+
this._state = null;
|
|
9528
|
+
this._rect$.complete();
|
|
9529
|
+
this._rect = null;
|
|
9530
|
+
}
|
|
9531
|
+
setState(param) {
|
|
9532
|
+
this._state = param;
|
|
9533
|
+
this._refresh(param);
|
|
9534
|
+
}
|
|
9535
|
+
getRect() {
|
|
9536
|
+
return this._rect;
|
|
9537
|
+
}
|
|
9538
|
+
setRect(param) {
|
|
9539
|
+
this._rect = param;
|
|
9540
|
+
this._rect$.next(param);
|
|
9541
|
+
}
|
|
9542
|
+
getState() {
|
|
9543
|
+
return this._state;
|
|
9544
|
+
}
|
|
9545
|
+
setFocus(param = false) {
|
|
9546
|
+
this._focus = param;
|
|
9547
|
+
this._focus$.next(param);
|
|
9548
|
+
}
|
|
9549
|
+
_refresh(param) {
|
|
9550
|
+
this._state$.next(param);
|
|
9551
|
+
}
|
|
9552
|
+
};
|
|
9553
|
+
const ICellEditorManagerService = (0, _univerjs_core.createIdentifier)("univer.sheet-cell-editor-manager.service");
|
|
9554
|
+
|
|
9555
|
+
//#endregion
|
|
9556
|
+
//#region src/services/sheet-embed-integration.service.ts
|
|
9557
|
+
const SHEET_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
|
|
9558
|
+
const SHEET_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE = "data-embed-runtime-focus-role";
|
|
9559
|
+
const SHEET_EMBED_FLOAT_DOM_ATTRIBUTE = "data-embed-float-dom";
|
|
9560
|
+
const SHEET_EMBED_ID_ATTRIBUTE = "data-embed-id";
|
|
9561
|
+
const SHEET_EMBED_HOST_UNIT_ID_ATTRIBUTE = "data-embed-host-unit-id";
|
|
9562
|
+
const SHEET_EMBED_CHILD_UNIT_ID_ATTRIBUTE = "data-embed-child-unit-id";
|
|
9563
|
+
const SHEET_EMBED_CHILD_TYPE_ATTRIBUTE = "data-embed-child-type";
|
|
9564
|
+
const ISheetEmbedInteractionBoundaryService = (0, _univerjs_core.createIdentifier)("sheets-ui.embed-interaction-boundary.service");
|
|
9565
|
+
const ISheetEmbedRuntimeFocusCoordinator = (0, _univerjs_core.createIdentifier)("sheets-ui.embed-runtime-focus-coordinator");
|
|
9566
|
+
const ISheetEmbedFloatingGeometryService = (0, _univerjs_core.createIdentifier)("sheets-ui.embed-floating-geometry.service");
|
|
9567
|
+
function resolveSheetEmbedRuntimeDomScope(element) {
|
|
9568
|
+
var _element$closest;
|
|
9569
|
+
if (!element) return;
|
|
9570
|
+
const embedId = ((_element$closest = element.closest(`[${"data-embed-interaction-boundary-owner"}]`)) === null || _element$closest === void 0 ? void 0 : _element$closest.getAttribute("data-embed-interaction-boundary-owner")) ?? void 0;
|
|
9571
|
+
const container = resolveSheetEmbedFloatDomContainer(element, embedId);
|
|
9572
|
+
const resolvedEmbedId = (container === null || container === void 0 ? void 0 : container.getAttribute("data-embed-id")) ?? embedId;
|
|
9573
|
+
if (!resolvedEmbedId) return;
|
|
9574
|
+
return {
|
|
9575
|
+
embedId: resolvedEmbedId,
|
|
9576
|
+
hostUnitId: (container === null || container === void 0 ? void 0 : container.getAttribute("data-embed-host-unit-id")) ?? void 0,
|
|
9577
|
+
childUnitId: (container === null || container === void 0 ? void 0 : container.getAttribute("data-embed-child-unit-id")) ?? void 0,
|
|
9578
|
+
childType: readChildType(container)
|
|
9579
|
+
};
|
|
9580
|
+
}
|
|
9581
|
+
function resolveActiveSheetEmbedRuntimeDomScope(ownerDocument = document) {
|
|
9582
|
+
const activeContainer = ownerDocument.querySelector(`[${SHEET_EMBED_FLOAT_DOM_ATTRIBUTE}="true"][data-embed-float-stage="stage2"]`);
|
|
9583
|
+
if (!activeContainer) return;
|
|
9584
|
+
return resolveSheetEmbedRuntimeDomScope(activeContainer);
|
|
9585
|
+
}
|
|
9586
|
+
function resolveSheetEmbedFloatDomContainer(element, embedId) {
|
|
9587
|
+
const ownContainer = element === null || element === void 0 ? void 0 : element.closest(`[${SHEET_EMBED_FLOAT_DOM_ATTRIBUTE}="true"]`);
|
|
9588
|
+
if (ownContainer && (!embedId || ownContainer.getAttribute("data-embed-id") === embedId)) return ownContainer;
|
|
9589
|
+
const ownerDocument = (element === null || element === void 0 ? void 0 : element.ownerDocument) ?? (typeof document === "undefined" ? void 0 : document);
|
|
9590
|
+
if (!ownerDocument || !embedId) return ownContainer ?? void 0;
|
|
9591
|
+
return ownerDocument.querySelector(`[${"data-embed-float-dom"}="true"][${"data-embed-id"}="${escapeAttributeValue(embedId)}"]`) ?? void 0;
|
|
9592
|
+
}
|
|
9593
|
+
function escapeAttributeValue(value) {
|
|
9594
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
9595
|
+
}
|
|
9596
|
+
function readChildType(container) {
|
|
9597
|
+
const value = container === null || container === void 0 ? void 0 : container.getAttribute(SHEET_EMBED_CHILD_TYPE_ATTRIBUTE);
|
|
9598
|
+
if (value == null || value === "") return;
|
|
9599
|
+
return Number(value);
|
|
9600
|
+
}
|
|
9601
|
+
|
|
9602
|
+
//#endregion
|
|
9603
|
+
//#region src/services/editor/cell-editor-resize.service.ts
|
|
9604
|
+
const EDITOR_INPUT_SELF_EXTEND_GAP = 5;
|
|
9605
|
+
const EDITOR_BORDER_SIZE = 2;
|
|
9606
|
+
let SheetCellEditorResizeService = class SheetCellEditorResizeService extends _univerjs_core.Disposable {
|
|
9607
|
+
constructor(_layoutService, _cellEditorManagerService, _editorBridgeService, _renderManagerService, _univerInstanceService, _configService, _embedFloatingGeometryService) {
|
|
9608
|
+
super();
|
|
9609
|
+
this._layoutService = _layoutService;
|
|
9610
|
+
this._cellEditorManagerService = _cellEditorManagerService;
|
|
9611
|
+
this._editorBridgeService = _editorBridgeService;
|
|
9612
|
+
this._renderManagerService = _renderManagerService;
|
|
9613
|
+
this._univerInstanceService = _univerInstanceService;
|
|
9614
|
+
this._configService = _configService;
|
|
9615
|
+
this._embedFloatingGeometryService = _embedFloatingGeometryService;
|
|
9616
|
+
}
|
|
9617
|
+
get _currentRenderer() {
|
|
9618
|
+
return (0, _univerjs_engine_render.getCurrentTypeOfRenderer)(_univerjs_core.UniverInstanceType.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService);
|
|
9619
|
+
}
|
|
9620
|
+
get _editingUnitId() {
|
|
9621
|
+
var _this$_editorBridgeSe;
|
|
9622
|
+
return ((_this$_editorBridgeSe = this._editorBridgeService.getEditCellState()) === null || _this$_editorBridgeSe === void 0 ? void 0 : _this$_editorBridgeSe.unitId) ?? "";
|
|
9623
|
+
}
|
|
9624
|
+
get _editingRenderer() {
|
|
9625
|
+
return this._renderManagerService.getRenderUnitById(this._editingUnitId);
|
|
9626
|
+
}
|
|
9627
|
+
get _renderer() {
|
|
9628
|
+
return this._editingRenderer ?? this._currentRenderer;
|
|
9629
|
+
}
|
|
9630
|
+
get _sheetSkeletonManagerService() {
|
|
9631
|
+
var _this$_renderer;
|
|
9632
|
+
return (_this$_renderer = this._renderer) === null || _this$_renderer === void 0 ? void 0 : _this$_renderer.with(SheetSkeletonManagerService);
|
|
9633
|
+
}
|
|
9634
|
+
get engine() {
|
|
9635
|
+
var _this$_renderer2;
|
|
9636
|
+
return (_this$_renderer2 = this._renderer) === null || _this$_renderer2 === void 0 ? void 0 : _this$_renderer2.engine;
|
|
9637
|
+
}
|
|
9638
|
+
fitTextSize(callback) {
|
|
9639
|
+
const param = this._editorBridgeService.getEditCellState();
|
|
9640
|
+
if (!param) return;
|
|
9641
|
+
const { position, documentLayoutObject, canvasOffset, scaleX, scaleY } = param;
|
|
9642
|
+
const { startX, startY, endX, endY } = position;
|
|
9643
|
+
const documentDataModel = this._univerInstanceService.getUnit(_univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
9644
|
+
if (documentDataModel == null) return;
|
|
9645
|
+
const documentSkeleton = this._getEditorSkeleton();
|
|
9646
|
+
if (!documentSkeleton) return;
|
|
9647
|
+
documentSkeleton.resetInitialWidth();
|
|
9648
|
+
const info = this._predictingSize(position, canvasOffset, documentSkeleton, documentLayoutObject, scaleX, scaleY);
|
|
9649
|
+
if (!info || info.actualWidth <= 0) return;
|
|
9650
|
+
let { actualWidth, actualHeight } = info;
|
|
9651
|
+
const { verticalAlign, horizontalAlign, paddingData, fill } = documentLayoutObject;
|
|
9652
|
+
actualWidth = actualWidth + (paddingData.l ?? 0) * scaleX + (paddingData.r ?? 0) * scaleX;
|
|
9653
|
+
actualHeight = actualHeight + (paddingData.t ?? 0) * scaleY + (paddingData.b ?? 0) * scaleY;
|
|
9654
|
+
let editorWidth = endX - startX;
|
|
9655
|
+
let editorHeight = endY - startY;
|
|
9656
|
+
if (editorWidth < actualWidth) editorWidth = Math.ceil(actualWidth);
|
|
9657
|
+
if (editorHeight < actualHeight) editorHeight = Math.ceil(actualHeight);
|
|
9658
|
+
let offsetTop = 0;
|
|
9659
|
+
if (verticalAlign === _univerjs_core.VerticalAlign.MIDDLE) offsetTop = (editorHeight - actualHeight) / 2 / scaleY;
|
|
9660
|
+
else if (verticalAlign === _univerjs_core.VerticalAlign.TOP) offsetTop = paddingData.t || 0;
|
|
9661
|
+
else offsetTop = (editorHeight - actualHeight) / scaleY;
|
|
9662
|
+
let offsetLeft = 0;
|
|
9663
|
+
if (horizontalAlign === _univerjs_core.HorizontalAlign.CENTER) {} else if (horizontalAlign === _univerjs_core.HorizontalAlign.RIGHT) offsetLeft = (editorWidth - actualWidth) / scaleX;
|
|
9664
|
+
else offsetLeft = paddingData.l || 0;
|
|
9665
|
+
offsetTop = Math.max(offsetTop, paddingData.t || 0);
|
|
9666
|
+
offsetLeft = Math.max(offsetLeft, paddingData.l || 0);
|
|
9667
|
+
documentDataModel.updateDocumentDataMargin({
|
|
9668
|
+
t: offsetTop,
|
|
9669
|
+
l: offsetLeft
|
|
9670
|
+
});
|
|
9671
|
+
documentSkeleton.calculate();
|
|
9672
|
+
this._editAreaProcessing(editorWidth, editorHeight, position, canvasOffset, fill, scaleX, scaleY, horizontalAlign, callback);
|
|
9312
9673
|
}
|
|
9313
9674
|
/**
|
|
9314
|
-
*
|
|
9315
|
-
*
|
|
9675
|
+
* Mainly used to pre-calculate the width of the editor,
|
|
9676
|
+
* to determine whether it needs to be automatically widened.
|
|
9316
9677
|
*/
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
const
|
|
9320
|
-
|
|
9321
|
-
const
|
|
9322
|
-
|
|
9323
|
-
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
Object.keys(data).filter((key) => key.startsWith(_univerjs_engine_render.SHEET_EXTENSION_PREFIX)).forEach((key) => {
|
|
9328
|
-
totalSum += sums[key];
|
|
9678
|
+
_predictingSize(actualRangeWithCoord, canvasOffset, documentSkeleton, documentLayoutObject, scaleX = 1, scaleY = 1) {
|
|
9679
|
+
const { startX, endX } = actualRangeWithCoord;
|
|
9680
|
+
const { textRotation, wrapStrategy, paddingData } = documentLayoutObject;
|
|
9681
|
+
const documentDataModel = this._univerInstanceService.getUnit(_univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
9682
|
+
const { vertexAngle: angle } = (0, _univerjs_engine_render.convertTextRotation)(textRotation);
|
|
9683
|
+
if (wrapStrategy === _univerjs_core.WrapStrategy.WRAP && angle === 0) {
|
|
9684
|
+
documentDataModel === null || documentDataModel === void 0 || documentDataModel.updateDocumentDataPageSize((endX - startX) / scaleX);
|
|
9685
|
+
documentDataModel === null || documentDataModel === void 0 || documentDataModel.updateDocumentDataMargin({
|
|
9686
|
+
l: paddingData.l,
|
|
9687
|
+
t: paddingData.t
|
|
9329
9688
|
});
|
|
9689
|
+
documentSkeleton.calculate();
|
|
9690
|
+
const { actualWidth, actualHeight } = documentSkeleton.getActualSize();
|
|
9330
9691
|
return {
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
};
|
|
9334
|
-
};
|
|
9335
|
-
const frameTimeListAfterSum = frameInfoList.map((info) => {
|
|
9336
|
-
return {
|
|
9337
|
-
...info,
|
|
9338
|
-
...sumValueForNumListFields(info)
|
|
9692
|
+
actualWidth: actualWidth * scaleX,
|
|
9693
|
+
actualHeight: actualHeight * scaleY
|
|
9339
9694
|
};
|
|
9695
|
+
}
|
|
9696
|
+
const maxSize = this._getEditorMaxSize(actualRangeWithCoord, canvasOffset, documentLayoutObject.horizontalAlign);
|
|
9697
|
+
if (!maxSize) return;
|
|
9698
|
+
documentDataModel === null || documentDataModel === void 0 || documentDataModel.updateDocumentDataPageSize(maxSize.width / scaleX);
|
|
9699
|
+
documentSkeleton.calculate();
|
|
9700
|
+
const size = documentSkeleton.getActualSize();
|
|
9701
|
+
let editorWidth = endX - startX;
|
|
9702
|
+
if (editorWidth < size.actualWidth * scaleX + EDITOR_INPUT_SELF_EXTEND_GAP * scaleX) editorWidth = size.actualWidth * scaleX + EDITOR_INPUT_SELF_EXTEND_GAP * scaleX;
|
|
9703
|
+
documentDataModel === null || documentDataModel === void 0 || documentDataModel.updateDocumentDataPageSize(editorWidth / scaleX);
|
|
9704
|
+
/**
|
|
9705
|
+
* Do not rely on cell layout logic, depend on the document's internal alignment logic.
|
|
9706
|
+
*/
|
|
9707
|
+
documentDataModel === null || documentDataModel === void 0 || documentDataModel.updateDocumentRenderConfig({
|
|
9708
|
+
horizontalAlign: _univerjs_core.HorizontalAlign.UNSPECIFIED,
|
|
9709
|
+
cellValueType: void 0
|
|
9340
9710
|
});
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
const max = Math.max(...values);
|
|
9345
|
-
const min = Math.min(...values);
|
|
9346
|
-
const avg = values.reduce((sum, val) => sum + val, 0) / values.length;
|
|
9347
|
-
acc[key] = {
|
|
9348
|
-
max: Math.round(max * 100) / 100,
|
|
9349
|
-
min: Math.round(min * 100) / 100,
|
|
9350
|
-
avg: Math.round(avg * 100) / 100
|
|
9351
|
-
};
|
|
9352
|
-
return acc;
|
|
9353
|
-
}, {});
|
|
9354
|
-
};
|
|
9355
|
-
const summaryFrameStats = getSummaryStats(frameTimeListAfterSum);
|
|
9356
|
-
const elapsedTimeToStart = filteredFrameInfo[filteredFrameInfo.length - 1].elapsedTime;
|
|
9357
|
-
const telemetryData = {
|
|
9358
|
-
sheetId: this._context.unit.getActiveSheet().getSheetId(),
|
|
9359
|
-
unitId: this._context.unit.getUnitId(),
|
|
9360
|
-
elapsedTimeToStart,
|
|
9361
|
-
...summaryFrameStats
|
|
9362
|
-
};
|
|
9363
|
-
this._renderMetric$.next(telemetryData);
|
|
9364
|
-
(_this$_telemetryServi = this._telemetryService) === null || _this$_telemetryServi === void 0 || _this$_telemetryServi.capture("sheet_render_cost", telemetryData);
|
|
9365
|
-
}
|
|
9366
|
-
_addComponent(workbook) {
|
|
9367
|
-
const { scene, components } = this._context;
|
|
9368
|
-
const worksheet = workbook.getActiveSheet();
|
|
9369
|
-
const spreadsheet = new _univerjs_engine_render.Spreadsheet("__SpreadsheetRender__");
|
|
9370
|
-
this._addViewport(worksheet);
|
|
9371
|
-
const spreadsheetRowHeader = new _univerjs_engine_render.SpreadsheetRowHeader("__SpreadsheetRowHeader__");
|
|
9372
|
-
const spreadsheetColumnHeader = new _univerjs_engine_render.SpreadsheetColumnHeader("__SpreadsheetColumnHeader__");
|
|
9373
|
-
const SpreadsheetLeftTopPlaceholder = new _univerjs_engine_render.Rect("__SpreadsheetLeftTopPlaceholder__", {
|
|
9374
|
-
zIndex: 2,
|
|
9375
|
-
left: -1,
|
|
9376
|
-
top: -1,
|
|
9377
|
-
fill: "rgb(248, 249, 250)",
|
|
9378
|
-
stroke: "rgb(217, 217, 217)",
|
|
9379
|
-
strokeWidth: 1
|
|
9380
|
-
});
|
|
9381
|
-
this._context.mainComponent = spreadsheet;
|
|
9382
|
-
components.set("__SpreadsheetRender__", spreadsheet);
|
|
9383
|
-
components.set("__SpreadsheetRowHeader__", spreadsheetRowHeader);
|
|
9384
|
-
components.set("__SpreadsheetColumnHeader__", spreadsheetColumnHeader);
|
|
9385
|
-
components.set("__SpreadsheetLeftTopPlaceholder__", SpreadsheetLeftTopPlaceholder);
|
|
9386
|
-
scene.addObjects([spreadsheet], 0);
|
|
9387
|
-
scene.addObjects([
|
|
9388
|
-
spreadsheetRowHeader,
|
|
9389
|
-
spreadsheetColumnHeader,
|
|
9390
|
-
SpreadsheetLeftTopPlaceholder
|
|
9391
|
-
], 10);
|
|
9392
|
-
scene.enableLayerCache(0, 10);
|
|
9393
|
-
}
|
|
9394
|
-
_initViewports(scene, rowHeader, columnHeader) {
|
|
9395
|
-
const rowHeaderWidth = rowHeader.hidden ? 0 : rowHeader.width;
|
|
9396
|
-
const columnHeaderHeight = columnHeader.hidden ? 0 : columnHeader.height;
|
|
9397
|
-
const bufferEdgeX = 100;
|
|
9398
|
-
const bufferEdgeY = 100;
|
|
9399
|
-
const viewMain = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN, scene, {
|
|
9400
|
-
left: rowHeaderWidth,
|
|
9401
|
-
top: columnHeaderHeight,
|
|
9402
|
-
bottom: 0,
|
|
9403
|
-
right: 0,
|
|
9404
|
-
isWheelPreventDefaultX: true,
|
|
9405
|
-
allowCache: true,
|
|
9406
|
-
bufferEdgeX,
|
|
9407
|
-
bufferEdgeY
|
|
9408
|
-
});
|
|
9409
|
-
const viewMainLeftTop = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP, scene, {
|
|
9410
|
-
isWheelPreventDefaultX: true,
|
|
9411
|
-
active: false,
|
|
9412
|
-
allowCache: true,
|
|
9413
|
-
bufferEdgeX: 0,
|
|
9414
|
-
bufferEdgeY: 0
|
|
9415
|
-
});
|
|
9416
|
-
const viewMainLeft = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT, scene, {
|
|
9417
|
-
isWheelPreventDefaultX: true,
|
|
9418
|
-
active: false,
|
|
9419
|
-
allowCache: true,
|
|
9420
|
-
bufferEdgeX: 0,
|
|
9421
|
-
bufferEdgeY
|
|
9422
|
-
});
|
|
9423
|
-
const viewMainTop = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP, scene, {
|
|
9424
|
-
isWheelPreventDefaultX: true,
|
|
9425
|
-
active: false,
|
|
9426
|
-
allowCache: true,
|
|
9427
|
-
bufferEdgeX,
|
|
9428
|
-
bufferEdgeY: 0
|
|
9429
|
-
});
|
|
9430
|
-
const viewRowTop = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP, scene, {
|
|
9431
|
-
active: false,
|
|
9432
|
-
isWheelPreventDefaultX: true
|
|
9433
|
-
});
|
|
9434
|
-
const viewRowBottom = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM, scene, {
|
|
9435
|
-
left: 0,
|
|
9436
|
-
top: columnHeaderHeight,
|
|
9437
|
-
bottom: 0,
|
|
9438
|
-
width: rowHeaderWidth + 1,
|
|
9439
|
-
isWheelPreventDefaultX: true
|
|
9440
|
-
});
|
|
9441
|
-
const viewColumnLeft = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT, scene, {
|
|
9442
|
-
active: false,
|
|
9443
|
-
isWheelPreventDefaultX: true
|
|
9444
|
-
});
|
|
9445
|
-
const viewColumnRight = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT, scene, {
|
|
9446
|
-
left: rowHeaderWidth,
|
|
9447
|
-
top: 0,
|
|
9448
|
-
height: columnHeaderHeight + 1,
|
|
9449
|
-
right: 0,
|
|
9450
|
-
isWheelPreventDefaultX: true
|
|
9451
|
-
});
|
|
9452
|
-
return {
|
|
9453
|
-
viewMain,
|
|
9454
|
-
viewLeftTop: new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP, scene, {
|
|
9455
|
-
left: 0,
|
|
9456
|
-
top: 0,
|
|
9457
|
-
width: rowHeaderWidth,
|
|
9458
|
-
height: columnHeaderHeight,
|
|
9459
|
-
isWheelPreventDefaultX: true
|
|
9460
|
-
}),
|
|
9461
|
-
viewMainLeftTop,
|
|
9462
|
-
viewMainLeft,
|
|
9463
|
-
viewMainTop,
|
|
9464
|
-
viewColumnLeft,
|
|
9465
|
-
viewRowTop,
|
|
9466
|
-
viewRowBottom,
|
|
9467
|
-
viewColumnRight
|
|
9468
|
-
};
|
|
9469
|
-
}
|
|
9470
|
-
/**
|
|
9471
|
-
*
|
|
9472
|
-
* initViewport & wheel event
|
|
9473
|
-
* +-----------------+--------------------+-------------------+
|
|
9474
|
-
* | VIEW_LEFT_TOP | VIEW_COLUMN_LEFT | VIEW_COLUMN_RIGHT |
|
|
9475
|
-
* +-----------------+--------------------+-------------------+
|
|
9476
|
-
* | VIEW_ROW_TOP | VIEW_MAIN_LEFT_TOP | VIEW_MAIN_TOP |
|
|
9477
|
-
* +-----------------+--------------------+-------------------+
|
|
9478
|
-
* | VIEW_ROW_BOTTOM | VIEW_MAIN_LEFT | VIEW_MAIN |
|
|
9479
|
-
* +-----------------+--------------------+-------------------+
|
|
9480
|
-
*/
|
|
9481
|
-
_addViewport(worksheet) {
|
|
9482
|
-
const scene = this._context.scene;
|
|
9483
|
-
const { rowHeader, columnHeader } = worksheet.getConfig();
|
|
9484
|
-
const { viewMain } = this._initViewports(scene, rowHeader, columnHeader);
|
|
9485
|
-
const sheetsUIConfig = this._configService.getConfig(SHEETS_UI_PLUGIN_CONFIG_KEY);
|
|
9486
|
-
new _univerjs_engine_render.ScrollBar(viewMain, sheetsUIConfig === null || sheetsUIConfig === void 0 ? void 0 : sheetsUIConfig.scrollConfig);
|
|
9487
|
-
scene.attachControl();
|
|
9488
|
-
return viewMain;
|
|
9489
|
-
}
|
|
9490
|
-
_initRerenderScheduler() {
|
|
9491
|
-
this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
|
|
9492
|
-
if (!param) return null;
|
|
9493
|
-
const { skeleton: spreadsheetSkeleton, sheetId } = param;
|
|
9494
|
-
const workbook = this._context.unit;
|
|
9495
|
-
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(sheetId);
|
|
9496
|
-
if (workbook == null || worksheet == null) return;
|
|
9497
|
-
const { mainComponent, components } = this._context;
|
|
9498
|
-
const spreadsheet = mainComponent;
|
|
9499
|
-
const spreadsheetRowHeader = components.get("__SpreadsheetRowHeader__");
|
|
9500
|
-
const spreadsheetColumnHeader = components.get("__SpreadsheetColumnHeader__");
|
|
9501
|
-
const spreadsheetLeftTopPlaceholder = components.get("__SpreadsheetLeftTopPlaceholder__");
|
|
9502
|
-
const leftTopPlaceholderSize = getLeftTopPlaceholderSize(spreadsheetSkeleton);
|
|
9503
|
-
spreadsheet === null || spreadsheet === void 0 || spreadsheet.updateSkeleton(spreadsheetSkeleton);
|
|
9504
|
-
spreadsheetRowHeader === null || spreadsheetRowHeader === void 0 || spreadsheetRowHeader.updateSkeleton(spreadsheetSkeleton);
|
|
9505
|
-
spreadsheetColumnHeader === null || spreadsheetColumnHeader === void 0 || spreadsheetColumnHeader.updateSkeleton(spreadsheetSkeleton);
|
|
9506
|
-
spreadsheetLeftTopPlaceholder === null || spreadsheetLeftTopPlaceholder === void 0 || spreadsheetLeftTopPlaceholder.transformByState({
|
|
9507
|
-
width: leftTopPlaceholderSize.width,
|
|
9508
|
-
height: leftTopPlaceholderSize.height
|
|
9509
|
-
});
|
|
9510
|
-
}));
|
|
9511
|
-
}
|
|
9512
|
-
_initCommandListener() {
|
|
9513
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((command, options) => {
|
|
9514
|
-
const { unit: workbook } = this._context;
|
|
9515
|
-
const { id: commandId } = command;
|
|
9516
|
-
if (_univerjs_sheets.COMMAND_LISTENER_SKELETON_CHANGE.includes(commandId) || this._sheetRenderService.checkMutationShouldTriggerRerender(commandId)) {
|
|
9517
|
-
const { unitId, subUnitId } = command.params;
|
|
9518
|
-
const worksheet = workbook.getActiveSheet();
|
|
9519
|
-
if (!worksheet) return;
|
|
9520
|
-
const workbookId = this._context.unitId;
|
|
9521
|
-
const worksheetId = worksheet.getSheetId();
|
|
9522
|
-
if (unitId !== workbookId || subUnitId !== worksheetId) return;
|
|
9523
|
-
this._sheetSkeletonManagerService.makeDirty({
|
|
9524
|
-
sheetId: worksheetId,
|
|
9525
|
-
commandId
|
|
9526
|
-
}, true);
|
|
9527
|
-
this._sheetSkeletonManagerService.setCurrent({
|
|
9528
|
-
sheetId: worksheetId,
|
|
9529
|
-
commandId
|
|
9530
|
-
});
|
|
9531
|
-
} else if (_univerjs_sheets.COMMAND_LISTENER_VALUE_CHANGE.includes(commandId)) this._sheetSkeletonManagerService.reCalculate();
|
|
9532
|
-
if (command.type === _univerjs_core.CommandType.MUTATION) this._markUnitDirty(command, options);
|
|
9533
|
-
}));
|
|
9534
|
-
}
|
|
9535
|
-
_markUnitDirty(command, options) {
|
|
9536
|
-
if (command.id.substring(0, 3) === "doc") return;
|
|
9537
|
-
const { mainComponent: spreadsheet, scene } = this._context;
|
|
9538
|
-
if (command.id === _univerjs_engine_formula.SetFormulaCalculationNotificationMutation.id) {
|
|
9539
|
-
if (command.params.stageInfo != null) return;
|
|
9540
|
-
}
|
|
9541
|
-
if (spreadsheet) spreadsheet.makeDirty();
|
|
9542
|
-
scene.makeDirty();
|
|
9543
|
-
if (!command.params) return;
|
|
9544
|
-
const cmdParams = command.params;
|
|
9545
|
-
const viewports = this._spreadsheetViewports(scene);
|
|
9546
|
-
if (command.id === _univerjs_sheets.SetRangeValuesMutation.id && cmdParams.cellValue && !(options === null || options === void 0 ? void 0 : options.fromChangeset)) {
|
|
9547
|
-
const dirtyRange = this._cellValueToRange(cmdParams.cellValue);
|
|
9548
|
-
const dirtyBounds = this._rangeToBounds([dirtyRange]);
|
|
9549
|
-
this._markViewportDirty(viewports, dirtyBounds);
|
|
9550
|
-
spreadsheet.setDirtyArea(dirtyBounds);
|
|
9551
|
-
}
|
|
9552
|
-
if (command.id === _univerjs_sheets.MoveRangeMutation.id && cmdParams.from && cmdParams.to && !(options === null || options === void 0 ? void 0 : options.fromChangeset)) {
|
|
9553
|
-
const fromRange = cmdParams.fromRange || this._cellValueToRange(cmdParams.from.value);
|
|
9554
|
-
const toRange = cmdParams.toRange || this._cellValueToRange(cmdParams.to.value);
|
|
9555
|
-
const dirtyBounds = this._rangeToBounds([fromRange, toRange]);
|
|
9556
|
-
this._markViewportDirty(viewports, dirtyBounds);
|
|
9557
|
-
spreadsheet.setDirtyArea(dirtyBounds);
|
|
9558
|
-
}
|
|
9559
|
-
}
|
|
9560
|
-
/**
|
|
9561
|
-
* cellValue data structure:
|
|
9562
|
-
* {[row]: { [col]: value}}
|
|
9563
|
-
* @param cellValue
|
|
9564
|
-
* @returns IRange
|
|
9565
|
-
*/
|
|
9566
|
-
_cellValueToRange(cellValue) {
|
|
9567
|
-
const columns = [];
|
|
9568
|
-
let minCol = 0;
|
|
9569
|
-
let maxCol = 0;
|
|
9570
|
-
let minRow = 0;
|
|
9571
|
-
let maxRow = 0;
|
|
9572
|
-
for (const [_row, columnObj] of Object.entries(cellValue)) {
|
|
9573
|
-
for (const column in columnObj) {
|
|
9574
|
-
columns.push(Number(column));
|
|
9575
|
-
if (minCol > Number(column)) minCol = Number(column);
|
|
9576
|
-
if (maxCol < Number(column)) maxCol = Number(column);
|
|
9577
|
-
}
|
|
9578
|
-
if (minRow > Number(_row)) minRow = Number(_row);
|
|
9579
|
-
if (maxRow < Number(_row)) maxRow = Number(_row);
|
|
9580
|
-
}
|
|
9581
|
-
return {
|
|
9582
|
-
startRow: minRow,
|
|
9583
|
-
endRow: maxRow,
|
|
9584
|
-
startColumn: minCol,
|
|
9585
|
-
endColumn: maxCol
|
|
9586
|
-
};
|
|
9587
|
-
}
|
|
9588
|
-
_rangeToBounds(ranges) {
|
|
9589
|
-
const { rowHeightAccumulation, columnWidthAccumulation, rowHeaderWidth, columnHeaderHeight } = this._sheetSkeletonManagerService.getCurrentParam().skeleton;
|
|
9590
|
-
const dirtyBounds = [];
|
|
9591
|
-
for (const r of ranges) {
|
|
9592
|
-
const { startRow, endRow, startColumn, endColumn } = r;
|
|
9593
|
-
const top = startRow === 0 ? 0 : rowHeightAccumulation[startRow - 1] + columnHeaderHeight;
|
|
9594
|
-
const bottom = rowHeightAccumulation[endRow] + columnHeaderHeight;
|
|
9595
|
-
const left = startColumn === 0 ? 0 : columnWidthAccumulation[startColumn - 1] + rowHeaderWidth;
|
|
9596
|
-
const right = columnWidthAccumulation[endColumn] + rowHeaderWidth;
|
|
9597
|
-
dirtyBounds.push({
|
|
9598
|
-
top,
|
|
9599
|
-
left,
|
|
9600
|
-
bottom,
|
|
9601
|
-
right,
|
|
9602
|
-
width: right - left,
|
|
9603
|
-
height: bottom - top
|
|
9604
|
-
});
|
|
9605
|
-
}
|
|
9606
|
-
return dirtyBounds;
|
|
9607
|
-
}
|
|
9608
|
-
_markViewportDirty(viewports, dirtyBounds) {
|
|
9609
|
-
const activeViewports = viewports.filter((vp) => vp.isActive && vp.cacheBound);
|
|
9610
|
-
for (const vp of activeViewports) for (const b of dirtyBounds) if (_univerjs_core.Rectangle.hasIntersectionBetweenTwoRect(vp.cacheBound, b)) vp.markDirty(true);
|
|
9611
|
-
}
|
|
9612
|
-
_spreadsheetViewports(scene) {
|
|
9613
|
-
return scene.getViewports().filter((v) => [
|
|
9614
|
-
"viewMain",
|
|
9615
|
-
"viewMainLeftTop",
|
|
9616
|
-
"viewMainTop",
|
|
9617
|
-
"viewMainLeft"
|
|
9618
|
-
].includes(v.viewportKey));
|
|
9619
|
-
}
|
|
9620
|
-
};
|
|
9621
|
-
SheetRenderController = __decorate([
|
|
9622
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.IConfigService)),
|
|
9623
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(SheetSkeletonManagerService)),
|
|
9624
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(SheetsRenderService)),
|
|
9625
|
-
__decorateParam(4, _univerjs_core.ICommandService),
|
|
9626
|
-
__decorateParam(5, (0, _univerjs_core.Optional)(_univerjs_telemetry.ITelemetryService))
|
|
9627
|
-
], SheetRenderController);
|
|
9628
|
-
function getLeftTopPlaceholderSize(skeleton) {
|
|
9629
|
-
return {
|
|
9630
|
-
width: skeleton.rowHeaderWidthAndMarginLeft ?? skeleton.rowHeaderWidth,
|
|
9631
|
-
height: skeleton.columnHeaderHeightAndMarginTop ?? skeleton.columnHeaderHeight
|
|
9632
|
-
};
|
|
9633
|
-
}
|
|
9634
|
-
|
|
9635
|
-
//#endregion
|
|
9636
|
-
//#region src/controllers/render-controllers/skeleton.render-controller.ts
|
|
9637
|
-
let SheetSkeletonRenderController = class SheetSkeletonRenderController extends _univerjs_core.Disposable {
|
|
9638
|
-
constructor(_context, _sheetSkeletonManagerService, _renderManagerService) {
|
|
9639
|
-
super();
|
|
9640
|
-
this._context = _context;
|
|
9641
|
-
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
9642
|
-
this._renderManagerService = _renderManagerService;
|
|
9643
|
-
this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
|
|
9644
|
-
this._updateSceneSize(param);
|
|
9645
|
-
}));
|
|
9646
|
-
}
|
|
9647
|
-
_updateSceneSize(param) {
|
|
9648
|
-
var _this$_renderManagerS;
|
|
9649
|
-
if (param == null) return;
|
|
9650
|
-
const { unitId } = this._context;
|
|
9651
|
-
const { skeleton } = param;
|
|
9652
|
-
const scene = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
|
|
9653
|
-
if (skeleton == null || scene == null) return;
|
|
9654
|
-
const { rowTotalHeight, columnTotalWidth, rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = skeleton;
|
|
9655
|
-
if (!this._context.unit.getActiveSheet()) return;
|
|
9656
|
-
scene === null || scene === void 0 || scene.transformByState({
|
|
9657
|
-
width: rowHeaderWidthAndMarginLeft + columnTotalWidth,
|
|
9658
|
-
height: columnHeaderHeightAndMarginTop + rowTotalHeight
|
|
9659
|
-
});
|
|
9660
|
-
scene.getMainViewport().setMargin(rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop);
|
|
9661
|
-
}
|
|
9662
|
-
};
|
|
9663
|
-
SheetSkeletonRenderController = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(SheetSkeletonManagerService)), __decorateParam(2, _univerjs_engine_render.IRenderManagerService)], SheetSkeletonRenderController);
|
|
9664
|
-
|
|
9665
|
-
//#endregion
|
|
9666
|
-
//#region src/services/sheet-loading-render.service.ts
|
|
9667
|
-
const PREVIEW_UNIT_SUFFIX = "__snapshot_loading_preview__";
|
|
9668
|
-
const PREVIEW_SCENE_PREFIX = "_UNIVER_SCENE_";
|
|
9669
|
-
const PREVIEW_CANVAS_Z_INDEX = "9";
|
|
9670
|
-
const ISheetLoadingRenderService = (0, _univerjs_core.createIdentifier)("sheets-ui.sheet-loading-render.service");
|
|
9671
|
-
let SheetLoadingRenderService = class SheetLoadingRenderService extends _univerjs_core.Disposable {
|
|
9672
|
-
constructor(_injector, _layoutService, _sheetInterceptorService, _renderManagerService) {
|
|
9673
|
-
super();
|
|
9674
|
-
this._injector = _injector;
|
|
9675
|
-
this._layoutService = _layoutService;
|
|
9676
|
-
this._sheetInterceptorService = _sheetInterceptorService;
|
|
9677
|
-
this._renderManagerService = _renderManagerService;
|
|
9678
|
-
_defineProperty(this, "workbook$", new rxjs.BehaviorSubject(null));
|
|
9679
|
-
_defineProperty(this, "loading$", new rxjs.BehaviorSubject(false));
|
|
9680
|
-
_defineProperty(this, "previewReady$", new rxjs.BehaviorSubject(false));
|
|
9681
|
-
_defineProperty(this, "_loadingRender", null);
|
|
9682
|
-
_defineProperty(this, "_finalCanvasGuard", null);
|
|
9683
|
-
_defineProperty(this, "_hiddenFinalCanvas", null);
|
|
9684
|
-
_defineProperty(this, "_finalCanvasVisibility", "");
|
|
9685
|
-
}
|
|
9686
|
-
showSkeleton(workbookData, activeSheetId) {
|
|
9687
|
-
var _this$_loadingRender;
|
|
9688
|
-
const sourceUnitId = workbookData.id;
|
|
9689
|
-
if (((_this$_loadingRender = this._loadingRender) === null || _this$_loadingRender === void 0 ? void 0 : _this$_loadingRender.sourceUnitId) !== sourceUnitId) {
|
|
9690
|
-
this._disposeLoadingRender();
|
|
9691
|
-
this.previewReady$.next(false);
|
|
9692
|
-
this._loadingRender = {
|
|
9693
|
-
sourceUnitId,
|
|
9694
|
-
workbook: this._createLoadingWorkbook(workbookData, activeSheetId),
|
|
9695
|
-
render: null
|
|
9696
|
-
};
|
|
9697
|
-
this.workbook$.next(this._loadingRender.workbook);
|
|
9698
|
-
this.loading$.next(true);
|
|
9699
|
-
this._guardFinalCanvas(sourceUnitId);
|
|
9700
|
-
}
|
|
9701
|
-
const worksheet = this._loadingRender.workbook.getSheetBySheetId(activeSheetId);
|
|
9702
|
-
if (worksheet && this._loadingRender.workbook.getActiveSheet().getSheetId() !== activeSheetId) this._loadingRender.workbook.setActiveSheet(worksheet);
|
|
9703
|
-
}
|
|
9704
|
-
show(workbookData, activeSheetId, cellData) {
|
|
9705
|
-
this.showSkeleton(workbookData, activeSheetId);
|
|
9706
|
-
const loadingRender = this._loadingRender;
|
|
9707
|
-
if (!loadingRender) return;
|
|
9708
|
-
let shouldRender = false;
|
|
9709
|
-
if (!loadingRender.render) {
|
|
9710
|
-
const contentElement = this._layoutService.getContentElement();
|
|
9711
|
-
if (!contentElement) return;
|
|
9712
|
-
loadingRender.render = this._createLoadingRender(loadingRender.workbook, loadingRender.sourceUnitId, contentElement);
|
|
9713
|
-
shouldRender = true;
|
|
9714
|
-
}
|
|
9715
|
-
const worksheet = loadingRender.workbook.getSheetBySheetId(activeSheetId);
|
|
9716
|
-
if (!worksheet) return;
|
|
9717
|
-
if (loadingRender.workbook.getActiveSheet().getSheetId() !== activeSheetId) {
|
|
9718
|
-
loadingRender.workbook.setActiveSheet(worksheet);
|
|
9719
|
-
loadingRender.render.with(SheetSkeletonManagerService).setCurrent({ sheetId: activeSheetId });
|
|
9720
|
-
shouldRender = true;
|
|
9721
|
-
}
|
|
9722
|
-
if (cellData && cellData !== loadingRender.lastCellData) {
|
|
9723
|
-
loadingRender.lastCellData = cellData;
|
|
9724
|
-
const target = worksheet.getCellMatrix();
|
|
9725
|
-
const getDisplayCell = this._sheetInterceptorService.fetchThroughInterceptors(_univerjs_sheets.INTERCEPTOR_POINT.CELL_CONTENT, _univerjs_core.InterceptorEffectEnum.Value | _univerjs_core.InterceptorEffectEnum.Style);
|
|
9726
|
-
new _univerjs_core.ObjectMatrix(cellData).forValue((row, column, rawData) => {
|
|
9727
|
-
const displayCell = getDisplayCell(rawData, {
|
|
9728
|
-
unitId: loadingRender.sourceUnitId,
|
|
9729
|
-
subUnitId: activeSheetId,
|
|
9730
|
-
row,
|
|
9731
|
-
col: column,
|
|
9732
|
-
workbook: loadingRender.workbook,
|
|
9733
|
-
worksheet,
|
|
9734
|
-
rawData
|
|
9735
|
-
});
|
|
9736
|
-
target.setValue(row, column, displayCell);
|
|
9737
|
-
});
|
|
9738
|
-
const skeletonManager = loadingRender.render.with(SheetSkeletonManagerService);
|
|
9739
|
-
skeletonManager.makeDirty({ sheetId: activeSheetId });
|
|
9740
|
-
skeletonManager.reCalculate();
|
|
9741
|
-
if (loadingRender.render.mainComponent instanceof _univerjs_engine_render.Spreadsheet) loadingRender.render.mainComponent.makeForceDirty(true);
|
|
9742
|
-
loadingRender.render.scene.makeDirty(true);
|
|
9743
|
-
shouldRender = true;
|
|
9744
|
-
}
|
|
9745
|
-
if (shouldRender) loadingRender.render.scene.render();
|
|
9746
|
-
if (!this.previewReady$.value) this.previewReady$.next(true);
|
|
9747
|
-
}
|
|
9748
|
-
async handoff(sourceUnitId, timeoutMs) {
|
|
9749
|
-
var _this$_loadingRender2, _this$_finalCanvasGua;
|
|
9750
|
-
if (((_this$_loadingRender2 = this._loadingRender) === null || _this$_loadingRender2 === void 0 ? void 0 : _this$_loadingRender2.sourceUnitId) !== sourceUnitId) return true;
|
|
9751
|
-
if (!this._loadingRender.render) {
|
|
9752
|
-
this.hide(sourceUnitId);
|
|
9753
|
-
return true;
|
|
9754
|
-
}
|
|
9755
|
-
(_this$_finalCanvasGua = this._finalCanvasGuard) === null || _this$_finalCanvasGua === void 0 || _this$_finalCanvasGua.unsubscribe();
|
|
9756
|
-
this._finalCanvasGuard = null;
|
|
9757
|
-
try {
|
|
9758
|
-
await (0, rxjs.firstValueFrom)(this._getFinalRender$(sourceUnitId).pipe((0, rxjs.take)(1), (0, rxjs.switchMap)((render) => this._waitForFinalCanvas(render).pipe((0, rxjs.switchMap)(() => {
|
|
9759
|
-
this._hideFinalCanvas(render);
|
|
9760
|
-
return this._requestFinalRender(render);
|
|
9761
|
-
}))), (0, rxjs.timeout)(timeoutMs)));
|
|
9762
|
-
this.hide(sourceUnitId);
|
|
9763
|
-
return true;
|
|
9764
|
-
} catch {
|
|
9765
|
-
return false;
|
|
9766
|
-
}
|
|
9767
|
-
}
|
|
9768
|
-
hide(sourceUnitId) {
|
|
9769
|
-
var _this$_loadingRender3;
|
|
9770
|
-
if (((_this$_loadingRender3 = this._loadingRender) === null || _this$_loadingRender3 === void 0 ? void 0 : _this$_loadingRender3.sourceUnitId) !== sourceUnitId) return;
|
|
9771
|
-
this._disposeLoadingRender();
|
|
9772
|
-
}
|
|
9773
|
-
dispose() {
|
|
9774
|
-
this._disposeLoadingRender();
|
|
9775
|
-
this.workbook$.complete();
|
|
9776
|
-
this.loading$.complete();
|
|
9777
|
-
this.previewReady$.complete();
|
|
9778
|
-
super.dispose();
|
|
9779
|
-
}
|
|
9780
|
-
_createLoadingWorkbook(workbookData, activeSheetId) {
|
|
9781
|
-
const previewUnitId = `${workbookData.id}${PREVIEW_UNIT_SUFFIX}`;
|
|
9782
|
-
const workbook = this._injector.createInstance(_univerjs_core.Workbook, {
|
|
9783
|
-
...workbookData,
|
|
9784
|
-
id: previewUnitId
|
|
9785
|
-
});
|
|
9786
|
-
const activeSheet = workbook.getSheetBySheetId(activeSheetId);
|
|
9787
|
-
if (activeSheet) workbook.setActiveSheet(activeSheet);
|
|
9788
|
-
return workbook;
|
|
9789
|
-
}
|
|
9790
|
-
_createLoadingRender(workbook, sourceUnitId, contentElement) {
|
|
9791
|
-
const previewUnitId = workbook.getUnitId();
|
|
9792
|
-
const { width, height } = contentElement.getBoundingClientRect();
|
|
9793
|
-
const engine = this._injector.createInstance(_univerjs_engine_render.Engine, previewUnitId, void 0);
|
|
9794
|
-
const scene = new _univerjs_engine_render.Scene(`${PREVIEW_SCENE_PREFIX}${previewUnitId}`, engine, {
|
|
9795
|
-
width,
|
|
9796
|
-
height
|
|
9797
|
-
});
|
|
9798
|
-
scene.disableObjectsEvent();
|
|
9799
|
-
const render = this._injector.createInstance(_univerjs_engine_render.RenderUnit, {
|
|
9800
|
-
unit: workbook,
|
|
9801
|
-
engine,
|
|
9802
|
-
scene,
|
|
9803
|
-
isMainScene: true
|
|
9804
|
-
});
|
|
9805
|
-
try {
|
|
9806
|
-
render.addRenderDependencies([
|
|
9807
|
-
[SheetSkeletonManagerService],
|
|
9808
|
-
[SheetSkeletonRenderController],
|
|
9809
|
-
[SheetRenderController]
|
|
9810
|
-
]);
|
|
9811
|
-
const canvas = engine.getCanvas();
|
|
9812
|
-
canvas.setId(`univer-sheet-loading-canvas_${sourceUnitId}`);
|
|
9813
|
-
canvas.getCanvasEle().dataset.uUnitId = sourceUnitId;
|
|
9814
|
-
canvas.getCanvasEle().style.pointerEvents = "none";
|
|
9815
|
-
canvas.getCanvasEle().style.zIndex = PREVIEW_CANVAS_Z_INDEX;
|
|
9816
|
-
engine.mount(contentElement);
|
|
9817
|
-
return render;
|
|
9818
|
-
} catch (error) {
|
|
9819
|
-
this._disposeRender(render);
|
|
9820
|
-
throw error;
|
|
9821
|
-
}
|
|
9822
|
-
}
|
|
9823
|
-
_waitForFinalCanvas(render) {
|
|
9824
|
-
return new rxjs.Observable((subscriber) => {
|
|
9825
|
-
let frameId;
|
|
9826
|
-
const canvasElement = render.engine.getCanvasElement();
|
|
9827
|
-
const checkMounted = () => {
|
|
9828
|
-
const contentElement = this._layoutService.getContentElement();
|
|
9829
|
-
if (contentElement && canvasElement.parentElement === contentElement && canvasElement.width > 0 && canvasElement.height > 0) {
|
|
9830
|
-
subscriber.next();
|
|
9831
|
-
subscriber.complete();
|
|
9832
|
-
return;
|
|
9833
|
-
}
|
|
9834
|
-
frameId = window.requestAnimationFrame(checkMounted);
|
|
9835
|
-
};
|
|
9836
|
-
checkMounted();
|
|
9837
|
-
return () => {
|
|
9838
|
-
if (frameId !== void 0) window.cancelAnimationFrame(frameId);
|
|
9839
|
-
};
|
|
9840
|
-
});
|
|
9841
|
-
}
|
|
9842
|
-
_getFinalRender$(sourceUnitId) {
|
|
9843
|
-
const existingRender = this._renderManagerService.getRenderUnitById(sourceUnitId);
|
|
9844
|
-
return existingRender ? (0, rxjs.of)(existingRender) : this._renderManagerService.created$.pipe((0, rxjs.filter)((render) => render.unitId === sourceUnitId));
|
|
9845
|
-
}
|
|
9846
|
-
_guardFinalCanvas(sourceUnitId) {
|
|
9847
|
-
var _this$_finalCanvasGua2;
|
|
9848
|
-
(_this$_finalCanvasGua2 = this._finalCanvasGuard) === null || _this$_finalCanvasGua2 === void 0 || _this$_finalCanvasGua2.unsubscribe();
|
|
9849
|
-
this._finalCanvasGuard = this._getFinalRender$(sourceUnitId).pipe((0, rxjs.take)(1), (0, rxjs.switchMap)((render) => this._waitForFinalCanvas(render).pipe((0, rxjs.map)(() => render)))).subscribe((render) => this._hideFinalCanvas(render));
|
|
9850
|
-
}
|
|
9851
|
-
_requestFinalRender(render) {
|
|
9852
|
-
render.scene.makeDirty(true);
|
|
9853
|
-
return (0, rxjs.from)(render.scene.requestRender()).pipe((0, rxjs.switchMap)(() => this._waitForNextAnimationFrame()));
|
|
9854
|
-
}
|
|
9855
|
-
_hideFinalCanvas(render) {
|
|
9856
|
-
const canvasElement = render.engine.getCanvasElement();
|
|
9857
|
-
if (this._hiddenFinalCanvas === canvasElement) return;
|
|
9858
|
-
this._restoreFinalCanvas();
|
|
9859
|
-
this._hiddenFinalCanvas = canvasElement;
|
|
9860
|
-
this._finalCanvasVisibility = canvasElement.style.visibility;
|
|
9861
|
-
canvasElement.style.visibility = "hidden";
|
|
9862
|
-
}
|
|
9863
|
-
_restoreFinalCanvas() {
|
|
9864
|
-
if (!this._hiddenFinalCanvas) return;
|
|
9865
|
-
this._hiddenFinalCanvas.style.visibility = this._finalCanvasVisibility;
|
|
9866
|
-
this._hiddenFinalCanvas = null;
|
|
9867
|
-
this._finalCanvasVisibility = "";
|
|
9868
|
-
}
|
|
9869
|
-
_waitForNextAnimationFrame() {
|
|
9870
|
-
return new rxjs.Observable((subscriber) => {
|
|
9871
|
-
const frameId = window.requestAnimationFrame(() => {
|
|
9872
|
-
subscriber.next();
|
|
9873
|
-
subscriber.complete();
|
|
9874
|
-
});
|
|
9875
|
-
return () => window.cancelAnimationFrame(frameId);
|
|
9876
|
-
});
|
|
9877
|
-
}
|
|
9878
|
-
_disposeLoadingRender() {
|
|
9879
|
-
var _this$_finalCanvasGua3;
|
|
9880
|
-
(_this$_finalCanvasGua3 = this._finalCanvasGuard) === null || _this$_finalCanvasGua3 === void 0 || _this$_finalCanvasGua3.unsubscribe();
|
|
9881
|
-
this._finalCanvasGuard = null;
|
|
9882
|
-
this._restoreFinalCanvas();
|
|
9883
|
-
const loadingRender = this._loadingRender;
|
|
9884
|
-
this._loadingRender = null;
|
|
9885
|
-
this.workbook$.next(null);
|
|
9886
|
-
this.loading$.next(false);
|
|
9887
|
-
this.previewReady$.next(false);
|
|
9888
|
-
if (!loadingRender) return;
|
|
9889
|
-
if (loadingRender.render) this._disposeRender(loadingRender.render);
|
|
9890
|
-
loadingRender.workbook.dispose();
|
|
9891
|
-
}
|
|
9892
|
-
_disposeRender(render) {
|
|
9893
|
-
render.components.forEach((component) => component.dispose());
|
|
9894
|
-
render.scene.dispose();
|
|
9895
|
-
render.dispose();
|
|
9896
|
-
render.engine.dispose();
|
|
9897
|
-
}
|
|
9898
|
-
};
|
|
9899
|
-
SheetLoadingRenderService = __decorate([
|
|
9900
|
-
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
9901
|
-
__decorateParam(1, _univerjs_ui.ILayoutService),
|
|
9902
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
9903
|
-
__decorateParam(3, _univerjs_engine_render.IRenderManagerService)
|
|
9904
|
-
], SheetLoadingRenderService);
|
|
9905
|
-
|
|
9906
|
-
//#endregion
|
|
9907
|
-
//#region src/views/hook.ts
|
|
9908
|
-
const SheetLoadingWorkbookContext = (0, react.createContext)(null);
|
|
9909
|
-
function useActiveWorkbook() {
|
|
9910
|
-
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
9911
|
-
const loadingWorkbook = (0, react.useContext)(SheetLoadingWorkbookContext);
|
|
9912
|
-
const workbook = (0, _univerjs_ui.useObservable)(() => univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET), void 0, void 0, []);
|
|
9913
|
-
return loadingWorkbook ?? workbook ?? null;
|
|
9914
|
-
}
|
|
9915
|
-
function useSheetLoadingWorkbook() {
|
|
9916
|
-
return (0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(ISheetLoadingRenderService).workbook$) ?? null;
|
|
9917
|
-
}
|
|
9918
|
-
function useSheetLoading() {
|
|
9919
|
-
return (0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(ISheetLoadingRenderService).loading$) ?? false;
|
|
9920
|
-
}
|
|
9921
|
-
function useSheetLoadingPreviewReady() {
|
|
9922
|
-
return (0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(ISheetLoadingRenderService).previewReady$) ?? false;
|
|
9923
|
-
}
|
|
9924
|
-
function useActiveWorksheet(workbook) {
|
|
9925
|
-
return (0, _univerjs_ui.useObservable)(() => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? (0, rxjs.of)(null), void 0, void 0, [workbook]);
|
|
9926
|
-
}
|
|
9927
|
-
function useWorkbooks() {
|
|
9928
|
-
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
9929
|
-
return (0, _univerjs_ui.useObservable)(() => {
|
|
9930
|
-
return (0, rxjs.merge)([univerInstanceService.getTypeOfUnitAdded$(_univerjs_core.UniverInstanceType.UNIVER_SHEET), univerInstanceService.getTypeOfUnitDisposed$(_univerjs_core.UniverInstanceType.UNIVER_SHEET)]).pipe((0, rxjs.map)(() => univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)), (0, rxjs.startWith)(univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)));
|
|
9931
|
-
}, [], void 0, [univerInstanceService]);
|
|
9932
|
-
}
|
|
9933
|
-
|
|
9934
|
-
//#endregion
|
|
9935
|
-
//#region src/views/clipboard/ClipboardPopupMenu.tsx
|
|
9936
|
-
const DEFAULT_PADDING = 2;
|
|
9937
|
-
const SheetPasteOptions = [
|
|
9938
|
-
{
|
|
9939
|
-
value: "DEFAULT_PASTE",
|
|
9940
|
-
label: "sheets-ui.rightClick.paste"
|
|
9941
|
-
},
|
|
9942
|
-
{
|
|
9943
|
-
value: "SPECIAL_PASTE_VALUE",
|
|
9944
|
-
label: "sheets-ui.rightClick.pasteValue"
|
|
9945
|
-
},
|
|
9946
|
-
{
|
|
9947
|
-
value: "SPECIAL_PASTE_FORMAT",
|
|
9948
|
-
label: "sheets-ui.rightClick.pasteFormat"
|
|
9949
|
-
},
|
|
9950
|
-
{
|
|
9951
|
-
value: "SPECIAL_PASTE_COL_WIDTH",
|
|
9952
|
-
label: "sheets-ui.rightClick.pasteColWidth"
|
|
9953
|
-
},
|
|
9954
|
-
{
|
|
9955
|
-
value: "SPECIAL_PASTE_BESIDES_BORDER",
|
|
9956
|
-
label: "sheets-ui.rightClick.pasteBesidesBorder"
|
|
9957
|
-
},
|
|
9958
|
-
{
|
|
9959
|
-
value: "SPECIAL_PASTE_FORMULA",
|
|
9960
|
-
label: "sheets-ui.rightClick.pasteFormula"
|
|
9961
|
-
}
|
|
9962
|
-
];
|
|
9963
|
-
const useMenuPosition = (range) => {
|
|
9964
|
-
var _scene$getEngine;
|
|
9965
|
-
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
9966
|
-
const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
|
|
9967
|
-
const workbook = useActiveWorkbook();
|
|
9968
|
-
if (!range || !workbook) return null;
|
|
9969
|
-
const anchor = {
|
|
9970
|
-
startRow: range.rows[0],
|
|
9971
|
-
startCol: range.cols[0],
|
|
9972
|
-
endRow: range.rows[range.rows.length - 1],
|
|
9973
|
-
endCol: range.cols[range.cols.length - 1]
|
|
9974
|
-
};
|
|
9975
|
-
if (anchor.endRow < 0 || anchor.endCol < 0) return null;
|
|
9976
|
-
const ru = renderManagerService.getRenderUnitById(workbook.getUnitId());
|
|
9977
|
-
const sheetSkeletonManagerService = ru === null || ru === void 0 ? void 0 : ru.with(SheetSkeletonManagerService);
|
|
9978
|
-
const sheetObject = getSheetObject(univerInstanceService, renderManagerService);
|
|
9979
|
-
if (!sheetObject) return null;
|
|
9980
|
-
const { scene } = sheetObject;
|
|
9981
|
-
const skeleton = sheetSkeletonManagerService === null || sheetSkeletonManagerService === void 0 ? void 0 : sheetSkeletonManagerService.getCurrentSkeleton();
|
|
9982
|
-
const viewport = getViewportByCell(anchor.endRow, anchor.endCol, scene, workbook.getActiveSheet());
|
|
9983
|
-
if (!viewport) return null;
|
|
9984
|
-
const scaleX = scene === null || scene === void 0 ? void 0 : scene.scaleX;
|
|
9985
|
-
const scaleY = scene === null || scene === void 0 ? void 0 : scene.scaleY;
|
|
9986
|
-
const scrollXY = scene === null || scene === void 0 ? void 0 : scene.getViewportScrollXY(viewport);
|
|
9987
|
-
const canvas = (_scene$getEngine = scene.getEngine()) === null || _scene$getEngine === void 0 ? void 0 : _scene$getEngine.getCanvas();
|
|
9988
|
-
if (!scaleX || !scene || !scaleX || !scaleY || !scrollXY) return null;
|
|
9989
|
-
const endPosition = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getNoMergeCellWithCoordByIndex(anchor.endRow, anchor.endCol);
|
|
9990
|
-
const endX = (endPosition === null || endPosition === void 0 ? void 0 : endPosition.endX) ?? 0;
|
|
9991
|
-
const endY = (endPosition === null || endPosition === void 0 ? void 0 : endPosition.endY) ?? 0;
|
|
9992
|
-
const positionEndX = (0, _univerjs_engine_render.convertTransformToOffsetX)(endX, scaleX, scrollXY) ?? -9999;
|
|
9993
|
-
const positionEndY = (0, _univerjs_engine_render.convertTransformToOffsetY)(endY, scaleY, scrollXY) ?? -9999;
|
|
9994
|
-
const canvasWidth = canvas === null || canvas === void 0 ? void 0 : canvas.getWidth();
|
|
9995
|
-
const canvasHeight = canvas === null || canvas === void 0 ? void 0 : canvas.getHeight();
|
|
9996
|
-
if (!canvasWidth || !canvasHeight) return null;
|
|
9997
|
-
const XInSideView = positionEndX + 50 <= canvasWidth;
|
|
9998
|
-
const YInSideView = positionEndY + 50 <= canvasHeight;
|
|
9999
|
-
let positionX = positionEndX;
|
|
10000
|
-
let positionY = positionEndY;
|
|
10001
|
-
if (!XInSideView) positionX = canvasWidth - 100;
|
|
10002
|
-
if (!YInSideView) positionY = canvasHeight - 100;
|
|
10003
|
-
return {
|
|
10004
|
-
positionX,
|
|
10005
|
-
positionY
|
|
10006
|
-
};
|
|
10007
|
-
};
|
|
10008
|
-
const ClipboardPopupMenu = () => {
|
|
10009
|
-
const clipboardService = (0, _univerjs_ui.useDependency)(ISheetClipboardService);
|
|
10010
|
-
const showMenu = (0, _univerjs_ui.useObservable)(clipboardService.showMenu$, false);
|
|
10011
|
-
const pasteOptionsCache = (0, _univerjs_ui.useObservable)(clipboardService.pasteOptionsCache$, null);
|
|
10012
|
-
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
10013
|
-
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
10014
|
-
const [menuHovered, setMenuHovered] = (0, react.useState)(false);
|
|
10015
|
-
const [visible, setVisible] = (0, react.useState)(false);
|
|
10016
|
-
const range = pasteOptionsCache === null || pasteOptionsCache === void 0 ? void 0 : pasteOptionsCache.target.pastedRange;
|
|
10017
|
-
const relativePosition = useMenuPosition(range);
|
|
10018
|
-
if (!relativePosition || !showMenu) return null;
|
|
10019
|
-
if (relativePosition.positionX < 50 || relativePosition.positionY < 30) return null;
|
|
10020
|
-
const showMore = menuHovered || visible;
|
|
10021
|
-
const handleClick = (type) => {
|
|
10022
|
-
setVisible(false);
|
|
10023
|
-
commandService.executeCommand(SheetOptionalPasteCommand.id, { type });
|
|
10024
|
-
};
|
|
10025
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
10026
|
-
className: "univer-absolute univer-inset-0 univer-z-10 univer-size-0",
|
|
10027
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
10028
|
-
className: "univer-absolute",
|
|
10029
|
-
style: {
|
|
10030
|
-
left: relativePosition.positionX + DEFAULT_PADDING,
|
|
10031
|
-
top: relativePosition.positionY + DEFAULT_PADDING
|
|
10032
|
-
},
|
|
10033
|
-
onMouseEnter: () => setMenuHovered(true),
|
|
10034
|
-
onMouseLeave: () => setMenuHovered(false),
|
|
10035
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
10036
|
-
align: "start",
|
|
10037
|
-
items: SheetPasteOptions.map((item) => ({
|
|
10038
|
-
type: "checkbox",
|
|
10039
|
-
value: item.value,
|
|
10040
|
-
label: localeService.t(item.label),
|
|
10041
|
-
checked: (pasteOptionsCache === null || pasteOptionsCache === void 0 ? void 0 : pasteOptionsCache.pasteType) === PREDEFINED_HOOK_NAME_PASTE[item.value],
|
|
10042
|
-
onSelect: () => handleClick(item.value)
|
|
10043
|
-
})),
|
|
10044
|
-
open: visible,
|
|
10045
|
-
onOpenChange: setVisible,
|
|
10046
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
10047
|
-
className: (0, _univerjs_design.clsx)("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", _univerjs_design.borderClassName, {
|
|
10048
|
-
"univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
|
|
10049
|
-
"univer-bg-white dark:!univer-bg-gray-900": !visible
|
|
10050
|
-
}),
|
|
10051
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.PasteSpecialDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white" }), showMore && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "dark:!univer-text-white" })]
|
|
10052
|
-
})
|
|
10053
|
-
})
|
|
10054
|
-
})
|
|
10055
|
-
});
|
|
10056
|
-
};
|
|
10057
|
-
|
|
10058
|
-
//#endregion
|
|
10059
|
-
//#region src/controllers/clipboard/const.ts
|
|
10060
|
-
/**
|
|
10061
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
10062
|
-
*
|
|
10063
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10064
|
-
* you may not use this file except in compliance with the License.
|
|
10065
|
-
* You may obtain a copy of the License at
|
|
10066
|
-
*
|
|
10067
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10068
|
-
*
|
|
10069
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
10070
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10071
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10072
|
-
* See the License for the specific language governing permissions and
|
|
10073
|
-
* limitations under the License.
|
|
10074
|
-
*/
|
|
10075
|
-
const RemovePasteMenuCommands = [
|
|
10076
|
-
SetCellEditVisibleOperation.id,
|
|
10077
|
-
_univerjs_sheets.SetRangeValuesCommand.id,
|
|
10078
|
-
SetZoomRatioOperation.id,
|
|
10079
|
-
_univerjs_sheets.MoveRangeMutation.id,
|
|
10080
|
-
_univerjs_sheets.RemoveRowMutation.id,
|
|
10081
|
-
_univerjs_sheets.RemoveColMutation.id,
|
|
10082
|
-
_univerjs_sheets.InsertRowMutation.id,
|
|
10083
|
-
_univerjs_sheets.InsertColMutation.id,
|
|
10084
|
-
_univerjs_sheets.MoveRowsMutation.id,
|
|
10085
|
-
_univerjs_sheets.MoveColsMutation.id,
|
|
10086
|
-
_univerjs_sheets.SetWorksheetColWidthMutation.id,
|
|
10087
|
-
_univerjs_sheets.SetWorksheetRowHeightMutation.id,
|
|
10088
|
-
_univerjs_sheets.SetSelectionsOperation.id,
|
|
10089
|
-
_univerjs_core.UndoCommandId
|
|
10090
|
-
];
|
|
10091
|
-
|
|
10092
|
-
//#endregion
|
|
10093
|
-
//#region src/services/editor/cell-editor-manager.service.ts
|
|
10094
|
-
var CellEditorManagerService = class {
|
|
10095
|
-
constructor() {
|
|
10096
|
-
_defineProperty(this, "_state", null);
|
|
10097
|
-
_defineProperty(this, "_rect", null);
|
|
10098
|
-
_defineProperty(this, "_state$", new rxjs.BehaviorSubject(null));
|
|
10099
|
-
_defineProperty(this, "state$", this._state$.asObservable());
|
|
10100
|
-
_defineProperty(this, "_rect$", new rxjs.BehaviorSubject(null));
|
|
10101
|
-
_defineProperty(this, "rect$", this._rect$.asObservable());
|
|
10102
|
-
_defineProperty(this, "_focus", false);
|
|
10103
|
-
_defineProperty(this, "_focus$", new rxjs.BehaviorSubject(this._focus));
|
|
10104
|
-
_defineProperty(this, "focus$", this._focus$.asObservable());
|
|
10105
|
-
}
|
|
10106
|
-
dispose() {
|
|
10107
|
-
this._state$.complete();
|
|
10108
|
-
this._state = null;
|
|
10109
|
-
this._rect$.complete();
|
|
10110
|
-
this._rect = null;
|
|
10111
|
-
}
|
|
10112
|
-
setState(param) {
|
|
10113
|
-
this._state = param;
|
|
10114
|
-
this._refresh(param);
|
|
10115
|
-
}
|
|
10116
|
-
getRect() {
|
|
10117
|
-
return this._rect;
|
|
10118
|
-
}
|
|
10119
|
-
setRect(param) {
|
|
10120
|
-
this._rect = param;
|
|
10121
|
-
this._rect$.next(param);
|
|
10122
|
-
}
|
|
10123
|
-
getState() {
|
|
10124
|
-
return this._state;
|
|
10125
|
-
}
|
|
10126
|
-
setFocus(param = false) {
|
|
10127
|
-
this._focus = param;
|
|
10128
|
-
this._focus$.next(param);
|
|
10129
|
-
}
|
|
10130
|
-
_refresh(param) {
|
|
10131
|
-
this._state$.next(param);
|
|
10132
|
-
}
|
|
10133
|
-
};
|
|
10134
|
-
const ICellEditorManagerService = (0, _univerjs_core.createIdentifier)("univer.sheet-cell-editor-manager.service");
|
|
10135
|
-
|
|
10136
|
-
//#endregion
|
|
10137
|
-
//#region src/services/sheet-embed-integration.service.ts
|
|
10138
|
-
const SHEET_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE = "data-embed-interaction-boundary-owner";
|
|
10139
|
-
const SHEET_EMBED_RUNTIME_FOCUS_ROLE_ATTRIBUTE = "data-embed-runtime-focus-role";
|
|
10140
|
-
const SHEET_EMBED_FLOAT_DOM_ATTRIBUTE = "data-embed-float-dom";
|
|
10141
|
-
const SHEET_EMBED_ID_ATTRIBUTE = "data-embed-id";
|
|
10142
|
-
const SHEET_EMBED_HOST_UNIT_ID_ATTRIBUTE = "data-embed-host-unit-id";
|
|
10143
|
-
const SHEET_EMBED_CHILD_UNIT_ID_ATTRIBUTE = "data-embed-child-unit-id";
|
|
10144
|
-
const SHEET_EMBED_CHILD_TYPE_ATTRIBUTE = "data-embed-child-type";
|
|
10145
|
-
const ISheetEmbedInteractionBoundaryService = (0, _univerjs_core.createIdentifier)("sheets-ui.embed-interaction-boundary.service");
|
|
10146
|
-
const ISheetEmbedRuntimeFocusCoordinator = (0, _univerjs_core.createIdentifier)("sheets-ui.embed-runtime-focus-coordinator");
|
|
10147
|
-
const ISheetEmbedFloatingGeometryService = (0, _univerjs_core.createIdentifier)("sheets-ui.embed-floating-geometry.service");
|
|
10148
|
-
function resolveSheetEmbedRuntimeDomScope(element) {
|
|
10149
|
-
var _element$closest;
|
|
10150
|
-
if (!element) return;
|
|
10151
|
-
const embedId = ((_element$closest = element.closest(`[${"data-embed-interaction-boundary-owner"}]`)) === null || _element$closest === void 0 ? void 0 : _element$closest.getAttribute("data-embed-interaction-boundary-owner")) ?? void 0;
|
|
10152
|
-
const container = resolveSheetEmbedFloatDomContainer(element, embedId);
|
|
10153
|
-
const resolvedEmbedId = (container === null || container === void 0 ? void 0 : container.getAttribute("data-embed-id")) ?? embedId;
|
|
10154
|
-
if (!resolvedEmbedId) return;
|
|
10155
|
-
return {
|
|
10156
|
-
embedId: resolvedEmbedId,
|
|
10157
|
-
hostUnitId: (container === null || container === void 0 ? void 0 : container.getAttribute("data-embed-host-unit-id")) ?? void 0,
|
|
10158
|
-
childUnitId: (container === null || container === void 0 ? void 0 : container.getAttribute("data-embed-child-unit-id")) ?? void 0,
|
|
10159
|
-
childType: readChildType(container)
|
|
10160
|
-
};
|
|
10161
|
-
}
|
|
10162
|
-
function resolveActiveSheetEmbedRuntimeDomScope(ownerDocument = document) {
|
|
10163
|
-
const activeContainer = ownerDocument.querySelector(`[${SHEET_EMBED_FLOAT_DOM_ATTRIBUTE}="true"][data-embed-float-stage="stage2"]`);
|
|
10164
|
-
if (!activeContainer) return;
|
|
10165
|
-
return resolveSheetEmbedRuntimeDomScope(activeContainer);
|
|
10166
|
-
}
|
|
10167
|
-
function resolveSheetEmbedFloatDomContainer(element, embedId) {
|
|
10168
|
-
const ownContainer = element === null || element === void 0 ? void 0 : element.closest(`[${SHEET_EMBED_FLOAT_DOM_ATTRIBUTE}="true"]`);
|
|
10169
|
-
if (ownContainer && (!embedId || ownContainer.getAttribute("data-embed-id") === embedId)) return ownContainer;
|
|
10170
|
-
const ownerDocument = (element === null || element === void 0 ? void 0 : element.ownerDocument) ?? (typeof document === "undefined" ? void 0 : document);
|
|
10171
|
-
if (!ownerDocument || !embedId) return ownContainer ?? void 0;
|
|
10172
|
-
return ownerDocument.querySelector(`[${"data-embed-float-dom"}="true"][${"data-embed-id"}="${escapeAttributeValue(embedId)}"]`) ?? void 0;
|
|
10173
|
-
}
|
|
10174
|
-
function escapeAttributeValue(value) {
|
|
10175
|
-
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
10176
|
-
}
|
|
10177
|
-
function readChildType(container) {
|
|
10178
|
-
const value = container === null || container === void 0 ? void 0 : container.getAttribute(SHEET_EMBED_CHILD_TYPE_ATTRIBUTE);
|
|
10179
|
-
if (value == null || value === "") return;
|
|
10180
|
-
return Number(value);
|
|
10181
|
-
}
|
|
10182
|
-
|
|
10183
|
-
//#endregion
|
|
10184
|
-
//#region src/services/editor/cell-editor-resize.service.ts
|
|
10185
|
-
const EDITOR_INPUT_SELF_EXTEND_GAP = 5;
|
|
10186
|
-
const EDITOR_BORDER_SIZE = 2;
|
|
10187
|
-
let SheetCellEditorResizeService = class SheetCellEditorResizeService extends _univerjs_core.Disposable {
|
|
10188
|
-
constructor(_layoutService, _cellEditorManagerService, _editorBridgeService, _renderManagerService, _univerInstanceService, _configService, _embedFloatingGeometryService) {
|
|
10189
|
-
super();
|
|
10190
|
-
this._layoutService = _layoutService;
|
|
10191
|
-
this._cellEditorManagerService = _cellEditorManagerService;
|
|
10192
|
-
this._editorBridgeService = _editorBridgeService;
|
|
10193
|
-
this._renderManagerService = _renderManagerService;
|
|
10194
|
-
this._univerInstanceService = _univerInstanceService;
|
|
10195
|
-
this._configService = _configService;
|
|
10196
|
-
this._embedFloatingGeometryService = _embedFloatingGeometryService;
|
|
10197
|
-
}
|
|
10198
|
-
get _currentRenderer() {
|
|
10199
|
-
return (0, _univerjs_engine_render.getCurrentTypeOfRenderer)(_univerjs_core.UniverInstanceType.UNIVER_SHEET, this._univerInstanceService, this._renderManagerService);
|
|
10200
|
-
}
|
|
10201
|
-
get _editingUnitId() {
|
|
10202
|
-
var _this$_editorBridgeSe;
|
|
10203
|
-
return ((_this$_editorBridgeSe = this._editorBridgeService.getEditCellState()) === null || _this$_editorBridgeSe === void 0 ? void 0 : _this$_editorBridgeSe.unitId) ?? "";
|
|
10204
|
-
}
|
|
10205
|
-
get _editingRenderer() {
|
|
10206
|
-
return this._renderManagerService.getRenderUnitById(this._editingUnitId);
|
|
10207
|
-
}
|
|
10208
|
-
get _renderer() {
|
|
10209
|
-
return this._editingRenderer ?? this._currentRenderer;
|
|
10210
|
-
}
|
|
10211
|
-
get _sheetSkeletonManagerService() {
|
|
10212
|
-
var _this$_renderer;
|
|
10213
|
-
return (_this$_renderer = this._renderer) === null || _this$_renderer === void 0 ? void 0 : _this$_renderer.with(SheetSkeletonManagerService);
|
|
10214
|
-
}
|
|
10215
|
-
get engine() {
|
|
10216
|
-
var _this$_renderer2;
|
|
10217
|
-
return (_this$_renderer2 = this._renderer) === null || _this$_renderer2 === void 0 ? void 0 : _this$_renderer2.engine;
|
|
10218
|
-
}
|
|
10219
|
-
fitTextSize(callback) {
|
|
10220
|
-
const param = this._editorBridgeService.getEditCellState();
|
|
10221
|
-
if (!param) return;
|
|
10222
|
-
const { position, documentLayoutObject, canvasOffset, scaleX, scaleY } = param;
|
|
10223
|
-
const { startX, startY, endX, endY } = position;
|
|
10224
|
-
const documentDataModel = this._univerInstanceService.getUnit(_univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
10225
|
-
if (documentDataModel == null) return;
|
|
10226
|
-
const documentSkeleton = this._getEditorSkeleton();
|
|
10227
|
-
if (!documentSkeleton) return;
|
|
10228
|
-
documentSkeleton.resetInitialWidth();
|
|
10229
|
-
const info = this._predictingSize(position, canvasOffset, documentSkeleton, documentLayoutObject, scaleX, scaleY);
|
|
10230
|
-
if (!info || info.actualWidth <= 0) return;
|
|
10231
|
-
let { actualWidth, actualHeight } = info;
|
|
10232
|
-
const { verticalAlign, horizontalAlign, paddingData, fill } = documentLayoutObject;
|
|
10233
|
-
actualWidth = actualWidth + (paddingData.l ?? 0) * scaleX + (paddingData.r ?? 0) * scaleX;
|
|
10234
|
-
actualHeight = actualHeight + (paddingData.t ?? 0) * scaleY + (paddingData.b ?? 0) * scaleY;
|
|
10235
|
-
let editorWidth = endX - startX;
|
|
10236
|
-
let editorHeight = endY - startY;
|
|
10237
|
-
if (editorWidth < actualWidth) editorWidth = Math.ceil(actualWidth);
|
|
10238
|
-
if (editorHeight < actualHeight) editorHeight = Math.ceil(actualHeight);
|
|
10239
|
-
let offsetTop = 0;
|
|
10240
|
-
if (verticalAlign === _univerjs_core.VerticalAlign.MIDDLE) offsetTop = (editorHeight - actualHeight) / 2 / scaleY;
|
|
10241
|
-
else if (verticalAlign === _univerjs_core.VerticalAlign.TOP) offsetTop = paddingData.t || 0;
|
|
10242
|
-
else offsetTop = (editorHeight - actualHeight) / scaleY;
|
|
10243
|
-
let offsetLeft = 0;
|
|
10244
|
-
if (horizontalAlign === _univerjs_core.HorizontalAlign.CENTER) {} else if (horizontalAlign === _univerjs_core.HorizontalAlign.RIGHT) offsetLeft = (editorWidth - actualWidth) / scaleX;
|
|
10245
|
-
else offsetLeft = paddingData.l || 0;
|
|
10246
|
-
offsetTop = Math.max(offsetTop, paddingData.t || 0);
|
|
10247
|
-
offsetLeft = Math.max(offsetLeft, paddingData.l || 0);
|
|
10248
|
-
documentDataModel.updateDocumentDataMargin({
|
|
10249
|
-
t: offsetTop,
|
|
10250
|
-
l: offsetLeft
|
|
10251
|
-
});
|
|
10252
|
-
documentSkeleton.calculate();
|
|
10253
|
-
this._editAreaProcessing(editorWidth, editorHeight, position, canvasOffset, fill, scaleX, scaleY, horizontalAlign, callback);
|
|
10254
|
-
}
|
|
10255
|
-
/**
|
|
10256
|
-
* Mainly used to pre-calculate the width of the editor,
|
|
10257
|
-
* to determine whether it needs to be automatically widened.
|
|
10258
|
-
*/
|
|
10259
|
-
_predictingSize(actualRangeWithCoord, canvasOffset, documentSkeleton, documentLayoutObject, scaleX = 1, scaleY = 1) {
|
|
10260
|
-
const { startX, endX } = actualRangeWithCoord;
|
|
10261
|
-
const { textRotation, wrapStrategy, paddingData } = documentLayoutObject;
|
|
10262
|
-
const documentDataModel = this._univerInstanceService.getUnit(_univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
10263
|
-
const { vertexAngle: angle } = (0, _univerjs_engine_render.convertTextRotation)(textRotation);
|
|
10264
|
-
if (wrapStrategy === _univerjs_core.WrapStrategy.WRAP && angle === 0) {
|
|
10265
|
-
documentDataModel === null || documentDataModel === void 0 || documentDataModel.updateDocumentDataPageSize((endX - startX) / scaleX);
|
|
10266
|
-
documentDataModel === null || documentDataModel === void 0 || documentDataModel.updateDocumentDataMargin({
|
|
10267
|
-
l: paddingData.l,
|
|
10268
|
-
t: paddingData.t
|
|
10269
|
-
});
|
|
10270
|
-
documentSkeleton.calculate();
|
|
10271
|
-
const { actualWidth, actualHeight } = documentSkeleton.getActualSize();
|
|
10272
|
-
return {
|
|
10273
|
-
actualWidth: actualWidth * scaleX,
|
|
10274
|
-
actualHeight: actualHeight * scaleY
|
|
10275
|
-
};
|
|
10276
|
-
}
|
|
10277
|
-
const maxSize = this._getEditorMaxSize(actualRangeWithCoord, canvasOffset, documentLayoutObject.horizontalAlign);
|
|
10278
|
-
if (!maxSize) return;
|
|
10279
|
-
documentDataModel === null || documentDataModel === void 0 || documentDataModel.updateDocumentDataPageSize(maxSize.width / scaleX);
|
|
10280
|
-
documentSkeleton.calculate();
|
|
10281
|
-
const size = documentSkeleton.getActualSize();
|
|
10282
|
-
let editorWidth = endX - startX;
|
|
10283
|
-
if (editorWidth < size.actualWidth * scaleX + EDITOR_INPUT_SELF_EXTEND_GAP * scaleX) editorWidth = size.actualWidth * scaleX + EDITOR_INPUT_SELF_EXTEND_GAP * scaleX;
|
|
10284
|
-
documentDataModel === null || documentDataModel === void 0 || documentDataModel.updateDocumentDataPageSize(editorWidth / scaleX);
|
|
10285
|
-
/**
|
|
10286
|
-
* Do not rely on cell layout logic, depend on the document's internal alignment logic.
|
|
10287
|
-
*/
|
|
10288
|
-
documentDataModel === null || documentDataModel === void 0 || documentDataModel.updateDocumentRenderConfig({
|
|
10289
|
-
horizontalAlign: _univerjs_core.HorizontalAlign.UNSPECIFIED,
|
|
10290
|
-
cellValueType: void 0
|
|
10291
|
-
});
|
|
10292
|
-
return {
|
|
10293
|
-
actualWidth: size.actualWidth * scaleX,
|
|
10294
|
-
actualHeight: size.actualHeight * scaleY
|
|
9711
|
+
return {
|
|
9712
|
+
actualWidth: size.actualWidth * scaleX,
|
|
9713
|
+
actualHeight: size.actualHeight * scaleY
|
|
10295
9714
|
};
|
|
10296
9715
|
}
|
|
10297
9716
|
_getEditorMaxSize(position, canvasOffset, horizontalAlign) {
|
|
@@ -10569,7 +9988,9 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends _u
|
|
|
10569
9988
|
if (!sheetObject) return;
|
|
10570
9989
|
const { spreadsheet, spreadsheetColumnHeader, spreadsheetLeftTopPlaceholder, spreadsheetRowHeader } = sheetObject;
|
|
10571
9990
|
d.add(spreadsheet.onDblclick$.subscribeEvent((evt) => {
|
|
9991
|
+
var _this$_editorBridgeSe;
|
|
10572
9992
|
if (evt.button === 2) return;
|
|
9993
|
+
if ((0, _univerjs_sheets.isCellImage)((_this$_editorBridgeSe = this._editorBridgeService.getEditCellState()) === null || _this$_editorBridgeSe === void 0 || (_this$_editorBridgeSe = _this$_editorBridgeSe.documentLayoutObject.documentModel) === null || _this$_editorBridgeSe === void 0 ? void 0 : _this$_editorBridgeSe.getSnapshot())) return;
|
|
10573
9994
|
this._commandService.executeCommand(SetCellEditVisibleOperation.id, {
|
|
10574
9995
|
visible: true,
|
|
10575
9996
|
eventType: _univerjs_engine_render.DeviceInputEventType.Dblclick,
|
|
@@ -10665,9 +10086,9 @@ let EditorBridgeRenderController = class EditorBridgeRenderController extends _u
|
|
|
10665
10086
|
this._hideEditor();
|
|
10666
10087
|
}
|
|
10667
10088
|
_isEmbeddedFormulaEditorActive() {
|
|
10668
|
-
var _this$_embedRuntimeFo2, _this$
|
|
10089
|
+
var _this$_embedRuntimeFo2, _this$_editorBridgeSe2;
|
|
10669
10090
|
if (((_this$_embedRuntimeFo2 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo2 === void 0 ? void 0 : _this$_embedRuntimeFo2.isChildUnitInActiveSession(this._context.unitId)) !== true) return false;
|
|
10670
|
-
const dataStream = (_this$
|
|
10091
|
+
const dataStream = (_this$_editorBridgeSe2 = this._editorBridgeService.getEditCellState()) === null || _this$_editorBridgeSe2 === void 0 || (_this$_editorBridgeSe2 = _this$_editorBridgeSe2.documentLayoutObject.documentModel) === null || _this$_editorBridgeSe2 === void 0 || (_this$_editorBridgeSe2 = _this$_editorBridgeSe2.getSnapshot().body) === null || _this$_editorBridgeSe2 === void 0 ? void 0 : _this$_editorBridgeSe2.dataStream;
|
|
10671
10092
|
return typeof dataStream === "string" && dataStream.startsWith("=");
|
|
10672
10093
|
}
|
|
10673
10094
|
_isCurrentEmbedRuntimeEvent(evt) {
|
|
@@ -14003,7 +13424,7 @@ let SheetPermissionCheckUIController = class SheetPermissionCheckUIController ex
|
|
|
14003
13424
|
workbookTypes: [_univerjs_sheets.WorkbookEditablePermission],
|
|
14004
13425
|
worksheetTypes: [_univerjs_sheets.WorksheetSetCellValuePermission, _univerjs_sheets.WorksheetEditPermission],
|
|
14005
13426
|
rangeTypes: [_univerjs_sheets.RangeProtectionPermissionEditPoint]
|
|
14006
|
-
});
|
|
13427
|
+
}, params.unitId);
|
|
14007
13428
|
errorMsg = this._localeService.t("sheets-ui.permission.dialog.editErr");
|
|
14008
13429
|
break;
|
|
14009
13430
|
case ApplyFormatPainterCommand.id:
|
|
@@ -15754,9 +15175,9 @@ var HeaderUnhideRangeService = class {
|
|
|
15754
15175
|
|
|
15755
15176
|
//#endregion
|
|
15756
15177
|
//#region src/menu/header-menu-shape.ts
|
|
15757
|
-
const HEADER_MENU_SHAPE_CIRCLE_FILL = "
|
|
15758
|
-
const HEADER_MENU_SHAPE_TRIANGLE_FILL = "
|
|
15759
|
-
const HEADER_MENU_BACKGROUND_COLOR = "
|
|
15178
|
+
const HEADER_MENU_SHAPE_CIRCLE_FILL = "gray.200";
|
|
15179
|
+
const HEADER_MENU_SHAPE_TRIANGLE_FILL = "gray.900";
|
|
15180
|
+
const HEADER_MENU_BACKGROUND_COLOR = "gray.50";
|
|
15760
15181
|
var HeaderMenuShape = class extends _univerjs_engine_render.Shape {
|
|
15761
15182
|
constructor(key, props) {
|
|
15762
15183
|
super(key, props);
|
|
@@ -15929,157 +15350,549 @@ var HeaderUnhideShape = class extends _univerjs_engine_render.Shape {
|
|
|
15929
15350
|
]],
|
|
15930
15351
|
fill: HEADER_MENU_SHAPE_TRIANGLE_FILL
|
|
15931
15352
|
});
|
|
15932
|
-
if (this._hasNext) {
|
|
15933
|
-
const offset = this._hasPrevious ? 3 : 1;
|
|
15934
|
-
_univerjs_engine_render.RegularPolygon.drawWith(ctx, {
|
|
15935
|
-
pointsGroup: [[
|
|
15936
|
-
{
|
|
15937
|
-
x: top + this._size * offset / 2,
|
|
15938
|
-
y: this._size / 2
|
|
15939
|
-
},
|
|
15940
|
-
{
|
|
15941
|
-
x: -left + this._size * offset / 2,
|
|
15942
|
-
y: this._size / 2 - left
|
|
15943
|
-
},
|
|
15944
|
-
{
|
|
15945
|
-
x: -left + this._size * offset / 2,
|
|
15946
|
-
y: this._size / 2 + left
|
|
15947
|
-
}
|
|
15948
|
-
]],
|
|
15949
|
-
fill: HEADER_MENU_SHAPE_TRIANGLE_FILL
|
|
15950
|
-
});
|
|
15951
|
-
}
|
|
15353
|
+
if (this._hasNext) {
|
|
15354
|
+
const offset = this._hasPrevious ? 3 : 1;
|
|
15355
|
+
_univerjs_engine_render.RegularPolygon.drawWith(ctx, {
|
|
15356
|
+
pointsGroup: [[
|
|
15357
|
+
{
|
|
15358
|
+
x: top + this._size * offset / 2,
|
|
15359
|
+
y: this._size / 2
|
|
15360
|
+
},
|
|
15361
|
+
{
|
|
15362
|
+
x: -left + this._size * offset / 2,
|
|
15363
|
+
y: this._size / 2 - left
|
|
15364
|
+
},
|
|
15365
|
+
{
|
|
15366
|
+
x: -left + this._size * offset / 2,
|
|
15367
|
+
y: this._size / 2 + left
|
|
15368
|
+
}
|
|
15369
|
+
]],
|
|
15370
|
+
fill: HEADER_MENU_SHAPE_TRIANGLE_FILL
|
|
15371
|
+
});
|
|
15372
|
+
}
|
|
15373
|
+
}
|
|
15374
|
+
};
|
|
15375
|
+
|
|
15376
|
+
//#endregion
|
|
15377
|
+
//#region src/controllers/render-controllers/header-unhide.render-controller.ts
|
|
15378
|
+
const HEADER_UNHIDE_CONTROLLER_SHAPE = "__SpreadsheetHeaderUnhideSHAPEControllerShape__";
|
|
15379
|
+
const HEADER_UNHIDE_RANGE_VISIBLE_CHECK = (0, _univerjs_core.createInterceptorKey)("headerUnhideRangeVisibleCheck");
|
|
15380
|
+
let HeaderUnhideRenderController = class HeaderUnhideRenderController extends _univerjs_core.RxDisposable {
|
|
15381
|
+
get _workbook() {
|
|
15382
|
+
return this._context.unit;
|
|
15383
|
+
}
|
|
15384
|
+
constructor(_context, _sheetSkeletonManagerService, _headerUnhideRangeService, _commandService) {
|
|
15385
|
+
super();
|
|
15386
|
+
this._context = _context;
|
|
15387
|
+
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
15388
|
+
this._headerUnhideRangeService = _headerUnhideRangeService;
|
|
15389
|
+
this._commandService = _commandService;
|
|
15390
|
+
_defineProperty(this, "_shapes", {
|
|
15391
|
+
cols: [],
|
|
15392
|
+
rows: []
|
|
15393
|
+
});
|
|
15394
|
+
_defineProperty(this, "interceptor", new _univerjs_core.InterceptorManager({ HEADER_UNHIDE_RANGE_VISIBLE_CHECK }));
|
|
15395
|
+
this._init();
|
|
15396
|
+
}
|
|
15397
|
+
dispose() {
|
|
15398
|
+
super.dispose();
|
|
15399
|
+
this._clearShapes();
|
|
15400
|
+
}
|
|
15401
|
+
_init() {
|
|
15402
|
+
let activeSheetId = "";
|
|
15403
|
+
this._context.unit.activeSheet$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((worksheet) => {
|
|
15404
|
+
this._clearShapes();
|
|
15405
|
+
if (!worksheet) {
|
|
15406
|
+
activeSheetId = "";
|
|
15407
|
+
return;
|
|
15408
|
+
}
|
|
15409
|
+
activeSheetId = worksheet.getSheetId();
|
|
15410
|
+
this._update(this._workbook, worksheet);
|
|
15411
|
+
});
|
|
15412
|
+
this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
|
|
15413
|
+
if (param) {
|
|
15414
|
+
const { unitId, sheetId } = param;
|
|
15415
|
+
if (unitId === this._workbook.getUnitId() && sheetId === activeSheetId) {
|
|
15416
|
+
const worksheet = this._workbook.getSheetBySheetId(sheetId);
|
|
15417
|
+
if (worksheet) this._update(this._workbook, worksheet);
|
|
15418
|
+
}
|
|
15419
|
+
}
|
|
15420
|
+
}));
|
|
15421
|
+
}
|
|
15422
|
+
_update(workbook, worksheet) {
|
|
15423
|
+
var _this$_sheetSkeletonM;
|
|
15424
|
+
const skeleton = (_this$_sheetSkeletonM = this._sheetSkeletonManagerService.getSkeletonParam(worksheet.getSheetId())) === null || _this$_sheetSkeletonM === void 0 ? void 0 : _this$_sheetSkeletonM.skeleton;
|
|
15425
|
+
if (!skeleton) return;
|
|
15426
|
+
const visibleCheck = this.interceptor.fetchThroughInterceptors(HEADER_UNHIDE_RANGE_VISIBLE_CHECK);
|
|
15427
|
+
const shouldRenderRange = (payload) => this._headerUnhideRangeService.shouldRenderRange(visibleCheck(true, payload) ?? true, payload);
|
|
15428
|
+
const hiddenRowRanges = worksheet.getHiddenRows().filter((range) => shouldRenderRange({
|
|
15429
|
+
axis: "row",
|
|
15430
|
+
range,
|
|
15431
|
+
workbook,
|
|
15432
|
+
worksheet
|
|
15433
|
+
}));
|
|
15434
|
+
const hiddenColRanges = worksheet.getHiddenCols().filter((range) => shouldRenderRange({
|
|
15435
|
+
axis: "column",
|
|
15436
|
+
range,
|
|
15437
|
+
workbook,
|
|
15438
|
+
worksheet
|
|
15439
|
+
}));
|
|
15440
|
+
const { scene } = this._getSheetObject();
|
|
15441
|
+
const rowCount = worksheet.getRowCount();
|
|
15442
|
+
const rowShapes = hiddenRowRanges.map((range) => {
|
|
15443
|
+
const { startRow, endRow } = range;
|
|
15444
|
+
const position = getCoordByCell(startRow, 0, scene, skeleton);
|
|
15445
|
+
const hasPrevious = startRow !== 0;
|
|
15446
|
+
const hasNext = endRow !== rowCount - 1;
|
|
15447
|
+
return new HeaderUnhideShape(HEADER_UNHIDE_CONTROLLER_SHAPE, {
|
|
15448
|
+
type: 0,
|
|
15449
|
+
hovered: false,
|
|
15450
|
+
hasPrevious,
|
|
15451
|
+
hasNext,
|
|
15452
|
+
top: position.startY - (hasPrevious ? 12 : 0),
|
|
15453
|
+
left: position.startX - 12
|
|
15454
|
+
}, () => this._commandService.executeCommand(_univerjs_sheets.SetSpecificRowsVisibleCommand.id, {
|
|
15455
|
+
unitId: workbook.getUnitId(),
|
|
15456
|
+
subUnitId: worksheet.getSheetId(),
|
|
15457
|
+
ranges: [range]
|
|
15458
|
+
}));
|
|
15459
|
+
});
|
|
15460
|
+
const colCount = worksheet.getColumnCount();
|
|
15461
|
+
const colShapes = hiddenColRanges.map((range) => {
|
|
15462
|
+
const { startColumn, endColumn } = range;
|
|
15463
|
+
const position = getCoordByCell(0, startColumn, scene, skeleton);
|
|
15464
|
+
const hasPrevious = startColumn !== 0;
|
|
15465
|
+
const hasNext = endColumn !== colCount - 1;
|
|
15466
|
+
return new HeaderUnhideShape(HEADER_UNHIDE_CONTROLLER_SHAPE, {
|
|
15467
|
+
type: 1,
|
|
15468
|
+
hovered: false,
|
|
15469
|
+
hasPrevious,
|
|
15470
|
+
hasNext,
|
|
15471
|
+
top: Math.max(skeleton.columnHeaderHeight, skeleton.columnHeaderHeightAndMarginTop) - 12,
|
|
15472
|
+
left: position.startX - (hasPrevious ? 12 : 0)
|
|
15473
|
+
}, () => this._commandService.executeCommand(_univerjs_sheets.SetSpecificColsVisibleCommand.id, {
|
|
15474
|
+
unitId: workbook.getUnitId(),
|
|
15475
|
+
subUnitId: worksheet.getSheetId(),
|
|
15476
|
+
ranges: [range]
|
|
15477
|
+
}));
|
|
15478
|
+
});
|
|
15479
|
+
scene.addObjects(colShapes, 12);
|
|
15480
|
+
scene.addObjects(rowShapes, 12);
|
|
15481
|
+
this._clearShapes();
|
|
15482
|
+
this._shapes = {
|
|
15483
|
+
cols: colShapes,
|
|
15484
|
+
rows: rowShapes
|
|
15485
|
+
};
|
|
15486
|
+
}
|
|
15487
|
+
_clearShapes() {
|
|
15488
|
+
this._shapes.cols.forEach((shape) => shape.dispose());
|
|
15489
|
+
this._shapes.rows.forEach((shape) => shape.dispose());
|
|
15490
|
+
this._shapes = {
|
|
15491
|
+
cols: [],
|
|
15492
|
+
rows: []
|
|
15493
|
+
};
|
|
15494
|
+
}
|
|
15495
|
+
_getSheetObject() {
|
|
15496
|
+
return getSheetObject(this._workbook, this._context);
|
|
15952
15497
|
}
|
|
15953
15498
|
};
|
|
15499
|
+
HeaderUnhideRenderController = __decorate([
|
|
15500
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(SheetSkeletonManagerService)),
|
|
15501
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(HeaderUnhideRangeService)),
|
|
15502
|
+
__decorateParam(3, _univerjs_core.ICommandService)
|
|
15503
|
+
], HeaderUnhideRenderController);
|
|
15954
15504
|
|
|
15955
15505
|
//#endregion
|
|
15956
|
-
//#region src/controllers/render-controllers/
|
|
15957
|
-
const
|
|
15958
|
-
|
|
15959
|
-
|
|
15960
|
-
get _workbook() {
|
|
15961
|
-
return this._context.unit;
|
|
15962
|
-
}
|
|
15963
|
-
constructor(_context, _sheetSkeletonManagerService, _headerUnhideRangeService, _commandService) {
|
|
15506
|
+
//#region src/controllers/render-controllers/sheet.render-controller.ts
|
|
15507
|
+
const FRAME_STACK_THRESHOLD = 60;
|
|
15508
|
+
let SheetRenderController = class SheetRenderController extends _univerjs_core.RxDisposable {
|
|
15509
|
+
constructor(_context, _configService, _sheetSkeletonManagerService, _sheetRenderService, _commandService, _telemetryService) {
|
|
15964
15510
|
super();
|
|
15965
15511
|
this._context = _context;
|
|
15512
|
+
this._configService = _configService;
|
|
15966
15513
|
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
15967
|
-
this.
|
|
15514
|
+
this._sheetRenderService = _sheetRenderService;
|
|
15968
15515
|
this._commandService = _commandService;
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15516
|
+
this._telemetryService = _telemetryService;
|
|
15517
|
+
_defineProperty(this, "_renderMetric$", new rxjs.Subject());
|
|
15518
|
+
_defineProperty(this, "renderMetric$", this._renderMetric$.asObservable());
|
|
15519
|
+
_defineProperty(this, "_renderFrameTimeMetric", null);
|
|
15520
|
+
_defineProperty(this, "_renderFrameTags", {});
|
|
15521
|
+
_defineProperty(this, "_afterRenderMetric$", new rxjs.Subject());
|
|
15522
|
+
this._addNewRender();
|
|
15523
|
+
this._initRenderMetricSubscriber();
|
|
15524
|
+
}
|
|
15525
|
+
_addNewRender() {
|
|
15526
|
+
const { scene, engine, unit: workbook } = this._context;
|
|
15527
|
+
this._addComponent(workbook);
|
|
15528
|
+
this._initRerenderScheduler();
|
|
15529
|
+
this._initCommandListener();
|
|
15530
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
15531
|
+
if (!worksheet) throw new Error("No active sheet found");
|
|
15532
|
+
const sheetId = worksheet.getSheetId();
|
|
15533
|
+
this._sheetSkeletonManagerService.setCurrent({ sheetId });
|
|
15534
|
+
const frameFn = () => scene.render();
|
|
15535
|
+
this.disposeWithMe(this._context.activated$.subscribe((activated) => {
|
|
15536
|
+
if (activated) engine.runRenderLoop(frameFn);
|
|
15537
|
+
else engine.stopRenderLoop(frameFn);
|
|
15538
|
+
}));
|
|
15539
|
+
}
|
|
15540
|
+
_initRenderMetricSubscriber() {
|
|
15541
|
+
const { engine } = this._context;
|
|
15542
|
+
this.disposeWithMe(engine.beginFrame$.subscribe(() => {
|
|
15543
|
+
this._renderFrameTimeMetric = null;
|
|
15544
|
+
this._renderFrameTags = {};
|
|
15545
|
+
}));
|
|
15546
|
+
this.disposeWithMe(engine.endFrame$.subscribe(() => {
|
|
15547
|
+
if (this._renderFrameTimeMetric && Object.keys(this._renderFrameTimeMetric).some((key) => key.startsWith(_univerjs_engine_render.SHEET_EXTENSION_PREFIX))) this._afterRenderMetric$.next({
|
|
15548
|
+
frameTimeMetric: this._renderFrameTimeMetric,
|
|
15549
|
+
tags: this._renderFrameTags
|
|
15550
|
+
});
|
|
15551
|
+
}));
|
|
15552
|
+
this.disposeWithMe(engine.renderFrameTimeMetric$.subscribe(([key, value]) => {
|
|
15553
|
+
if (!this._renderFrameTimeMetric) this._renderFrameTimeMetric = {};
|
|
15554
|
+
if (!this._renderFrameTimeMetric[key]) this._renderFrameTimeMetric[key] = [];
|
|
15555
|
+
this._renderFrameTimeMetric[key].push(Math.round(value * 100) / 100);
|
|
15556
|
+
}));
|
|
15557
|
+
this.disposeWithMe(engine.renderFrameTags$.subscribe(([key, value]) => {
|
|
15558
|
+
this._renderFrameTags[key] = value;
|
|
15559
|
+
}));
|
|
15560
|
+
const frameInfoList = [];
|
|
15561
|
+
this.disposeWithMe(this._afterRenderMetric$.pipe((0, rxjs.withLatestFrom)(engine.endFrame$)).subscribe(([sceneRenderDetail, basicFrameTimeInfo]) => {
|
|
15562
|
+
frameInfoList.push({
|
|
15563
|
+
FPS: basicFrameTimeInfo.FPS,
|
|
15564
|
+
elapsedTime: basicFrameTimeInfo.elapsedTime,
|
|
15565
|
+
frameTime: Math.round(basicFrameTimeInfo.frameTime * 100) / 100,
|
|
15566
|
+
...sceneRenderDetail.frameTimeMetric,
|
|
15567
|
+
...sceneRenderDetail.tags
|
|
15568
|
+
});
|
|
15569
|
+
if (frameInfoList.length > FRAME_STACK_THRESHOLD) {
|
|
15570
|
+
this._captureRenderMetric(frameInfoList);
|
|
15571
|
+
frameInfoList.length = 0;
|
|
15572
|
+
}
|
|
15573
|
+
}));
|
|
15574
|
+
}
|
|
15575
|
+
/**
|
|
15576
|
+
* Send render metric to telemetry service
|
|
15577
|
+
* @param frameInfoList
|
|
15578
|
+
*/
|
|
15579
|
+
_captureRenderMetric(frameInfoList) {
|
|
15580
|
+
var _this$_telemetryServi;
|
|
15581
|
+
const filteredFrameInfo = frameInfoList;
|
|
15582
|
+
if (filteredFrameInfo.length === 0) return;
|
|
15583
|
+
const sumValueForNumListFields = (data) => {
|
|
15584
|
+
let totalSum = 0;
|
|
15585
|
+
const sums = Object.entries(data).filter(([_, value]) => Array.isArray(value)).map(([key]) => key).reduce((acc, key) => {
|
|
15586
|
+
acc[key] = data[key].reduce((sum, num) => sum + num, 0);
|
|
15587
|
+
return acc;
|
|
15588
|
+
}, {});
|
|
15589
|
+
Object.keys(data).filter((key) => key.startsWith(_univerjs_engine_render.SHEET_EXTENSION_PREFIX)).forEach((key) => {
|
|
15590
|
+
totalSum += sums[key];
|
|
15591
|
+
});
|
|
15592
|
+
return {
|
|
15593
|
+
...sums,
|
|
15594
|
+
extensionTotal: totalSum
|
|
15595
|
+
};
|
|
15596
|
+
};
|
|
15597
|
+
const frameTimeListAfterSum = frameInfoList.map((info) => {
|
|
15598
|
+
return {
|
|
15599
|
+
...info,
|
|
15600
|
+
...sumValueForNumListFields(info)
|
|
15601
|
+
};
|
|
15602
|
+
});
|
|
15603
|
+
const getSummaryStats = (list) => {
|
|
15604
|
+
return Object.entries(list[0]).filter(([key, _]) => !["elapsedTime"].includes(key)).filter(([_, value]) => typeof value === "number").map(([key]) => key).reduce((acc, key) => {
|
|
15605
|
+
const values = list.map((obj) => obj[key]);
|
|
15606
|
+
const max = Math.max(...values);
|
|
15607
|
+
const min = Math.min(...values);
|
|
15608
|
+
const avg = values.reduce((sum, val) => sum + val, 0) / values.length;
|
|
15609
|
+
acc[key] = {
|
|
15610
|
+
max: Math.round(max * 100) / 100,
|
|
15611
|
+
min: Math.round(min * 100) / 100,
|
|
15612
|
+
avg: Math.round(avg * 100) / 100
|
|
15613
|
+
};
|
|
15614
|
+
return acc;
|
|
15615
|
+
}, {});
|
|
15616
|
+
};
|
|
15617
|
+
const summaryFrameStats = getSummaryStats(frameTimeListAfterSum);
|
|
15618
|
+
const elapsedTimeToStart = filteredFrameInfo[filteredFrameInfo.length - 1].elapsedTime;
|
|
15619
|
+
const telemetryData = {
|
|
15620
|
+
sheetId: this._context.unit.getActiveSheet().getSheetId(),
|
|
15621
|
+
unitId: this._context.unit.getUnitId(),
|
|
15622
|
+
elapsedTimeToStart,
|
|
15623
|
+
...summaryFrameStats
|
|
15624
|
+
};
|
|
15625
|
+
this._renderMetric$.next(telemetryData);
|
|
15626
|
+
(_this$_telemetryServi = this._telemetryService) === null || _this$_telemetryServi === void 0 || _this$_telemetryServi.capture("sheet_render_cost", telemetryData);
|
|
15627
|
+
}
|
|
15628
|
+
_addComponent(workbook) {
|
|
15629
|
+
const { scene, components } = this._context;
|
|
15630
|
+
const worksheet = workbook.getActiveSheet();
|
|
15631
|
+
const spreadsheet = new _univerjs_engine_render.Spreadsheet("__SpreadsheetRender__");
|
|
15632
|
+
this._addViewport(worksheet);
|
|
15633
|
+
const spreadsheetRowHeader = new _univerjs_engine_render.SpreadsheetRowHeader("__SpreadsheetRowHeader__");
|
|
15634
|
+
const spreadsheetColumnHeader = new _univerjs_engine_render.SpreadsheetColumnHeader("__SpreadsheetColumnHeader__");
|
|
15635
|
+
const SpreadsheetLeftTopPlaceholder = new _univerjs_engine_render.Rect("__SpreadsheetLeftTopPlaceholder__", {
|
|
15636
|
+
zIndex: 2,
|
|
15637
|
+
left: -1,
|
|
15638
|
+
top: -1,
|
|
15639
|
+
fill: "gray.50",
|
|
15640
|
+
stroke: "gray.200",
|
|
15641
|
+
strokeWidth: 1
|
|
15642
|
+
});
|
|
15643
|
+
this._context.mainComponent = spreadsheet;
|
|
15644
|
+
components.set("__SpreadsheetRender__", spreadsheet);
|
|
15645
|
+
components.set("__SpreadsheetRowHeader__", spreadsheetRowHeader);
|
|
15646
|
+
components.set("__SpreadsheetColumnHeader__", spreadsheetColumnHeader);
|
|
15647
|
+
components.set("__SpreadsheetLeftTopPlaceholder__", SpreadsheetLeftTopPlaceholder);
|
|
15648
|
+
scene.addObjects([spreadsheet], 0);
|
|
15649
|
+
scene.addObjects([
|
|
15650
|
+
spreadsheetRowHeader,
|
|
15651
|
+
spreadsheetColumnHeader,
|
|
15652
|
+
SpreadsheetLeftTopPlaceholder
|
|
15653
|
+
], 10);
|
|
15654
|
+
scene.enableLayerCache(0, 10);
|
|
15655
|
+
}
|
|
15656
|
+
_initViewports(scene, rowHeader, columnHeader) {
|
|
15657
|
+
const rowHeaderWidth = rowHeader.hidden ? 0 : rowHeader.width;
|
|
15658
|
+
const columnHeaderHeight = columnHeader.hidden ? 0 : columnHeader.height;
|
|
15659
|
+
const bufferEdgeX = 100;
|
|
15660
|
+
const bufferEdgeY = 100;
|
|
15661
|
+
const viewMain = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN, scene, {
|
|
15662
|
+
left: rowHeaderWidth,
|
|
15663
|
+
top: columnHeaderHeight,
|
|
15664
|
+
bottom: 0,
|
|
15665
|
+
right: 0,
|
|
15666
|
+
isWheelPreventDefaultX: true,
|
|
15667
|
+
allowCache: true,
|
|
15668
|
+
bufferEdgeX,
|
|
15669
|
+
bufferEdgeY
|
|
15670
|
+
});
|
|
15671
|
+
const viewMainLeftTop = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP, scene, {
|
|
15672
|
+
isWheelPreventDefaultX: true,
|
|
15673
|
+
active: false,
|
|
15674
|
+
allowCache: true,
|
|
15675
|
+
bufferEdgeX: 0,
|
|
15676
|
+
bufferEdgeY: 0
|
|
15677
|
+
});
|
|
15678
|
+
const viewMainLeft = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT, scene, {
|
|
15679
|
+
isWheelPreventDefaultX: true,
|
|
15680
|
+
active: false,
|
|
15681
|
+
allowCache: true,
|
|
15682
|
+
bufferEdgeX: 0,
|
|
15683
|
+
bufferEdgeY
|
|
15972
15684
|
});
|
|
15973
|
-
|
|
15974
|
-
|
|
15685
|
+
const viewMainTop = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP, scene, {
|
|
15686
|
+
isWheelPreventDefaultX: true,
|
|
15687
|
+
active: false,
|
|
15688
|
+
allowCache: true,
|
|
15689
|
+
bufferEdgeX,
|
|
15690
|
+
bufferEdgeY: 0
|
|
15691
|
+
});
|
|
15692
|
+
const viewRowTop = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP, scene, {
|
|
15693
|
+
active: false,
|
|
15694
|
+
isWheelPreventDefaultX: true
|
|
15695
|
+
});
|
|
15696
|
+
const viewRowBottom = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM, scene, {
|
|
15697
|
+
left: 0,
|
|
15698
|
+
top: columnHeaderHeight,
|
|
15699
|
+
bottom: 0,
|
|
15700
|
+
width: rowHeaderWidth + 1,
|
|
15701
|
+
isWheelPreventDefaultX: true
|
|
15702
|
+
});
|
|
15703
|
+
const viewColumnLeft = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT, scene, {
|
|
15704
|
+
active: false,
|
|
15705
|
+
isWheelPreventDefaultX: true
|
|
15706
|
+
});
|
|
15707
|
+
const viewColumnRight = new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT, scene, {
|
|
15708
|
+
left: rowHeaderWidth,
|
|
15709
|
+
top: 0,
|
|
15710
|
+
height: columnHeaderHeight + 1,
|
|
15711
|
+
right: 0,
|
|
15712
|
+
isWheelPreventDefaultX: true
|
|
15713
|
+
});
|
|
15714
|
+
return {
|
|
15715
|
+
viewMain,
|
|
15716
|
+
viewLeftTop: new _univerjs_engine_render.Viewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP, scene, {
|
|
15717
|
+
left: 0,
|
|
15718
|
+
top: 0,
|
|
15719
|
+
width: rowHeaderWidth,
|
|
15720
|
+
height: columnHeaderHeight,
|
|
15721
|
+
isWheelPreventDefaultX: true
|
|
15722
|
+
}),
|
|
15723
|
+
viewMainLeftTop,
|
|
15724
|
+
viewMainLeft,
|
|
15725
|
+
viewMainTop,
|
|
15726
|
+
viewColumnLeft,
|
|
15727
|
+
viewRowTop,
|
|
15728
|
+
viewRowBottom,
|
|
15729
|
+
viewColumnRight
|
|
15730
|
+
};
|
|
15975
15731
|
}
|
|
15976
|
-
|
|
15977
|
-
|
|
15978
|
-
|
|
15732
|
+
/**
|
|
15733
|
+
*
|
|
15734
|
+
* initViewport & wheel event
|
|
15735
|
+
* +-----------------+--------------------+-------------------+
|
|
15736
|
+
* | VIEW_LEFT_TOP | VIEW_COLUMN_LEFT | VIEW_COLUMN_RIGHT |
|
|
15737
|
+
* +-----------------+--------------------+-------------------+
|
|
15738
|
+
* | VIEW_ROW_TOP | VIEW_MAIN_LEFT_TOP | VIEW_MAIN_TOP |
|
|
15739
|
+
* +-----------------+--------------------+-------------------+
|
|
15740
|
+
* | VIEW_ROW_BOTTOM | VIEW_MAIN_LEFT | VIEW_MAIN |
|
|
15741
|
+
* +-----------------+--------------------+-------------------+
|
|
15742
|
+
*/
|
|
15743
|
+
_addViewport(worksheet) {
|
|
15744
|
+
const scene = this._context.scene;
|
|
15745
|
+
const { rowHeader, columnHeader } = worksheet.getConfig();
|
|
15746
|
+
const { viewMain } = this._initViewports(scene, rowHeader, columnHeader);
|
|
15747
|
+
const sheetsUIConfig = this._configService.getConfig(SHEETS_UI_PLUGIN_CONFIG_KEY);
|
|
15748
|
+
new _univerjs_engine_render.ScrollBar(viewMain, sheetsUIConfig === null || sheetsUIConfig === void 0 ? void 0 : sheetsUIConfig.scrollConfig);
|
|
15749
|
+
scene.attachControl();
|
|
15750
|
+
return viewMain;
|
|
15979
15751
|
}
|
|
15980
|
-
|
|
15981
|
-
let activeSheetId = "";
|
|
15982
|
-
this._context.unit.activeSheet$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((worksheet) => {
|
|
15983
|
-
this._clearShapes();
|
|
15984
|
-
if (!worksheet) {
|
|
15985
|
-
activeSheetId = "";
|
|
15986
|
-
return;
|
|
15987
|
-
}
|
|
15988
|
-
activeSheetId = worksheet.getSheetId();
|
|
15989
|
-
this._update(this._workbook, worksheet);
|
|
15990
|
-
});
|
|
15752
|
+
_initRerenderScheduler() {
|
|
15991
15753
|
this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
|
|
15992
|
-
if (param)
|
|
15993
|
-
|
|
15994
|
-
|
|
15995
|
-
|
|
15996
|
-
|
|
15997
|
-
|
|
15998
|
-
|
|
15754
|
+
if (!param) return null;
|
|
15755
|
+
const { skeleton: spreadsheetSkeleton, sheetId } = param;
|
|
15756
|
+
const workbook = this._context.unit;
|
|
15757
|
+
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(sheetId);
|
|
15758
|
+
if (workbook == null || worksheet == null) return;
|
|
15759
|
+
const { mainComponent, components } = this._context;
|
|
15760
|
+
const spreadsheet = mainComponent;
|
|
15761
|
+
const spreadsheetRowHeader = components.get("__SpreadsheetRowHeader__");
|
|
15762
|
+
const spreadsheetColumnHeader = components.get("__SpreadsheetColumnHeader__");
|
|
15763
|
+
const spreadsheetLeftTopPlaceholder = components.get("__SpreadsheetLeftTopPlaceholder__");
|
|
15764
|
+
const leftTopPlaceholderSize = getLeftTopPlaceholderSize(spreadsheetSkeleton);
|
|
15765
|
+
spreadsheet === null || spreadsheet === void 0 || spreadsheet.updateSkeleton(spreadsheetSkeleton);
|
|
15766
|
+
spreadsheetRowHeader === null || spreadsheetRowHeader === void 0 || spreadsheetRowHeader.updateSkeleton(spreadsheetSkeleton);
|
|
15767
|
+
spreadsheetColumnHeader === null || spreadsheetColumnHeader === void 0 || spreadsheetColumnHeader.updateSkeleton(spreadsheetSkeleton);
|
|
15768
|
+
spreadsheetLeftTopPlaceholder === null || spreadsheetLeftTopPlaceholder === void 0 || spreadsheetLeftTopPlaceholder.transformByState({
|
|
15769
|
+
width: leftTopPlaceholderSize.width,
|
|
15770
|
+
height: leftTopPlaceholderSize.height
|
|
15771
|
+
});
|
|
15999
15772
|
}));
|
|
16000
15773
|
}
|
|
16001
|
-
|
|
16002
|
-
|
|
16003
|
-
|
|
16004
|
-
|
|
16005
|
-
|
|
16006
|
-
|
|
16007
|
-
|
|
16008
|
-
|
|
16009
|
-
|
|
16010
|
-
|
|
16011
|
-
|
|
16012
|
-
|
|
16013
|
-
|
|
16014
|
-
|
|
16015
|
-
|
|
16016
|
-
|
|
16017
|
-
|
|
15774
|
+
_initCommandListener() {
|
|
15775
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command, options) => {
|
|
15776
|
+
const { unit: workbook } = this._context;
|
|
15777
|
+
const { id: commandId } = command;
|
|
15778
|
+
if (_univerjs_sheets.COMMAND_LISTENER_SKELETON_CHANGE.includes(commandId) || this._sheetRenderService.checkMutationShouldTriggerRerender(commandId)) {
|
|
15779
|
+
const { unitId, subUnitId } = command.params;
|
|
15780
|
+
const worksheet = workbook.getActiveSheet();
|
|
15781
|
+
if (!worksheet) return;
|
|
15782
|
+
const workbookId = this._context.unitId;
|
|
15783
|
+
const worksheetId = worksheet.getSheetId();
|
|
15784
|
+
if (unitId !== workbookId || subUnitId !== worksheetId) return;
|
|
15785
|
+
this._sheetSkeletonManagerService.makeDirty({
|
|
15786
|
+
sheetId: worksheetId,
|
|
15787
|
+
commandId
|
|
15788
|
+
}, true);
|
|
15789
|
+
this._sheetSkeletonManagerService.setCurrent({
|
|
15790
|
+
sheetId: worksheetId,
|
|
15791
|
+
commandId
|
|
15792
|
+
});
|
|
15793
|
+
} else if (_univerjs_sheets.COMMAND_LISTENER_VALUE_CHANGE.includes(commandId)) this._sheetSkeletonManagerService.reCalculate();
|
|
15794
|
+
if (command.type === _univerjs_core.CommandType.MUTATION) this._markUnitDirty(command, options);
|
|
16018
15795
|
}));
|
|
16019
|
-
|
|
16020
|
-
|
|
16021
|
-
|
|
16022
|
-
|
|
16023
|
-
|
|
16024
|
-
|
|
16025
|
-
|
|
16026
|
-
|
|
16027
|
-
|
|
16028
|
-
|
|
16029
|
-
|
|
16030
|
-
|
|
16031
|
-
|
|
16032
|
-
|
|
16033
|
-
|
|
16034
|
-
|
|
16035
|
-
|
|
16036
|
-
|
|
16037
|
-
|
|
16038
|
-
|
|
16039
|
-
|
|
16040
|
-
|
|
16041
|
-
|
|
16042
|
-
|
|
16043
|
-
|
|
16044
|
-
|
|
16045
|
-
|
|
16046
|
-
|
|
16047
|
-
|
|
16048
|
-
|
|
16049
|
-
|
|
16050
|
-
|
|
16051
|
-
|
|
16052
|
-
|
|
16053
|
-
|
|
16054
|
-
|
|
16055
|
-
|
|
16056
|
-
|
|
16057
|
-
|
|
16058
|
-
|
|
16059
|
-
|
|
16060
|
-
|
|
16061
|
-
|
|
16062
|
-
|
|
16063
|
-
|
|
15796
|
+
}
|
|
15797
|
+
_markUnitDirty(command, options) {
|
|
15798
|
+
if (command.id.substring(0, 3) === "doc") return;
|
|
15799
|
+
const { mainComponent: spreadsheet, scene } = this._context;
|
|
15800
|
+
if (command.id === _univerjs_engine_formula.SetFormulaCalculationNotificationMutation.id) {
|
|
15801
|
+
if (command.params.stageInfo != null) return;
|
|
15802
|
+
}
|
|
15803
|
+
if (spreadsheet) spreadsheet.makeDirty();
|
|
15804
|
+
scene.makeDirty();
|
|
15805
|
+
if (!command.params) return;
|
|
15806
|
+
const cmdParams = command.params;
|
|
15807
|
+
const viewports = this._spreadsheetViewports(scene);
|
|
15808
|
+
if (command.id === _univerjs_sheets.SetRangeValuesMutation.id && cmdParams.cellValue && !(options === null || options === void 0 ? void 0 : options.fromChangeset)) {
|
|
15809
|
+
const dirtyRange = this._cellValueToRange(cmdParams.cellValue);
|
|
15810
|
+
const dirtyBounds = this._rangeToBounds([dirtyRange]);
|
|
15811
|
+
this._markViewportDirty(viewports, dirtyBounds);
|
|
15812
|
+
spreadsheet.setDirtyArea(dirtyBounds);
|
|
15813
|
+
}
|
|
15814
|
+
if (command.id === _univerjs_sheets.MoveRangeMutation.id && cmdParams.from && cmdParams.to && !(options === null || options === void 0 ? void 0 : options.fromChangeset)) {
|
|
15815
|
+
const fromRange = cmdParams.fromRange || this._cellValueToRange(cmdParams.from.value);
|
|
15816
|
+
const toRange = cmdParams.toRange || this._cellValueToRange(cmdParams.to.value);
|
|
15817
|
+
const dirtyBounds = this._rangeToBounds([fromRange, toRange]);
|
|
15818
|
+
this._markViewportDirty(viewports, dirtyBounds);
|
|
15819
|
+
spreadsheet.setDirtyArea(dirtyBounds);
|
|
15820
|
+
}
|
|
15821
|
+
}
|
|
15822
|
+
/**
|
|
15823
|
+
* cellValue data structure:
|
|
15824
|
+
* {[row]: { [col]: value}}
|
|
15825
|
+
* @param cellValue
|
|
15826
|
+
* @returns IRange
|
|
15827
|
+
*/
|
|
15828
|
+
_cellValueToRange(cellValue) {
|
|
15829
|
+
const columns = [];
|
|
15830
|
+
let minCol = 0;
|
|
15831
|
+
let maxCol = 0;
|
|
15832
|
+
let minRow = 0;
|
|
15833
|
+
let maxRow = 0;
|
|
15834
|
+
for (const [_row, columnObj] of Object.entries(cellValue)) {
|
|
15835
|
+
for (const column in columnObj) {
|
|
15836
|
+
columns.push(Number(column));
|
|
15837
|
+
if (minCol > Number(column)) minCol = Number(column);
|
|
15838
|
+
if (maxCol < Number(column)) maxCol = Number(column);
|
|
15839
|
+
}
|
|
15840
|
+
if (minRow > Number(_row)) minRow = Number(_row);
|
|
15841
|
+
if (maxRow < Number(_row)) maxRow = Number(_row);
|
|
15842
|
+
}
|
|
15843
|
+
return {
|
|
15844
|
+
startRow: minRow,
|
|
15845
|
+
endRow: maxRow,
|
|
15846
|
+
startColumn: minCol,
|
|
15847
|
+
endColumn: maxCol
|
|
16064
15848
|
};
|
|
16065
15849
|
}
|
|
16066
|
-
|
|
16067
|
-
this.
|
|
16068
|
-
|
|
16069
|
-
|
|
16070
|
-
|
|
16071
|
-
|
|
16072
|
-
|
|
15850
|
+
_rangeToBounds(ranges) {
|
|
15851
|
+
const { rowHeightAccumulation, columnWidthAccumulation, rowHeaderWidth, columnHeaderHeight } = this._sheetSkeletonManagerService.getCurrentParam().skeleton;
|
|
15852
|
+
const dirtyBounds = [];
|
|
15853
|
+
for (const r of ranges) {
|
|
15854
|
+
const { startRow, endRow, startColumn, endColumn } = r;
|
|
15855
|
+
const top = startRow === 0 ? 0 : rowHeightAccumulation[startRow - 1] + columnHeaderHeight;
|
|
15856
|
+
const bottom = rowHeightAccumulation[endRow] + columnHeaderHeight;
|
|
15857
|
+
const left = startColumn === 0 ? 0 : columnWidthAccumulation[startColumn - 1] + rowHeaderWidth;
|
|
15858
|
+
const right = columnWidthAccumulation[endColumn] + rowHeaderWidth;
|
|
15859
|
+
dirtyBounds.push({
|
|
15860
|
+
top,
|
|
15861
|
+
left,
|
|
15862
|
+
bottom,
|
|
15863
|
+
right,
|
|
15864
|
+
width: right - left,
|
|
15865
|
+
height: bottom - top
|
|
15866
|
+
});
|
|
15867
|
+
}
|
|
15868
|
+
return dirtyBounds;
|
|
15869
|
+
}
|
|
15870
|
+
_markViewportDirty(viewports, dirtyBounds) {
|
|
15871
|
+
const activeViewports = viewports.filter((vp) => vp.isActive && vp.cacheBound);
|
|
15872
|
+
for (const vp of activeViewports) for (const b of dirtyBounds) if (_univerjs_core.Rectangle.hasIntersectionBetweenTwoRect(vp.cacheBound, b)) vp.markDirty(true);
|
|
16073
15873
|
}
|
|
16074
|
-
|
|
16075
|
-
return
|
|
15874
|
+
_spreadsheetViewports(scene) {
|
|
15875
|
+
return scene.getViewports().filter((v) => [
|
|
15876
|
+
"viewMain",
|
|
15877
|
+
"viewMainLeftTop",
|
|
15878
|
+
"viewMainTop",
|
|
15879
|
+
"viewMainLeft"
|
|
15880
|
+
].includes(v.viewportKey));
|
|
16076
15881
|
}
|
|
16077
15882
|
};
|
|
16078
|
-
|
|
16079
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(
|
|
16080
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(
|
|
16081
|
-
__decorateParam(3, _univerjs_core.
|
|
16082
|
-
|
|
15883
|
+
SheetRenderController = __decorate([
|
|
15884
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.IConfigService)),
|
|
15885
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(SheetSkeletonManagerService)),
|
|
15886
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(SheetsRenderService)),
|
|
15887
|
+
__decorateParam(4, _univerjs_core.ICommandService),
|
|
15888
|
+
__decorateParam(5, (0, _univerjs_core.Optional)(_univerjs_telemetry.ITelemetryService))
|
|
15889
|
+
], SheetRenderController);
|
|
15890
|
+
function getLeftTopPlaceholderSize(skeleton) {
|
|
15891
|
+
return {
|
|
15892
|
+
width: skeleton.rowHeaderWidthAndMarginLeft ?? skeleton.rowHeaderWidth,
|
|
15893
|
+
height: skeleton.columnHeaderHeightAndMarginTop ?? skeleton.columnHeaderHeight
|
|
15894
|
+
};
|
|
15895
|
+
}
|
|
16083
15896
|
|
|
16084
15897
|
//#endregion
|
|
16085
15898
|
//#region src/services/status-bar.service.ts
|
|
@@ -17358,6 +17171,7 @@ function ToggleGridlinesMenuFactory(accessor) {
|
|
|
17358
17171
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
17359
17172
|
tooltip: "sheets-ui.toolbar.toggleGridlines",
|
|
17360
17173
|
icon: "HideGridlinesIcon",
|
|
17174
|
+
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
17361
17175
|
activated$: new rxjs.Observable((observer) => {
|
|
17362
17176
|
const getValue = () => {
|
|
17363
17177
|
const workbook = instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
@@ -18104,7 +17918,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
|
|
|
18104
17918
|
selectable: false
|
|
18105
17919
|
},
|
|
18106
17920
|
value$: new rxjs.Observable((subscriber) => {
|
|
18107
|
-
const defaultValue =
|
|
17921
|
+
const defaultValue = themeService.getColorFromTheme("gray.900");
|
|
18108
17922
|
const { isAllValuesSame, value: currentValue } = selectionManagerService.getCellStylesProperty("cl");
|
|
18109
17923
|
if (isAllValuesSame) subscriber.next((currentValue === null || currentValue === void 0 ? void 0 : currentValue.rgb) ?? defaultValue);
|
|
18110
17924
|
else subscriber.next(defaultValue);
|
|
@@ -20180,7 +19994,7 @@ function getEmbedSheetsTabCustomData(snapshot) {
|
|
|
20180
19994
|
function isEmbedSheetsTabCustomData(value) {
|
|
20181
19995
|
if (!value || typeof value !== "object") return false;
|
|
20182
19996
|
const candidate = value;
|
|
20183
|
-
return candidate.version === 1 && typeof candidate.embedId === "string" && typeof candidate.hostAnchorId === "string";
|
|
19997
|
+
return candidate.version === 1 && typeof candidate.embedId === "string" && typeof candidate.hostAnchorId === "string" && (candidate.childType === void 0 || typeof candidate.childType === "number");
|
|
20184
19998
|
}
|
|
20185
19999
|
|
|
20186
20000
|
//#endregion
|
|
@@ -20189,10 +20003,6 @@ const ISheetEmbedRuntimeService = (0, _univerjs_core.createIdentifier)("sheet-ui
|
|
|
20189
20003
|
|
|
20190
20004
|
//#endregion
|
|
20191
20005
|
//#region src/views/auto-fill-popup-menu/AutoFillPopupMenu.tsx
|
|
20192
|
-
const useUpdate = () => {
|
|
20193
|
-
const [, setState] = (0, react.useState)({});
|
|
20194
|
-
return (0, react.useCallback)(() => setState((prevState) => !prevState), []);
|
|
20195
|
-
};
|
|
20196
20006
|
function AutoFillPopupMenu() {
|
|
20197
20007
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
20198
20008
|
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
@@ -20222,7 +20032,8 @@ function AutoFillPopupMenu() {
|
|
|
20222
20032
|
col: -1
|
|
20223
20033
|
}, false, [autoFillService]);
|
|
20224
20034
|
const selected = (0, _univerjs_ui.useObservable)(autoFillService.applyType$, _univerjs_sheets.AUTO_FILL_APPLY_TYPE.SERIES);
|
|
20225
|
-
const [isHovered,
|
|
20035
|
+
const [isHovered, setIsHovered] = (0, react.useState)(false);
|
|
20036
|
+
const [, forceUpdate] = (0, react.useReducer)((version) => version + 1, 0);
|
|
20226
20037
|
const workbook = useActiveWorkbook();
|
|
20227
20038
|
const sheetSkeletonManagerService = (0, react.useMemo)(() => {
|
|
20228
20039
|
if (workbook) {
|
|
@@ -20232,14 +20043,13 @@ function AutoFillPopupMenu() {
|
|
|
20232
20043
|
return null;
|
|
20233
20044
|
}, [workbook, renderManagerService]);
|
|
20234
20045
|
const handleMouseEnter = () => {
|
|
20235
|
-
|
|
20046
|
+
setIsHovered(true);
|
|
20236
20047
|
};
|
|
20237
20048
|
const handleMouseLeave = () => {
|
|
20238
|
-
|
|
20049
|
+
setIsHovered(false);
|
|
20239
20050
|
};
|
|
20240
|
-
const forceUpdate = useUpdate();
|
|
20241
20051
|
(0, react.useEffect)(() => {
|
|
20242
|
-
return commandService.onCommandExecuted((command
|
|
20052
|
+
return commandService.onCommandExecuted((command) => {
|
|
20243
20053
|
if (command.id === SetScrollOperation.id) forceUpdate();
|
|
20244
20054
|
}).dispose;
|
|
20245
20055
|
}, [forceUpdate, commandService]);
|
|
@@ -20284,7 +20094,11 @@ function AutoFillPopupMenu() {
|
|
|
20284
20094
|
const showMore = visible || isHovered;
|
|
20285
20095
|
const availableMenu = menu.filter((item) => !item.disable);
|
|
20286
20096
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
20287
|
-
className: "univer-absolute univer-
|
|
20097
|
+
className: "univer-absolute univer-z-10 univer-size-0",
|
|
20098
|
+
style: {
|
|
20099
|
+
left: 0,
|
|
20100
|
+
top: 0
|
|
20101
|
+
},
|
|
20288
20102
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
20289
20103
|
className: "univer-absolute",
|
|
20290
20104
|
style: {
|
|
@@ -20309,9 +20123,9 @@ function AutoFillPopupMenu() {
|
|
|
20309
20123
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
20310
20124
|
className: (0, _univerjs_design.clsx)("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", _univerjs_design.borderClassName, {
|
|
20311
20125
|
"univer-bg-gray-100 dark:!univer-bg-gray-800": visible,
|
|
20312
|
-
"univer-bg-
|
|
20126
|
+
"univer-bg-gray-0 dark:!univer-bg-gray-900": !visible
|
|
20313
20127
|
}),
|
|
20314
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AutofillDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-
|
|
20128
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AutofillDoubleIcon, { className: "univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-gray-0" }), showMore && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "dark:!univer-text-gray-0" })]
|
|
20315
20129
|
})
|
|
20316
20130
|
})
|
|
20317
20131
|
})
|
|
@@ -20458,7 +20272,7 @@ const EDITOR_DEFAULT_POSITION = {
|
|
|
20458
20272
|
left: HIDDEN_EDITOR_POSITION
|
|
20459
20273
|
};
|
|
20460
20274
|
const CELL_EDITOR_DARK_SURFACE_THEME_COLOR = "gray.800";
|
|
20461
|
-
const CELL_EDITOR_LIGHT_SURFACE_THEME_COLOR = "
|
|
20275
|
+
const CELL_EDITOR_LIGHT_SURFACE_THEME_COLOR = "gray.0";
|
|
20462
20276
|
/**
|
|
20463
20277
|
* @returns the host background color for the cell editor.
|
|
20464
20278
|
*/
|
|
@@ -20517,6 +20331,7 @@ function isEmbedRuntimeEditorOrPopup(target) {
|
|
|
20517
20331
|
* @returns the rendered cell editor container.
|
|
20518
20332
|
*/
|
|
20519
20333
|
function EditorContainer() {
|
|
20334
|
+
var _workbook$getSheetByS;
|
|
20520
20335
|
const [state, setState] = (0, react.useState)({ ...EDITOR_DEFAULT_POSITION });
|
|
20521
20336
|
const cellEditorManagerService = (0, _univerjs_ui.useDependency)(ICellEditorManagerService);
|
|
20522
20337
|
const injector = (0, _univerjs_ui.useDependency)(_univerjs_core.Injector);
|
|
@@ -20535,9 +20350,12 @@ function EditorContainer() {
|
|
|
20535
20350
|
const disableAutoFocus = (0, _univerjs_ui.useObservable)(() => contextService.subscribeContextValue$(_univerjs_ui.DISABLE_AUTO_FOCUS_KEY), false, void 0, [contextService, _univerjs_ui.DISABLE_AUTO_FOCUS_KEY]);
|
|
20536
20351
|
const FormulaEditor = componentManager.get(EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY);
|
|
20537
20352
|
const editState = (0, _univerjs_ui.useObservable)(editorBridgeService.currentEditCellState$);
|
|
20353
|
+
const workbook = editState ? instanceService.getUnit(editState.unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET) ?? null : null;
|
|
20354
|
+
const activeSheet = useActiveWorksheet(workbook);
|
|
20538
20355
|
const darkMode = (0, _univerjs_ui.useObservable)(themeService.darkMode$, themeService.darkMode);
|
|
20539
20356
|
const [showEditCellAddress, setShowEditCellAddress] = (0, react.useState)(false);
|
|
20540
|
-
const
|
|
20357
|
+
const editSheetName = editState ? workbook === null || workbook === void 0 || (_workbook$getSheetByS = workbook.getSheetBySheetId(editState.sheetId)) === null || _workbook$getSheetByS === void 0 ? void 0 : _workbook$getSheetByS.getName() : null;
|
|
20358
|
+
const editCellAddress = editState ? `${activeSheet && editSheetName && activeSheet.getSheetId() !== editState.sheetId ? `'${(0, _univerjs_engine_formula.quoteSheetName)(editSheetName)}'!` : ""}${(0, _univerjs_core.numberToABC)(editState.column)}${editState.row + 1}` : null;
|
|
20541
20359
|
const editorBorderColor = genNormalSelectionStyle(themeService).stroke;
|
|
20542
20360
|
const focusCoordinator = injector.has(ISheetEmbedRuntimeFocusCoordinator) ? injector.get(ISheetEmbedRuntimeFocusCoordinator) : void 0;
|
|
20543
20361
|
const resolveRuntimeFocusState = () => {
|
|
@@ -20857,7 +20675,7 @@ function EditorContainer() {
|
|
|
20857
20675
|
className: "univer-pointer-events-none univer-absolute univer-left-0 univer-top-0 univer-z-10 univer-whitespace-nowrap univer-rounded-t univer-px-1.5 univer-text-xs univer-leading-5",
|
|
20858
20676
|
style: {
|
|
20859
20677
|
backgroundColor: editorBorderColor,
|
|
20860
|
-
color: themeService.getColorFromTheme("
|
|
20678
|
+
color: themeService.getColorFromTheme("gray.0"),
|
|
20861
20679
|
transform: "translateY(-100%)"
|
|
20862
20680
|
},
|
|
20863
20681
|
children: editCellAddress
|
|
@@ -21094,7 +20912,13 @@ function DefinedName({ disable }) {
|
|
|
21094
20912
|
return () => {
|
|
21095
20913
|
subscription.unsubscribe();
|
|
21096
20914
|
};
|
|
21097
|
-
}, [
|
|
20915
|
+
}, [
|
|
20916
|
+
definedNamesService,
|
|
20917
|
+
lexerTreeBuilder,
|
|
20918
|
+
selectionManagerService,
|
|
20919
|
+
unitId,
|
|
20920
|
+
workbook
|
|
20921
|
+
]);
|
|
21098
20922
|
const handleDefinedNamesList = (0, _univerjs_core.debounce)((value) => {
|
|
21099
20923
|
const hasMatch = definedNames.find((i) => i.name.toLowerCase().includes(value.toLowerCase()));
|
|
21100
20924
|
if (hasMatch && !open) setOpen(true);
|
|
@@ -21196,7 +21020,7 @@ function DefinedName({ disable }) {
|
|
|
21196
21020
|
className: "univer-relative univer-box-border univer-flex univer-h-full univer-w-24 univer-border-r-gray-200 univer-py-1.5 univer-transition-all",
|
|
21197
21021
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
21198
21022
|
ref: inputRef,
|
|
21199
|
-
className: (0, _univerjs_design.clsx)("univer-box-border univer-size-full univer-appearance-none univer-pl-1.5 univer-pr-5 univer-text-gray-900 focus:univer-outline-none
|
|
21023
|
+
className: (0, _univerjs_design.clsx)("univer-box-border univer-size-full univer-appearance-none univer-bg-transparent univer-pl-1.5 univer-pr-5 univer-text-gray-900 focus:univer-outline-none dark:!univer-border-r-gray-700 dark:!univer-text-gray-0", _univerjs_design.borderRightClassName, { "univer-cursor-not-allowed": disable }),
|
|
21200
21024
|
type: "text",
|
|
21201
21025
|
value: inputValue,
|
|
21202
21026
|
onChange: handleChangeSelection,
|
|
@@ -21215,7 +21039,7 @@ function DefinedName({ disable }) {
|
|
|
21215
21039
|
onOpenChange: setOpen,
|
|
21216
21040
|
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
21217
21041
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
21218
|
-
className: (0, _univerjs_design.clsx)("univer-absolute univer-right-0 univer-top-0 univer-flex univer-h-full univer-cursor-pointer univer-items-center univer-justify-center univer-px-1 univer-transition-colors univer-duration-200 hover:univer-bg-gray-100
|
|
21042
|
+
className: (0, _univerjs_design.clsx)("univer-absolute univer-right-0 univer-top-0 univer-flex univer-h-full univer-cursor-pointer univer-items-center univer-justify-center univer-px-1 univer-transition-colors univer-duration-200 hover:univer-bg-gray-100 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-800", { "univer-cursor-not-allowed univer-text-gray-300 hover:univer-bg-transparent dark:!univer-text-gray-700": disable }),
|
|
21219
21043
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {})
|
|
21220
21044
|
})
|
|
21221
21045
|
})]
|
|
@@ -21350,7 +21174,7 @@ function FormulaBar(props) {
|
|
|
21350
21174
|
const workbookEditDisable = !((workbookEditablePermission === null || workbookEditablePermission === void 0 ? void 0 : workbookEditablePermission.value) ?? true);
|
|
21351
21175
|
const editorActivationDisable = editDisable || workbookEditDisable;
|
|
21352
21176
|
const disabled = editDisable || imageDisable;
|
|
21353
|
-
const
|
|
21177
|
+
const shouldSkipFocusRef = (0, react.useRef)(false);
|
|
21354
21178
|
const handlePointerDown = () => {
|
|
21355
21179
|
try {
|
|
21356
21180
|
contextService.setContextValue(_univerjs_core.FOCUSING_FX_BAR_EDITOR, true);
|
|
@@ -21365,25 +21189,26 @@ function FormulaBar(props) {
|
|
|
21365
21189
|
unitId: editState.unitId
|
|
21366
21190
|
})) {
|
|
21367
21191
|
contextService.setContextValue(_univerjs_core.FOCUSING_FX_BAR_EDITOR, false);
|
|
21368
|
-
|
|
21192
|
+
shouldSkipFocusRef.current = true;
|
|
21369
21193
|
}
|
|
21370
21194
|
}
|
|
21371
21195
|
} catch (e) {
|
|
21372
21196
|
contextService.setContextValue(_univerjs_core.FOCUSING_FX_BAR_EDITOR, false);
|
|
21373
|
-
|
|
21197
|
+
shouldSkipFocusRef.current = true;
|
|
21374
21198
|
throw e;
|
|
21375
21199
|
}
|
|
21376
21200
|
};
|
|
21377
21201
|
const handlePointerUp = () => {
|
|
21378
|
-
if (
|
|
21202
|
+
if (shouldSkipFocusRef.current) setTimeout(() => {
|
|
21379
21203
|
editorService.blur(true);
|
|
21380
21204
|
}, 30);
|
|
21381
|
-
|
|
21205
|
+
shouldSkipFocusRef.current = false;
|
|
21382
21206
|
};
|
|
21383
21207
|
const hideEditor = (0, _univerjs_sheets.isCellImage)(editState === null || editState === void 0 || (_editState$documentLa = editState.documentLayoutObject.documentModel) === null || _editState$documentLa === void 0 ? void 0 : _editState$documentLa.getSnapshot()) || viewDisable;
|
|
21384
21208
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
21209
|
+
dir: "ltr",
|
|
21385
21210
|
"data-u-comp": "formula-bar",
|
|
21386
|
-
className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-bg-
|
|
21211
|
+
className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-bg-gray-0 univer-text-gray-900 univer-transition-[height] univer-ease-linear dark:!univer-bg-gray-800", _univerjs_design.borderBottomClassName, className, {
|
|
21387
21212
|
"univer-h-7": arrowDirection === 0,
|
|
21388
21213
|
"univer-h-20": arrowDirection === 1,
|
|
21389
21214
|
"univer-pointer-events-none": editDisable
|
|
@@ -21401,17 +21226,17 @@ function FormulaBar(props) {
|
|
|
21401
21226
|
className: (0, _univerjs_design.clsx)("univer-relative univer-box-border univer-flex univer-h-full univer-w-20 univer-items-center univer-justify-center univer-text-xs", _univerjs_design.borderRightClassName),
|
|
21402
21227
|
children: [
|
|
21403
21228
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
21404
|
-
className: (0, _univerjs_design.clsx)("univer-flex univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-
|
|
21229
|
+
className: (0, _univerjs_design.clsx)("univer-flex univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-gray-0", { "univer-cursor-pointer univer-text-red-600 hover:univer-bg-gray-100 dark:!univer-text-green-400 dark:hover:!univer-bg-gray-700": iconActivated }),
|
|
21405
21230
|
onClick: handleCloseBtnClick,
|
|
21406
21231
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CloseIcon, {})
|
|
21407
21232
|
}),
|
|
21408
21233
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
21409
|
-
className: (0, _univerjs_design.clsx)("univer-flex univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-
|
|
21234
|
+
className: (0, _univerjs_design.clsx)("univer-flex univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base dark:!univer-text-gray-0", { "univer-cursor-pointer univer-text-green-600 hover:univer-bg-gray-100 dark:!univer-text-red-400 dark:hover:!univer-bg-gray-700": iconActivated }),
|
|
21410
21235
|
onClick: handleConfirmBtnClick,
|
|
21411
21236
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CheckMarkIcon, {})
|
|
21412
21237
|
}),
|
|
21413
21238
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
21414
|
-
className: "univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base hover:univer-bg-gray-100 dark:!univer-text-
|
|
21239
|
+
className: "univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-base hover:univer-bg-gray-100 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700",
|
|
21415
21240
|
onClick: handlerFxBtnClick,
|
|
21416
21241
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.FxIcon, {})
|
|
21417
21242
|
})
|
|
@@ -21421,7 +21246,7 @@ function FormulaBar(props) {
|
|
|
21421
21246
|
className: "univer-flex univer-w-full univer-flex-1 univer-overflow-hidden univer-pl-3",
|
|
21422
21247
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
21423
21248
|
ref,
|
|
21424
|
-
className: "univer-relative univer-flex-1 univer-bg-
|
|
21249
|
+
className: "univer-relative univer-flex-1 univer-bg-gray-0 dark:!univer-bg-gray-800",
|
|
21425
21250
|
onPointerDown: handlePointerDown,
|
|
21426
21251
|
onPointerUp: handlePointerUp,
|
|
21427
21252
|
style: { pointerEvents: hideEditor ? "none" : "auto" },
|
|
@@ -21446,7 +21271,7 @@ function FormulaBar(props) {
|
|
|
21446
21271
|
},
|
|
21447
21272
|
autoScrollbar: false,
|
|
21448
21273
|
disableContextMenu: false
|
|
21449
|
-
}), hideEditor && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-pointer-events-none univer-relative univer-left-0 univer-top-0 univer-z-[100] univer-size-full univer-cursor-not-allowed univer-bg-
|
|
21274
|
+
}), hideEditor && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-pointer-events-none univer-relative univer-left-0 univer-top-0 univer-z-[100] univer-size-full univer-cursor-not-allowed univer-bg-gray-0 dark:!univer-bg-gray-800" })]
|
|
21450
21275
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
21451
21276
|
className: (0, _univerjs_design.clsx)("univer-flex univer-h-full univer-w-5 univer-cursor-pointer univer-items-center univer-justify-center univer-text-xs univer-text-gray-700 dark:!univer-text-gray-200", { "univer-cursor-not-allowed univer-text-gray-200 dark:!univer-text-gray-700": editDisable }),
|
|
21452
21277
|
onClick: handleArrowClick,
|
|
@@ -21587,7 +21412,7 @@ function SheetBarItem(props) {
|
|
|
21587
21412
|
const themeService = (0, _univerjs_ui.useDependency)(_univerjs_core.ThemeService);
|
|
21588
21413
|
const getTextColor = (color) => {
|
|
21589
21414
|
const darkTextColor = themeService.getColorFromTheme("gray.900");
|
|
21590
|
-
const lightTextColor = themeService.getColorFromTheme("
|
|
21415
|
+
const lightTextColor = themeService.getColorFromTheme("gray.0");
|
|
21591
21416
|
return new _univerjs_core.ColorKit(color).isDark() ? lightTextColor : darkTextColor;
|
|
21592
21417
|
};
|
|
21593
21418
|
const currentSelected = Boolean(selected);
|
|
@@ -21601,8 +21426,8 @@ function SheetBarItem(props) {
|
|
|
21601
21426
|
onKeyDown,
|
|
21602
21427
|
onClick,
|
|
21603
21428
|
className: (0, _univerjs_design.clsx)("univer-mx-1 univer-box-border univer-flex univer-flex-grow univer-cursor-pointer univer-select-none univer-flex-row univer-items-center univer-rounded univer-text-xs univer-transition-[colors,box-shadow] focus-visible:univer-ring-2 focus-visible:univer-ring-primary-500", {
|
|
21604
|
-
"dark:!univer-text-
|
|
21605
|
-
"univer-justify-center univer-bg-
|
|
21429
|
+
"dark:!univer-text-gray-0": !color || color && !textColor,
|
|
21430
|
+
"univer-justify-center univer-bg-gray-0 univer-font-bold univer-text-primary-700 univer-shadow": currentSelected,
|
|
21606
21431
|
"dark:!univer-bg-gray-700": currentSelected && !color,
|
|
21607
21432
|
"univer-font-medium univer-text-gray-900 hover:univer-bg-gray-100": !currentSelected,
|
|
21608
21433
|
"dark:hover:!univer-bg-gray-700": !currentSelected && !color
|
|
@@ -22529,6 +22354,32 @@ const SCROLL_SHADOW_NONE = "";
|
|
|
22529
22354
|
const SCROLL_SHADOW_LEFT = "inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)";
|
|
22530
22355
|
const SCROLL_SHADOW_RIGHT = "inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)";
|
|
22531
22356
|
const SCROLL_SHADOW_BOTH = "inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)";
|
|
22357
|
+
function EmbedSheetTabProductIcon({ childType }) {
|
|
22358
|
+
const className = "univer-size-4 univer-shrink-0";
|
|
22359
|
+
switch (childType) {
|
|
22360
|
+
case _univerjs_core.UniverInstanceType.UNIVER_SHEET: return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SheetsMultiIcon, {
|
|
22361
|
+
"aria-hidden": true,
|
|
22362
|
+
className
|
|
22363
|
+
});
|
|
22364
|
+
case _univerjs_core.UniverInstanceType.UNIVER_DOC: return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DocsMultiIcon, {
|
|
22365
|
+
"aria-hidden": true,
|
|
22366
|
+
className
|
|
22367
|
+
});
|
|
22368
|
+
case _univerjs_core.UniverInstanceType.UNIVER_SLIDE: return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SlidesMultiIcon, {
|
|
22369
|
+
"aria-hidden": true,
|
|
22370
|
+
className
|
|
22371
|
+
});
|
|
22372
|
+
case _univerjs_core.UniverInstanceType.UNIVER_BASE: return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.BasesMultiIcon, {
|
|
22373
|
+
"aria-hidden": true,
|
|
22374
|
+
className
|
|
22375
|
+
});
|
|
22376
|
+
case _univerjs_core.UniverInstanceType.UNIVER_BOARD: return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.BoardsMultiIcon, {
|
|
22377
|
+
"aria-hidden": true,
|
|
22378
|
+
className
|
|
22379
|
+
});
|
|
22380
|
+
default: return null;
|
|
22381
|
+
}
|
|
22382
|
+
}
|
|
22532
22383
|
function getScrollShadow(state) {
|
|
22533
22384
|
const { leftEnd, rightEnd } = state;
|
|
22534
22385
|
if (leftEnd && rightEnd) return SCROLL_SHADOW_NONE;
|
|
@@ -22549,6 +22400,7 @@ function shouldRefreshSheetTabs(commandInfo) {
|
|
|
22549
22400
|
}
|
|
22550
22401
|
}
|
|
22551
22402
|
function SheetBarTabs() {
|
|
22403
|
+
const injector = (0, _univerjs_ui.useDependency)(_univerjs_core.Injector);
|
|
22552
22404
|
const [sheetList, setSheetList] = (0, react.useState)([]);
|
|
22553
22405
|
const [activeSheetId, setActiveSheetId] = (0, react.useState)("");
|
|
22554
22406
|
const [scrollShadow, setScrollShadow] = (0, react.useState)("");
|
|
@@ -22670,19 +22522,28 @@ function SheetBarTabs() {
|
|
|
22670
22522
|
const updateSheetItems = (0, react.useCallback)(() => {
|
|
22671
22523
|
const activeSheet = workbook.getActiveSheet();
|
|
22672
22524
|
const currentSubUnitId = (activeSheet === null || activeSheet === void 0 ? void 0 : activeSheet.getSheetId()) ?? "";
|
|
22525
|
+
const embedRuntimeService = injector.has(ISheetEmbedRuntimeService) ? injector.get(ISheetEmbedRuntimeService) : void 0;
|
|
22673
22526
|
const sheetListItems = workbook.getSheets().filter((sheet) => !sheet.isSheetHidden()).map((sheet, index) => {
|
|
22527
|
+
var _embedRuntimeService$;
|
|
22674
22528
|
const worksheetRule = worksheetProtectionRuleModel.getRule(workbook.getUnitId(), sheet.getSheetId());
|
|
22675
22529
|
const hasSelectionRule = rangeProtectionRuleModel.getSubunitRuleList(workbook.getUnitId(), sheet.getSheetId()).length > 0;
|
|
22676
22530
|
const hasProtection = Boolean((worksheetRule === null || worksheetRule === void 0 ? void 0 : worksheetRule.permissionId) || hasSelectionRule);
|
|
22531
|
+
const embedData = getEmbedSheetsTabCustomData(sheet.getConfig());
|
|
22532
|
+
const embedChildType = (embedData === null || embedData === void 0 ? void 0 : embedData.childType) ?? (embedData ? embedRuntimeService === null || embedRuntimeService === void 0 || (_embedRuntimeService$ = embedRuntimeService.getSheetTabChildType) === null || _embedRuntimeService$ === void 0 ? void 0 : _embedRuntimeService$.call(embedRuntimeService, {
|
|
22533
|
+
hostUnitId: workbook.getUnitId(),
|
|
22534
|
+
hostAnchorId: embedData.hostAnchorId,
|
|
22535
|
+
embedId: embedData.embedId
|
|
22536
|
+
}) : void 0);
|
|
22677
22537
|
return {
|
|
22678
22538
|
sheetId: sheet.getSheetId(),
|
|
22679
|
-
label:
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
|
|
22684
|
-
|
|
22685
|
-
|
|
22539
|
+
label: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
22540
|
+
embedChildType != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmbedSheetTabProductIcon, { childType: embedChildType }),
|
|
22541
|
+
hasProtection && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LockIcon, { className: "univer-shrink-0" }),
|
|
22542
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
22543
|
+
className: "univer-truncate univer-outline-none",
|
|
22544
|
+
children: sheet.getName()
|
|
22545
|
+
})
|
|
22546
|
+
] }),
|
|
22686
22547
|
index,
|
|
22687
22548
|
selected: activeSheet === sheet,
|
|
22688
22549
|
color: sheet.getTabColor() ?? void 0
|
|
@@ -22691,6 +22552,7 @@ function SheetBarTabs() {
|
|
|
22691
22552
|
setSheetList(sheetListItems);
|
|
22692
22553
|
setActiveSheetId(currentSubUnitId);
|
|
22693
22554
|
}, [
|
|
22555
|
+
injector,
|
|
22694
22556
|
rangeProtectionRuleModel,
|
|
22695
22557
|
workbook,
|
|
22696
22558
|
worksheetProtectionRuleModel
|
|
@@ -23158,120 +23020,98 @@ const functionDisplayNames = {
|
|
|
23158
23020
|
[_univerjs_engine_formula.FUNCTION_NAMES_STATISTICAL.COUNTA]: "sheets-ui.statusbar.countA",
|
|
23159
23021
|
[_univerjs_engine_formula.FUNCTION_NAMES_TEXT.CONCATENATE]: "concatenate"
|
|
23160
23022
|
};
|
|
23161
|
-
const CopyableStatisticItem = (item) => {
|
|
23162
|
-
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
23163
|
-
const messageService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IMessageService);
|
|
23164
|
-
const clipboardService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IClipboardInterfaceService);
|
|
23165
|
-
const formateValue = formatNumber(item);
|
|
23166
|
-
const copyToClipboard = async () => {
|
|
23167
|
-
await clipboardService.writeText(item.value.toString());
|
|
23168
|
-
messageService.show({
|
|
23169
|
-
type: _univerjs_design.MessageType.Success,
|
|
23170
|
-
content: localeService.t("sheets-ui.statusbar.copied")
|
|
23171
|
-
});
|
|
23172
|
-
};
|
|
23173
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
23174
|
-
title: localeService.t("sheets-ui.statusbar.clickToCopy"),
|
|
23175
|
-
placement: "top",
|
|
23176
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23177
|
-
className: "univer-flex univer-cursor-pointer univer-truncate univer-text-center univer-text-xs univer-text-gray-400",
|
|
23178
|
-
onClick: copyToClipboard,
|
|
23179
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: `${localeService.t((functionDisplayNames === null || functionDisplayNames === void 0 ? void 0 : functionDisplayNames[item.name]) || item.name)}: ${formateValue}` })
|
|
23180
|
-
}, item.name)
|
|
23181
|
-
});
|
|
23182
|
-
};
|
|
23183
23023
|
function formatNumber(item) {
|
|
23184
23024
|
const { pattern, value: num } = item;
|
|
23185
23025
|
if (typeof num !== "number") return 0;
|
|
23186
|
-
if (num >= 1e8) return num.toExponential(2);
|
|
23187
23026
|
if (pattern && allowPatternFunctions.includes(item.name)) return _univerjs_core.numfmt.format(pattern, num, { throws: false });
|
|
23188
23027
|
return num.toLocaleString();
|
|
23189
23028
|
}
|
|
23190
23029
|
|
|
23191
23030
|
//#endregion
|
|
23192
23031
|
//#region src/views/status-bar/StatusBar.tsx
|
|
23193
|
-
const SINGLE_MODE_WIDTH = 800;
|
|
23194
|
-
const ROW_COUNT_THRESHOLD = 3;
|
|
23195
23032
|
const StatusBar = () => {
|
|
23196
|
-
const
|
|
23033
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
23197
23034
|
const statusBarService = (0, _univerjs_ui.useDependency)(IStatusBarService);
|
|
23198
|
-
const
|
|
23035
|
+
const [selectedFunction, setSelectedFunction] = (0, react.useState)(_univerjs_engine_formula.FUNCTION_NAMES_MATH.SUM);
|
|
23036
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
23037
|
+
const [statistics, setStatistics] = (0, react.useState)(() => statusBarService.getFunctions().map((item) => ({
|
|
23199
23038
|
name: item.func,
|
|
23200
23039
|
value: 0,
|
|
23201
23040
|
show: true,
|
|
23202
|
-
disable:
|
|
23041
|
+
disable: true,
|
|
23203
23042
|
pattern: null
|
|
23204
|
-
}));
|
|
23205
|
-
|
|
23206
|
-
const
|
|
23207
|
-
|
|
23208
|
-
|
|
23209
|
-
|
|
23210
|
-
const showList = (0, react.useMemo)(() => isSingle && firstItem ? [firstItem] : filteredStatistics, [
|
|
23211
|
-
isSingle,
|
|
23212
|
-
firstItem,
|
|
23213
|
-
filteredStatistics
|
|
23214
|
-
]);
|
|
23215
|
-
const updateStatistics = (0, react.useCallback)((state) => {
|
|
23216
|
-
const items = state === null || state === void 0 ? void 0 : state.values;
|
|
23217
|
-
if (!(items === null || items === void 0 ? void 0 : items.length)) {
|
|
23218
|
-
setShow(false);
|
|
23219
|
-
return;
|
|
23220
|
-
}
|
|
23221
|
-
setShow(true);
|
|
23222
|
-
setStatistics((prevStats) => prevStats.map((stat) => {
|
|
23223
|
-
var _items$find;
|
|
23043
|
+
})));
|
|
23044
|
+
(0, react.useEffect)(() => {
|
|
23045
|
+
const subscription = statusBarService.state$.subscribe((state) => {
|
|
23046
|
+
const values = (state === null || state === void 0 ? void 0 : state.values) ?? [];
|
|
23047
|
+
setStatistics((previousStatistics) => previousStatistics.map((statistic) => {
|
|
23048
|
+
const value = values.find((item) => item.func === statistic.name);
|
|
23224
23049
|
return {
|
|
23225
|
-
...
|
|
23226
|
-
value: (
|
|
23227
|
-
disable: !
|
|
23050
|
+
...statistic,
|
|
23051
|
+
value: (value === null || value === void 0 ? void 0 : value.value) ?? statistic.value,
|
|
23052
|
+
disable: !value,
|
|
23228
23053
|
pattern: (state === null || state === void 0 ? void 0 : state.pattern) ?? null
|
|
23229
23054
|
};
|
|
23230
23055
|
}));
|
|
23231
|
-
}
|
|
23232
|
-
|
|
23233
|
-
|
|
23234
|
-
|
|
23235
|
-
|
|
23236
|
-
|
|
23237
|
-
|
|
23238
|
-
|
|
23239
|
-
|
|
23240
|
-
};
|
|
23056
|
+
});
|
|
23057
|
+
return () => subscription.unsubscribe();
|
|
23058
|
+
}, [statusBarService]);
|
|
23059
|
+
const availableStatistics = statistics.filter((item) => item.show && !item.disable);
|
|
23060
|
+
const selectedStatistic = availableStatistics.find((item) => item.name === selectedFunction) ?? availableStatistics.find((item) => item.name === _univerjs_engine_formula.FUNCTION_NAMES_MATH.SUM) ?? availableStatistics[0];
|
|
23061
|
+
if (!selectedStatistic) return null;
|
|
23062
|
+
const formatStatistic = (item) => {
|
|
23063
|
+
const localeKey = functionDisplayNames[item.name] || item.name;
|
|
23064
|
+
return `${localeService.t(localeKey)}: ${formatNumber(item)}`;
|
|
23241
23065
|
};
|
|
23242
|
-
const
|
|
23243
|
-
|
|
23244
|
-
|
|
23245
|
-
if (isSingle !== newSingleState) setIsSingle(newSingleState);
|
|
23246
|
-
}, 100);
|
|
23247
|
-
(0, react.useEffect)(() => {
|
|
23248
|
-
window.addEventListener("resize", handleResize);
|
|
23249
|
-
return () => {
|
|
23250
|
-
window.removeEventListener("resize", handleResize);
|
|
23251
|
-
};
|
|
23252
|
-
}, [isSingle]);
|
|
23253
|
-
const getStatisticLayout = (showList, rowCountThreshold, CopyableStatisticItem) => {
|
|
23254
|
-
if (showList.length > rowCountThreshold) return showList.reduce((acc, _, index) => {
|
|
23255
|
-
if (index % 2 === 0) acc.push(showList.slice(index, index + 2));
|
|
23256
|
-
return acc;
|
|
23257
|
-
}, []).map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
23258
|
-
className: "univer-grid univer-h-full univer-items-center",
|
|
23259
|
-
children: [item[0] && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyableStatisticItem, { ...item[0] }, item[0].name), item[1] && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyableStatisticItem, { ...item[1] }, item[1].name)]
|
|
23260
|
-
}, `stat-col-${index}`));
|
|
23261
|
-
return showList.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23262
|
-
className: "univer-grid univer-h-full univer-items-center",
|
|
23263
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyableStatisticItem, { ...item })
|
|
23264
|
-
}, item.name));
|
|
23066
|
+
const handleSelect = (name) => {
|
|
23067
|
+
setSelectedFunction(name);
|
|
23068
|
+
setOpen(false);
|
|
23265
23069
|
};
|
|
23266
|
-
|
|
23267
|
-
|
|
23268
|
-
|
|
23269
|
-
"
|
|
23270
|
-
"
|
|
23271
|
-
|
|
23272
|
-
|
|
23273
|
-
|
|
23274
|
-
|
|
23070
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23071
|
+
className: "univer-relative univer-box-border univer-flex univer-h-full univer-min-w-0 univer-max-w-64 univer-items-center univer-overflow-hidden univer-px-2 after:univer-absolute after:univer-right-0 after:univer-top-1/2 after:univer-block after:univer-h-4 after:univer-w-px after:-univer-translate-y-1/2 after:univer-bg-gray-200 after:univer-content-[\"\"]",
|
|
23072
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
|
|
23073
|
+
align: "end",
|
|
23074
|
+
side: "top",
|
|
23075
|
+
open,
|
|
23076
|
+
onOpenChange: setOpen,
|
|
23077
|
+
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23078
|
+
"data-u-comp": "status-bar-statistic-menu",
|
|
23079
|
+
className: "univer-grid univer-w-max univer-max-w-[calc(100vw-16px)] univer-gap-0.5 univer-p-1.5",
|
|
23080
|
+
children: availableStatistics.map((item) => {
|
|
23081
|
+
const text = formatStatistic(item);
|
|
23082
|
+
const selected = item.name === selectedStatistic.name;
|
|
23083
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
23084
|
+
type: "button",
|
|
23085
|
+
className: (0, _univerjs_design.clsx)("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-px-2 univer-py-1.5 univer-text-left univer-text-xs univer-text-gray-900 hover:univer-bg-gray-100 dark:!univer-text-gray-200 dark:hover:!univer-bg-gray-800", { "univer-bg-gray-100 dark:!univer-bg-gray-800": selected }),
|
|
23086
|
+
"aria-pressed": selected,
|
|
23087
|
+
onClick: () => handleSelect(item.name),
|
|
23088
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
23089
|
+
className: "univer-w-3 univer-shrink-0",
|
|
23090
|
+
children: selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CheckMarkIcon, {})
|
|
23091
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
23092
|
+
title: text,
|
|
23093
|
+
placement: "top",
|
|
23094
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
23095
|
+
className: "univer-min-w-0 univer-flex-1 univer-truncate",
|
|
23096
|
+
children: text
|
|
23097
|
+
})
|
|
23098
|
+
})]
|
|
23099
|
+
}, item.name);
|
|
23100
|
+
})
|
|
23101
|
+
}),
|
|
23102
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
23103
|
+
type: "button",
|
|
23104
|
+
"data-u-comp": "status-bar-statistic-picker",
|
|
23105
|
+
className: "univer-flex univer-min-w-0 univer-max-w-full univer-cursor-pointer univer-items-center univer-gap-1 univer-border-none univer-bg-transparent univer-p-0 univer-text-xs univer-text-gray-400",
|
|
23106
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
23107
|
+
title: formatStatistic(selectedStatistic),
|
|
23108
|
+
placement: "top",
|
|
23109
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
23110
|
+
className: "univer-min-w-0 univer-flex-1 univer-truncate",
|
|
23111
|
+
children: formatStatistic(selectedStatistic)
|
|
23112
|
+
})
|
|
23113
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "univer-shrink-0" })]
|
|
23114
|
+
})
|
|
23275
23115
|
})
|
|
23276
23116
|
});
|
|
23277
23117
|
};
|
|
@@ -23283,9 +23123,7 @@ function RenderSheetFooter() {
|
|
|
23283
23123
|
const config = (0, _univerjs_ui.useConfigValue)(SHEETS_UI_PLUGIN_CONFIG_KEY);
|
|
23284
23124
|
const menuManagerService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IMenuManagerService);
|
|
23285
23125
|
const showFooter = (config === null || config === void 0 ? void 0 : config.footer) ?? true;
|
|
23286
|
-
const
|
|
23287
|
-
const workbook = useSheetLoadingWorkbook() ?? activeWorkbook;
|
|
23288
|
-
const isLoading = useSheetLoading();
|
|
23126
|
+
const workbook = useRootWorkbenchWorkbook();
|
|
23289
23127
|
const activeWorkbookEmbeddedRender = useActiveWorkbookIsEmbeddedRender(workbook);
|
|
23290
23128
|
const focusedUnitType = useFocusedUnitType();
|
|
23291
23129
|
const activeEmbedTab = useActiveSheetEmbedTabData(workbook);
|
|
@@ -23298,33 +23136,27 @@ function RenderSheetFooter() {
|
|
|
23298
23136
|
const showMenus = activeEmbedTab ? false : menus;
|
|
23299
23137
|
const showZoomSlider = activeEmbedTab ? false : zoomSlider;
|
|
23300
23138
|
if (!sheetBar && !showStatisticBar && !showMenus && !showZoomSlider) return null;
|
|
23301
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
23302
|
-
|
|
23303
|
-
|
|
23304
|
-
|
|
23305
|
-
|
|
23306
|
-
|
|
23307
|
-
|
|
23308
|
-
|
|
23309
|
-
|
|
23310
|
-
|
|
23311
|
-
|
|
23312
|
-
|
|
23313
|
-
|
|
23314
|
-
|
|
23315
|
-
|
|
23316
|
-
|
|
23317
|
-
}),
|
|
23318
|
-
showZoomSlider && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetZoomSlider, {})
|
|
23319
|
-
]
|
|
23320
|
-
})
|
|
23139
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
23140
|
+
className: "univer-box-border univer-grid univer-w-full univer-grid-flow-col univer-grid-cols-[1fr,auto,auto,auto] univer-items-center univer-justify-between univer-bg-gray-0 univer-px-5 univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-gray-200",
|
|
23141
|
+
"data-range-selector": true,
|
|
23142
|
+
style: { height: 36 },
|
|
23143
|
+
children: [
|
|
23144
|
+
sheetBar && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetBar, {}),
|
|
23145
|
+
showStatisticBar && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusBar, {}),
|
|
23146
|
+
showMenus && footerMenus.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23147
|
+
className: "univer-box-border univer-flex univer-gap-2 univer-px-2",
|
|
23148
|
+
children: footerMenus.map((item) => {
|
|
23149
|
+
var _item$children;
|
|
23150
|
+
return (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.map((child) => (child === null || child === void 0 ? void 0 : child.item) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.ToolbarItem, { ...child.item }, child.key));
|
|
23151
|
+
})
|
|
23152
|
+
}),
|
|
23153
|
+
showZoomSlider && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetZoomSlider, {})
|
|
23154
|
+
]
|
|
23321
23155
|
});
|
|
23322
23156
|
}
|
|
23323
23157
|
function RenderSheetHeader() {
|
|
23324
23158
|
const config = (0, _univerjs_ui.useConfigValue)(SHEETS_UI_PLUGIN_CONFIG_KEY);
|
|
23325
|
-
const
|
|
23326
|
-
const workbook = useSheetLoadingWorkbook() ?? activeWorkbook;
|
|
23327
|
-
const isLoading = useSheetLoading();
|
|
23159
|
+
const workbook = useRootWorkbenchWorkbook();
|
|
23328
23160
|
const hasWorkbook = !!workbook;
|
|
23329
23161
|
const activeWorkbookEmbeddedRender = useActiveWorkbookIsEmbeddedRender(workbook);
|
|
23330
23162
|
const focusedUnitType = useFocusedUnitType();
|
|
@@ -23334,17 +23166,10 @@ function RenderSheetHeader() {
|
|
|
23334
23166
|
if (activeEmbedTab) return null;
|
|
23335
23167
|
if (focusedUnitType != null && focusedUnitType !== _univerjs_core.UniverInstanceType.UNIVER_SHEET) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23336
23168
|
"aria-hidden": true,
|
|
23337
|
-
className: "univer-h-7 univer-border-b univer-border-gray-200 univer-bg-
|
|
23169
|
+
className: "univer-h-7 univer-border-b univer-border-gray-200 univer-bg-gray-0 dark:!univer-border-gray-700 dark:!univer-bg-gray-900",
|
|
23338
23170
|
"data-u-comp": "formula-bar-placeholder"
|
|
23339
23171
|
});
|
|
23340
|
-
if ((config === null || config === void 0 ? void 0 : config.formulaBar) !== false) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
23341
|
-
value: workbook,
|
|
23342
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23343
|
-
"aria-disabled": isLoading,
|
|
23344
|
-
className: (0, _univerjs_design.clsx)({ "univer-pointer-events-none": isLoading }),
|
|
23345
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormulaBar, {})
|
|
23346
|
-
})
|
|
23347
|
-
});
|
|
23172
|
+
if ((config === null || config === void 0 ? void 0 : config.formulaBar) !== false) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormulaBar, {});
|
|
23348
23173
|
return null;
|
|
23349
23174
|
}
|
|
23350
23175
|
/**
|
|
@@ -23352,18 +23177,17 @@ function RenderSheetHeader() {
|
|
|
23352
23177
|
*/
|
|
23353
23178
|
function RenderSheetContent() {
|
|
23354
23179
|
const config = (0, _univerjs_ui.useConfigValue)(SHEETS_UI_PLUGIN_CONFIG_KEY);
|
|
23355
|
-
const isLoading = useSheetLoading();
|
|
23356
|
-
const isPreviewReady = useSheetLoadingPreviewReady();
|
|
23357
23180
|
const componentManager = (0, _univerjs_ui.useDependency)(_univerjs_ui.ComponentManager);
|
|
23358
|
-
const
|
|
23359
|
-
const workbook = useSheetLoadingWorkbook() ?? activeWorkbook;
|
|
23181
|
+
const workbook = useRootWorkbenchWorkbook();
|
|
23360
23182
|
const activeEmbedTab = useActiveSheetEmbedTabData(workbook);
|
|
23361
23183
|
const injector = (0, _univerjs_ui.useDependency)(_univerjs_core.Injector);
|
|
23362
23184
|
const activeWorkbookEmbeddedRender = useActiveWorkbookIsEmbeddedRender(workbook);
|
|
23185
|
+
const focusedUnitType = useFocusedUnitType();
|
|
23186
|
+
const rootWorkbenchOwnsSheet = activeEmbedTab != null || focusedUnitType == null || focusedUnitType === _univerjs_core.UniverInstanceType.UNIVER_SHEET;
|
|
23363
23187
|
const ShapeTextEditorContainer = componentManager.get("SheetShapeTextEditorContainer") ?? componentManager.get("ShapeTextEditorContainer");
|
|
23364
23188
|
(0, react.useEffect)(() => {
|
|
23365
23189
|
var _tryGetSheetEmbedRunt;
|
|
23366
|
-
if (!workbook ||
|
|
23190
|
+
if (!workbook || activeEmbedTab || activeWorkbookEmbeddedRender || !rootWorkbenchOwnsSheet) return;
|
|
23367
23191
|
const instanceService = injector.get(_univerjs_core.IUniverInstanceService);
|
|
23368
23192
|
instanceService.setCurrentUnitForType(workbook.getUnitId());
|
|
23369
23193
|
instanceService.focusUnit(workbook.getUnitId());
|
|
@@ -23372,11 +23196,11 @@ function RenderSheetContent() {
|
|
|
23372
23196
|
activeEmbedTab,
|
|
23373
23197
|
activeWorkbookEmbeddedRender,
|
|
23374
23198
|
injector,
|
|
23375
|
-
|
|
23199
|
+
rootWorkbenchOwnsSheet,
|
|
23376
23200
|
workbook
|
|
23377
23201
|
]);
|
|
23378
23202
|
if (!workbook) return null;
|
|
23379
|
-
if (
|
|
23203
|
+
if (!rootWorkbenchOwnsSheet) return null;
|
|
23380
23204
|
if (activeWorkbookEmbeddedRender) return null;
|
|
23381
23205
|
if (activeEmbedTab && workbook) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderSheetEmbedTabHost, {
|
|
23382
23206
|
workbook,
|
|
@@ -23388,42 +23212,6 @@ function RenderSheetContent() {
|
|
|
23388
23212
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(AutoFillPopupMenu, {})
|
|
23389
23213
|
] });
|
|
23390
23214
|
}
|
|
23391
|
-
function SheetLoadingSkeleton() {
|
|
23392
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
23393
|
-
"data-u-comp": "sheet-loading-skeleton",
|
|
23394
|
-
"aria-busy": true,
|
|
23395
|
-
className: "univer-absolute univer-inset-0 univer-z-10 univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-900",
|
|
23396
|
-
children: [
|
|
23397
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23398
|
-
className: "univer-absolute univer-right-0 univer-top-0 univer-border-b univer-border-gray-200 univer-bg-gray-50 dark:!univer-border-gray-700 dark:!univer-bg-gray-800",
|
|
23399
|
-
style: {
|
|
23400
|
-
left: _univerjs_core.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH,
|
|
23401
|
-
height: _univerjs_core.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT
|
|
23402
|
-
}
|
|
23403
|
-
}),
|
|
23404
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23405
|
-
className: "univer-absolute univer-bottom-0 univer-left-0 univer-border-r univer-border-gray-200 univer-bg-gray-50 dark:!univer-border-gray-700 dark:!univer-bg-gray-800",
|
|
23406
|
-
style: {
|
|
23407
|
-
top: _univerjs_core.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT,
|
|
23408
|
-
width: _univerjs_core.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH
|
|
23409
|
-
}
|
|
23410
|
-
}),
|
|
23411
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23412
|
-
className: "univer-absolute univer-bottom-0 univer-right-0 univer-animate-pulse univer-text-gray-200 dark:!univer-text-gray-700",
|
|
23413
|
-
style: {
|
|
23414
|
-
top: _univerjs_core.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT,
|
|
23415
|
-
left: _univerjs_core.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH,
|
|
23416
|
-
backgroundImage: "linear-gradient(to right, currentColor 1px, transparent 1px), linear-gradient(to bottom, currentColor 1px, transparent 1px)",
|
|
23417
|
-
backgroundSize: `${_univerjs_core.DEFAULT_WORKSHEET_COLUMN_WIDTH}px ${_univerjs_core.DEFAULT_WORKSHEET_ROW_HEIGHT}px`
|
|
23418
|
-
}
|
|
23419
|
-
}),
|
|
23420
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LoadingMultiIcon, {
|
|
23421
|
-
"aria-hidden": true,
|
|
23422
|
-
className: "univer-absolute univer-left-1/2 univer-top-1/2 univer-size-6 -univer-translate-x-1/2 -univer-translate-y-1/2 univer-animate-spin univer-text-violet-500"
|
|
23423
|
-
})
|
|
23424
|
-
]
|
|
23425
|
-
});
|
|
23426
|
-
}
|
|
23427
23215
|
function RenderSheetEmbedTabHost(props) {
|
|
23428
23216
|
const { workbook, worksheet } = props;
|
|
23429
23217
|
const injector = (0, _univerjs_ui.useDependency)(_univerjs_core.Injector);
|
|
@@ -23455,16 +23243,42 @@ function RenderSheetEmbedTabHost(props) {
|
|
|
23455
23243
|
]);
|
|
23456
23244
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
23457
23245
|
"data-embed-sheets-sheet-tab-host": hostAnchorId,
|
|
23458
|
-
className: "univer-absolute univer-inset-0 univer-z-40 univer-bg-
|
|
23246
|
+
className: "univer-absolute univer-inset-0 univer-z-40 univer-bg-gray-0 dark:!univer-bg-gray-900"
|
|
23459
23247
|
});
|
|
23460
23248
|
}
|
|
23461
23249
|
function useActiveWorkbookIsEmbeddedRender(workbook) {
|
|
23462
23250
|
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
23251
|
+
const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
|
|
23252
|
+
const injector = (0, _univerjs_ui.useDependency)(_univerjs_core.Injector);
|
|
23253
|
+
const runtimeFocusCoordinator = injector.has(ISheetEmbedRuntimeFocusCoordinator) ? injector.get(ISheetEmbedRuntimeFocusCoordinator) : void 0;
|
|
23463
23254
|
return (0, react.useMemo)(() => {
|
|
23464
|
-
var _univerInstanceServic;
|
|
23255
|
+
var _renderManagerService, _univerInstanceServic;
|
|
23465
23256
|
if (!workbook) return false;
|
|
23466
|
-
return ((_univerInstanceServic = univerInstanceService.getUnitCreateOptions(workbook.getUnitId())) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.embeddedRender) === true;
|
|
23467
|
-
}, [
|
|
23257
|
+
return (runtimeFocusCoordinator === null || runtimeFocusCoordinator === void 0 ? void 0 : runtimeFocusCoordinator.resolveRuntimeScopeByChildUnitId(workbook.getUnitId())) != null || ((_renderManagerService = renderManagerService.getRenderUnitById(workbook.getUnitId())) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.isMainScene) === false || ((_univerInstanceServic = univerInstanceService.getUnitCreateOptions(workbook.getUnitId())) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.embeddedRender) === true;
|
|
23258
|
+
}, [
|
|
23259
|
+
(0, _univerjs_ui.useObservable)(() => (0, rxjs.merge)(renderManagerService.created$, renderManagerService.disposed$, (runtimeFocusCoordinator === null || runtimeFocusCoordinator === void 0 ? void 0 : runtimeFocusCoordinator.runtimeSessionChanged$) ?? rxjs.EMPTY), null, false, [renderManagerService, runtimeFocusCoordinator]),
|
|
23260
|
+
renderManagerService,
|
|
23261
|
+
runtimeFocusCoordinator,
|
|
23262
|
+
univerInstanceService,
|
|
23263
|
+
workbook
|
|
23264
|
+
]);
|
|
23265
|
+
}
|
|
23266
|
+
function useRootWorkbenchWorkbook() {
|
|
23267
|
+
const activeWorkbook = useActiveWorkbook();
|
|
23268
|
+
const injector = (0, _univerjs_ui.useDependency)(_univerjs_core.Injector);
|
|
23269
|
+
const instanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
23270
|
+
const runtimeFocusCoordinator = injector.has(ISheetEmbedRuntimeFocusCoordinator) ? injector.get(ISheetEmbedRuntimeFocusCoordinator) : void 0;
|
|
23271
|
+
return (0, react.useMemo)(() => {
|
|
23272
|
+
if (!activeWorkbook || !runtimeFocusCoordinator) return activeWorkbook;
|
|
23273
|
+
const runtimeScope = runtimeFocusCoordinator.resolveRuntimeScopeByChildUnitId(activeWorkbook.getUnitId());
|
|
23274
|
+
if (!(runtimeScope === null || runtimeScope === void 0 ? void 0 : runtimeScope.hostUnitId)) return activeWorkbook;
|
|
23275
|
+
return instanceService.getUnit(runtimeScope.hostUnitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET) ?? activeWorkbook;
|
|
23276
|
+
}, [
|
|
23277
|
+
activeWorkbook,
|
|
23278
|
+
instanceService,
|
|
23279
|
+
runtimeFocusCoordinator,
|
|
23280
|
+
(0, _univerjs_ui.useObservable)(() => (runtimeFocusCoordinator === null || runtimeFocusCoordinator === void 0 ? void 0 : runtimeFocusCoordinator.runtimeSessionChanged$) ?? rxjs.EMPTY, null, false, [runtimeFocusCoordinator])
|
|
23281
|
+
]);
|
|
23468
23282
|
}
|
|
23469
23283
|
function useFocusedUnitType() {
|
|
23470
23284
|
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
@@ -24099,7 +23913,7 @@ const useHighlightRange = (ranges = []) => {
|
|
|
24099
23913
|
//#endregion
|
|
24100
23914
|
//#region package.json
|
|
24101
23915
|
var name = "@univerjs/sheets-ui";
|
|
24102
|
-
var version = "1.0.0-beta.
|
|
23916
|
+
var version = "1.0.0-beta.1";
|
|
24103
23917
|
|
|
24104
23918
|
//#endregion
|
|
24105
23919
|
//#region src/views/cell-popup/config.ts
|
|
@@ -24269,6 +24083,8 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends _u
|
|
|
24269
24083
|
disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
|
|
24270
24084
|
if (shouldUpdatePosition(commandInfo.id)) position$.next(calc());
|
|
24271
24085
|
}));
|
|
24086
|
+
const viewMain = currentRender.scene.getViewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN);
|
|
24087
|
+
if (viewMain) disposable.add(viewMain.onScrollAfter$.subscribeEvent(() => position$.next(calc())));
|
|
24272
24088
|
return {
|
|
24273
24089
|
position,
|
|
24274
24090
|
position$,
|
|
@@ -24315,6 +24131,9 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends _u
|
|
|
24315
24131
|
};
|
|
24316
24132
|
const { position, position$, disposable } = this._createPositionObserver(bound, currentRender, skeleton, worksheet);
|
|
24317
24133
|
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
24134
|
+
const canvasElement = currentRender.engine.getCanvasElement();
|
|
24135
|
+
const scaleAdjust = canvasElement.getBoundingClientRect().width / pxToNum(canvasElement.style.width);
|
|
24136
|
+
const { scaleX, scaleY } = currentRender.scene.getAncestorScale();
|
|
24318
24137
|
const id = this._globalPopupManagerService.addPopup({
|
|
24319
24138
|
...popup,
|
|
24320
24139
|
unitId,
|
|
@@ -24322,7 +24141,11 @@ let SheetCanvasPopManagerService = class SheetCanvasPopManagerService extends _u
|
|
|
24322
24141
|
connectorInjector: popupInjector,
|
|
24323
24142
|
anchorRect: position,
|
|
24324
24143
|
anchorRect$: position$,
|
|
24325
|
-
canvasElement
|
|
24144
|
+
canvasElement,
|
|
24145
|
+
boundaryInsets: popup.constrainToCanvas ? {
|
|
24146
|
+
left: skeleton.rowHeaderWidth * scaleAdjust * scaleX,
|
|
24147
|
+
top: skeleton.columnHeaderHeight * scaleAdjust * scaleY
|
|
24148
|
+
} : popup.boundaryInsets
|
|
24326
24149
|
});
|
|
24327
24150
|
const disposableCollection = new _univerjs_core.DisposableCollection();
|
|
24328
24151
|
disposableCollection.add(disposable);
|
|
@@ -24735,6 +24558,11 @@ function shouldUpdatePosition(commandId) {
|
|
|
24735
24558
|
|
|
24736
24559
|
//#endregion
|
|
24737
24560
|
//#region src/services/cell-popup-manager.service.ts
|
|
24561
|
+
const CELL_POPUP_DIRECTIONS = [
|
|
24562
|
+
"horizontal",
|
|
24563
|
+
"vertical",
|
|
24564
|
+
"left-center"
|
|
24565
|
+
];
|
|
24738
24566
|
let CellPopupManagerService = class CellPopupManagerService extends _univerjs_core.Disposable {
|
|
24739
24567
|
constructor(_sheetCanvasPopManagerService) {
|
|
24740
24568
|
super();
|
|
@@ -24790,7 +24618,7 @@ let CellPopupManagerService = class CellPopupManagerService extends _univerjs_co
|
|
|
24790
24618
|
direction
|
|
24791
24619
|
},
|
|
24792
24620
|
noPushMinimumGap: true,
|
|
24793
|
-
autoRelayout: false,
|
|
24621
|
+
autoRelayout: popup.autoRelayout ?? false,
|
|
24794
24622
|
zIndex: 90
|
|
24795
24623
|
}, unitId, subUnitId);
|
|
24796
24624
|
subUnitMap.setValue(row, col, {
|
|
@@ -24818,31 +24646,21 @@ let CellPopupManagerService = class CellPopupManagerService extends _univerjs_co
|
|
|
24818
24646
|
const subUnitMap = this._ensureCellPopupMap(unitId, subUnitId);
|
|
24819
24647
|
const cache = subUnitMap.getValue(row, col);
|
|
24820
24648
|
if (!cache) return;
|
|
24821
|
-
|
|
24822
|
-
var
|
|
24823
|
-
|
|
24824
|
-
|
|
24825
|
-
|
|
24826
|
-
|
|
24827
|
-
subUnitId,
|
|
24828
|
-
row,
|
|
24829
|
-
col,
|
|
24830
|
-
direction: "horizontal"
|
|
24831
|
-
});
|
|
24832
|
-
}
|
|
24833
|
-
if (cache.vertical) {
|
|
24834
|
-
var _cache$vertical$dispo;
|
|
24835
|
-
(_cache$vertical$dispo = cache.vertical.disposable) === null || _cache$vertical$dispo === void 0 || _cache$vertical$dispo.dispose();
|
|
24836
|
-
cache.vertical = void 0;
|
|
24649
|
+
CELL_POPUP_DIRECTIONS.forEach((direction) => {
|
|
24650
|
+
var _directionCache$dispo2;
|
|
24651
|
+
const directionCache = cache[direction];
|
|
24652
|
+
if (!directionCache) return;
|
|
24653
|
+
(_directionCache$dispo2 = directionCache.disposable) === null || _directionCache$dispo2 === void 0 || _directionCache$dispo2.dispose();
|
|
24654
|
+
cache[direction] = void 0;
|
|
24837
24655
|
this._change$.next({
|
|
24838
24656
|
unitId,
|
|
24839
24657
|
subUnitId,
|
|
24840
24658
|
row,
|
|
24841
24659
|
col,
|
|
24842
|
-
direction
|
|
24660
|
+
direction
|
|
24843
24661
|
});
|
|
24844
|
-
}
|
|
24845
|
-
if (
|
|
24662
|
+
});
|
|
24663
|
+
if (CELL_POPUP_DIRECTIONS.every((direction) => !cache[direction])) subUnitMap.realDeleteValue(row, col);
|
|
24846
24664
|
}
|
|
24847
24665
|
hidePopupsForUnit(unitId, subUnitId) {
|
|
24848
24666
|
const unitMap = this._cellPopupMap.get(unitId);
|
|
@@ -25561,12 +25379,12 @@ function BorderPanel(props) {
|
|
|
25561
25379
|
})
|
|
25562
25380
|
}),
|
|
25563
25381
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
25564
|
-
className: "univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
25382
|
+
className: "univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-p-1 univer-text-gray-900 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
25565
25383
|
type: "button",
|
|
25566
25384
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.PaintBucketDoubleIcon, {
|
|
25567
|
-
className: "univer-fill-primary-600 dark:!univer-text-
|
|
25385
|
+
className: "univer-fill-primary-600 dark:!univer-text-gray-0",
|
|
25568
25386
|
extend: { colorChannel1: (value === null || value === void 0 ? void 0 : value.color) ?? "" }
|
|
25569
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "dark:!univer-text-
|
|
25387
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "dark:!univer-text-gray-0" })]
|
|
25570
25388
|
})
|
|
25571
25389
|
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
|
|
25572
25390
|
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
@@ -25577,19 +25395,19 @@ function BorderPanel(props) {
|
|
|
25577
25395
|
className: "univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-px-1 univer-py-3 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
25578
25396
|
onClick: () => handleClick(item.value, "style"),
|
|
25579
25397
|
children: [item.value === type && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CheckMarkIcon, { className: "univer-absolute univer-left-3 univer-text-primary-600" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BorderLine, {
|
|
25580
|
-
className: "univer-ml-6 univer-fill-gray-900 dark:!univer-fill-
|
|
25398
|
+
className: "univer-ml-6 univer-fill-gray-900 dark:!univer-fill-gray-0",
|
|
25581
25399
|
type: item.value
|
|
25582
25400
|
})]
|
|
25583
25401
|
}, item.value))
|
|
25584
25402
|
})
|
|
25585
25403
|
}),
|
|
25586
25404
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
25587
|
-
className: "univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
25405
|
+
className: "univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-p-1 univer-text-gray-900 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
25588
25406
|
type: "button",
|
|
25589
25407
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BorderLine, {
|
|
25590
|
-
className: "univer-fill-gray-900 dark:!univer-fill-
|
|
25408
|
+
className: "univer-fill-gray-900 dark:!univer-fill-gray-0",
|
|
25591
25409
|
type: type ?? _univerjs_core.BorderStyleTypes.THIN
|
|
25592
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "dark:!univer-text-
|
|
25410
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "dark:!univer-text-gray-0" })]
|
|
25593
25411
|
})
|
|
25594
25412
|
}) })]
|
|
25595
25413
|
})
|
|
@@ -25621,6 +25439,7 @@ let CellAlertManagerService = class CellAlertManagerService extends _univerjs_co
|
|
|
25621
25439
|
});
|
|
25622
25440
|
}
|
|
25623
25441
|
showAlert(alert) {
|
|
25442
|
+
var _alert$menu, _alert$menu2, _alert$menu3;
|
|
25624
25443
|
let lastPopup = this._currentAlert.get(alert.key);
|
|
25625
25444
|
if (lastPopup) lastPopup.dispose.dispose();
|
|
25626
25445
|
if (lastPopup) lastPopup.dispose.dispose();
|
|
@@ -25641,7 +25460,9 @@ let CellAlertManagerService = class CellAlertManagerService extends _univerjs_co
|
|
|
25641
25460
|
col
|
|
25642
25461
|
}, {
|
|
25643
25462
|
componentKey: CELL_ALERT_KEY,
|
|
25644
|
-
direction: "horizontal",
|
|
25463
|
+
direction: ((_alert$menu = alert.menu) === null || _alert$menu === void 0 ? void 0 : _alert$menu.length) ? "left-center" : "horizontal",
|
|
25464
|
+
autoRelayout: Boolean((_alert$menu2 = alert.menu) === null || _alert$menu2 === void 0 ? void 0 : _alert$menu2.length),
|
|
25465
|
+
showOnSelectionMoving: Boolean((_alert$menu3 = alert.menu) === null || _alert$menu3 === void 0 ? void 0 : _alert$menu3.length),
|
|
25645
25466
|
extraProps: { alert },
|
|
25646
25467
|
priority: 1
|
|
25647
25468
|
});
|
|
@@ -25681,18 +25502,53 @@ CellAlertManagerService = __decorate([__decorateParam(0, _univerjs_engine_render
|
|
|
25681
25502
|
*/
|
|
25682
25503
|
function CellAlert({ popup }) {
|
|
25683
25504
|
var _popup$extraProps;
|
|
25505
|
+
const [visible, setVisible] = (0, react.useState)(false);
|
|
25506
|
+
const [isHovered, setIsHovered] = (0, react.useState)(false);
|
|
25684
25507
|
const alert = (_popup$extraProps = popup.extraProps) === null || _popup$extraProps === void 0 ? void 0 : _popup$extraProps.alert;
|
|
25685
25508
|
if (!alert) return null;
|
|
25686
|
-
const { type, title, message } = alert;
|
|
25509
|
+
const { type, title, message, menu } = alert;
|
|
25510
|
+
if (menu === null || menu === void 0 ? void 0 : menu.length) {
|
|
25511
|
+
const accessibleLabel = [title, message].filter((value) => typeof value === "string").join(": ");
|
|
25512
|
+
const showMore = visible || isHovered;
|
|
25513
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
25514
|
+
onMouseEnter: () => setIsHovered(true),
|
|
25515
|
+
onMouseLeave: () => setIsHovered(false),
|
|
25516
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
25517
|
+
align: "start",
|
|
25518
|
+
open: visible,
|
|
25519
|
+
onOpenChange: setVisible,
|
|
25520
|
+
items: [
|
|
25521
|
+
{
|
|
25522
|
+
type: "custom",
|
|
25523
|
+
className: "univer-px-2 univer-py-1.5 univer-font-medium univer-text-gray-900 dark:!univer-text-gray-0",
|
|
25524
|
+
children: message
|
|
25525
|
+
},
|
|
25526
|
+
{ type: "separator" },
|
|
25527
|
+
...menu.map((item) => ({
|
|
25528
|
+
type: "item",
|
|
25529
|
+
children: item.label,
|
|
25530
|
+
disabled: item.disabled,
|
|
25531
|
+
onSelect: item.onSelect
|
|
25532
|
+
}))
|
|
25533
|
+
],
|
|
25534
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
25535
|
+
type: "button",
|
|
25536
|
+
"aria-label": accessibleLabel || void 0,
|
|
25537
|
+
className: "univer-flex univer-items-center univer-gap-1 univer-rounded univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-p-1 univer-shadow hover:univer-bg-gray-100 dark:!univer-border-gray-600 dark:!univer-bg-gray-900 dark:hover:!univer-bg-gray-800",
|
|
25538
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.WarningIcon, { className: "univer-text-yellow-500" }), showMore && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, { className: "univer-text-gray-600 dark:!univer-text-gray-300" })]
|
|
25539
|
+
})
|
|
25540
|
+
})
|
|
25541
|
+
});
|
|
25542
|
+
}
|
|
25687
25543
|
const iconMap = {
|
|
25688
|
-
[2]: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ErrorIcon, { className: "univer-
|
|
25689
|
-
[0]: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.InfoIcon, { className: "univer-
|
|
25690
|
-
[1]: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.WarningIcon, { className: "univer-
|
|
25544
|
+
[2]: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ErrorIcon, { className: "univer-text-red-500" }),
|
|
25545
|
+
[0]: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.InfoIcon, { className: "univer-text-blue-500" }),
|
|
25546
|
+
[1]: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.WarningIcon, { className: "univer-text-yellow-500" })
|
|
25691
25547
|
};
|
|
25692
25548
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
25693
|
-
className: "univer-z-[100] univer-box-border univer-w-[156px] univer-rounded-lg univer-bg-
|
|
25549
|
+
className: "univer-z-[100] univer-box-border univer-w-[156px] univer-rounded-lg univer-bg-gray-0 univer-px-2 univer-py-1 univer-text-gray-900 univer-shadow dark:!univer-bg-gray-1000 dark:!univer-text-gray-0",
|
|
25694
25550
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
25695
|
-
className: "univer-mb-1.5 univer-flex univer-h-5 univer-flex-row univer-items-center univer-text-sm univer-font-medium",
|
|
25551
|
+
className: "univer-mb-1.5 univer-flex univer-h-5 univer-flex-row univer-items-center univer-gap-x-1.5 univer-text-sm univer-font-medium",
|
|
25696
25552
|
children: [type ? iconMap[type] : null, title]
|
|
25697
25553
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
25698
25554
|
className: "univer-text-sm",
|
|
@@ -25722,7 +25578,10 @@ const CellPopup = (props) => {
|
|
|
25722
25578
|
const componentManager = (0, _univerjs_ui.useDependency)(_univerjs_ui.ComponentManager);
|
|
25723
25579
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
25724
25580
|
"data-u-comp": "sheets-ui-cell-popup",
|
|
25725
|
-
className:
|
|
25581
|
+
className: `
|
|
25582
|
+
${direction === "left-center" ? "univer-mr-px" : "univer-ml-px"}
|
|
25583
|
+
univer-flex univer-flex-col
|
|
25584
|
+
`,
|
|
25726
25585
|
children: popups.map((popup) => {
|
|
25727
25586
|
const Component = componentManager.get(popup.componentKey);
|
|
25728
25587
|
return Component ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, { popup }, popup.id ?? popup.componentKey) : null;
|
|
@@ -25864,7 +25723,7 @@ function DefinedNameInputContent(props) {
|
|
|
25864
25723
|
className: "univer-relative univer-h-8 univer-select-none",
|
|
25865
25724
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormulaEditor, {
|
|
25866
25725
|
ref: formulaEditorRef,
|
|
25867
|
-
className: (0, _univerjs_design.clsx)("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-
|
|
25726
|
+
className: (0, _univerjs_design.clsx)("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-gray-0 univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", _univerjs_design.borderClassName),
|
|
25868
25727
|
initValue: formulaOrRefStringValue,
|
|
25869
25728
|
unitId,
|
|
25870
25729
|
subUnitId,
|
|
@@ -26100,7 +25959,7 @@ const DefinedNameContainer = () => {
|
|
|
26100
25959
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
26101
25960
|
title: definedName.comment,
|
|
26102
25961
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
26103
|
-
className: "univer-my-1 univer-max-h-[100px] univer-max-w-[190px] univer-truncate univer-text-sm univer-font-medium univer-text-gray-900 dark:!univer-text-
|
|
25962
|
+
className: "univer-my-1 univer-max-h-[100px] univer-max-w-[190px] univer-truncate univer-text-sm univer-font-medium univer-text-gray-900 dark:!univer-text-gray-0",
|
|
26104
25963
|
children: [definedName.name, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
26105
25964
|
className: "univer-text-xxs univer-ml-1 univer-text-gray-400",
|
|
26106
25965
|
children: definedName.localSheetId === _univerjs_sheets.SCOPE_WORKBOOK_VALUE_DEFINED_NAME || definedName.localSheetId == null ? "" : getSheetNameBySheetId(definedName.localSheetId)
|
|
@@ -26207,7 +26066,7 @@ function DateDropdown(props) {
|
|
|
26207
26066
|
if (await (onChange === null || onChange === void 0 ? void 0 : onChange(date))) hideFn();
|
|
26208
26067
|
};
|
|
26209
26068
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
26210
|
-
className: "univer-rounded univer-bg-
|
|
26069
|
+
className: "univer-rounded univer-bg-gray-0 univer-p-2 univer-shadow-lg dark:!univer-bg-gray-1000",
|
|
26211
26070
|
children: [patternType === "time" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.TimeInput, {
|
|
26212
26071
|
value: date.toDate(),
|
|
26213
26072
|
onValueChange: (newValue) => {
|
|
@@ -26260,6 +26119,8 @@ function getListDropdownValue(value, multiple) {
|
|
|
26260
26119
|
function SelectList(props) {
|
|
26261
26120
|
const { value, onChange, multiple, options, onEdit, style, location, showEdit: showEditOnDropdown, showSearch: showSearchOnDropdown } = props;
|
|
26262
26121
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
26122
|
+
const themeService = (0, _univerjs_ui.useDependency)(_univerjs_core.ThemeService);
|
|
26123
|
+
(0, _univerjs_ui.useObservable)(themeService.currentTheme$);
|
|
26263
26124
|
const { row, col, unitId, subUnitId } = location;
|
|
26264
26125
|
const searchRef = (0, react.useRef)(null);
|
|
26265
26126
|
(0, react.useEffect)(() => {
|
|
@@ -26298,14 +26159,14 @@ function SelectList(props) {
|
|
|
26298
26159
|
]);
|
|
26299
26160
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
26300
26161
|
"data-u-comp": "sheets-dropdown-list",
|
|
26301
|
-
className: (0, _univerjs_design.clsx)("univer-box-border univer-rounded-lg univer-bg-
|
|
26162
|
+
className: (0, _univerjs_design.clsx)("univer-box-border univer-rounded-lg univer-bg-gray-0 univer-py-1 univer-text-gray-900 univer-shadow dark:!univer-bg-gray-1000 dark:!univer-text-gray-0", _univerjs_design.borderClassName),
|
|
26302
26163
|
style,
|
|
26303
26164
|
children: [
|
|
26304
26165
|
showSearchOnDropdown && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
26305
26166
|
className: "univer-box-border univer-flex univer-w-full univer-px-2",
|
|
26306
26167
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
26307
26168
|
ref: searchRef,
|
|
26308
|
-
className: (0, _univerjs_design.clsx)("univer-w-full univer-rounded-md univer-px-2 univer-py-1 univer-text-sm focus:univer-border-primary-500 focus:univer-outline-none dark:!univer-bg-
|
|
26169
|
+
className: (0, _univerjs_design.clsx)("univer-w-full univer-rounded-md univer-bg-gray-0 univer-px-2 univer-py-1 univer-text-sm univer-text-gray-900 focus:univer-border-primary-500 focus:univer-outline-none dark:!univer-bg-gray-1000 dark:!univer-text-gray-0", _univerjs_design.borderClassName),
|
|
26309
26170
|
type: "text",
|
|
26310
26171
|
value: lowerFilter,
|
|
26311
26172
|
autoFocus: true,
|
|
@@ -26319,6 +26180,7 @@ function SelectList(props) {
|
|
|
26319
26180
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
26320
26181
|
className: (0, _univerjs_design.clsx)("univer-flex univer-max-h-52 univer-flex-col univer-gap-1 univer-overflow-y-auto univer-px-2 univer-py-1", _univerjs_design.scrollbarClassName),
|
|
26321
26182
|
children: filteredOptions.map((item, i) => {
|
|
26183
|
+
var _item$color;
|
|
26322
26184
|
const selected = value.indexOf(item.value) > -1;
|
|
26323
26185
|
const handleClick = () => {
|
|
26324
26186
|
let set;
|
|
@@ -26331,16 +26193,18 @@ function SelectList(props) {
|
|
|
26331
26193
|
onChange(newValue);
|
|
26332
26194
|
};
|
|
26333
26195
|
const index = item.label.toLocaleLowerCase().indexOf(lowerFilter);
|
|
26334
|
-
const
|
|
26196
|
+
const isThemeColor = Boolean(((_item$color = item.color) === null || _item$color === void 0 ? void 0 : _item$color.includes(".")) && themeService.isValidThemeColor(item.color));
|
|
26197
|
+
const backgroundColor = isThemeColor ? themeService.getColorFromTheme(item.color) : item.color;
|
|
26198
|
+
const isDark = new _univerjs_core.ColorKit(backgroundColor).isDark();
|
|
26335
26199
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
26336
26200
|
className: "univer-flex univer-cursor-pointer univer-flex-row univer-items-center univer-justify-between univer-rounded-md univer-px-1.5 univer-py-1 hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700",
|
|
26337
26201
|
onClick: handleClick,
|
|
26338
26202
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
26339
26203
|
className: (0, _univerjs_design.clsx)("univer-inline-flex univer-h-4 univer-w-fit univer-items-center univer-truncate univer-rounded-full univer-px-1.5 univer-text-xs", {
|
|
26340
|
-
"univer-text-gray-900": !isDark,
|
|
26341
|
-
"univer-text-
|
|
26204
|
+
"univer-text-gray-900": isThemeColor || !isDark,
|
|
26205
|
+
"univer-text-gray-0": !isThemeColor && isDark
|
|
26342
26206
|
}),
|
|
26343
|
-
style: { background:
|
|
26207
|
+
style: { background: backgroundColor },
|
|
26344
26208
|
children: lowerFilter && item.label.toLowerCase().includes(lowerFilter) ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
26345
26209
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: item.label.substring(0, index) }),
|
|
26346
26210
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -26410,7 +26274,7 @@ const Spin = ({ loading, children }) => {
|
|
|
26410
26274
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
26411
26275
|
className: "univer-relative univer-size-full",
|
|
26412
26276
|
children: [loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
26413
|
-
className: "univer-absolute -univer-bottom-0.5 -univer-left-0.5 -univer-right-0.5 -univer-top-0.5 univer-z-10 univer-flex univer-items-center univer-justify-center univer-bg-
|
|
26277
|
+
className: "univer-absolute -univer-bottom-0.5 -univer-left-0.5 -univer-right-0.5 -univer-top-0.5 univer-z-10 univer-flex univer-items-center univer-justify-center univer-bg-gray-0 univer-backdrop-blur dark:!univer-bg-gray-1000",
|
|
26414
26278
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-size-10 univer-animate-spin univer-rounded-full univer-border-4 univer-border-solid univer-border-gray-100 univer-border-t-primary-500" })
|
|
26415
26279
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
26416
26280
|
className: loading ? "univer-pointer-events-none univer-blur-sm" : "",
|
|
@@ -27018,7 +26882,7 @@ const PermissionDetailUserPart = (props) => {
|
|
|
27018
26882
|
src: (_item$subject2 = item.subject) === null || _item$subject2 === void 0 ? void 0 : _item$subject2.avatar
|
|
27019
26883
|
}),
|
|
27020
26884
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
27021
|
-
className: "univer-ml-1.5 univer-w-[130px] univer-truncate univer-text-gray-900 dark:!univer-text-
|
|
26885
|
+
className: "univer-ml-1.5 univer-w-[130px] univer-truncate univer-text-gray-900 dark:!univer-text-gray-0",
|
|
27022
26886
|
children: (_item$subject3 = item.subject) === null || _item$subject3 === void 0 ? void 0 : _item$subject3.name
|
|
27023
26887
|
}),
|
|
27024
26888
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
@@ -27385,11 +27249,11 @@ function SheetPermissionPanelListContent() {
|
|
|
27385
27249
|
}) })
|
|
27386
27250
|
}),
|
|
27387
27251
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
27388
|
-
className: "univer-h-4 univer-flex-grow univer-text-xs univer-text-gray-900 dark:!univer-text-
|
|
27252
|
+
className: "univer-h-4 univer-flex-grow univer-text-xs univer-text-gray-900 dark:!univer-text-gray-0",
|
|
27389
27253
|
children: localeService.t("sheets-ui.permission.panel.created")
|
|
27390
27254
|
}),
|
|
27391
27255
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
27392
|
-
className: "univer-h-4 univer-text-xs univer-text-gray-900 dark:!univer-text-
|
|
27256
|
+
className: "univer-h-4 univer-text-xs univer-text-gray-900 dark:!univer-text-gray-0",
|
|
27393
27257
|
children: editPermission ? `${localeService.t("sheets-ui.permission.panel.iCanEdit")}` : `${localeService.t("sheets-ui.permission.panel.iCanNotEdit")}`
|
|
27394
27258
|
})
|
|
27395
27259
|
]
|
|
@@ -27397,10 +27261,10 @@ function SheetPermissionPanelListContent() {
|
|
|
27397
27261
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
27398
27262
|
className: "univer-mt-2 univer-flex univer-items-center",
|
|
27399
27263
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
27400
|
-
className: "univer-h-4 univer-flex-grow univer-text-xs univer-text-gray-900 dark:!univer-text-
|
|
27264
|
+
className: "univer-h-4 univer-flex-grow univer-text-xs univer-text-gray-900 dark:!univer-text-gray-0",
|
|
27401
27265
|
children: localeService.t("sheets-ui.permission.panel.viewPermission")
|
|
27402
27266
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
27403
|
-
className: "univer-h-4 univer-text-xs univer-text-gray-900 dark:!univer-text-
|
|
27267
|
+
className: "univer-h-4 univer-text-xs univer-text-gray-900 dark:!univer-text-gray-0",
|
|
27404
27268
|
children: viewPermission ? `${localeService.t("sheets-ui.permission.panel.iCanView")}` : `${localeService.t("sheets-ui.permission.panel.iCanNotView")}`
|
|
27405
27269
|
})]
|
|
27406
27270
|
}),
|
|
@@ -27842,7 +27706,7 @@ const formulaEditorStyle = {
|
|
|
27842
27706
|
}
|
|
27843
27707
|
};
|
|
27844
27708
|
let EditorDataSyncController = class EditorDataSyncController extends _univerjs_core.Disposable {
|
|
27845
|
-
constructor(_univerInstanceService, _renderManagerService, _editorBridgeService, _commandService, _rangeProtectionRuleModel, _worksheetProtectionRuleModel, _formulaEditorController, _formulaEditorManagerService, _contextService) {
|
|
27709
|
+
constructor(_univerInstanceService, _renderManagerService, _editorBridgeService, _commandService, _rangeProtectionRuleModel, _worksheetProtectionRuleModel, _formulaEditorController, _formulaEditorManagerService, _contextService, _themeService) {
|
|
27846
27710
|
super();
|
|
27847
27711
|
this._univerInstanceService = _univerInstanceService;
|
|
27848
27712
|
this._renderManagerService = _renderManagerService;
|
|
@@ -27853,12 +27717,14 @@ let EditorDataSyncController = class EditorDataSyncController extends _univerjs_
|
|
|
27853
27717
|
this._formulaEditorController = _formulaEditorController;
|
|
27854
27718
|
this._formulaEditorManagerService = _formulaEditorManagerService;
|
|
27855
27719
|
this._contextService = _contextService;
|
|
27720
|
+
this._themeService = _themeService;
|
|
27856
27721
|
this._initialize();
|
|
27857
27722
|
}
|
|
27858
27723
|
_initialize() {
|
|
27859
27724
|
this._syncFormulaEditorContent();
|
|
27860
27725
|
this._commandExecutedListener();
|
|
27861
27726
|
this._syncFormulaRefRenderStyleOnFocusChange();
|
|
27727
|
+
this._syncFormulaBarTextColorOnThemeChange();
|
|
27862
27728
|
}
|
|
27863
27729
|
_getEditorViewModel(unitId) {
|
|
27864
27730
|
var _this$_renderManagerS;
|
|
@@ -27982,6 +27848,11 @@ let EditorDataSyncController = class EditorDataSyncController extends _univerjs_
|
|
|
27982
27848
|
this._refreshRenderStyleConfig(_univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
|
|
27983
27849
|
}));
|
|
27984
27850
|
}
|
|
27851
|
+
_syncFormulaBarTextColorOnThemeChange() {
|
|
27852
|
+
this.disposeWithMe(this._themeService.currentTheme$.pipe((0, rxjs.skip)(1)).subscribe(() => {
|
|
27853
|
+
this._refreshRenderStyleConfig(_univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
|
|
27854
|
+
}));
|
|
27855
|
+
}
|
|
27985
27856
|
_refreshRenderStyleConfig(unitId) {
|
|
27986
27857
|
var _currentRender$mainCo3;
|
|
27987
27858
|
const currentRender = this._renderManagerService.getRenderUnitById(unitId);
|
|
@@ -28000,7 +27871,10 @@ let EditorDataSyncController = class EditorDataSyncController extends _univerjs_
|
|
|
28000
27871
|
const snapshot = documentDataModel.getSnapshot();
|
|
28001
27872
|
if (snapshot.id !== _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY && snapshot.id !== _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY) return;
|
|
28002
27873
|
const isFormulaBar = snapshot.id === _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;
|
|
28003
|
-
if (isFormulaBar) snapshot.documentStyle =
|
|
27874
|
+
if (isFormulaBar) snapshot.documentStyle = {
|
|
27875
|
+
...formulaEditorStyle,
|
|
27876
|
+
textStyle: { cl: { rgb: this._themeService.getColorFromTheme("gray.900") } }
|
|
27877
|
+
};
|
|
28004
27878
|
else snapshot.documentStyle ??= {};
|
|
28005
27879
|
let renderConfig = snapshot.documentStyle.renderConfig;
|
|
28006
27880
|
if (renderConfig == null) {
|
|
@@ -28037,84 +27911,97 @@ EditorDataSyncController = __decorate([
|
|
|
28037
27911
|
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets.WorksheetProtectionRuleModel)),
|
|
28038
27912
|
__decorateParam(6, (0, _univerjs_core.Inject)(FormulaEditorController)),
|
|
28039
27913
|
__decorateParam(7, IFormulaEditorManagerService),
|
|
28040
|
-
__decorateParam(8, _univerjs_core.IContextService)
|
|
27914
|
+
__decorateParam(8, _univerjs_core.IContextService),
|
|
27915
|
+
__decorateParam(9, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService))
|
|
28041
27916
|
], EditorDataSyncController);
|
|
28042
27917
|
|
|
28043
27918
|
//#endregion
|
|
28044
27919
|
//#region src/controllers/force-string-alert-render.controller.ts
|
|
28045
27920
|
const ALERT_KEY = "SHEET_FORCE_STRING_ALERT";
|
|
28046
27921
|
let ForceStringAlertRenderController = class ForceStringAlertRenderController extends _univerjs_core.Disposable {
|
|
28047
|
-
constructor(_context,
|
|
27922
|
+
constructor(_context, _selectionManagerService, _cellAlertManagerService, _localeService, _configService, _commandService, _univerInstanceService) {
|
|
28048
27923
|
super();
|
|
28049
27924
|
this._context = _context;
|
|
28050
|
-
this.
|
|
27925
|
+
this._selectionManagerService = _selectionManagerService;
|
|
28051
27926
|
this._cellAlertManagerService = _cellAlertManagerService;
|
|
28052
27927
|
this._localeService = _localeService;
|
|
28053
27928
|
this._configService = _configService;
|
|
27929
|
+
this._commandService = _commandService;
|
|
27930
|
+
this._univerInstanceService = _univerInstanceService;
|
|
28054
27931
|
this._init();
|
|
28055
27932
|
}
|
|
28056
27933
|
_init() {
|
|
28057
27934
|
this._initCellAlertPopup();
|
|
28058
27935
|
}
|
|
28059
27936
|
_initCellAlertPopup() {
|
|
28060
|
-
this.disposeWithMe(this.
|
|
28061
|
-
|
|
28062
|
-
|
|
28063
|
-
|
|
28064
|
-
|
|
28065
|
-
|
|
28066
|
-
|
|
28067
|
-
|
|
28068
|
-
|
|
28069
|
-
|
|
28070
|
-
|
|
28071
|
-
|
|
28072
|
-
|
|
28073
|
-
|
|
28074
|
-
|
|
28075
|
-
|
|
28076
|
-
|
|
28077
|
-
|
|
28078
|
-
|
|
28079
|
-
|
|
28080
|
-
|
|
28081
|
-
|
|
28082
|
-
|
|
28083
|
-
|
|
28084
|
-
|
|
28085
|
-
|
|
28086
|
-
|
|
28087
|
-
|
|
28088
|
-
|
|
28089
|
-
|
|
28090
|
-
|
|
28091
|
-
|
|
28092
|
-
|
|
28093
|
-
|
|
28094
|
-
|
|
28095
|
-
|
|
28096
|
-
|
|
28097
|
-
|
|
28098
|
-
|
|
28099
|
-
|
|
28100
|
-
|
|
28101
|
-
|
|
28102
|
-
|
|
28103
|
-
|
|
27937
|
+
this.disposeWithMe(this._selectionManagerService.selectionChanged$.subscribe((selections) => this._updateAlert(selections)));
|
|
27938
|
+
this.disposeWithMe(this._context.unit.activeSheet$.subscribe(() => this._updateAlert(this._selectionManagerService.getCurrentSelections())));
|
|
27939
|
+
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).subscribe(() => this._updateAlert(this._selectionManagerService.getCurrentSelections())));
|
|
27940
|
+
}
|
|
27941
|
+
_isCurrentSheet(worksheet) {
|
|
27942
|
+
const selectionParam = this._selectionManagerService.currentSelectionParam;
|
|
27943
|
+
return Boolean(worksheet && (selectionParam === null || selectionParam === void 0 ? void 0 : selectionParam.unitId) === this._context.unit.getUnitId() && selectionParam.sheetId === worksheet.getSheetId());
|
|
27944
|
+
}
|
|
27945
|
+
_updateAlert(selections) {
|
|
27946
|
+
var _this$_configService$, _cellStyle$n;
|
|
27947
|
+
this._hideAlert();
|
|
27948
|
+
const workbook = this._context.unit;
|
|
27949
|
+
const worksheet = workbook.getActiveSheet();
|
|
27950
|
+
if (!this._isCurrentSheet(worksheet)) return;
|
|
27951
|
+
if ((selections === null || selections === void 0 ? void 0 : selections.length) !== 1) return;
|
|
27952
|
+
if ((_this$_configService$ = this._configService.getConfig("sheets-ui.config")) === null || _this$_configService$ === void 0 ? void 0 : _this$_configService$.disableForceStringAlert) return;
|
|
27953
|
+
const selection = selections[0];
|
|
27954
|
+
const primary = selection.primary;
|
|
27955
|
+
if (!primary) return;
|
|
27956
|
+
const row = primary.actualRow;
|
|
27957
|
+
const col = primary.actualColumn;
|
|
27958
|
+
const cellData = worksheet.getCell(row, col);
|
|
27959
|
+
if (!cellData || cellData.v === null || cellData.v === void 0) return;
|
|
27960
|
+
const cellStyle = workbook.getStyles().get(cellData.s);
|
|
27961
|
+
if ((0, _univerjs_core.isTextFormat)(cellStyle === null || cellStyle === void 0 || (_cellStyle$n = cellStyle.n) === null || _cellStyle$n === void 0 ? void 0 : _cellStyle$n.pattern)) return;
|
|
27962
|
+
if (cellData.t !== _univerjs_core.CellValueType.FORCE_STRING && cellData.t !== _univerjs_core.CellValueType.STRING || !(0, _univerjs_core.isRealNum)(cellData.v) && !(typeof cellData.v === "string" && (0, _univerjs_core.getNumfmtParseValueFilter)(cellData.v))) return;
|
|
27963
|
+
const unitId = workbook.getUnitId();
|
|
27964
|
+
const subUnitId = worksheet.getSheetId();
|
|
27965
|
+
const range = { ...selection.range };
|
|
27966
|
+
this._cellAlertManagerService.showAlert({
|
|
27967
|
+
type: 1,
|
|
27968
|
+
title: this._localeService.t("sheets-ui.info.error"),
|
|
27969
|
+
message: this._localeService.t("sheets-ui.info.forceStringInfo"),
|
|
27970
|
+
location: {
|
|
27971
|
+
unitId,
|
|
27972
|
+
subUnitId,
|
|
27973
|
+
row,
|
|
27974
|
+
col
|
|
27975
|
+
},
|
|
27976
|
+
width: 200,
|
|
27977
|
+
height: 74,
|
|
27978
|
+
key: this._alertKey,
|
|
27979
|
+
menu: [{
|
|
27980
|
+
label: this._localeService.t("sheets-ui.info.convertToNumber"),
|
|
27981
|
+
onSelect: () => {
|
|
27982
|
+
if (this._commandService.syncExecuteCommand(_univerjs_sheets.TextToNumberCommand.id, {
|
|
27983
|
+
unitId,
|
|
27984
|
+
subUnitId,
|
|
27985
|
+
ranges: [range]
|
|
27986
|
+
})) this._hideAlert();
|
|
28104
27987
|
}
|
|
28105
|
-
}
|
|
28106
|
-
|
|
28107
|
-
|
|
27988
|
+
}]
|
|
27989
|
+
});
|
|
27990
|
+
}
|
|
27991
|
+
get _alertKey() {
|
|
27992
|
+
return `${ALERT_KEY}:${this._context.unit.getUnitId()}`;
|
|
28108
27993
|
}
|
|
28109
27994
|
_hideAlert() {
|
|
28110
|
-
this._cellAlertManagerService.removeAlert(
|
|
27995
|
+
this._cellAlertManagerService.removeAlert(this._alertKey);
|
|
28111
27996
|
}
|
|
28112
27997
|
};
|
|
28113
27998
|
ForceStringAlertRenderController = __decorate([
|
|
28114
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(
|
|
27999
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetsSelectionsService)),
|
|
28115
28000
|
__decorateParam(2, (0, _univerjs_core.Inject)(CellAlertManagerService)),
|
|
28116
28001
|
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
28117
|
-
__decorateParam(4, _univerjs_core.IConfigService)
|
|
28002
|
+
__decorateParam(4, _univerjs_core.IConfigService),
|
|
28003
|
+
__decorateParam(5, _univerjs_core.ICommandService),
|
|
28004
|
+
__decorateParam(6, _univerjs_core.IUniverInstanceService)
|
|
28118
28005
|
], ForceStringAlertRenderController);
|
|
28119
28006
|
|
|
28120
28007
|
//#endregion
|
|
@@ -28544,7 +28431,7 @@ function MobileSheetBarImpl(props) {
|
|
|
28544
28431
|
tabMapRef.current.set(sheet.sheetId, element);
|
|
28545
28432
|
},
|
|
28546
28433
|
className: (0, _univerjs_design.clsx)("univer-relative univer-box-border univer-flex univer-h-full univer-max-w-36 univer-shrink-0 univer-cursor-pointer univer-select-none univer-items-center univer-justify-center univer-truncate univer-px-1 univer-py-0.5 univer-text-sm univer-font-medium univer-leading-6 univer-transition-all", _univerjs_design.borderRightClassName, {
|
|
28547
|
-
"univer-bg-
|
|
28434
|
+
"univer-bg-gray-0 univer-text-blue-600 dark:!univer-bg-gray-700 dark:!univer-text-blue-400": sheet.sheetId === activeKey,
|
|
28548
28435
|
"univer-text-gray-600 hover:univer-bg-gray-50 active:univer-bg-gray-100 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700": sheet.sheetId !== activeKey
|
|
28549
28436
|
}),
|
|
28550
28437
|
role: "tab",
|
|
@@ -29360,7 +29247,7 @@ FormatPainterRenderController = __decorate([
|
|
|
29360
29247
|
//#region src/controllers/render-controllers/header-menu.render-controller.ts
|
|
29361
29248
|
const HEADER_MENU_CONTROLLER_SHAPE = "__SpreadsheetHeaderMenuSHAPEControllerShape__";
|
|
29362
29249
|
const HEADER_MENU_CONTROLLER_MENU = "__SpreadsheetHeaderMenuMAINControllerShape__";
|
|
29363
|
-
const HEADER_MENU_CONTROLLER_SHAPE_COLOR = "
|
|
29250
|
+
const HEADER_MENU_CONTROLLER_SHAPE_COLOR = "gray.100";
|
|
29364
29251
|
let HeaderMenuRenderController = class HeaderMenuRenderController extends _univerjs_core.Disposable {
|
|
29365
29252
|
constructor(_context, _sheetSkeletonManagerService, _contextMenuService, _commandService, _selectionManagerService) {
|
|
29366
29253
|
super();
|
|
@@ -30838,6 +30725,36 @@ MobileSheetsScrollRenderController = __decorate([
|
|
|
30838
30725
|
__decorateParam(7, _univerjs_core.IContextService)
|
|
30839
30726
|
], MobileSheetsScrollRenderController);
|
|
30840
30727
|
|
|
30728
|
+
//#endregion
|
|
30729
|
+
//#region src/controllers/render-controllers/skeleton.render-controller.ts
|
|
30730
|
+
let SheetSkeletonRenderController = class SheetSkeletonRenderController extends _univerjs_core.Disposable {
|
|
30731
|
+
constructor(_context, _sheetSkeletonManagerService, _renderManagerService) {
|
|
30732
|
+
super();
|
|
30733
|
+
this._context = _context;
|
|
30734
|
+
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
30735
|
+
this._renderManagerService = _renderManagerService;
|
|
30736
|
+
this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
|
|
30737
|
+
this._updateSceneSize(param);
|
|
30738
|
+
}));
|
|
30739
|
+
}
|
|
30740
|
+
_updateSceneSize(param) {
|
|
30741
|
+
var _this$_renderManagerS;
|
|
30742
|
+
if (param == null) return;
|
|
30743
|
+
const { unitId } = this._context;
|
|
30744
|
+
const { skeleton } = param;
|
|
30745
|
+
const scene = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.scene;
|
|
30746
|
+
if (skeleton == null || scene == null) return;
|
|
30747
|
+
const { rowTotalHeight, columnTotalWidth, rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop } = skeleton;
|
|
30748
|
+
if (!this._context.unit.getActiveSheet()) return;
|
|
30749
|
+
scene === null || scene === void 0 || scene.transformByState({
|
|
30750
|
+
width: rowHeaderWidthAndMarginLeft + columnTotalWidth,
|
|
30751
|
+
height: columnHeaderHeightAndMarginTop + rowTotalHeight
|
|
30752
|
+
});
|
|
30753
|
+
scene.getMainViewport().setMargin(rowHeaderWidthAndMarginLeft, columnHeaderHeightAndMarginTop);
|
|
30754
|
+
}
|
|
30755
|
+
};
|
|
30756
|
+
SheetSkeletonRenderController = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(SheetSkeletonManagerService)), __decorateParam(2, _univerjs_engine_render.IRenderManagerService)], SheetSkeletonRenderController);
|
|
30757
|
+
|
|
30841
30758
|
//#endregion
|
|
30842
30759
|
//#region src/services/auto-height.service.ts
|
|
30843
30760
|
const IAutoHeightService = (0, _univerjs_core.createIdentifier)("sheets-ui.services.auto-height");
|
|
@@ -31743,7 +31660,6 @@ let UniverSheetsMobileUIPlugin = class UniverSheetsMobileUIPlugin extends _unive
|
|
|
31743
31660
|
[SelectAllService],
|
|
31744
31661
|
[ISheetCellDropdownManagerService, { useClass: SheetCellDropdownManagerService }],
|
|
31745
31662
|
[SheetCellEditorResizeService],
|
|
31746
|
-
[ISheetLoadingRenderService, { useClass: SheetLoadingRenderService }],
|
|
31747
31663
|
[AutoHeightController],
|
|
31748
31664
|
[AutoWidthController],
|
|
31749
31665
|
[FormulaEditorController],
|
|
@@ -32361,7 +32277,6 @@ let UniverSheetsUIPlugin = class UniverSheetsUIPlugin extends _univerjs_core.Plu
|
|
|
32361
32277
|
[SelectAllService],
|
|
32362
32278
|
[ISheetCellDropdownManagerService, { useClass: SheetCellDropdownManagerService }],
|
|
32363
32279
|
[SheetCellEditorResizeService],
|
|
32364
|
-
[ISheetLoadingRenderService, { useClass: SheetLoadingRenderService }],
|
|
32365
32280
|
[AutoHeightController],
|
|
32366
32281
|
[AutoWidthController],
|
|
32367
32282
|
[FormulaEditorController],
|
|
@@ -32623,6 +32538,7 @@ exports.IFormatPainterService = IFormatPainterService;
|
|
|
32623
32538
|
exports.IFormulaEditorManagerService = IFormulaEditorManagerService;
|
|
32624
32539
|
exports.IMarkSelectionService = IMarkSelectionService;
|
|
32625
32540
|
exports.IRepeatLastActionService = IRepeatLastActionService;
|
|
32541
|
+
exports.ISheetBarService = ISheetBarService;
|
|
32626
32542
|
exports.ISheetCellDropdownManagerService = ISheetCellDropdownManagerService;
|
|
32627
32543
|
exports.ISheetClipboardService = ISheetClipboardService;
|
|
32628
32544
|
exports.ISheetEmbedFloatingGeometryService = ISheetEmbedFloatingGeometryService;
|
|
@@ -32630,7 +32546,6 @@ exports.ISheetEmbedInteractionBoundaryService = ISheetEmbedInteractionBoundarySe
|
|
|
32630
32546
|
exports.ISheetEmbedRuntimeFocusCoordinator = ISheetEmbedRuntimeFocusCoordinator;
|
|
32631
32547
|
exports.ISheetEmbedRuntimeService = ISheetEmbedRuntimeService;
|
|
32632
32548
|
exports.ISheetHostChromeOverrideService = ISheetHostChromeOverrideService;
|
|
32633
|
-
exports.ISheetLoadingRenderService = ISheetLoadingRenderService;
|
|
32634
32549
|
exports.ISheetSelectionRenderService = ISheetSelectionRenderService;
|
|
32635
32550
|
exports.IStatusBarService = IStatusBarService;
|
|
32636
32551
|
exports.InsertRangeMoveDownConfirmCommand = InsertRangeMoveDownConfirmCommand;
|
|
@@ -32708,6 +32623,7 @@ exports.SetWorksheetColAutoWidthCommand = SetWorksheetColAutoWidthCommand;
|
|
|
32708
32623
|
exports.SetZoomRatioCommand = SetZoomRatioCommand;
|
|
32709
32624
|
exports.SetZoomRatioOperation = SetZoomRatioOperation;
|
|
32710
32625
|
exports.SheetBar = SheetBar;
|
|
32626
|
+
exports.SheetBarService = SheetBarService;
|
|
32711
32627
|
Object.defineProperty(exports, 'SheetCanvasPopManagerService', {
|
|
32712
32628
|
enumerable: true,
|
|
32713
32629
|
get: function () {
|