Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix: cursor position error (#1072)

Ran Luo1f4ff46cb026
diff --git a/packages/engine-render/src/components/docs/common/liquid.ts b/packages/engine-render/src/components/docs/common/liquid.ts
index 3ff3c31ce8..85d6879b91 100644
--- a/packages/engine-render/src/components/docs/common/liquid.ts
+++ b/packages/engine-render/src/components/docs/common/liquid.ts
@@ -128,17 +128,17 @@ export class Liquid {
bottom = 0
) {
const {
- sections,
- marginTop: pagePaddingTop = 0,
- marginBottom: pagePaddingBottom = 0,
- marginLeft: pagePaddingLeft = 0,
- marginRight: pagePaddingRight = 0,
+ // sections,
+ // marginTop: pagePaddingTop = 0,
+ // marginBottom: pagePaddingBottom = 0,
+ // marginLeft: pagePaddingLeft = 0,
+ // marginRight: pagePaddingRight = 0,
pageWidth,
pageHeight,
- width,
- height,
- pageNumber = 1,
- renderConfig = {},
+ // width,
+ // height,
+ // pageNumber = 1,
+ // renderConfig = {},
} = page;
let pageTop = 0;
diff --git a/packages/engine-render/src/components/docs/common/text-range.ts b/packages/engine-render/src/components/docs/common/text-range.ts
index b89b012e00..2367330869 100644
--- a/packages/engine-render/src/components/docs/common/text-range.ts
+++ b/packages/engine-render/src/components/docs/common/text-range.ts
@@ -215,8 +215,6 @@ export class TextRange {
const { docsLeft, docsTop } = documentOffsetConfig;
- // console.log(this._scene, this._docSkeleton, documentOffsetConfig);
-
const convertor = new NodePositionConvertToCursor(documentOffsetConfig, _docSkeleton);
if (this._isCollapsed()) {
diff --git a/packages/engine-render/src/components/docs/document.ts b/packages/engine-render/src/components/docs/document.ts
index 724795c4c8..d1dfd72dea 100644
--- a/packages/engine-render/src/components/docs/document.ts
+++ b/packages/engine-render/src/components/docs/document.ts
@@ -22,7 +22,7 @@ import { HorizontalAlign, Observable, VerticalAlign, WrapStrategy } from '@unive
import { calculateRectRotate, getRotateOffsetAndFarthestHypotenuse } from '../../basics/draw';
import type { IDocumentSkeletonCached, IDocumentSkeletonPage } from '../../basics/i-document-skeleton-cached';
import { LineType, PageLayoutType } from '../../basics/i-document-skeleton-cached';
-import { degToRad, getScale } from '../../basics/tools';
+import { degToRad } from '../../basics/tools';
import type { Transform } from '../../basics/transform';
import type { IViewportBound } from '../../basics/vector2';
import { Vector2 } from '../../basics/vector2';
@@ -176,8 +176,6 @@ export class Documents extends DocComponent {
return (this.getScene() as Scene).getEngine();
}
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
-
override draw(ctx: UniverRenderingContext, bounds?: IViewportBound) {
const documentSkeleton = this.getSkeleton();
@@ -201,7 +199,7 @@ export class Documents extends DocComponent {
const { pages } = skeletonData;
const parentScale = this.getParentScale();
- const scale = getScale(parentScale);
+ // const scale = getScale(parentScale);
const extensions = this.getExtensionsByOrder();
for (const extension of extensions) {
@@ -324,7 +322,7 @@ export class Documents extends DocComponent {
rotateTranslateXListApply = rotateTranslateXList;
} else if (wrapStrategy === WrapStrategy.WRAP) {
- alignOffset.x = pagePaddingLeft * scale;
+ // alignOffset.x = pagePaddingLeft * scale;
}
for (let i = 0; i < linesCount; i++) {
diff --git a/packages/engine-render/src/components/docs/text-selection-render-manager.ts b/packages/engine-render/src/components/docs/text-selection-render-manager.ts
index 14a2b4ab31..9285fd23c3 100644
--- a/packages/engine-render/src/components/docs/text-selection-render-manager.ts
+++ b/packages/engine-render/src/components/docs/text-selection-render-manager.ts
@@ -818,11 +818,12 @@ export class TextSelectionRenderManager extends RxDisposable implements ITextSel
private _scrollToSelection() {
const activeRangeInstance = this._getActiveRangeInstance();
const anchor = activeRangeInstance?.getAnchor();
+
if (!anchor || (anchor && !anchor.visible) || this._activeViewport == null) {
return;
}
- const { scaleX, scaleY } = this._scene?.getAncestorScale() || { scaleX: 1, scaleY: 1 };
+ // const { scaleX, scaleY } = this._scene?.getAncestorScale() || { scaleX: 1, scaleY: 1 };
const { left, top, height, width } = anchor;
@@ -836,8 +837,8 @@ export class TextSelectionRenderManager extends RxDisposable implements ITextSel
right: boundRight,
bottom: boundBottom,
} = this._activeViewport.getBounding().viewBound;
- const constantOffsetWidth = width / scaleX;
- const constantOffsetHeight = height / scaleY;
+ const constantOffsetWidth = width;
+ const constantOffsetHeight = height;
let offsetY = 0;
let offsetX = 0;
diff --git a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts
index a84d97f521..e136c790f4 100644
--- a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts
+++ b/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts
@@ -363,7 +363,7 @@ export class StartEditController extends Disposable {
physicHeight = clientHeight;
if (scrollBar == null) {
- viewportMain && new ScrollBar(viewportMain, { enableHorizontal: false });
+ viewportMain && new ScrollBar(viewportMain, { enableHorizontal: false, barSize: 8 });
} else {
viewportMain?.resetSizeAndScrollBar();
}