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-ui): insert custom range error (#4878)

ZhangWei1f53ac29076e
diff --git a/packages/docs-ui/src/commands/commands/insert-custom-range.command.ts b/packages/docs-ui/src/commands/commands/insert-custom-range.command.ts
index 4169de2d3e..dc0a060bd6 100644
--- a/packages/docs-ui/src/commands/commands/insert-custom-range.command.ts
+++ b/packages/docs-ui/src/commands/commands/insert-custom-range.command.ts
@@ -26,7 +26,7 @@ export interface IInsertCustomRangeCommandParams {
textRanges?: ITextRangeWithStyle[];
properties?: Record<string, any>;
text: string;
-
+ wholeEntity?: boolean;
}
export const InsertCustomRangeCommand: ICommand<IInsertCustomRangeCommandParams> = {
@@ -35,7 +35,7 @@ export const InsertCustomRangeCommand: ICommand<IInsertCustomRangeCommandParams>
handler: (accessor, params) => {
if (!params) return false;
const commandService = accessor.get(ICommandService);
- const { unitId, rangeId = generateRandomId(), textRanges, properties, text } = params;
+ const { unitId, rangeId = generateRandomId(), textRanges, properties, text, wholeEntity } = params;
const replaceSelectionParams: IReplaceSelectionCommandParams = {
unitId,
textRanges,
@@ -47,6 +47,7 @@ export const InsertCustomRangeCommand: ICommand<IInsertCustomRangeCommandParams>
rangeId,
rangeType: CustomRangeType.CUSTOM,
properties,
+ wholeEntity,
}],
},
};
diff --git a/packages/docs-ui/src/commands/commands/replace-content.command.ts b/packages/docs-ui/src/commands/commands/replace-content.command.ts
index 1255ccc0c7..e4ad2ea696 100644
--- a/packages/docs-ui/src/commands/commands/replace-content.command.ts
+++ b/packages/docs-ui/src/commands/commands/replace-content.command.ts
@@ -314,6 +314,7 @@ export const ReplaceSelectionCommand: ICommand<IReplaceSelectionCommandParams> =
if (!params) {
return false;
}
+ const commandService = accessor.get(ICommandService);
const { unitId, body: insertBody, textRanges } = params;
const univerInstanceService = accessor.get(IUniverInstanceService);
const docDataModel = univerInstanceService.getUnit<DocumentDataModel>(unitId);
@@ -343,8 +344,7 @@ export const ReplaceSelectionCommand: ICommand<IReplaceSelectionCommandParams> =
// delete
textX.push(...BuildTextUtils.selection.delete([selection], body, 0, insertBody));
doMutation.params.actions = jsonX.editOp(textX.serialize());
-
- return true;
+ return commandService.syncExecuteCommand(doMutation.id, doMutation.params);
},
};
diff --git a/packages/engine-render/src/components/docs/layout/style/custom-range.ts b/packages/engine-render/src/components/docs/layout/style/custom-range.ts
index 7132caa5ed..2144650e36 100644
--- a/packages/engine-render/src/components/docs/layout/style/custom-range.ts
+++ b/packages/engine-render/src/components/docs/layout/style/custom-range.ts
@@ -20,7 +20,8 @@ import { BooleanNumber, CustomRangeType } from '@univerjs/core';
export function getCustomRangeStyle(customRange: ICustomRangeForInterceptor): Nullable<ITextStyle> {
if (
customRange.rangeType === CustomRangeType.HYPERLINK ||
- customRange.rangeType === CustomRangeType.MENTION
+ customRange.rangeType === CustomRangeType.MENTION ||
+ customRange.rangeType === CustomRangeType.CUSTOM
) {
return {
...(customRange.active ?? true) ? { ul: { s: BooleanNumber.TRUE } } : null,