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.

feat(design): dialog could assign width (#1107)

Wenzhao Hueda5cc5dc137
diff --git a/examples/src/plugins/debugger/commands/operations/dialog.operation.ts b/examples/src/plugins/debugger/commands/operations/dialog.operation.ts
index 0e8ddd9150..8a506b7fc5 100644
--- a/examples/src/plugins/debugger/commands/operations/dialog.operation.ts
+++ b/examples/src/plugins/debugger/commands/operations/dialog.operation.ts
@@ -36,6 +36,7 @@ export const DialogOperation: ICommand = {
children: { title: 'Draggable Dialog Content' },
title: { title: 'Draggable Dialog' },
draggable: true,
+ width: 350,
onClose() {
dialogService.close('draggable');
},
diff --git a/packages/design/src/components/dialog/Dialog.tsx b/packages/design/src/components/dialog/Dialog.tsx
index d4563c8d9a..0ffe188cd4 100644
--- a/packages/design/src/components/dialog/Dialog.tsx
+++ b/packages/design/src/components/dialog/Dialog.tsx
@@ -23,6 +23,8 @@ import { ConfigContext } from '../config-provider/ConfigProvider';
import styles from './index.module.less';
export interface IDialogProps {
+ width?: number | string;
+
children: React.ReactNode;
/**
@@ -61,7 +63,16 @@ export interface IDialogProps {
}
export function Dialog(props: IDialogProps) {
- const { children, visible = false, title, draggable = false, closeIcon = <CloseSingle />, footer, onClose } = props;
+ const {
+ children,
+ visible = false,
+ title,
+ draggable = false,
+ closeIcon = <CloseSingle />,
+ footer,
+ onClose,
+ width,
+ } = props;
const [dragDisabled, setDragDisabled] = useState(false);
const { mountContainer } = useContext(ConfigContext);
@@ -94,6 +105,7 @@ export function Dialog(props: IDialogProps) {
return (
<RcDialog
+ width={width}
prefixCls={styles.dialog}
rootClassName={draggable ? styles.dialogRootDraggable : styles.dialogRoot}
getContainer={() => mountContainer}