+
-
diff --git a/packages/drawing-ui/src/views/panel/index.module.less b/packages/drawing-ui/src/views/panel/index.module.less
deleted file mode 100644
index 6a9392c566..0000000000
--- a/packages/drawing-ui/src/views/panel/index.module.less
+++ /dev/null
@@ -1,67 +0,0 @@
-.image-common-panel {
- text-align: center;
- padding: var(--padding-sm);
- font-size: var(--font-size-sm);
- &-grid {
- position: relative;
- width: 100%;
- }
-
- &-border {
- border-top: 1px solid rgb(var(--border-color));
- margin-top: 20px;
- }
-
- &-title {
- color: rgb(var(--text-color-secondary));
- text-align: left;
- }
-
- &-subtitle {
- color: rgb(var(--text-color-primary));
- text-align: left;
- }
-
- &-row {
- position: relative;
- display: flex;
- justify-content: flex-start;
- align-items: flex-start;
- height: 100%;
- margin-top: 10px;
-
- &-vertical {
- justify-content: center;
- align-items: center;
- height: 36px;
- }
- }
-
- &-column {
- width: 100%;
-
- &-center {
- display: flex;
- justify-content: center;
- align-items: center;
- }
- }
-
- &-inline {
- display: flex;
- align-items: center;
- gap: var(--margin-xxs);
- }
-
- &-span2 {
- width: 50%;
- }
-
- &-span3 {
- width: 33.33333333%;
- }
-
- &-input {
- width: 90%;
- }
-}
diff --git a/packages/drawing-ui/src/views/utils/classnames.ts b/packages/drawing-ui/src/views/utils/classnames.ts
new file mode 100644
index 0000000000..314f5f3e55
--- /dev/null
+++ b/packages/drawing-ui/src/views/utils/classnames.ts
@@ -0,0 +1,22 @@
+/**
+ * Copyright 2023-present DreamNum Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// TODO@siam-ese: these styles are widely used in drawing's components. They should be deprecated once the
+// Form component is completed.
+
+export const rowClassName = 'univer-relative univer-mt-2.5 univer-flex univer-h-full univer-items-start univer-justify-between univer-gap-2 univer-flex-no-wrap';
+export const columnTitleClassName = 'univer-w-full univer-text-left univer-text-gray-400';
+export const inlineClassName = 'univer-flex univer-items-center univer-gap-1';
diff --git a/packages/sheets-drawing-ui/src/controllers/drawing-popup-menu.controller.ts b/packages/sheets-drawing-ui/src/controllers/drawing-popup-menu.controller.ts
index 670cdd38ec..5b94931b1b 100644
--- a/packages/sheets-drawing-ui/src/controllers/drawing-popup-menu.controller.ts
+++ b/packages/sheets-drawing-ui/src/controllers/drawing-popup-menu.controller.ts
@@ -15,31 +15,33 @@
*/
import type { IDisposable, Nullable, Workbook } from '@univerjs/core';
+import type { ImageIoService } from '@univerjs/drawing';
import type { BaseObject, Scene } from '@univerjs/engine-render';
import type { ISheetFloatDom } from '@univerjs/sheets-drawing';
-import { DrawingTypeEnum, FOCUSING_COMMON_DRAWINGS, ICommandService, IContextService, Inject, Injector, IUniverInstanceService, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';
+import { DrawingTypeEnum, FOCUSING_COMMON_DRAWINGS, ICommandService, IContextService, IImageIoService, Inject, Injector, IUniverInstanceService, LocaleService, RxDisposable, UniverInstanceType } from '@univerjs/core';
+import { MessageType } from '@univerjs/design';
import { IDrawingManagerService, SetDrawingSelectedOperation } from '@univerjs/drawing';
import { COMPONENT_IMAGE_POPUP_MENU, ImageCropperObject, ImageResetSizeOperation, OpenImageCropOperation } from '@univerjs/drawing-ui';
import { IRenderManagerService } from '@univerjs/engine-render';
import { SheetCanvasPopManagerService } from '@univerjs/sheets-ui';
-import { BuiltInUIPart, connectInjector, IUIPartsService } from '@univerjs/ui';
-
+import { IMessageService } from '@univerjs/ui';
import { takeUntil } from 'rxjs';
import { RemoveSheetDrawingCommand } from '../commands/commands/remove-sheet-drawing.command';
import { EditSheetDrawingOperation } from '../commands/operations/edit-sheet-drawing.operation';
-import { UploadLoading } from '../views/upload-loading/UploadLoading';
export class DrawingPopupMenuController extends RxDisposable {
private _initImagePopupMenu = new Set
();
constructor(
@Inject(Injector) private _injector: Injector,
+ @Inject(LocaleService) private readonly _localeService: LocaleService,
@IDrawingManagerService private readonly _drawingManagerService: IDrawingManagerService,
@Inject(SheetCanvasPopManagerService) private readonly _canvasPopManagerService: SheetCanvasPopManagerService,
@IRenderManagerService private readonly _renderManagerService: IRenderManagerService,
@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
+ @IMessageService private readonly _messageService: IMessageService,
@IContextService private readonly _contextService: IContextService,
- @Inject(IUIPartsService) private readonly _uiPartsService: IUIPartsService,
+ @IImageIoService private readonly _ioService: ImageIoService,
@ICommandService private readonly _commandService: ICommandService
) {
super();
@@ -52,10 +54,31 @@ export class DrawingPopupMenuController extends RxDisposable {
this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._dispose(workbook));
this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => this._create(workbook));
- this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(UploadLoading, this._injector));
+ this._setupLoadingStatus();
+ }
+
+ private _setupLoadingStatus() {
+ const MESSAGE_ID = 'image-upload-loading';
+
+ let messageDisposable: IDisposable | undefined;
+ this.disposeWithMe(this._ioService.change$.subscribe((status) => {
+ if (status > 0 && !messageDisposable) {
+ messageDisposable = this._messageService.show({
+ id: MESSAGE_ID,
+ type: MessageType.Loading,
+ content: `${this._localeService.t('uploadLoading.loading')}: ${status}`,
+ duration: 0,
+ });
+ } else if (status === 0) {
+ messageDisposable?.dispose();
+ messageDisposable = undefined;
+ }
+ }));
}
private _dispose(workbook: Workbook) {
+ super.dispose();
+
const unitId = workbook.getUnitId();
this._renderManagerService.removeRender(unitId);
}
@@ -93,52 +116,50 @@ export class DrawingPopupMenuController extends RxDisposable {
if (!transformer) {
return;
}
+
let singletonPopupDisposer: IDisposable;
- this.disposeWithMe(
- toDisposable(
- transformer.createControl$.subscribe(() => {
- this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, true);
+ this.disposeWithMe(transformer.createControl$.subscribe(() => {
+ this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, true);
- if (this._hasCropObject(scene)) {
- return;
- }
+ if (this._hasCropObject(scene)) {
+ return;
+ }
- const selectedObjects = transformer.getSelectedObjectMap();
- if (selectedObjects.size > 1) {
- singletonPopupDisposer?.dispose();
- return;
- }
+ const selectedObjects = transformer.getSelectedObjectMap();
+ if (selectedObjects.size > 1) {
+ singletonPopupDisposer?.dispose();
+ return;
+ }
- const object = selectedObjects.values().next().value as Nullable;
- if (!object) {
- return;
- }
+ const object = selectedObjects.values().next().value as Nullable;
+ if (!object) {
+ return;
+ }
- const oKey = object.oKey;
- const drawingParam = this._drawingManagerService.getDrawingOKey(oKey);
- if (!drawingParam) {
- return;
- }
+ const oKey = object.oKey;
+ const drawingParam = this._drawingManagerService.getDrawingOKey(oKey);
+ if (!drawingParam) {
+ return;
+ }
- const { unitId, subUnitId, drawingId, drawingType } = drawingParam;
+ const { unitId, subUnitId, drawingId, drawingType } = drawingParam;
// drawingParam should be ICanvasFloatDom, use for disable popup dialog
- const data = (drawingParam as ISheetFloatDom).data as Record;
- if (data && data.disablePopup) {
- return;
- }
+ const data = (drawingParam as ISheetFloatDom).data as Record;
+ if (data && data.disablePopup) {
+ return;
+ }
- singletonPopupDisposer?.dispose();
- const menus = this._canvasPopManagerService.getFeatureMenu(unitId, subUnitId, drawingId, drawingType);
- singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
- componentKey: COMPONENT_IMAGE_POPUP_MENU,
- direction: 'horizontal',
- offset: [2, 0],
- extraProps: {
- menuItems: menus || this._getImageMenuItems(unitId, subUnitId, drawingId, drawingType),
- },
- }));
- })
- )
+ singletonPopupDisposer?.dispose();
+ const menus = this._canvasPopManagerService.getFeatureMenu(unitId, subUnitId, drawingId, drawingType);
+ singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
+ componentKey: COMPONENT_IMAGE_POPUP_MENU,
+ direction: 'horizontal',
+ offset: [2, 0],
+ extraProps: {
+ menuItems: menus || this._getImageMenuItems(unitId, subUnitId, drawingId, drawingType),
+ },
+ }));
+ })
);
this.disposeWithMe(
transformer.clearControl$.subscribe(() => {
diff --git a/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetDrawingAnchor.tsx b/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetDrawingAnchor.tsx
index 6f36094cfe..6918906327 100644
--- a/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetDrawingAnchor.tsx
+++ b/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetDrawingAnchor.tsx
@@ -18,14 +18,13 @@ import type { IDrawingParam, Nullable } from '@univerjs/core';
import type { BaseObject } from '@univerjs/engine-render';
import type { ISheetDrawing } from '@univerjs/sheets-drawing';
import { ICommandService, LocaleService } from '@univerjs/core';
-import { clsx, Radio, RadioGroup } from '@univerjs/design';
+import { Radio, RadioGroup } from '@univerjs/design';
import { IDrawingManagerService } from '@univerjs/drawing';
import { IRenderManagerService } from '@univerjs/engine-render';
import { SheetDrawingAnchorType } from '@univerjs/sheets-drawing';
import { useDependency } from '@univerjs/ui';
import { useEffect, useState } from 'react';
import { SetSheetDrawingCommand } from '../../commands/commands/set-sheet-drawing.command';
-import styles from './index.module.less';
export interface ISheetDrawingAnchorProps {
drawings: IDrawingParam[];
@@ -140,14 +139,28 @@ export const SheetDrawingAnchor = (props: ISheetDrawingAnchorProps) => {
};
return (
-
-
-
+
+
+
{localeService.t('drawing-anchor.title')}
-
-
+
+
{localeService.t('drawing-anchor.both')}
{localeService.t('drawing-anchor.position')}
diff --git a/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetDrawingPanel.tsx b/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetDrawingPanel.tsx
index ca0fe631ec..ea487be273 100644
--- a/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetDrawingPanel.tsx
+++ b/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetDrawingPanel.tsx
@@ -18,8 +18,7 @@ import type { IDrawingParam } from '@univerjs/core';
import { IDrawingManagerService } from '@univerjs/drawing';
import { DrawingCommonPanel } from '@univerjs/drawing-ui';
import { useDependency } from '@univerjs/ui';
-import React, { useEffect, useState } from 'react';
-import styles from './index.module.less';
+import { useEffect, useState } from 'react';
import { SheetDrawingAnchor } from './SheetDrawingAnchor';
export const SheetDrawingPanel = () => {
@@ -39,7 +38,7 @@ export const SheetDrawingPanel = () => {
}, []);
return !!drawings?.length && (
-
+
diff --git a/packages/sheets-drawing-ui/src/views/sheet-image-panel/index.module.less b/packages/sheets-drawing-ui/src/views/sheet-image-panel/index.module.less
deleted file mode 100644
index 38282a2ec1..0000000000
--- a/packages/sheets-drawing-ui/src/views/sheet-image-panel/index.module.less
+++ /dev/null
@@ -1,14 +0,0 @@
-@import '@univerjs/drawing-ui/src/views/panel/index.module.less';
-
-.sheet-image {
- &-menu {
- position: absolute;
- height: 100%;
- width: 100%;
- text-align: center;
-
- &-input {
- display: none;
- }
- }
-}
diff --git a/packages/sheets-drawing-ui/src/views/upload-loading/UploadLoading.tsx b/packages/sheets-drawing-ui/src/views/upload-loading/UploadLoading.tsx
deleted file mode 100644
index a209dc2f9a..0000000000
--- a/packages/sheets-drawing-ui/src/views/upload-loading/UploadLoading.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { LocaleService } from '@univerjs/core';
-import { IImageIoService } from '@univerjs/drawing';
-import { useDependency } from '@univerjs/ui';
-import React, { useEffect } from 'react';
-
-import styles from './index.module.less';
-
-export const UploadLoading = () => {
- const imageIoService = useDependency(IImageIoService);
- const localeService = useDependency(LocaleService);
-
- const [remain, setRemain] = React.useState(0);
-
- useEffect(() => {
- const sub = imageIoService.change$.subscribe((count) => {
- setRemain(count);
- });
-
- return () => {
- sub.unsubscribe();
- };
- }, [imageIoService]);
-
- return (
-
0 ? 'block' : 'none' }} className={styles.uploadLoading}>
-
-
-
{`${localeService.t('uploadLoading.loading')}: ${remain}` }
-
-
- );
-};
diff --git a/packages/sheets-drawing-ui/src/views/upload-loading/index.module.less b/packages/sheets-drawing-ui/src/views/upload-loading/index.module.less
deleted file mode 100644
index e615b3663d..0000000000
--- a/packages/sheets-drawing-ui/src/views/upload-loading/index.module.less
+++ /dev/null
@@ -1,47 +0,0 @@
-.upload-loading {
- position: absolute;
- height: 100%;
- width: 100%;
- text-align: center;
- background-color: rgba(var(--color-black), 0.5);
- z-index: 1000;
- user-select: none;
-
- &-body {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background-color: rgb(var(--color-white));
- padding: 20px 40px;
- display: flex;
- align-items: center;
- justify-items: center;
- border-radius: var(--border-radius-lg);
-
- &-animation {
- width: 30px;
- height: 30px;
- border: 2px solid rgb(var(--color-black));
- border-top-color: transparent;
- border-radius: 100%;
-
- animation: UniverCircleAnimation infinite 0.75s linear;
- }
-
- &-text {
- font-size: var(--font-size-xs);
- color: var(--color-black);
- padding: 10px;
- }
- }
-}
-
-@keyframes UniverCircleAnimation {
- 0% {
- transform: rotate(0);
- }
- 100% {
- transform: rotate(360deg);
- }
-}
diff --git a/packages/ui/src/services/message/__testing__/mock-message.service.ts b/packages/ui/src/services/message/__testing__/mock-message.service.ts
index c783528793..a332f040c3 100644
--- a/packages/ui/src/services/message/__testing__/mock-message.service.ts
+++ b/packages/ui/src/services/message/__testing__/mock-message.service.ts
@@ -28,6 +28,14 @@ export class MockMessageService implements IMessageService {
return toDisposable(() => { /* empty */ });
}
+ remove(_id: string): void {
+ // empty
+ }
+
+ removeAll(): void {
+ // empty
+ }
+
setContainer(): void {
// empty
}
diff --git a/packages/ui/src/services/message/desktop-message.service.ts b/packages/ui/src/services/message/desktop-message.service.ts
index 6508d79e07..398f1149da 100644
--- a/packages/ui/src/services/message/desktop-message.service.ts
+++ b/packages/ui/src/services/message/desktop-message.service.ts
@@ -14,9 +14,10 @@
* limitations under the License.
*/
+import type { IDisposable } from '@univerjs/core';
import type { IMessageProps } from '@univerjs/design';
import type { IMessageService } from './message.service';
-import { Disposable, Inject, Injector } from '@univerjs/core';
+import { Disposable, Inject, Injector, toDisposable } from '@univerjs/core';
import { message, Messager, removeMessage } from '@univerjs/design';
import { connectInjector } from '../../utils/di';
import { BuiltInUIPart, IUIPartsService } from '../parts/parts.service';
@@ -41,7 +42,21 @@ export class DesktopMessageService extends Disposable implements IMessageService
removeMessage();
}
- show(options: IMessageProps) {
- message(options);
+ show(options: IMessageProps): IDisposable {
+ let op = options;
+ if (typeof options.id === 'undefined') {
+ op = Object.assign({}, options, { id: `message-${Date.now()}` });
+ }
+
+ message(op);
+ return toDisposable(() => removeMessage(op.id));
+ }
+
+ remove(id: string): void {
+ removeMessage(id);
+ }
+
+ removeAll(): void {
+ removeMessage();
}
}
diff --git a/packages/ui/src/services/message/message.service.ts b/packages/ui/src/services/message/message.service.ts
index fa3323590b..a5a094c091 100644
--- a/packages/ui/src/services/message/message.service.ts
+++ b/packages/ui/src/services/message/message.service.ts
@@ -14,11 +14,14 @@
* limitations under the License.
*/
+import type { IDisposable } from '@univerjs/core';
import type { IMessageProps } from '@univerjs/design';
import { createIdentifier } from '@univerjs/core';
export const IMessageService = createIdentifier
('ui.message.service');
export interface IMessageService {
- show(options: IMessageProps): void;
+ show(options: IMessageProps): IDisposable;
+ remove(id: string): void;
+ removeAll(): void;
}
diff --git a/tests/formula-integration/src/__testing__/util.ts b/tests/formula-integration/src/__testing__/util.ts
index 1d533d1a8b..cd28529211 100644
--- a/tests/formula-integration/src/__testing__/util.ts
+++ b/tests/formula-integration/src/__testing__/util.ts
@@ -34,9 +34,6 @@ export function getTestFilePath() {
return name.replace(/[ >]/g, '-').toLowerCase();
}
-/**
- *
- */
export async function expectCalculationResultMatchesSnapshot() {
const testBed = createFormulaTestBed();
const snapshotRootDir = path.join(import.meta.dirname, '../__snapshots__');
@@ -49,7 +46,7 @@ export async function expectCalculationResultMatchesSnapshot() {
const testSnapshotRaw = fs.readFileSync(testSnapshotPath, 'utf-8');
const testSnapshot = JSON.parse(testSnapshotRaw) as IWorkbookData;
- const workbook = testBed.api.createUniverSheet(testSnapshot);
+ const workbook = testBed.api.createWorkbook(testSnapshot);
const formula = testBed.api.getFormula();
await formula.onCalculationEnd();