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(docs): inline format in table (#4089)

Ran Luobf33540e94d3
diff --git a/packages/docs-ui/src/commands/commands/inline-format.command.ts b/packages/docs-ui/src/commands/commands/inline-format.command.ts
index 9636d4fe33..d1aba7c606 100644
--- a/packages/docs-ui/src/commands/commands/inline-format.command.ts
+++ b/packages/docs-ui/src/commands/commands/inline-format.command.ts
@@ -244,9 +244,9 @@ export const SetInlineFormatCommand: ICommand<ISetInlineFormatCommandParams> = {
const docMenuStyleService = accessor.get(DocMenuStyleService);
const docRanges = docSelectionManagerService.getDocRanges();
- const activeTextRange = docSelectionManagerService.getActiveTextRange();
+ const activeRange = docRanges.find((r) => r.isActive) ?? docRanges[0];
- if (docRanges.length === 0 || activeTextRange == null) {
+ if (docRanges.length === 0) {
return false;
}
@@ -277,7 +277,7 @@ export const SetInlineFormatCommand: ICommand<ISetInlineFormatCommandParams> = {
const defaultStyle = docMenuStyleService.getDefaultStyle();
const curTextStyle = getStyleInTextRange(
body,
- activeTextRange,
+ activeRange,
defaultStyle
);
diff --git a/packages/docs-ui/src/controllers/menu/menu.ts b/packages/docs-ui/src/controllers/menu/menu.ts
index 6cc1f81790..be9d53e887 100644
--- a/packages/docs-ui/src/controllers/menu/menu.ts
+++ b/packages/docs-ui/src/controllers/menu/menu.ts
@@ -925,12 +925,13 @@ function getFontStyleAtCursor(accessor: IAccessor) {
const docMenuStyleService = accessor.get(DocMenuStyleService);
const docDataModel = univerInstanceService.getCurrentUnitForType<DocumentDataModel>(UniverInstanceType.UNIVER_DOC);
- const activeTextRange = textSelectionService.getActiveTextRange();
+ const docRanges = textSelectionService.getDocRanges();
+ const activeRange = docRanges.find((r) => r.isActive) ?? docRanges[0];
const defaultTextStyle = docMenuStyleService.getDefaultStyle();
const cacheStyle = docMenuStyleService.getStyleCache() ?? {};
- if (docDataModel == null || activeTextRange == null) {
+ if (docDataModel == null || activeRange == null) {
return {
ts: {
...defaultTextStyle,
@@ -939,7 +940,7 @@ function getFontStyleAtCursor(accessor: IAccessor) {
};
}
- const { segmentId } = activeTextRange;
+ const { segmentId } = activeRange;
const body = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody();
if (body == null) {
@@ -951,7 +952,7 @@ function getFontStyleAtCursor(accessor: IAccessor) {
};
}
- const curTextStyle = getStyleInTextRange(body, activeTextRange, defaultTextStyle);
+ const curTextStyle = getStyleInTextRange(body, activeRange, defaultTextStyle);
return {
ts: {