Skip to content

Commit

Permalink
fix(sheets-drawing): drawing snapshot error (#3230)
Browse files Browse the repository at this point in the history
  • Loading branch information
weird94 authored Aug 30, 2024
1 parent f06192d commit f5f52bf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import { Disposable, Inject, LifecycleService, LifecycleStages, UniverInstanceType } from '@univerjs/core';
import { IDrawingManagerService } from '@univerjs/drawing';
import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';
import { ISheetDrawingService } from '@univerjs/sheets-drawing';
import { filter, first } from 'rxjs';
Expand All @@ -23,6 +24,7 @@ export class SheetsDrawingRenderController extends Disposable implements IRender
constructor(
private _context: IRenderContext,
@ISheetDrawingService private readonly _sheetDrawingService: ISheetDrawingService,
@IDrawingManagerService private readonly _drawingManagerService: IDrawingManagerService,
@Inject(LifecycleService) private _lifecycleService: LifecycleService
) {
super();
Expand All @@ -38,6 +40,7 @@ export class SheetsDrawingRenderController extends Disposable implements IRender
this._lifecycleService.lifecycle$.pipe(filter((e) => e === LifecycleStages.Steady), first()).subscribe(() => {
if (this._context.type === UniverInstanceType.UNIVER_SHEET) {
this._sheetDrawingService.initializeNotification(this._context.unitId);
this._drawingManagerService.initializeNotification(this._context.unitId);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import type { ICommandInfo, IDrawingSearch, IRange, Nullable, Workbook } from '@univerjs/core';
import type { ICommandInfo, IRange, Nullable, Workbook } from '@univerjs/core';
import { Disposable, FOCUSING_COMMON_DRAWINGS, ICommandService, IContextService, Inject, LocaleService } from '@univerjs/core';
import type { IImageData, IImageIoServiceParam } from '@univerjs/drawing';
import { DRAWING_IMAGE_ALLOW_SIZE, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, DrawingTypeEnum, getImageSize, IDrawingManagerService, IImageIoService, ImageUploadStatusType } from '@univerjs/drawing';
Expand Down Expand Up @@ -61,7 +61,6 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
this._updateOrderListener();
this._groupDrawingListener();
this._focusDrawingListener();
this._drawingAddListener();
}

/**
Expand Down Expand Up @@ -355,31 +354,4 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderM
})
);
}

private _drawingAddListener() {
this.disposeWithMe(
this._sheetDrawingService.add$.subscribe((params) => {
this._registerDrawing(params);
})
);
}

private _registerDrawing(params: IDrawingSearch[]) {
(params).forEach((param) => {
const drawingParam = this._sheetDrawingService.getDrawingByParam(param) as ISheetDrawing;

if (drawingParam == null || drawingParam.unitId !== this._context.unitId) {
return;
}

const { sheetTransform } = drawingParam;

drawingParam.transform = drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService);
});

const unitId = params[0].unitId;

this._drawingManagerService.registerDrawingData(unitId, this._sheetDrawingService.getDrawingDataForUnit(unitId));
this._drawingManagerService.initializeNotification(unitId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class SheetsDrawingLoadController extends Disposable {
},
onLoad: (unitId, value) => {
this._sheetDrawingService.registerDrawingData(unitId, value);
this._drawingManagerService.registerDrawingData(unitId, value);
},
})
);
Expand Down

0 comments on commit f5f52bf

Please sign in to comment.