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-ui): menu align when select table cells (#4127)
Ran Luoe1d7713393c2
diff --git a/packages/docs-ui/src/controllers/menu/menu.ts b/packages/docs-ui/src/controllers/menu/menu.tsindex be9d53e887..8a54b1f125 100644--- a/packages/docs-ui/src/controllers/menu/menu.ts+++ b/packages/docs-ui/src/controllers/menu/menu.ts@@ -767,7 +767,9 @@ const listValueFactory$ = (accessor: IAccessor) => {}textSubscription = docSelectionManagerService.textSelection$.subscribe(() => {- const range = docSelectionManagerService.getActiveTextRange();+ const docRanges = docSelectionManagerService.getDocRanges();+ const range = docRanges.find((r) => r.isActive) ?? docRanges[0];+if (range) {const doc = docDataModel.getSelfOrHeaderFooterModel(range?.segmentId);const paragraphs = getParagraphsInRange(range, doc.getBody()?.paragraphs ?? []);@@ -965,14 +967,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;