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
refactor: rename export of duplicate names (#4179)
#FF000057ba54868520
diff --git a/packages/core/src/types/interfaces/i-slide-data.ts b/packages/core/src/types/interfaces/i-slide-data.tsindex f32e69291a..f613f73043 100644--- a/packages/core/src/types/interfaces/i-slide-data.ts+++ b/packages/core/src/types/interfaces/i-slide-data.ts@@ -86,7 +86,7 @@ interface IMasterProperties {name: string;}-export interface IRichTextProps extends ITransformState, IStyleBase {+export interface ISlideRichTextProps extends ITransformState, IStyleBase {text?: string;rich?: IDocumentData;}@@ -115,7 +115,7 @@ export interface IPageElement {// elementGroup: IGroup;shape?: IShape;image?: IImage;- richText?: IRichTextProps;+ richText?: ISlideRichTextProps;/** @deprecated */spreadsheet?: {diff --git a/packages/engine-render/src/components/docs/extensions/font-and-base-line.ts b/packages/engine-render/src/components/docs/extensions/font-and-base-line.tsindex 4a52d59229..af7e13f469 100644--- a/packages/engine-render/src/components/docs/extensions/font-and-base-line.ts+++ b/packages/engine-render/src/components/docs/extensions/font-and-base-line.ts@@ -21,7 +21,7 @@ import { BaselineOffset, getColorStyle } from '@univerjs/core';import { GlyphType, hasCJK } from '../../../basics';import { COLOR_BLACK_RGB } from '../../../basics/const';import { Vector2 } from '../../../basics/vector2';-import { Checkbox } from '../../../shape';+import { CheckboxShape } from '../../../shape';import { DocumentsSpanAndLineExtensionRegistry } from '../../extension';import { docExtension } from '../doc-extension';@@ -111,7 +111,7 @@ export class FontAndBaseLine extends docExtension {const leftOffset = left;const BORDER_WIDTH = 1;ctx.translate(leftOffset - BORDER_WIDTH / 2, topOffset - BORDER_WIDTH / 2);- Checkbox.drawWith(ctx, {+ CheckboxShape.drawWith(ctx, {width: size,height: size,checked: content === CHECKED_GLYPH,diff --git a/packages/engine-render/src/shape/checkbox.ts b/packages/engine-render/src/shape/checkbox.tsindex 47deca116d..2ec6aea667 100644--- a/packages/engine-render/src/shape/checkbox.ts+++ b/packages/engine-render/src/shape/checkbox.ts@@ -15,21 +15,21 @@*/import type { IKeyValue } from '@univerjs/core';-import { Tools } from '@univerjs/core';import type { UniverRenderingContext } from '../context';import type { IShapeProps } from './shape';+import { Tools } from '@univerjs/core';import { Shape } from './shape';-export interface ICheckboxProps extends IShapeProps {+export interface ICheckboxShapeProps extends IShapeProps {checked?: boolean;}export const CHECK_OBJECT_ARRAY = ['checked'];-export class Checkbox extends Shape<ICheckboxProps> {+export class CheckboxShape extends Shape<ICheckboxShapeProps> {_checked = false;- constructor(key: string, props: ICheckboxProps) {+ constructor(key: string, props: ICheckboxShapeProps) {super(key, props);if (Tools.isDefine(props.checked)) {@@ -41,7 +41,7 @@ export class Checkbox extends Shape<ICheckboxProps> {return this._checked;}- static override drawWith(ctx: UniverRenderingContext, props: ICheckboxProps) {+ static override drawWith(ctx: UniverRenderingContext, props: ICheckboxShapeProps) {const { width = 16, height = 16, fill, checked, top = 0, left = 0 } = props;const uncheckedPath = new Path2D('M12 2.65381H4C3.17157 2.65381 2.5 3.32538 2.5 4.15381V12.1538C2.5 12.9822 3.17157 13.6538 4 13.6538H12C12.8284 13.6538 13.5 12.9822 13.5 12.1538V4.15381C13.5 3.32538 12.8284 2.65381 12 2.65381ZM4 1.65381C2.61929 1.65381 1.5 2.7731 1.5 4.15381V12.1538C1.5 13.5345 2.61929 14.6538 4 14.6538H12C13.3807 14.6538 14.5 13.5345 14.5 12.1538V4.15381C14.5 2.7731 13.3807 1.65381 12 1.65381H4Z');const checkedPath = new Path2D('M3.99243 1.65381C2.61172 1.65381 1.49243 2.77295 1.49243 4.15381V12.1538C1.49243 13.5347 2.61172 14.6538 3.99243 14.6538H11.9924C13.3731 14.6538 14.4924 13.5347 14.4924 12.1538V4.15381C14.4924 2.77295 13.3731 1.65381 11.9924 1.65381H3.99243ZM12.3779 6.3623C12.6317 6.1084 12.6317 5.69678 12.3779 5.44287C12.1241 5.18896 11.7125 5.18896 11.4586 5.44287L7.21062 9.69092L5.00681 7.4873C4.75296 7.2334 4.3414 7.2334 4.08755 7.4873C3.83372 7.74072 3.83372 8.15234 4.08757 8.40625L6.85709 11.1758C7.05234 11.3711 7.36893 11.3711 7.56418 11.1758L12.3779 6.3623Z');@@ -63,14 +63,14 @@ export class Checkbox extends Shape<ICheckboxProps> {}protected override _draw(ctx: UniverRenderingContext) {- Checkbox.drawWith(ctx, this);+ CheckboxShape.drawWith(ctx, this);}override toJson() {const props: IKeyValue = {};CHECK_OBJECT_ARRAY.forEach((key) => {- if (this[key as keyof Checkbox]) {- props[key] = this[key as keyof Checkbox];+ if (this[key as keyof CheckboxShape]) {+ props[key] = this[key as keyof CheckboxShape];}});diff --git a/packages/sheets-conditional-formatting/src/utils/is-ranges-equal.ts b/packages/sheets-conditional-formatting/src/utils/is-ranges-equal.tsindex 342d04095c..8397e21db9 100644--- a/packages/sheets-conditional-formatting/src/utils/is-ranges-equal.ts+++ b/packages/sheets-conditional-formatting/src/utils/is-ranges-equal.ts@@ -14,9 +14,4 @@* limitations under the License.*/-import type { IRange } from '@univerjs/core';-import { Rectangle } from '@univerjs/core';--export const isRangesEqual = (oldRanges: IRange[], ranges: IRange[]) => {- return ranges.length === oldRanges.length && !oldRanges.some((oldRange) => ranges.some((range) => !Rectangle.equals(range, oldRange)));-};+export { isRangesEqual } from '@univerjs/core';diff --git a/packages/sheets-data-validation-ui/src/views/widgets/checkbox-widget.ts b/packages/sheets-data-validation-ui/src/views/widgets/checkbox-widget.tsindex 4b4b16ea98..a06920419a 100644--- a/packages/sheets-data-validation-ui/src/views/widgets/checkbox-widget.ts+++ b/packages/sheets-data-validation-ui/src/views/widgets/checkbox-widget.ts@@ -20,7 +20,7 @@ import type { IMouseEvent, IPointerEvent, UniverRenderingContext, UniverRenderinimport type { ISetRangeValuesCommandParams } from '@univerjs/sheets';import type { CheckboxValidator } from '@univerjs/sheets-data-validation';import { HorizontalAlign, ICommandService, Inject, isFormulaString, ThemeService, UniverInstanceType, VerticalAlign } from '@univerjs/core';-import { Checkbox, CURSOR_TYPE, fixLineWidthByScale, IRenderManagerService, Transform } from '@univerjs/engine-render';+import { CheckboxShape as Checkbox, CURSOR_TYPE, fixLineWidthByScale, IRenderManagerService, Transform } from '@univerjs/engine-render';import { SetRangeValuesCommand } from '@univerjs/sheets';import { CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2, DataValidationFormulaService, getCellValueOrigin, getFormulaResult, isLegalFormulaResult, SheetDataValidationModel, transformCheckboxValue } from '@univerjs/sheets-data-validation';diff --git a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.tsindex bc05c98035..c89562345a 100644--- a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts+++ b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts@@ -27,7 +27,7 @@ import { getDrawingShapeKeyByDrawingSearch, IDrawingManagerService } from '@univimport { DRAWING_OBJECT_LAYER_INDEX, IRenderManagerService, ObjectType, Rect, SHEET_VIEWPORT_KEY } from '@univerjs/engine-render';import { getSheetCommandTarget, SetFrozenMutation } from '@univerjs/sheets';import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation } from '@univerjs/sheets-drawing';-import { ISheetSelectionRenderService, SetZoomRatioOperation, SheetSkeletonManagerService, VIEWPORT_KEY } from '@univerjs/sheets-ui';+import { ISheetSelectionRenderService, SetZoomRatioOperation, SheetSkeletonManagerService } from '@univerjs/sheets-ui';import { CanvasFloatDomService } from '@univerjs/ui';import { BehaviorSubject, filter, map, Subject, switchMap, take } from 'rxjs';import { InsertSheetDrawingCommand } from '../commands/commands/insert-sheet-drawing.command';@@ -459,7 +459,7 @@ export class SheetCanvasFloatDomManagerService extends Disposable {}),filter((render) => !!render),switchMap((render) =>- fromEventSubject(render.render.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN)!.onScrollAfter$)+ fromEventSubject(render.render.scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN)!.onScrollAfter$).pipe(map(() => ({ unitId: render.unitId, subUnitId: render.subUnitId }))))).subscribe(({ unitId, subUnitId }) => {diff --git a/packages/sheets-ui/src/common/keys.ts b/packages/sheets-ui/src/common/keys.tsindex 1b46f3b056..4b5d70f405 100644--- a/packages/sheets-ui/src/common/keys.ts+++ b/packages/sheets-ui/src/common/keys.ts@@ -30,22 +30,6 @@ export enum SHEET_VIEW_KEY {LEFT_TOP = '__SpreadsheetLeftTopPlaceholder__',}-/**- * @deprecated. use SHEET_VIEWPORT_KEY from engine-render instead.- */-export enum SHEET_VIEWPORT_KEY {- VIEW_MAIN = 'viewMain',- VIEW_MAIN_LEFT_TOP = 'viewMainLeftTop',- VIEW_MAIN_TOP = 'viewMainTop',- VIEW_MAIN_LEFT = 'viewMainLeft',-- VIEW_ROW_TOP = 'viewRowTop',- VIEW_ROW_BOTTOM = 'viewRowBottom',- VIEW_COLUMN_LEFT = 'viewColumnLeft',- VIEW_COLUMN_RIGHT = 'viewColumnRight',- VIEW_LEFT_TOP = 'viewLeftTop',-}-export const SHEET_COMPONENT_MAIN_LAYER_INDEX = 0;export const SHEET_COMPONENT_SELECTION_LAYER_INDEX = 1;diff --git a/packages/sheets-ui/src/index.ts b/packages/sheets-ui/src/index.tsindex 34f67adef9..8064059fa1 100644--- a/packages/sheets-ui/src/index.ts+++ b/packages/sheets-ui/src/index.ts@@ -24,7 +24,6 @@ export { SheetScrollManagerService } from './services/scroll-manager.service';export { deriveStateFromActiveSheet$, getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$, getObservableWithExclusiveRange$ } from './controllers/menu/menu-util';export { SheetsRenderService } from './services/sheets-render.service';export { calculateDocSkeletonRects, getCustomRangePosition, getEditingCustomRangePosition } from './services/utils/doc-skeleton-util';-export { SHEET_VIEWPORT_KEY as VIEWPORT_KEY } from './common/keys';export { AutoFillController } from './controllers/auto-fill.controller';export { CellCustomRenderController } from './controllers/cell-custom-render.controller';export { SheetUIController } from './controllers/sheet-ui.controller';diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsxindex c255ebdd8f..a3555e8fb9 100644--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx@@ -37,7 +37,7 @@ import {WorkbookRenameSheetPermission,WorksheetProtectionRuleModel,} from '@univerjs/sheets';-import { ContextMenuPosition, IConfirmService, Menu, UI_PLUGIN_CONFIG_KEY, useObservable } from '@univerjs/ui';+import { ContextMenuPosition, IConfirmService, UI_PLUGIN_CONFIG_KEY, UIMenu, useObservable } from '@univerjs/ui';import React, { useCallback, useEffect, useRef, useState } from 'react';import { merge } from 'rxjs';import { useActiveWorkbook } from '../../../components/hook';@@ -414,7 +414,7 @@ export function SheetBarTabs() {align={{ offset }}trigger={['contextMenu']}overlay={(- <Menu+ <UIMenumenuType={ContextMenuPosition.FOOTER_TABS}onOptionSelect={(params) => {const { label: id, value, commandId } = params;diff --git a/packages/ui/src/components/hooks/observable.ts b/packages/ui/src/components/hooks/observable.tsindex 38b1a9df04..bfa07dec95 100644--- a/packages/ui/src/components/hooks/observable.ts+++ b/packages/ui/src/components/hooks/observable.ts@@ -18,8 +18,8 @@import type { Nullable } from '@univerjs/core';import type { RefObject } from 'react';-import type { Observable, Subscription } from 'rxjs';-import { useEffect, useMemo, useRef, useState } from 'react';+import type { Observable } from 'rxjs';+import { useEffect, useRef } from 'react';type ObservableOrFn<T> = Observable<T> | (() => Observable<T>);@@ -31,67 +31,14 @@ function unwrap<T>(o: ObservableOrFn<T>): Observable<T> {return o;}-export function useObservable<T>(observable: ObservableOrFn<T>, defaultValue: T | undefined, shouldHaveSyncValue?: true): T;-export function useObservable<T>(observable: Nullable<ObservableOrFn<T>>, defaultValue: T): T;-export function useObservable<T>(observable: Nullable<ObservableOrFn<T>>, defaultValue?: undefined): T | undefined;-export function useObservable<T>(observable: Nullable<ObservableOrFn<T>>, defaultValue: T, shouldHaveSyncValue?: boolean, deps?: any[]): T;-export function useObservable<T>(observable: Nullable<ObservableOrFn<T>>, defaultValue: undefined, shouldHaveSyncValue: true, deps?: any[]): T;-export function useObservable<T>(observable: Nullable<ObservableOrFn<T>>, defaultValue?: T, shouldHaveSyncValue?: boolean, deps?: any[]): T | undefined;-/**- * A hook to subscribe to an observable and get the latest value.- *- * @param observable The observable to subscribe to.- * @param defaultValue When the observable would not emit any value, the default value would be returned.- * @param shouldHaveSyncValue If true, the observable should emit a value synchronously.- * @param deps The dependencies to trigger a re-subscription.- */-export function useObservable<T>(observable: Nullable<ObservableOrFn<T>>, defaultValue?: T, shouldHaveSyncValue?: boolean, deps?: any[]): T | undefined {- if (typeof observable === 'function' && !deps) {- throw new Error('[useObservable]: expect deps when observable is a function! Otherwise it would cause an infinite loop.');- }-- const observableRef = useRef<Observable<T> | null>(null);- const initializedRef = useRef<boolean>(false);-- // eslint-disable-next-line react-hooks/exhaustive-deps- const destObservable = useMemo(() => observable, [...(typeof deps !== 'undefined' ? deps : [observable])]);-- // This state is only for trigger React to re-render. We do not use `setValue` directly because it may cause- // memory leaking.- const [_, setRenderCounter] = useState<number>(0);-- const valueRef = useRef((() => {- let innerDefaultValue: T | undefined;- if (destObservable) {- const sub = unwrap(destObservable).subscribe((value) => {- initializedRef.current = true;- innerDefaultValue = value;- });-- sub.unsubscribe();- }-- return innerDefaultValue ?? defaultValue;- })());-- useEffect(() => {- let subscription: Subscription | null = null;- if (destObservable) {- observableRef.current = unwrap(destObservable);- subscription = observableRef.current.subscribe((value) => {- valueRef.current = value;- setRenderCounter((prev) => prev + 1);- });- }-- return () => subscription?.unsubscribe();- }, [destObservable]);-- if (shouldHaveSyncValue && !initializedRef.current) {- throw new Error('[useObservable]: expect shouldHaveSyncValue but not getting a sync value!');- }-- return valueRef.current;+export { useObservable } from '@univerjs/core';+declare module '@univerjs/core' {+ export function useObservable<T>(observable: ObservableOrFn<T>, defaultValue: T | undefined, shouldHaveSyncValue?: true): T;+ export function useObservable<T>(observable: Nullable<ObservableOrFn<T>>, defaultValue: T): T;+ export function useObservable<T>(observable: Nullable<ObservableOrFn<T>>, defaultValue?: undefined): T | undefined;+ export function useObservable<T>(observable: Nullable<ObservableOrFn<T>>, defaultValue: T, shouldHaveSyncValue?: boolean, deps?: any[]): T;+ export function useObservable<T>(observable: Nullable<ObservableOrFn<T>>, defaultValue: undefined, shouldHaveSyncValue: true, deps?: any[]): T;+ export function useObservable<T>(observable: Nullable<ObservableOrFn<T>>, defaultValue?: T, shouldHaveSyncValue?: boolean, deps?: any[]): T | undefined;}export function useObservableRef<T>(observable: Nullable<ObservableOrFn<T>>, defaultValue?: T): RefObject<Nullable<T>> {diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.tsindex 3c08086c59..10df692c8b 100644--- a/packages/ui/src/index.ts+++ b/packages/ui/src/index.ts@@ -25,7 +25,7 @@ export { t } from './components/hooks/locale';export { useObservable, useObservableRef } from './components/hooks/observable';export { RectPopup } from './views/components/popup/RectPopup';export { useVirtualList } from './components/hooks/virtual-list';-export { Menu } from './components/menu/desktop/Menu';+export { Menu as UIMenu } from './components/menu/desktop/Menu';export { type INotificationOptions, type NotificationType } from './components/notification/Notification';export { ProgressBar } from './components/progress-bar/ProgressBar';export { UNI_DISABLE_CHANGING_FOCUS_KEY } from './const';