@univerjs/sheets-ui 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +58 -32
- package/lib/es/index.js +58 -32
- package/lib/index.js +58 -32
- package/lib/types/controllers/editor/utils/get-edit-cell-input-position.d.ts +31 -0
- package/lib/umd/index.js +5 -7
- package/package.json +14 -14
package/lib/cjs/index.js
CHANGED
|
@@ -11460,6 +11460,29 @@ function processNumberStringWithSpaces(token, numStr) {
|
|
|
11460
11460
|
};
|
|
11461
11461
|
}
|
|
11462
11462
|
|
|
11463
|
+
//#endregion
|
|
11464
|
+
//#region src/controllers/editor/utils/get-edit-cell-input-position.ts
|
|
11465
|
+
/**
|
|
11466
|
+
* Get the position of the hidden editor input for the current edit cell.
|
|
11467
|
+
*
|
|
11468
|
+
* The OS anchors the IME candidate window to the focused input, so the input should stay on the
|
|
11469
|
+
* selected cell even before the cell editor opens. The position is kept inside the sheet canvas,
|
|
11470
|
+
* so a cell scrolled out of view never moves the input outside the sheet.
|
|
11471
|
+
*/
|
|
11472
|
+
function getEditCellInputPosition(layout, canvasSize) {
|
|
11473
|
+
const { position, canvasOffset } = layout;
|
|
11474
|
+
const x = canvasOffset.left + position.startX;
|
|
11475
|
+
const y = canvasOffset.top + position.startY;
|
|
11476
|
+
if (!canvasSize) return {
|
|
11477
|
+
x,
|
|
11478
|
+
y
|
|
11479
|
+
};
|
|
11480
|
+
return {
|
|
11481
|
+
x: Math.min(Math.max(x, canvasOffset.left), canvasOffset.left + canvasSize.width),
|
|
11482
|
+
y: Math.min(Math.max(y, canvasOffset.top), canvasOffset.top + canvasSize.height)
|
|
11483
|
+
};
|
|
11484
|
+
}
|
|
11485
|
+
|
|
11463
11486
|
//#endregion
|
|
11464
11487
|
//#region src/controllers/editor/utils/is-range-selector.ts
|
|
11465
11488
|
/**
|
|
@@ -11676,7 +11699,11 @@ let EditingRenderController = class EditingRenderController extends _univerjs_co
|
|
|
11676
11699
|
if ((cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 ? void 0 : cellSelectionRenderManager.canFocusing) || (formulaSelectionRenderManager === null || formulaSelectionRenderManager === void 0 ? void 0 : formulaSelectionRenderManager.canFocusing)) {
|
|
11677
11700
|
this._univerInstanceService.setCurrentUnitForType(_univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
|
|
11678
11701
|
if (this._contextService.getContextValue(_univerjs_ui.DISABLE_AUTO_FOCUS_KEY)) cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 || cellSelectionRenderManager.setInputPosition(HIDDEN_EDITOR_POSITION$1, HIDDEN_EDITOR_POSITION$1);
|
|
11679
|
-
else
|
|
11702
|
+
else {
|
|
11703
|
+
var _this$_renderManagerS5;
|
|
11704
|
+
const { x, y } = getEditCellInputPosition(state, (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(state.unitId)) === null || _this$_renderManagerS5 === void 0 ? void 0 : _this$_renderManagerS5.engine);
|
|
11705
|
+
cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 || cellSelectionRenderManager.activate(x, y, true);
|
|
11706
|
+
}
|
|
11680
11707
|
}
|
|
11681
11708
|
}));
|
|
11682
11709
|
}
|
|
@@ -11750,7 +11777,7 @@ let EditingRenderController = class EditingRenderController extends _univerjs_co
|
|
|
11750
11777
|
}));
|
|
11751
11778
|
}
|
|
11752
11779
|
_handleEditorVisible(param) {
|
|
11753
|
-
var _documentDataModel$ge, _this$
|
|
11780
|
+
var _documentDataModel$ge, _this$_renderManagerS7;
|
|
11754
11781
|
const { eventType, keycode } = param;
|
|
11755
11782
|
this._cursorChange = eventType === _univerjs_engine_render.DeviceInputEventType.PointerDown || eventType === _univerjs_engine_render.DeviceInputEventType.Dblclick ? 2 : 1;
|
|
11756
11783
|
const editCellState = this._editorBridgeService.getEditLocation();
|
|
@@ -11779,8 +11806,8 @@ let EditingRenderController = class EditingRenderController extends _univerjs_co
|
|
|
11779
11806
|
const resetPointerSelection = isInArrayFormulaRange && eventType === _univerjs_engine_render.DeviceInputEventType.PointerDown;
|
|
11780
11807
|
const editorId = this._contextService.getContextValue(_univerjs_core.FOCUSING_FX_BAR_EDITOR) ? _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY : this._editorBridgeService.getCurrentEditorId();
|
|
11781
11808
|
if (resetPointerSelection) {
|
|
11782
|
-
var _this$
|
|
11783
|
-
(_this$
|
|
11809
|
+
var _this$_renderManagerS6;
|
|
11810
|
+
(_this$_renderManagerS6 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS6 === void 0 || _this$_renderManagerS6.with(_univerjs_docs_ui.DocSelectionRenderService).cancelPointerSelection();
|
|
11784
11811
|
}
|
|
11785
11812
|
this._emptyDocumentDataModel(documentDataModel.getSnapshot().documentStyle, !!isInArrayFormulaRange);
|
|
11786
11813
|
document.makeDirty();
|
|
@@ -11858,7 +11885,7 @@ let EditingRenderController = class EditingRenderController extends _univerjs_co
|
|
|
11858
11885
|
collapsed: true
|
|
11859
11886
|
});
|
|
11860
11887
|
}
|
|
11861
|
-
(_this$
|
|
11888
|
+
(_this$_renderManagerS7 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS7 === void 0 || _this$_renderManagerS7.scene.resetCursor();
|
|
11862
11889
|
}
|
|
11863
11890
|
_resizeEditorOnOpen(param, editorObject, isInArrayFormulaRange) {
|
|
11864
11891
|
var _this$_sheetCellEdito4;
|
|
@@ -11874,8 +11901,8 @@ let EditingRenderController = class EditingRenderController extends _univerjs_co
|
|
|
11874
11901
|
if (!pointerPosition || isInArrayFormulaRange) return;
|
|
11875
11902
|
const rect = engine.getCanvasElement().getBoundingClientRect();
|
|
11876
11903
|
if (rect.width > 0 && rect.height > 0) {
|
|
11877
|
-
var _this$
|
|
11878
|
-
(_this$
|
|
11904
|
+
var _this$_renderManagerS8;
|
|
11905
|
+
(_this$_renderManagerS8 = this._renderManagerService.getRenderUnitById(_univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _this$_renderManagerS8 === void 0 || _this$_renderManagerS8.with(_univerjs_docs_ui.DocSelectionRenderService).setCursorManually((pointerPosition.x - rect.left) * engine.width / rect.width, (pointerPosition.y - rect.top) * engine.height / rect.height, true, true, { strict: false });
|
|
11879
11906
|
}
|
|
11880
11907
|
});
|
|
11881
11908
|
}
|
|
@@ -12077,12 +12104,12 @@ let EditingRenderController = class EditingRenderController extends _univerjs_co
|
|
|
12077
12104
|
return this._univerInstanceService.getUnit(_univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
12078
12105
|
}
|
|
12079
12106
|
_getEditorSkeleton(editorId) {
|
|
12080
|
-
var _this$
|
|
12081
|
-
return (_this$
|
|
12107
|
+
var _this$_renderManagerS9;
|
|
12108
|
+
return (_this$_renderManagerS9 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS9 === void 0 ? void 0 : _this$_renderManagerS9.with(_univerjs_docs.DocSkeletonManagerService).getSkeleton();
|
|
12082
12109
|
}
|
|
12083
12110
|
_getEditorViewModel(editorId) {
|
|
12084
|
-
var _this$
|
|
12085
|
-
return (_this$
|
|
12111
|
+
var _this$_renderManagerS10;
|
|
12112
|
+
return (_this$_renderManagerS10 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS10 === void 0 ? void 0 : _this$_renderManagerS10.with(_univerjs_docs.DocSkeletonManagerService).getViewModel();
|
|
12086
12113
|
}
|
|
12087
12114
|
_getEditingUnit() {
|
|
12088
12115
|
return this._editingUnit ? this._univerInstanceService.getUnit(this._editingUnit, _univerjs_core.UniverInstanceType.UNIVER_SHEET) : null;
|
|
@@ -12140,13 +12167,13 @@ function getCellDataByInput(cellData, snapshot, lexerTreeBuilder, localeService,
|
|
|
12140
12167
|
cellData.si = null;
|
|
12141
12168
|
cellData.p = snapshot;
|
|
12142
12169
|
cellData.t = _univerjs_core.CellValueType.STRING;
|
|
12143
|
-
} else if (cellData.s && (0, _univerjs_core.isTextFormat)(styles === null || styles === void 0 || (_styles$get = styles.get(cellData.s)) === null || _styles$get === void 0 || (_styles$get = _styles$get.n) === null || _styles$get === void 0 ? void 0 : _styles$get.pattern)) {
|
|
12170
|
+
} else if (newDataStream !== "" && cellData.s && (0, _univerjs_core.isTextFormat)(styles === null || styles === void 0 || (_styles$get = styles.get(cellData.s)) === null || _styles$get === void 0 || (_styles$get = _styles$get.n) === null || _styles$get === void 0 ? void 0 : _styles$get.pattern)) {
|
|
12144
12171
|
cellData.v = newDataStream;
|
|
12145
12172
|
cellData.f = null;
|
|
12146
12173
|
cellData.si = null;
|
|
12147
12174
|
cellData.p = null;
|
|
12148
12175
|
cellData.t = _univerjs_core.CellValueType.STRING;
|
|
12149
|
-
if (isRichText(body)
|
|
12176
|
+
if (isRichText(body)) cellData.p = snapshot;
|
|
12150
12177
|
const style = getCellStyleBySnapshot(snapshot);
|
|
12151
12178
|
if (style) cellData.s = style;
|
|
12152
12179
|
} else if ((0, _univerjs_core.isFormulaString)(newDataStream)) {
|
|
@@ -12163,21 +12190,14 @@ function getCellDataByInput(cellData, snapshot, lexerTreeBuilder, localeService,
|
|
|
12163
12190
|
cellData.si = null;
|
|
12164
12191
|
cellData.p = null;
|
|
12165
12192
|
cellData.t = _univerjs_core.CellValueType.FORCE_STRING;
|
|
12166
|
-
} else if (isRichText(body)) {
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
cellData.p = null;
|
|
12172
|
-
} else {
|
|
12173
|
-
cellData.p = snapshot;
|
|
12174
|
-
cellData.v = null;
|
|
12175
|
-
cellData.f = null;
|
|
12176
|
-
cellData.si = null;
|
|
12177
|
-
}
|
|
12193
|
+
} else if (newDataStream !== "" && isRichText(body)) {
|
|
12194
|
+
cellData.p = snapshot;
|
|
12195
|
+
cellData.v = null;
|
|
12196
|
+
cellData.f = null;
|
|
12197
|
+
cellData.si = null;
|
|
12178
12198
|
} else {
|
|
12179
|
-
if (newDataStream === "" && cellData.v == null && cellData.p == null) return null;
|
|
12180
|
-
cellData.v = newDataStream;
|
|
12199
|
+
if (newDataStream === "" && cellData.v == null && cellData.p == null && cellData.f == null && cellData.si == null) return null;
|
|
12200
|
+
cellData.v = newDataStream === "" ? null : newDataStream;
|
|
12181
12201
|
cellData.f = null;
|
|
12182
12202
|
cellData.si = null;
|
|
12183
12203
|
cellData.p = null;
|
|
@@ -25072,7 +25092,7 @@ const useHighlightRange = (ranges = []) => {
|
|
|
25072
25092
|
//#endregion
|
|
25073
25093
|
//#region package.json
|
|
25074
25094
|
var name = "@univerjs/sheets-ui";
|
|
25075
|
-
var version = "1.
|
|
25095
|
+
var version = "1.2.0";
|
|
25076
25096
|
|
|
25077
25097
|
//#endregion
|
|
25078
25098
|
//#region src/views/cell-popup/config.ts
|
|
@@ -27589,7 +27609,7 @@ const DefinedNameContainer = ({ ConfirmComponent = _univerjs_design.Confirm, Def
|
|
|
27589
27609
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
27590
27610
|
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",
|
|
27591
27611
|
children: [definedName.name, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
27592
|
-
className: "univer-
|
|
27612
|
+
className: "univer-ml-1 univer-text-xs univer-text-gray-400",
|
|
27593
27613
|
children: definedName.localSheetId === _univerjs_sheets.SCOPE_WORKBOOK_VALUE_DEFINED_NAME || definedName.localSheetId == null ? "" : getSheetNameBySheetId(definedName.localSheetId)
|
|
27594
27614
|
})]
|
|
27595
27615
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -28801,7 +28821,7 @@ function SheetPermissionPanelListContent({ ActionRowComponent }) {
|
|
|
28801
28821
|
rule.description && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
28802
28822
|
title: rule.description,
|
|
28803
28823
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
28804
|
-
className: "univer-
|
|
28824
|
+
className: "univer-mt-2 univer-max-w-64 univer-truncate univer-text-sm univer-text-gray-400",
|
|
28805
28825
|
children: rule.description
|
|
28806
28826
|
})
|
|
28807
28827
|
})
|
|
@@ -35791,6 +35811,12 @@ let DesktopCellEditRenderController = class DesktopCellEditRenderController exte
|
|
|
35791
35811
|
var _params;
|
|
35792
35812
|
if (params === null || params === void 0 || (_params = params[params.length - 1]) === null || _params === void 0 ? void 0 : _params.primary) this._updateInputPosition();
|
|
35793
35813
|
}));
|
|
35814
|
+
const viewportMain = this._context.scene.getViewport(_univerjs_engine_render.SHEET_VIEWPORT_KEY.VIEW_MAIN);
|
|
35815
|
+
if (viewportMain) d.add(viewportMain.onScrollEnd$.subscribeEvent(() => {
|
|
35816
|
+
if (this._editorBridgeService.isVisible().visible) return;
|
|
35817
|
+
this._editorBridgeService.refreshEditCellPosition(false);
|
|
35818
|
+
this._updateInputPosition();
|
|
35819
|
+
}));
|
|
35794
35820
|
}
|
|
35795
35821
|
_updateInputPosition() {
|
|
35796
35822
|
var _this$_renderManagerS;
|
|
@@ -35798,8 +35824,8 @@ let DesktopCellEditRenderController = class DesktopCellEditRenderController exte
|
|
|
35798
35824
|
const layout = this._editorBridgeService.getEditCellLayout();
|
|
35799
35825
|
const docSelectionRenderService = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(_univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_docs_ui.DocSelectionRenderService);
|
|
35800
35826
|
if (!layout || !docSelectionRenderService) return;
|
|
35801
|
-
const {
|
|
35802
|
-
docSelectionRenderService.setInputPosition(
|
|
35827
|
+
const { x, y } = getEditCellInputPosition(layout, this._context.engine);
|
|
35828
|
+
docSelectionRenderService.setInputPosition(x, y);
|
|
35803
35829
|
}
|
|
35804
35830
|
_focusCellEditorInput() {
|
|
35805
35831
|
const focusedChildUnitId = (0, _univerjs_ui.getEmbedChildUnitId)(typeof document === "undefined" ? null : document.activeElement);
|
package/lib/es/index.js
CHANGED
|
@@ -11459,6 +11459,29 @@ function processNumberStringWithSpaces(token, numStr) {
|
|
|
11459
11459
|
};
|
|
11460
11460
|
}
|
|
11461
11461
|
|
|
11462
|
+
//#endregion
|
|
11463
|
+
//#region src/controllers/editor/utils/get-edit-cell-input-position.ts
|
|
11464
|
+
/**
|
|
11465
|
+
* Get the position of the hidden editor input for the current edit cell.
|
|
11466
|
+
*
|
|
11467
|
+
* The OS anchors the IME candidate window to the focused input, so the input should stay on the
|
|
11468
|
+
* selected cell even before the cell editor opens. The position is kept inside the sheet canvas,
|
|
11469
|
+
* so a cell scrolled out of view never moves the input outside the sheet.
|
|
11470
|
+
*/
|
|
11471
|
+
function getEditCellInputPosition(layout, canvasSize) {
|
|
11472
|
+
const { position, canvasOffset } = layout;
|
|
11473
|
+
const x = canvasOffset.left + position.startX;
|
|
11474
|
+
const y = canvasOffset.top + position.startY;
|
|
11475
|
+
if (!canvasSize) return {
|
|
11476
|
+
x,
|
|
11477
|
+
y
|
|
11478
|
+
};
|
|
11479
|
+
return {
|
|
11480
|
+
x: Math.min(Math.max(x, canvasOffset.left), canvasOffset.left + canvasSize.width),
|
|
11481
|
+
y: Math.min(Math.max(y, canvasOffset.top), canvasOffset.top + canvasSize.height)
|
|
11482
|
+
};
|
|
11483
|
+
}
|
|
11484
|
+
|
|
11462
11485
|
//#endregion
|
|
11463
11486
|
//#region src/controllers/editor/utils/is-range-selector.ts
|
|
11464
11487
|
/**
|
|
@@ -11675,7 +11698,11 @@ let EditingRenderController = class EditingRenderController extends Disposable {
|
|
|
11675
11698
|
if ((cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 ? void 0 : cellSelectionRenderManager.canFocusing) || (formulaSelectionRenderManager === null || formulaSelectionRenderManager === void 0 ? void 0 : formulaSelectionRenderManager.canFocusing)) {
|
|
11676
11699
|
this._univerInstanceService.setCurrentUnitForType(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
|
|
11677
11700
|
if (this._contextService.getContextValue(DISABLE_AUTO_FOCUS_KEY)) cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 || cellSelectionRenderManager.setInputPosition(HIDDEN_EDITOR_POSITION$1, HIDDEN_EDITOR_POSITION$1);
|
|
11678
|
-
else
|
|
11701
|
+
else {
|
|
11702
|
+
var _this$_renderManagerS5;
|
|
11703
|
+
const { x, y } = getEditCellInputPosition(state, (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(state.unitId)) === null || _this$_renderManagerS5 === void 0 ? void 0 : _this$_renderManagerS5.engine);
|
|
11704
|
+
cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 || cellSelectionRenderManager.activate(x, y, true);
|
|
11705
|
+
}
|
|
11679
11706
|
}
|
|
11680
11707
|
}));
|
|
11681
11708
|
}
|
|
@@ -11749,7 +11776,7 @@ let EditingRenderController = class EditingRenderController extends Disposable {
|
|
|
11749
11776
|
}));
|
|
11750
11777
|
}
|
|
11751
11778
|
_handleEditorVisible(param) {
|
|
11752
|
-
var _documentDataModel$ge, _this$
|
|
11779
|
+
var _documentDataModel$ge, _this$_renderManagerS7;
|
|
11753
11780
|
const { eventType, keycode } = param;
|
|
11754
11781
|
this._cursorChange = eventType === DeviceInputEventType.PointerDown || eventType === DeviceInputEventType.Dblclick ? 2 : 1;
|
|
11755
11782
|
const editCellState = this._editorBridgeService.getEditLocation();
|
|
@@ -11778,8 +11805,8 @@ let EditingRenderController = class EditingRenderController extends Disposable {
|
|
|
11778
11805
|
const resetPointerSelection = isInArrayFormulaRange && eventType === DeviceInputEventType.PointerDown;
|
|
11779
11806
|
const editorId = this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) ? DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY : this._editorBridgeService.getCurrentEditorId();
|
|
11780
11807
|
if (resetPointerSelection) {
|
|
11781
|
-
var _this$
|
|
11782
|
-
(_this$
|
|
11808
|
+
var _this$_renderManagerS6;
|
|
11809
|
+
(_this$_renderManagerS6 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS6 === void 0 || _this$_renderManagerS6.with(DocSelectionRenderService).cancelPointerSelection();
|
|
11783
11810
|
}
|
|
11784
11811
|
this._emptyDocumentDataModel(documentDataModel.getSnapshot().documentStyle, !!isInArrayFormulaRange);
|
|
11785
11812
|
document.makeDirty();
|
|
@@ -11857,7 +11884,7 @@ let EditingRenderController = class EditingRenderController extends Disposable {
|
|
|
11857
11884
|
collapsed: true
|
|
11858
11885
|
});
|
|
11859
11886
|
}
|
|
11860
|
-
(_this$
|
|
11887
|
+
(_this$_renderManagerS7 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS7 === void 0 || _this$_renderManagerS7.scene.resetCursor();
|
|
11861
11888
|
}
|
|
11862
11889
|
_resizeEditorOnOpen(param, editorObject, isInArrayFormulaRange) {
|
|
11863
11890
|
var _this$_sheetCellEdito4;
|
|
@@ -11873,8 +11900,8 @@ let EditingRenderController = class EditingRenderController extends Disposable {
|
|
|
11873
11900
|
if (!pointerPosition || isInArrayFormulaRange) return;
|
|
11874
11901
|
const rect = engine.getCanvasElement().getBoundingClientRect();
|
|
11875
11902
|
if (rect.width > 0 && rect.height > 0) {
|
|
11876
|
-
var _this$
|
|
11877
|
-
(_this$
|
|
11903
|
+
var _this$_renderManagerS8;
|
|
11904
|
+
(_this$_renderManagerS8 = this._renderManagerService.getRenderUnitById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _this$_renderManagerS8 === void 0 || _this$_renderManagerS8.with(DocSelectionRenderService).setCursorManually((pointerPosition.x - rect.left) * engine.width / rect.width, (pointerPosition.y - rect.top) * engine.height / rect.height, true, true, { strict: false });
|
|
11878
11905
|
}
|
|
11879
11906
|
});
|
|
11880
11907
|
}
|
|
@@ -12076,12 +12103,12 @@ let EditingRenderController = class EditingRenderController extends Disposable {
|
|
|
12076
12103
|
return this._univerInstanceService.getUnit(DOCS_NORMAL_EDITOR_UNIT_ID_KEY, UniverInstanceType.UNIVER_DOC);
|
|
12077
12104
|
}
|
|
12078
12105
|
_getEditorSkeleton(editorId) {
|
|
12079
|
-
var _this$
|
|
12080
|
-
return (_this$
|
|
12106
|
+
var _this$_renderManagerS9;
|
|
12107
|
+
return (_this$_renderManagerS9 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS9 === void 0 ? void 0 : _this$_renderManagerS9.with(DocSkeletonManagerService).getSkeleton();
|
|
12081
12108
|
}
|
|
12082
12109
|
_getEditorViewModel(editorId) {
|
|
12083
|
-
var _this$
|
|
12084
|
-
return (_this$
|
|
12110
|
+
var _this$_renderManagerS10;
|
|
12111
|
+
return (_this$_renderManagerS10 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS10 === void 0 ? void 0 : _this$_renderManagerS10.with(DocSkeletonManagerService).getViewModel();
|
|
12085
12112
|
}
|
|
12086
12113
|
_getEditingUnit() {
|
|
12087
12114
|
return this._editingUnit ? this._univerInstanceService.getUnit(this._editingUnit, UniverInstanceType.UNIVER_SHEET) : null;
|
|
@@ -12139,13 +12166,13 @@ function getCellDataByInput(cellData, snapshot, lexerTreeBuilder, localeService,
|
|
|
12139
12166
|
cellData.si = null;
|
|
12140
12167
|
cellData.p = snapshot;
|
|
12141
12168
|
cellData.t = CellValueType.STRING;
|
|
12142
|
-
} else if (cellData.s && isTextFormat(styles === null || styles === void 0 || (_styles$get = styles.get(cellData.s)) === null || _styles$get === void 0 || (_styles$get = _styles$get.n) === null || _styles$get === void 0 ? void 0 : _styles$get.pattern)) {
|
|
12169
|
+
} else if (newDataStream !== "" && cellData.s && isTextFormat(styles === null || styles === void 0 || (_styles$get = styles.get(cellData.s)) === null || _styles$get === void 0 || (_styles$get = _styles$get.n) === null || _styles$get === void 0 ? void 0 : _styles$get.pattern)) {
|
|
12143
12170
|
cellData.v = newDataStream;
|
|
12144
12171
|
cellData.f = null;
|
|
12145
12172
|
cellData.si = null;
|
|
12146
12173
|
cellData.p = null;
|
|
12147
12174
|
cellData.t = CellValueType.STRING;
|
|
12148
|
-
if (isRichText(body)
|
|
12175
|
+
if (isRichText(body)) cellData.p = snapshot;
|
|
12149
12176
|
const style = getCellStyleBySnapshot(snapshot);
|
|
12150
12177
|
if (style) cellData.s = style;
|
|
12151
12178
|
} else if (isFormulaString(newDataStream)) {
|
|
@@ -12162,21 +12189,14 @@ function getCellDataByInput(cellData, snapshot, lexerTreeBuilder, localeService,
|
|
|
12162
12189
|
cellData.si = null;
|
|
12163
12190
|
cellData.p = null;
|
|
12164
12191
|
cellData.t = CellValueType.FORCE_STRING;
|
|
12165
|
-
} else if (isRichText(body)) {
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
cellData.p = null;
|
|
12171
|
-
} else {
|
|
12172
|
-
cellData.p = snapshot;
|
|
12173
|
-
cellData.v = null;
|
|
12174
|
-
cellData.f = null;
|
|
12175
|
-
cellData.si = null;
|
|
12176
|
-
}
|
|
12192
|
+
} else if (newDataStream !== "" && isRichText(body)) {
|
|
12193
|
+
cellData.p = snapshot;
|
|
12194
|
+
cellData.v = null;
|
|
12195
|
+
cellData.f = null;
|
|
12196
|
+
cellData.si = null;
|
|
12177
12197
|
} else {
|
|
12178
|
-
if (newDataStream === "" && cellData.v == null && cellData.p == null) return null;
|
|
12179
|
-
cellData.v = newDataStream;
|
|
12198
|
+
if (newDataStream === "" && cellData.v == null && cellData.p == null && cellData.f == null && cellData.si == null) return null;
|
|
12199
|
+
cellData.v = newDataStream === "" ? null : newDataStream;
|
|
12180
12200
|
cellData.f = null;
|
|
12181
12201
|
cellData.si = null;
|
|
12182
12202
|
cellData.p = null;
|
|
@@ -25071,7 +25091,7 @@ const useHighlightRange = (ranges = []) => {
|
|
|
25071
25091
|
//#endregion
|
|
25072
25092
|
//#region package.json
|
|
25073
25093
|
var name = "@univerjs/sheets-ui";
|
|
25074
|
-
var version = "1.
|
|
25094
|
+
var version = "1.2.0";
|
|
25075
25095
|
|
|
25076
25096
|
//#endregion
|
|
25077
25097
|
//#region src/views/cell-popup/config.ts
|
|
@@ -27588,7 +27608,7 @@ const DefinedNameContainer = ({ ConfirmComponent = Confirm, DefinedNameInputComp
|
|
|
27588
27608
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
27589
27609
|
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",
|
|
27590
27610
|
children: [definedName.name, /* @__PURE__ */ jsx("span", {
|
|
27591
|
-
className: "univer-
|
|
27611
|
+
className: "univer-ml-1 univer-text-xs univer-text-gray-400",
|
|
27592
27612
|
children: definedName.localSheetId === SCOPE_WORKBOOK_VALUE_DEFINED_NAME || definedName.localSheetId == null ? "" : getSheetNameBySheetId(definedName.localSheetId)
|
|
27593
27613
|
})]
|
|
27594
27614
|
}), /* @__PURE__ */ jsx("div", {
|
|
@@ -28800,7 +28820,7 @@ function SheetPermissionPanelListContent({ ActionRowComponent }) {
|
|
|
28800
28820
|
rule.description && /* @__PURE__ */ jsx(Tooltip, {
|
|
28801
28821
|
title: rule.description,
|
|
28802
28822
|
children: /* @__PURE__ */ jsx("div", {
|
|
28803
|
-
className: "univer-
|
|
28823
|
+
className: "univer-mt-2 univer-max-w-64 univer-truncate univer-text-sm univer-text-gray-400",
|
|
28804
28824
|
children: rule.description
|
|
28805
28825
|
})
|
|
28806
28826
|
})
|
|
@@ -35790,6 +35810,12 @@ let DesktopCellEditRenderController = class DesktopCellEditRenderController exte
|
|
|
35790
35810
|
var _params;
|
|
35791
35811
|
if (params === null || params === void 0 || (_params = params[params.length - 1]) === null || _params === void 0 ? void 0 : _params.primary) this._updateInputPosition();
|
|
35792
35812
|
}));
|
|
35813
|
+
const viewportMain = this._context.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
|
|
35814
|
+
if (viewportMain) d.add(viewportMain.onScrollEnd$.subscribeEvent(() => {
|
|
35815
|
+
if (this._editorBridgeService.isVisible().visible) return;
|
|
35816
|
+
this._editorBridgeService.refreshEditCellPosition(false);
|
|
35817
|
+
this._updateInputPosition();
|
|
35818
|
+
}));
|
|
35793
35819
|
}
|
|
35794
35820
|
_updateInputPosition() {
|
|
35795
35821
|
var _this$_renderManagerS;
|
|
@@ -35797,8 +35823,8 @@ let DesktopCellEditRenderController = class DesktopCellEditRenderController exte
|
|
|
35797
35823
|
const layout = this._editorBridgeService.getEditCellLayout();
|
|
35798
35824
|
const docSelectionRenderService = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(DocSelectionRenderService);
|
|
35799
35825
|
if (!layout || !docSelectionRenderService) return;
|
|
35800
|
-
const {
|
|
35801
|
-
docSelectionRenderService.setInputPosition(
|
|
35826
|
+
const { x, y } = getEditCellInputPosition(layout, this._context.engine);
|
|
35827
|
+
docSelectionRenderService.setInputPosition(x, y);
|
|
35802
35828
|
}
|
|
35803
35829
|
_focusCellEditorInput() {
|
|
35804
35830
|
const focusedChildUnitId = getEmbedChildUnitId(typeof document === "undefined" ? null : document.activeElement);
|
package/lib/index.js
CHANGED
|
@@ -11459,6 +11459,29 @@ function processNumberStringWithSpaces(token, numStr) {
|
|
|
11459
11459
|
};
|
|
11460
11460
|
}
|
|
11461
11461
|
|
|
11462
|
+
//#endregion
|
|
11463
|
+
//#region src/controllers/editor/utils/get-edit-cell-input-position.ts
|
|
11464
|
+
/**
|
|
11465
|
+
* Get the position of the hidden editor input for the current edit cell.
|
|
11466
|
+
*
|
|
11467
|
+
* The OS anchors the IME candidate window to the focused input, so the input should stay on the
|
|
11468
|
+
* selected cell even before the cell editor opens. The position is kept inside the sheet canvas,
|
|
11469
|
+
* so a cell scrolled out of view never moves the input outside the sheet.
|
|
11470
|
+
*/
|
|
11471
|
+
function getEditCellInputPosition(layout, canvasSize) {
|
|
11472
|
+
const { position, canvasOffset } = layout;
|
|
11473
|
+
const x = canvasOffset.left + position.startX;
|
|
11474
|
+
const y = canvasOffset.top + position.startY;
|
|
11475
|
+
if (!canvasSize) return {
|
|
11476
|
+
x,
|
|
11477
|
+
y
|
|
11478
|
+
};
|
|
11479
|
+
return {
|
|
11480
|
+
x: Math.min(Math.max(x, canvasOffset.left), canvasOffset.left + canvasSize.width),
|
|
11481
|
+
y: Math.min(Math.max(y, canvasOffset.top), canvasOffset.top + canvasSize.height)
|
|
11482
|
+
};
|
|
11483
|
+
}
|
|
11484
|
+
|
|
11462
11485
|
//#endregion
|
|
11463
11486
|
//#region src/controllers/editor/utils/is-range-selector.ts
|
|
11464
11487
|
/**
|
|
@@ -11675,7 +11698,11 @@ let EditingRenderController = class EditingRenderController extends Disposable {
|
|
|
11675
11698
|
if ((cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 ? void 0 : cellSelectionRenderManager.canFocusing) || (formulaSelectionRenderManager === null || formulaSelectionRenderManager === void 0 ? void 0 : formulaSelectionRenderManager.canFocusing)) {
|
|
11676
11699
|
this._univerInstanceService.setCurrentUnitForType(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
|
|
11677
11700
|
if (this._contextService.getContextValue(DISABLE_AUTO_FOCUS_KEY)) cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 || cellSelectionRenderManager.setInputPosition(HIDDEN_EDITOR_POSITION$1, HIDDEN_EDITOR_POSITION$1);
|
|
11678
|
-
else
|
|
11701
|
+
else {
|
|
11702
|
+
var _this$_renderManagerS5;
|
|
11703
|
+
const { x, y } = getEditCellInputPosition(state, (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(state.unitId)) === null || _this$_renderManagerS5 === void 0 ? void 0 : _this$_renderManagerS5.engine);
|
|
11704
|
+
cellSelectionRenderManager === null || cellSelectionRenderManager === void 0 || cellSelectionRenderManager.activate(x, y, true);
|
|
11705
|
+
}
|
|
11679
11706
|
}
|
|
11680
11707
|
}));
|
|
11681
11708
|
}
|
|
@@ -11749,7 +11776,7 @@ let EditingRenderController = class EditingRenderController extends Disposable {
|
|
|
11749
11776
|
}));
|
|
11750
11777
|
}
|
|
11751
11778
|
_handleEditorVisible(param) {
|
|
11752
|
-
var _documentDataModel$ge, _this$
|
|
11779
|
+
var _documentDataModel$ge, _this$_renderManagerS7;
|
|
11753
11780
|
const { eventType, keycode } = param;
|
|
11754
11781
|
this._cursorChange = eventType === DeviceInputEventType.PointerDown || eventType === DeviceInputEventType.Dblclick ? 2 : 1;
|
|
11755
11782
|
const editCellState = this._editorBridgeService.getEditLocation();
|
|
@@ -11778,8 +11805,8 @@ let EditingRenderController = class EditingRenderController extends Disposable {
|
|
|
11778
11805
|
const resetPointerSelection = isInArrayFormulaRange && eventType === DeviceInputEventType.PointerDown;
|
|
11779
11806
|
const editorId = this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) ? DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY : this._editorBridgeService.getCurrentEditorId();
|
|
11780
11807
|
if (resetPointerSelection) {
|
|
11781
|
-
var _this$
|
|
11782
|
-
(_this$
|
|
11808
|
+
var _this$_renderManagerS6;
|
|
11809
|
+
(_this$_renderManagerS6 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS6 === void 0 || _this$_renderManagerS6.with(DocSelectionRenderService).cancelPointerSelection();
|
|
11783
11810
|
}
|
|
11784
11811
|
this._emptyDocumentDataModel(documentDataModel.getSnapshot().documentStyle, !!isInArrayFormulaRange);
|
|
11785
11812
|
document.makeDirty();
|
|
@@ -11857,7 +11884,7 @@ let EditingRenderController = class EditingRenderController extends Disposable {
|
|
|
11857
11884
|
collapsed: true
|
|
11858
11885
|
});
|
|
11859
11886
|
}
|
|
11860
|
-
(_this$
|
|
11887
|
+
(_this$_renderManagerS7 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS7 === void 0 || _this$_renderManagerS7.scene.resetCursor();
|
|
11861
11888
|
}
|
|
11862
11889
|
_resizeEditorOnOpen(param, editorObject, isInArrayFormulaRange) {
|
|
11863
11890
|
var _this$_sheetCellEdito4;
|
|
@@ -11873,8 +11900,8 @@ let EditingRenderController = class EditingRenderController extends Disposable {
|
|
|
11873
11900
|
if (!pointerPosition || isInArrayFormulaRange) return;
|
|
11874
11901
|
const rect = engine.getCanvasElement().getBoundingClientRect();
|
|
11875
11902
|
if (rect.width > 0 && rect.height > 0) {
|
|
11876
|
-
var _this$
|
|
11877
|
-
(_this$
|
|
11903
|
+
var _this$_renderManagerS8;
|
|
11904
|
+
(_this$_renderManagerS8 = this._renderManagerService.getRenderUnitById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _this$_renderManagerS8 === void 0 || _this$_renderManagerS8.with(DocSelectionRenderService).setCursorManually((pointerPosition.x - rect.left) * engine.width / rect.width, (pointerPosition.y - rect.top) * engine.height / rect.height, true, true, { strict: false });
|
|
11878
11905
|
}
|
|
11879
11906
|
});
|
|
11880
11907
|
}
|
|
@@ -12076,12 +12103,12 @@ let EditingRenderController = class EditingRenderController extends Disposable {
|
|
|
12076
12103
|
return this._univerInstanceService.getUnit(DOCS_NORMAL_EDITOR_UNIT_ID_KEY, UniverInstanceType.UNIVER_DOC);
|
|
12077
12104
|
}
|
|
12078
12105
|
_getEditorSkeleton(editorId) {
|
|
12079
|
-
var _this$
|
|
12080
|
-
return (_this$
|
|
12106
|
+
var _this$_renderManagerS9;
|
|
12107
|
+
return (_this$_renderManagerS9 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS9 === void 0 ? void 0 : _this$_renderManagerS9.with(DocSkeletonManagerService).getSkeleton();
|
|
12081
12108
|
}
|
|
12082
12109
|
_getEditorViewModel(editorId) {
|
|
12083
|
-
var _this$
|
|
12084
|
-
return (_this$
|
|
12110
|
+
var _this$_renderManagerS10;
|
|
12111
|
+
return (_this$_renderManagerS10 = this._renderManagerService.getRenderUnitById(editorId)) === null || _this$_renderManagerS10 === void 0 ? void 0 : _this$_renderManagerS10.with(DocSkeletonManagerService).getViewModel();
|
|
12085
12112
|
}
|
|
12086
12113
|
_getEditingUnit() {
|
|
12087
12114
|
return this._editingUnit ? this._univerInstanceService.getUnit(this._editingUnit, UniverInstanceType.UNIVER_SHEET) : null;
|
|
@@ -12139,13 +12166,13 @@ function getCellDataByInput(cellData, snapshot, lexerTreeBuilder, localeService,
|
|
|
12139
12166
|
cellData.si = null;
|
|
12140
12167
|
cellData.p = snapshot;
|
|
12141
12168
|
cellData.t = CellValueType.STRING;
|
|
12142
|
-
} else if (cellData.s && isTextFormat(styles === null || styles === void 0 || (_styles$get = styles.get(cellData.s)) === null || _styles$get === void 0 || (_styles$get = _styles$get.n) === null || _styles$get === void 0 ? void 0 : _styles$get.pattern)) {
|
|
12169
|
+
} else if (newDataStream !== "" && cellData.s && isTextFormat(styles === null || styles === void 0 || (_styles$get = styles.get(cellData.s)) === null || _styles$get === void 0 || (_styles$get = _styles$get.n) === null || _styles$get === void 0 ? void 0 : _styles$get.pattern)) {
|
|
12143
12170
|
cellData.v = newDataStream;
|
|
12144
12171
|
cellData.f = null;
|
|
12145
12172
|
cellData.si = null;
|
|
12146
12173
|
cellData.p = null;
|
|
12147
12174
|
cellData.t = CellValueType.STRING;
|
|
12148
|
-
if (isRichText(body)
|
|
12175
|
+
if (isRichText(body)) cellData.p = snapshot;
|
|
12149
12176
|
const style = getCellStyleBySnapshot(snapshot);
|
|
12150
12177
|
if (style) cellData.s = style;
|
|
12151
12178
|
} else if (isFormulaString(newDataStream)) {
|
|
@@ -12162,21 +12189,14 @@ function getCellDataByInput(cellData, snapshot, lexerTreeBuilder, localeService,
|
|
|
12162
12189
|
cellData.si = null;
|
|
12163
12190
|
cellData.p = null;
|
|
12164
12191
|
cellData.t = CellValueType.FORCE_STRING;
|
|
12165
|
-
} else if (isRichText(body)) {
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
cellData.p = null;
|
|
12171
|
-
} else {
|
|
12172
|
-
cellData.p = snapshot;
|
|
12173
|
-
cellData.v = null;
|
|
12174
|
-
cellData.f = null;
|
|
12175
|
-
cellData.si = null;
|
|
12176
|
-
}
|
|
12192
|
+
} else if (newDataStream !== "" && isRichText(body)) {
|
|
12193
|
+
cellData.p = snapshot;
|
|
12194
|
+
cellData.v = null;
|
|
12195
|
+
cellData.f = null;
|
|
12196
|
+
cellData.si = null;
|
|
12177
12197
|
} else {
|
|
12178
|
-
if (newDataStream === "" && cellData.v == null && cellData.p == null) return null;
|
|
12179
|
-
cellData.v = newDataStream;
|
|
12198
|
+
if (newDataStream === "" && cellData.v == null && cellData.p == null && cellData.f == null && cellData.si == null) return null;
|
|
12199
|
+
cellData.v = newDataStream === "" ? null : newDataStream;
|
|
12180
12200
|
cellData.f = null;
|
|
12181
12201
|
cellData.si = null;
|
|
12182
12202
|
cellData.p = null;
|
|
@@ -25071,7 +25091,7 @@ const useHighlightRange = (ranges = []) => {
|
|
|
25071
25091
|
//#endregion
|
|
25072
25092
|
//#region package.json
|
|
25073
25093
|
var name = "@univerjs/sheets-ui";
|
|
25074
|
-
var version = "1.
|
|
25094
|
+
var version = "1.2.0";
|
|
25075
25095
|
|
|
25076
25096
|
//#endregion
|
|
25077
25097
|
//#region src/views/cell-popup/config.ts
|
|
@@ -27588,7 +27608,7 @@ const DefinedNameContainer = ({ ConfirmComponent = Confirm, DefinedNameInputComp
|
|
|
27588
27608
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
27589
27609
|
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",
|
|
27590
27610
|
children: [definedName.name, /* @__PURE__ */ jsx("span", {
|
|
27591
|
-
className: "univer-
|
|
27611
|
+
className: "univer-ml-1 univer-text-xs univer-text-gray-400",
|
|
27592
27612
|
children: definedName.localSheetId === SCOPE_WORKBOOK_VALUE_DEFINED_NAME || definedName.localSheetId == null ? "" : getSheetNameBySheetId(definedName.localSheetId)
|
|
27593
27613
|
})]
|
|
27594
27614
|
}), /* @__PURE__ */ jsx("div", {
|
|
@@ -28800,7 +28820,7 @@ function SheetPermissionPanelListContent({ ActionRowComponent }) {
|
|
|
28800
28820
|
rule.description && /* @__PURE__ */ jsx(Tooltip, {
|
|
28801
28821
|
title: rule.description,
|
|
28802
28822
|
children: /* @__PURE__ */ jsx("div", {
|
|
28803
|
-
className: "univer-
|
|
28823
|
+
className: "univer-mt-2 univer-max-w-64 univer-truncate univer-text-sm univer-text-gray-400",
|
|
28804
28824
|
children: rule.description
|
|
28805
28825
|
})
|
|
28806
28826
|
})
|
|
@@ -35790,6 +35810,12 @@ let DesktopCellEditRenderController = class DesktopCellEditRenderController exte
|
|
|
35790
35810
|
var _params;
|
|
35791
35811
|
if (params === null || params === void 0 || (_params = params[params.length - 1]) === null || _params === void 0 ? void 0 : _params.primary) this._updateInputPosition();
|
|
35792
35812
|
}));
|
|
35813
|
+
const viewportMain = this._context.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
|
|
35814
|
+
if (viewportMain) d.add(viewportMain.onScrollEnd$.subscribeEvent(() => {
|
|
35815
|
+
if (this._editorBridgeService.isVisible().visible) return;
|
|
35816
|
+
this._editorBridgeService.refreshEditCellPosition(false);
|
|
35817
|
+
this._updateInputPosition();
|
|
35818
|
+
}));
|
|
35793
35819
|
}
|
|
35794
35820
|
_updateInputPosition() {
|
|
35795
35821
|
var _this$_renderManagerS;
|
|
@@ -35797,8 +35823,8 @@ let DesktopCellEditRenderController = class DesktopCellEditRenderController exte
|
|
|
35797
35823
|
const layout = this._editorBridgeService.getEditCellLayout();
|
|
35798
35824
|
const docSelectionRenderService = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(DOCS_NORMAL_EDITOR_UNIT_ID_KEY)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(DocSelectionRenderService);
|
|
35799
35825
|
if (!layout || !docSelectionRenderService) return;
|
|
35800
|
-
const {
|
|
35801
|
-
docSelectionRenderService.setInputPosition(
|
|
35826
|
+
const { x, y } = getEditCellInputPosition(layout, this._context.engine);
|
|
35827
|
+
docSelectionRenderService.setInputPosition(x, y);
|
|
35802
35828
|
}
|
|
35803
35829
|
_focusCellEditorInput() {
|
|
35804
35830
|
const focusedChildUnitId = getEmbedChildUnitId(typeof document === "undefined" ? null : document.activeElement);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { Nullable } from '@univerjs/core';
|
|
17
|
+
import type { ICellEditorLayout } from '../../../services/editor-bridge.service';
|
|
18
|
+
/**
|
|
19
|
+
* Get the position of the hidden editor input for the current edit cell.
|
|
20
|
+
*
|
|
21
|
+
* The OS anchors the IME candidate window to the focused input, so the input should stay on the
|
|
22
|
+
* selected cell even before the cell editor opens. The position is kept inside the sheet canvas,
|
|
23
|
+
* so a cell scrolled out of view never moves the input outside the sheet.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getEditCellInputPosition(layout: Pick<ICellEditorLayout, 'position' | 'canvasOffset'>, canvasSize?: Nullable<{
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}>): {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
};
|