From 328650b8f78bbd2c83fde94ae8c0cb3f018045ad Mon Sep 17 00:00:00 2001 From: jocs Date: Fri, 22 Nov 2024 20:25:03 +0800 Subject: [PATCH] fix: menu alin when select table cells --- packages/docs-ui/src/controllers/menu/menu.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/docs-ui/src/controllers/menu/menu.ts b/packages/docs-ui/src/controllers/menu/menu.ts index be9d53e88793..ddf2e11d8fc1 100644 --- a/packages/docs-ui/src/controllers/menu/menu.ts +++ b/packages/docs-ui/src/controllers/menu/menu.ts @@ -965,14 +965,17 @@ function getFontStyleAtCursor(accessor: IAccessor) { function getParagraphStyleAtCursor(accessor: IAccessor) { const univerInstanceService = accessor.get(IUniverInstanceService); const textSelectionService = accessor.get(DocSelectionManagerService); + const docDataModel = univerInstanceService.getCurrentUniverDocInstance(); - const activeTextRange = textSelectionService.getActiveTextRange(); - if (docDataModel == null || activeTextRange == null) { + const docRanges = textSelectionService.getDocRanges(); + const activeRange = docRanges.find((r) => r.isActive) ?? docRanges[0]; + + if (docDataModel == null || activeRange == null) { return; } - const { startOffset, segmentId } = activeTextRange; + const { startOffset, segmentId } = activeRange; const paragraphs = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()?.paragraphs;