Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(docs-ui): refactor to RenderUnit #2539

Open
wants to merge 22 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: refactor editor related modules
  • Loading branch information
wzhudev committed Jun 18, 2024
commit 721f5010b5607053a55ff78c5089d240ec9e4e6f
2 changes: 1 addition & 1 deletion packages/core/src/services/undoredo/undoredo.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface IUndoRedoService {
popUndoToRedo(): void;
popRedoToUndo(): void;

clearUndoRedo(unitID: string): void;
clearUndoRedo(unitId: string): void;

/**
* Batch undo redo elements into a single `IUndoRedoItem` util the returned `IDisposable` is called.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ import { DocSkeletonManagerService, TextSelectionManagerService } from '@univerj
import { docDrawingPositionToTransform, transformToDocDrawingPosition } from '@univerjs/docs-ui';
import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';

import type { IInsertImageOperationParams } from '../commands/operations/insert-image.operation';
import { InsertDocImageOperation } from '../commands/operations/insert-image.operation';
import type { IInsertDrawingCommandParams, ISetDrawingCommandParams } from '../commands/commands/interfaces';
import { type ISetDrawingArrangeCommandParams, SetDocDrawingArrangeCommand } from '../commands/commands/set-drawing-arrange.command';
import { InsertDocDrawingCommand } from '../commands/commands/insert-doc-drawing.command';
import { GroupDocDrawingCommand } from '../commands/commands/group-doc-drawing.command';
import { UngroupDocDrawingCommand } from '../commands/commands/ungroup-doc-drawing.command';
import { SetDocDrawingCommand } from '../commands/commands/set-doc-drawing.command';
import type { IInsertImageOperationParams } from '../../commands/operations/insert-image.operation';
import { InsertDocImageOperation } from '../../commands/operations/insert-image.operation';
import type { IInsertDrawingCommandParams, ISetDrawingCommandParams } from '../../commands/commands/interfaces';
import { type ISetDrawingArrangeCommandParams, SetDocDrawingArrangeCommand } from '../../commands/commands/set-drawing-arrange.command';
import { InsertDocDrawingCommand } from '../../commands/commands/insert-doc-drawing.command';
import { GroupDocDrawingCommand } from '../../commands/commands/group-doc-drawing.command';
import { UngroupDocDrawingCommand } from '../../commands/commands/ungroup-doc-drawing.command';
import { SetDocDrawingCommand } from '../../commands/commands/set-doc-drawing.command';

export class DocDrawingUpdateRenderController extends Disposable implements IRenderModule {
constructor(
Expand Down Expand Up @@ -121,8 +121,6 @@ export class DocDrawingUpdateRenderController extends Disposable implements IRen
const { imageId, imageSourceType, source, base64Cache } = imageParam;
const { width, height, image } = await getImageSize(base64Cache || '');

const { width: sceneWidth, height: sceneHeight } = this._context.scene;

this._imageIoService.addImageSourceCache(imageId, imageSourceType, image);

let scale = 1;
Expand Down Expand Up @@ -210,15 +208,11 @@ export class DocDrawingUpdateRenderController extends Disposable implements IRen
}

const sheetDrawing = this._sheetDrawingService.getDrawingByParam({ unitId, subUnitId, drawingId });

if (sheetDrawing == null) {
return;
}

// const { marginLeft, marginTop } = pageMarginCache.get(drawingId) || { marginLeft: 0, marginTop: 0 };

const docTransform = transformToDocDrawingPosition({ ...sheetDrawing.transform, ...transform });

if (docTransform == null) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/docs-drawing-ui/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { UniverDocsDrawingPlugin } from '@univerjs/docs-drawing';
import { IRenderManagerService } from '@univerjs/engine-render';
import { DocDrawingPopupMenuController } from './controllers/drawing-popup-menu.controller';
import { DocDrawingUIController } from './controllers/doc-drawing.controller';
import { DocDrawingUpdateRenderController } from './controllers/doc-drawing-update.controller';
import { DocDrawingUpdateRenderController } from './controllers/render-controllers/doc-drawing-update.render-controller';

const PLUGIN_NAME = 'DOCS_DRAWING_UI_PLUGIN';

Expand Down
122 changes: 0 additions & 122 deletions packages/docs-ui/src/controllers/back-scroll.controller.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class DocEditorBridgeController extends Disposable {
}

const skeleton = this._renderManagerService.getRenderById(editorDataModel.getUnitId())
?.with(DocSkeletonManagerService).getSkeleton()?.skeleton;
?.with(DocSkeletonManagerService).getSkeleton();
if (editor == null || editor.render == null || skeleton == null || editorDataModel == null) {
return;
}
Expand Down