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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(docs): prevent stale comment carets after focus changes (#8151)
白熱a57b187e4540
diff --git a/packages/docs-ui/src/views/__tests__/RichTextEditor.spec.tsx b/packages/docs-ui/src/views/__tests__/RichTextEditor.spec.tsxindex 1cccb323ad..71a32c7c27 100644--- a/packages/docs-ui/src/views/__tests__/RichTextEditor.spec.tsx+++ b/packages/docs-ui/src/views/__tests__/RichTextEditor.spec.tsx@@ -79,6 +79,8 @@ class TestEditorRender extends Disposable {textSelectionInner$: new Subject(),movingSelection$: new Subject(),isFocusing: false,+ getAllTextRanges: () => [],+ getAllRectRanges: () => [],};readonly components = new Map();diff --git a/packages/docs-ui/src/views/rich-text-editor/hooks/__tests__/use-resize.spec.tsx b/packages/docs-ui/src/views/rich-text-editor/hooks/__tests__/use-resize.spec.tsxindex 24525036c2..bf9e190f82 100644--- a/packages/docs-ui/src/views/rich-text-editor/hooks/__tests__/use-resize.spec.tsx+++ b/packages/docs-ui/src/views/rich-text-editor/hooks/__tests__/use-resize.spec.tsx@@ -18,130 +18,165 @@* @vitest-environment jsdom*/-import type { Editor } from '../../../../services/editor/editor';-import { Subject } from 'rxjs';-import { describe, expect, it, vi } from 'vitest';+import type { DocumentDataModel, IDocumentData } from '@univerjs/core';+import {+ DOCS_COMMENT_EDITOR_UNIT_ID_KEY,+ ICommandService,+ LocaleService,+ LocaleType,+ RichTextBuilder,+ Univer,+ UniverInstanceType,+} from '@univerjs/core';+import {+ DocLayoutExecutorService,+ DocSelectionManagerService,+ DocSkeletonManagerService,+ SetTextSelectionsOperation,+} from '@univerjs/docs';+import {+ CanvasColorService,+ Documents,+ ICanvasColorService,+ IRenderManagerService,+ RenderManagerService,+ Viewport,+} from '@univerjs/engine-render';+import { DesktopLayoutService, ILayoutService } from '@univerjs/ui';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { VIEWPORT_KEY } from '../../../../basics/docs-view-key';+import { DocSelectionRenderController } from '../../../../controllers/render-controllers/doc-selection-render.controller';+import { EditorService, IEditorService } from '../../../../services/editor/editor-manager.service';+import { DocSelectionRenderService } from '../../../../services/selection/doc-selection-render.service';import { resizeEditor } from '../use-resize';-describe('useResize', () => {- it('does not access canvas resources after the editor render is disposed', () => {- const getBoundingClientRect = vi.fn(() => {- throw new Error('Disposed editor DOM');+function createEditors() {+ const univer = new Univer({ locale: LocaleType.EN_US });+ const injector = univer.__getInjector();+ injector.add([ICanvasColorService, { useClass: CanvasColorService }]);+ injector.add([IRenderManagerService, { useClass: RenderManagerService }]);+ injector.add([ILayoutService, { useClass: DesktopLayoutService }]);+ injector.add([IEditorService, { useClass: EditorService }]);+ injector.add([DocLayoutExecutorService]);+ injector.add([DocSelectionManagerService]);+ injector.get(ICommandService).registerCommand(SetTextSelectionsOperation);+ injector.get(LocaleService).setDirection('ltr');+ const renderManager = injector.get(IRenderManagerService);+ renderManager.registerRenderModule(UniverInstanceType.UNIVER_DOC, [DocSkeletonManagerService]);+ renderManager.registerRenderModule(UniverInstanceType.UNIVER_DOC, [DocSelectionRenderService]);+ renderManager.registerRenderModule(UniverInstanceType.UNIVER_DOC, [DocSelectionRenderController]);+ const root = document.createElement('div');+ document.body.appendChild(root);+ injector.get(ILayoutService).registerRootContainerElement(root);+ const editors = ['PANEL', 'CELL'].map((location) => {+ const id = `${DOCS_COMMENT_EDITOR_UNIT_ID_KEY}_${location}_comment`;+ const container = document.createElement('div');+ root.appendChild(container);+ vi.spyOn(container, 'getBoundingClientRect').mockReturnValue(new DOMRect(0, 0, 320, 96));+ const doc = univer.createUnit<IDocumentData, DocumentDataModel>(UniverInstanceType.UNIVER_DOC, {+ ...RichTextBuilder.create().insertText('Comment draft').getData(),+ id,+ documentStyle: { pageSize: { width: 320, height: Infinity } },});- const editor = { render: { isDisposed: () => true }, getBoundingClientRect } as unknown as Editor;+ const render = renderManager.createRender(doc.getUnitId(), { makeCurrent: false });+ const skeleton = render.with(DocSkeletonManagerService).getSkeleton();+ const documents = new Documents('doc-main', skeleton);+ documents.resize(320, 96);+ render.mainComponent = documents;+ render.scene.addObject(documents);+ new Viewport(VIEWPORT_KEY.VIEW_MAIN, render.scene, { left: 0, top: 0, width: 320, height: 96 });+ render.with(DocSelectionRenderController);+ const editorService = injector.get(IEditorService);+ editorService.register({ initialSnapshot: doc.getSnapshot(), cancelDefaultResizeListener: true }, container);+ render.engine.resizeBySize(320, 96);+ return editorService.getAllEditor().get(id)!;+ });+ return { univer, injector, editors };+}++describe('resizeEditor', () => {+ let testBed: ReturnType<typeof createEditors>;++ beforeEach(() => {+ vi.useFakeTimers();+ testBed = createEditors();+ });++ afterEach(() => {+ testBed.univer.dispose();+ document.body.replaceChildren();+ vi.restoreAllMocks();+ vi.useRealTimers();+ });++ it('does not access canvas resources after the editor render is disposed', () => {+ const editor = testBed.editors[0];+ testBed.injector.get(IRenderManagerService).removeRender(editor.getEditorId());expect(() => resizeEditor(editor, false, { width: 100, height: 20 })).not.toThrow();- expect(getBoundingClientRect).not.toHaveBeenCalled();});it('preserves engine-owned sizing when no host dimensions are configured', () => {- const updateDocumentDataPageSize = vi.fn();- const sceneTransform = vi.fn();- const documentResize = vi.fn();- const documentTranslate = vi.fn();- const backgroundTranslate = vi.fn();- const engineResize = vi.fn();- const editor = {- getBoundingClientRect: () => ({ width: 320, height: 96 }),- getSelectionRanges: () => [],- input$: new Subject(),- render: {- isDisposed: () => false,- components: { get: () => ({ translate: backgroundTranslate }) },- engine: {- getCanvas: () => ({ setPixelRatio: vi.fn() }),- resizeBySize: engineResize,- },- mainComponent: { resize: documentResize, translate: documentTranslate },- scene: { transformByState: sceneTransform },- with: () => ({- getViewModel: () => ({- getDataModel: () => ({ updateDocumentDataPageSize }),- }),- }),- },- } as unknown as Editor;-+ const editor = testBed.editors[0];+ editor.render.engine.resizeBySize(400, 120);resizeEditor(editor, false);+ expect(editor.render.engine.width).toBe(400);+ expect(editor.getDocumentData().documentStyle.pageSize).toEqual({ width: 320, height: Infinity });+ expect(editor.render.mainComponent?.width).toBe(320);+ });- expect(updateDocumentDataPageSize).toHaveBeenCalledWith(320, Infinity);- expect(engineResize).not.toHaveBeenCalled();- expect(sceneTransform).toHaveBeenCalledWith({ width: 320, height: 96 });- expect(documentResize).toHaveBeenCalledWith(320, 96);- expect(documentTranslate).toHaveBeenCalledWith(0, 0);- expect(backgroundTranslate).toHaveBeenCalledWith(0, 0);+ it('uses explicit layout dimensions instead of transformed DOM dimensions', () => {+ const editor = testBed.editors[0];+ resizeEditor(editor, false, { width: 480, height: 24 }, 2);+ expect(editor.render.engine.width).toBe(480);+ expect(editor.render.engine.height).toBe(24);+ expect(editor.getDocumentData().documentStyle.pageSize).toEqual({ width: 480, height: Infinity });+ expect(editor.render.engine.getCanvas().getCanvasEle().width).toBe(960);});- it('uses the explicit layout size when the editor DOM is CSS transformed', () => {- const updateDocumentDataPageSize = vi.fn();- const sceneTransform = vi.fn();- const documentResize = vi.fn();- const engineResize = vi.fn();- const setPixelRatio = vi.fn();- const editor = {- getBoundingClientRect: () => ({ width: 24, height: 480 }),- getSelectionRanges: () => [],- input$: new Subject(),- render: {- isDisposed: () => false,- components: { get: () => ({ translate: vi.fn() }) },- engine: {- getCanvas: () => ({ setPixelRatio }),- resizeBySize: engineResize,- },- mainComponent: { resize: documentResize, translate: vi.fn() },- scene: { transformByState: sceneTransform },- with: () => ({- getViewModel: () => ({- getDataModel: () => ({ updateDocumentDataPageSize }),- }),- }),- },- } as unknown as Editor;+ it('can oversize the canvas without changing the document reflow width', () => {+ const editor = testBed.editors[0];+ resizeEditor(editor, false, { width: 240, height: 30 }, 1, { width: 204, height: 30 });+ expect(editor.render.engine.width).toBe(240);+ expect(editor.getDocumentData().documentStyle.pageSize).toEqual({ width: 204, height: Infinity });+ expect(editor.render.mainComponent?.width).toBe(204);+ });- resizeEditor(editor, false, { width: 480, height: 24 }, 2);+ it('does not restore a stale comment caret when a delayed resize runs after switching editors', () => {+ const [sidebar, popup] = testBed.editors;+ const editorService = testBed.injector.get(IEditorService);+ editorService.focus(sidebar.getEditorId());+ sidebar.setSelectionRanges([{ startOffset: 3, endOffset: 3 }]);+ setTimeout(() => resizeEditor(sidebar, false), 500);+ editorService.focus(popup.getEditorId());+ popup.setSelectionRanges([{ startOffset: 5, endOffset: 5 }]);- expect(updateDocumentDataPageSize).toHaveBeenCalledWith(480, Infinity);- expect(engineResize).toHaveBeenCalledWith(480, 24);- expect(setPixelRatio).toHaveBeenCalledWith(2);- expect(sceneTransform).toHaveBeenCalledWith({ width: 480, height: 24 });- expect(documentResize).toHaveBeenCalledWith(480, 24);+ vi.advanceTimersByTime(500);++ expect(sidebar.docSelectionRenderService.getAllTextRanges()).toEqual([]);+ expect(popup.docSelectionRenderService.getActiveTextRange()?.getAnchor()?.visible).toBe(true);+ expect(document.activeElement).toBe(popup.docSelectionRenderService.inputElement);+ expect(sidebar.getSelectionRanges()).toMatchObject([{ startOffset: 3, endOffset: 3 }]);+ expect(sidebar.getDocumentData().body?.dataStream).toBe('Comment draft\r\n');++ editorService.focus(sidebar.getEditorId());+ resizeEditor(sidebar, false);+ expect(sidebar.docSelectionRenderService.getActiveTextRange()).toMatchObject({ startOffset: 3, endOffset: 3 });+ expect(sidebar.docSelectionRenderService.getActiveTextRange()?.getAnchor()?.visible).toBe(true);+ expect(popup.docSelectionRenderService.getAllTextRanges()).toEqual([]);});- it('can oversize the canvas without changing the document reflow width', () => {- const updateDocumentDataPageSize = vi.fn();- const documentResize = vi.fn();- const engineResize = vi.fn();- const editor = {- getBoundingClientRect: () => ({ width: 204, height: 30 }),- getSelectionRanges: () => [],- input$: new Subject(),- render: {- isDisposed: () => false,- components: { get: () => ({ translate: vi.fn() }) },- engine: {- getCanvas: () => ({ setPixelRatio: vi.fn() }),- resizeBySize: engineResize,- },- mainComponent: { resize: documentResize, translate: vi.fn() },- scene: { transformByState: vi.fn() },- with: () => ({- getViewModel: () => ({- getDataModel: () => ({ updateDocumentDataPageSize }),- }),- }),- },- } as unknown as Editor;-- resizeEditor(- editor,- false,- { width: 240, height: 30 },- 1,- { width: 204, height: 30 }- );-- expect(engineResize).toHaveBeenCalledWith(240, 30);- expect(updateDocumentDataPageSize).toHaveBeenCalledWith(204, Infinity);- expect(documentResize).toHaveBeenCalledWith(204, 30);+ it.each([[3, 3], [2, 7]])('preserves the visible selection %i:%i when resizing while a toolbar control has focus', (startOffset, endOffset) => {+ const editor = testBed.editors[0];+ testBed.injector.get(IEditorService).focus(editor.getEditorId());+ editor.setSelectionRanges([{ startOffset, endOffset }]);+ const button = document.createElement('button');+ document.body.appendChild(button);+ button.focus();++ resizeEditor(editor, false, { width: 200, height: 96 });++ expect(editor.docSelectionRenderService.getActiveTextRange()).toMatchObject({ startOffset, endOffset });+ expect(editor.getSelectionRanges()).toMatchObject([{ startOffset, endOffset }]);+ expect(document.activeElement).toBe(button);});});diff --git a/packages/docs-ui/src/views/rich-text-editor/hooks/use-resize.ts b/packages/docs-ui/src/views/rich-text-editor/hooks/use-resize.tsindex b214d9f60c..3bc0bf4f01 100644--- a/packages/docs-ui/src/views/rich-text-editor/hooks/use-resize.ts+++ b/packages/docs-ui/src/views/rich-text-editor/hooks/use-resize.ts@@ -15,11 +15,11 @@*/import type { Nullable } from '@univerjs/core';-import type { Editor } from '../../../services/editor/editor';import { debounce } from '@univerjs/core';import { DocSkeletonManagerService } from '@univerjs/docs';import { ScrollBar } from '@univerjs/engine-render';import { useCallback, useEffect, useLayoutEffect, useMemo } from 'react';+import type { Editor } from '../../../services/editor/editor';import { DOCS_VIEW_KEY, VIEWPORT_KEY } from '../../../basics/docs-view-key';interface IUseResizeReturn {@@ -37,6 +37,11 @@ export function resizeEditor(if (editor.render.isDisposed()) {return;}+ const selection = editor.docSelectionRenderService;+ // Stored logical ranges outlive the visible caret when another editor takes focus.+ const restoreSelection = selection.isFocusing ||+ selection.getAllTextRanges().length > 0 ||+ selection.getAllRectRanges().length > 0;const { scene, mainComponent } = editor.render;const docSkeletonManagerService = editor.render.with(DocSkeletonManagerService);const { width, height } = layoutSize ?? editor.getBoundingClientRect();@@ -63,7 +68,7 @@ export function resizeEditor(editor.render.components.get(DOCS_VIEW_KEY.BACKGROUND)?.translate(0, 0);const selectionRanges = editor.getSelectionRanges();- if (selectionRanges.length > 0) {+ if (restoreSelection && selectionRanges.length > 0) {editor.setSelectionRanges(selectionRanges, false);}}diff --git a/packages/docs/src/commands/mutations/__tests__/core-editing.mutation.spec.ts b/packages/docs/src/commands/mutations/__tests__/core-editing.mutation.spec.tsindex 36181bc47e..3ef1243815 100644--- a/packages/docs/src/commands/mutations/__tests__/core-editing.mutation.spec.ts+++ b/packages/docs/src/commands/mutations/__tests__/core-editing.mutation.spec.ts@@ -15,18 +15,20 @@*/import type { IDocumentBody } from '@univerjs/core';-import type { IRichTextEditingMutationParams } from '../core-editing.mutation';import {CustomRangeType,DocumentFlavor,getRichTextEditPath,ICommandService,+ IUniverInstanceService,JSONX,TextX,Tools,+ UniverInstanceType,} from '@univerjs/core';import { NORMAL_TEXT_SELECTION_PLUGIN_STYLE, registerDocumentLayoutPresentation } from '@univerjs/engine-render';import { describe, expect, it, vi } from 'vitest';+import type { IRichTextEditingMutationParams } from '../core-editing.mutation';import { createDocumentData, createTestBed } from '../../../facade/__tests__/create-test-bed';import { DocSelectionManagerService } from '../../../services/doc-selection-manager.service';import { InsertTextCommand } from '../../commands/core-editing.command';@@ -88,6 +90,64 @@ describe('transformDocumentTextRanges', () => {});describe('RichTextEditingMutation selection scheduling', () => {+ it.each(['before', 'after'])('keeps an inactive comment draft without restoring its caret when updated %s switching editors', async (timing) => {+ const bed = createTestBed(createDocumentData('comment-sidebar', { dataStream: 'Draft\r\n' }));+ const selectionManager = bed.get(DocSelectionManagerService);+ const instances = bed.get(IUniverInstanceService);+ bed.univer.createUnit(UniverInstanceType.UNIVER_DOC, createDocumentData('comment-popup', { dataStream: 'Reply\r\n' }));+ const sidebar = { unitId: 'comment-sidebar', subUnitId: 'comment-sidebar' };+ const popup = { unitId: 'comment-popup', subUnitId: 'comment-popup' };+ for (const target of [sidebar, popup]) {+ selectionManager.replaceSelectionInfoWithoutRefresh({+ textRanges: [{ startOffset: 2, endOffset: 2, collapsed: true, isActive: true }],+ rectRanges: [],+ segmentId: '',+ segmentPage: 0,+ isEditing: true,+ style: NORMAL_TEXT_SELECTION_PLUGIN_STYLE,+ }, target);+ }+ instances.setCurrentUnitForType(sidebar.unitId);+ const refreshedUnits: string[] = [];+ const subscription = selectionManager.refreshSelection$.subscribe((event) => {+ if (event) {+ refreshedUnits.push(event.unitId);+ }+ });+ try {+ if (timing === 'after') {+ instances.setCurrentUnitForType(popup.unitId);+ }+ bed.get(ICommandService).syncExecuteCommand(RichTextEditingMutation.id, {+ unitId: sidebar.unitId,+ actions: JSONX.getInstance().editOp(new TextX().insert(1, { dataStream: 'X' }).serialize(), ['body']),+ textRanges: [{ startOffset: 3, endOffset: 3 }],+ trigger: 'test.comment-draft-update',+ });+ instances.setCurrentUnitForType(popup.unitId);+ await Promise.resolve();++ expect(refreshedUnits).toEqual([]);+ expect(bed.doc.getBody()?.dataStream).toBe('XDraft\r\n');+ expect(selectionManager.getSelectionInfo(sidebar)?.textRanges).toMatchObject([{ startOffset: 3, endOffset: 3 }]);+ expect(selectionManager.getActiveTextRange()).toMatchObject({ startOffset: 2, endOffset: 2 });++ instances.setCurrentUnitForType(sidebar.unitId);+ bed.get(ICommandService).syncExecuteCommand(InsertTextCommand.id, {+ unitId: sidebar.unitId,+ range: selectionManager.getActiveTextRange()!,+ body: { dataStream: 'Y' },+ });+ await Promise.resolve();+ expect(refreshedUnits).toEqual([sidebar.unitId]);+ expect(bed.doc.getBody()?.dataStream).toBe('XDrYaft\r\n');+ expect(selectionManager.getActiveTextRange()).toMatchObject({ startOffset: 4, endOffset: 4 });+ } finally {+ subscription.unsubscribe();+ bed.univer.dispose();+ }+ });+it.each(['', 'header', 'footer'])('replays formatting and history consistently in initialized segment %j', (segmentId) => {const plainBody = (): IDocumentBody => ({dataStream: 'Plain text\r\n',@@ -298,7 +358,12 @@ describe('RichTextEditingMutation selection scheduling', () => {it('does not refresh selection for metadata changes without ranges', async () => {const testBed = createTestBed();const selectionManager = testBed.get(DocSelectionManagerService);- const refreshSelection = vi.spyOn(selectionManager, 'refreshSelection');+ const refreshedUnits: string[] = [];+ const subscription = selectionManager.refreshSelection$.subscribe((event) => {+ if (event) {+ refreshedUnits.push(event.unitId);+ }+ });const documentStyle = testBed.doc.getDocumentStyle();const previousMargin = documentStyle.marginTop;const actions = JSONX.getInstance().replaceOp(@@ -315,7 +380,9 @@ describe('RichTextEditingMutation selection scheduling', () => {});await Promise.resolve();- expect(refreshSelection).not.toHaveBeenCalled();+ expect(refreshedUnits).toEqual([]);+ expect(testBed.doc.getDocumentStyle().marginTop).toBe((previousMargin ?? 0) + 1);+ subscription.unsubscribe();testBed.univer.dispose();});});diff --git a/packages/docs/src/commands/mutations/core-editing.mutation.ts b/packages/docs/src/commands/mutations/core-editing.mutation.tsindex 6f586f013f..a2a2477911 100644--- a/packages/docs/src/commands/mutations/core-editing.mutation.ts+++ b/packages/docs/src/commands/mutations/core-editing.mutation.ts@@ -27,7 +27,6 @@ import type {TPriority,} from '@univerjs/core';import type { DocumentViewModel, ITextRangeWithStyle } from '@univerjs/engine-render';-import type { IDocStateChangeInfo } from '../../services/doc-state-emit.service';import {CommandType,CustomRangeType,@@ -42,6 +41,7 @@ import {UniverInstanceType,} from '@univerjs/core';import { getDocumentLayoutPresentation, IRenderManagerService } from '@univerjs/engine-render';+import type { IDocStateChangeInfo } from '../../services/doc-state-emit.service';import { DocSelectionManagerService } from '../../services/doc-selection-manager.service';import { DocSkeletonManagerService } from '../../services/doc-skeleton-manager.service';import { DocStateEmitService } from '../../services/doc-state-emit.service';@@ -265,7 +265,8 @@ function scheduleDocumentSelectionUpdate(}const updatedSelection = selectionManager.getSelectionInfo(selectionTarget);queueMicrotask(() => {- if (selectionManager.getSelectionInfo(selectionTarget) !== updatedSelection) {+ if (selectionManager.__getCurrentSelection()?.unitId !== unitId ||+ selectionManager.getSelectionInfo(selectionTarget) !== updatedSelection) {return;}// Editing and history establish new input intent; geometry-only refreshes preserve it.diff --git a/packages/sheets-table-ui/src/views/components/__tests__/SheetTableFilterPanel.spec.tsx b/packages/sheets-table-ui/src/views/components/__tests__/SheetTableFilterPanel.spec.tsxindex 17f55b007d..8d8f21fcde 100644--- a/packages/sheets-table-ui/src/views/components/__tests__/SheetTableFilterPanel.spec.tsx+++ b/packages/sheets-table-ui/src/views/components/__tests__/SheetTableFilterPanel.spec.tsx@@ -240,6 +240,12 @@ class TestEditor {readonly focus$ = new Subject<void>();readonly selectionChange$ = new Subject<void>();readonly render = new TestEditorRender();+ readonly docSelectionRenderService = {+ isFocusing: false,+ getAllTextRanges: () => [],+ getAllRectRanges: () => [],+ };+private readonly _model: TestEditorModel;constructor(@@ -884,29 +890,38 @@ describe('sheet table view components', () => {expect(confirmed).toHaveLength(0);});- it('keeps the range selector editor stable when its delayed resize runs', async () => {+ it('confirms the selected table range after the editor delayed resize runs', async () => {vi.useFakeTimers();testBed = createTestBed();const unitId = testBed.workbook.getUnitId();+ const confirmed: unknown[] = [];const rendered = renderWithRediContext(testBed,<SheetTableSelectorunitId={unitId}subUnitId="sheet1"range={{ startRow: 0, endRow: 3, startColumn: 0, endColumn: 1 }}- onConfirm={() => {}}+ onConfirm={(info) => {+ confirmed.push(info);+ }}onCancel={() => {}}/>);root = rendered.root;container = rendered.container;+ await selectRangeThroughDialog(container, 'A10:B12');await act(async () => {vi.advanceTimersByTime(500);await Promise.resolve();});- expect(container.querySelector('svg')).not.toBeNull();+ clickButtonByText(container, 'Confirm');+ expect(confirmed).toEqual([{+ unitId,+ subUnitId: 'sheet1',+ range: expect.objectContaining({ startRow: 9, endRow: 11, startColumn: 0, endColumn: 1 }),+ }]);});it('cancels table range selection without submitting a range update', async () => {diff --git a/packages/sheets-thread-comment-ui/src/views/__tests__/SheetsThreadCommentPanel.spec.tsx b/packages/sheets-thread-comment-ui/src/views/__tests__/SheetsThreadCommentPanel.spec.tsxindex 17779791ba..b96ed84301 100644--- a/packages/sheets-thread-comment-ui/src/views/__tests__/SheetsThreadCommentPanel.spec.tsx+++ b/packages/sheets-thread-comment-ui/src/views/__tests__/SheetsThreadCommentPanel.spec.tsx@@ -285,6 +285,14 @@ class TestEditor {return this._record.focused;}+ get docSelectionRenderService() {+ return {+ isFocusing: this.isFocus(),+ getAllTextRanges: () => this.getSelectionRanges(),+ getAllRectRanges: () => [],+ };+ }+focus(): void {this._record.focused = true;this.focus$.next(undefined);diff --git a/packages/thread-comment-ui/src/views/__tests__/ThreadCommentEditor.spec.tsx b/packages/thread-comment-ui/src/views/__tests__/ThreadCommentEditor.spec.tsxindex 599596a361..e695a009c5 100644--- a/packages/thread-comment-ui/src/views/__tests__/ThreadCommentEditor.spec.tsx+++ b/packages/thread-comment-ui/src/views/__tests__/ThreadCommentEditor.spec.tsx@@ -136,6 +136,14 @@ class TestEditor {return this._record.focused;}+ get docSelectionRenderService() {+ return {+ isFocusing: this.isFocus(),+ getAllTextRanges: () => this.getSelectionRanges(),+ getAllRectRanges: () => [],+ };+ }+focus(): void {this._record.focused = true;this._record.order.push('editor.focus');diff --git a/packages/thread-comment-ui/src/views/__tests__/ThreadCommentPanel.spec.tsx b/packages/thread-comment-ui/src/views/__tests__/ThreadCommentPanel.spec.tsxindex f797e43921..e94977cf5c 100644--- a/packages/thread-comment-ui/src/views/__tests__/ThreadCommentPanel.spec.tsx+++ b/packages/thread-comment-ui/src/views/__tests__/ThreadCommentPanel.spec.tsx@@ -139,6 +139,14 @@ class TestEditor {return this._record.focused;}+ get docSelectionRenderService() {+ return {+ isFocusing: this.isFocus(),+ getAllTextRanges: () => this.getSelectionRanges(),+ getAllRectRanges: () => [],+ };+ }+focus(): void {this._record.focused = true;this.focus$.next(undefined);diff --git a/packages/thread-comment-ui/src/views/__tests__/ThreadCommentTree.spec.tsx b/packages/thread-comment-ui/src/views/__tests__/ThreadCommentTree.spec.tsxindex 2fbe662214..fee652be49 100644--- a/packages/thread-comment-ui/src/views/__tests__/ThreadCommentTree.spec.tsx+++ b/packages/thread-comment-ui/src/views/__tests__/ThreadCommentTree.spec.tsx@@ -162,6 +162,14 @@ class TestEditor {return this._record.focused;}+ get docSelectionRenderService() {+ return {+ isFocusing: this.isFocus(),+ getAllTextRanges: () => this.getSelectionRanges(),+ getAllRectRanges: () => [],+ };+ }+focus(): void {this._record.focused = true;this.focus$.next(undefined);