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
fix: fix type error
  • Loading branch information
wzhudev committed Jun 18, 2024
commit e0fda40759c3e594ea3f5ef16988f3d13a832066
4 changes: 2 additions & 2 deletions packages/docs/src/commands/commands/delete.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const DeleteLeftCommand: ICommand = {
const docSkeletonManagerService = getCommandSkeleton(accessor, unitId);
const activeRange = textSelectionManagerService.getActiveRange();
const ranges = textSelectionManagerService.getSelections();
const skeleton = docSkeletonManagerService?.getSkeleton()?.skeleton;
const skeleton = docSkeletonManagerService?.getSkeleton();
if (activeRange == null || skeleton == null || ranges == null) {
return false;
}
Expand Down Expand Up @@ -202,7 +202,7 @@ export const DeleteRightCommand: ICommand = {

const activeRange = textSelectionManagerService.getActiveRange();
const ranges = textSelectionManagerService.getSelections();
const skeleton = docSkeletonManagerService?.getSkeleton()?.skeleton;
const skeleton = docSkeletonManagerService?.getSkeleton();
if (activeRange == null || skeleton == null || ranges == null) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/docs/src/controllers/move-cursor.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class MoveCursorController extends Disposable {
}

const skeleton = this._renderManagerService.getRenderById(docDataModel.getUnitId())
?.with(DocSkeletonManagerService).getSkeleton()?.skeleton;
?.with(DocSkeletonManagerService).getSkeleton();
const docObject = this._getDocObject();

if (activeRange == null || skeleton == null || docObject == null) {
Expand Down Expand Up @@ -203,7 +203,7 @@ export class MoveCursorController extends Disposable {
}

const skeleton = this._renderManagerService.getRenderById(docDataModel.getUnitId())
?.with(DocSkeletonManagerService).getSkeleton()?.skeleton;
?.with(DocSkeletonManagerService).getSkeleton();
const docObject = this._getDocObject();

if (activeRange == null || skeleton == null || docObject == null || allRanges == null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/controllers/normal-input.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class NormalInputController extends Disposable {
const e = event as InputEvent;

const skeleton = this._renderManagerService.getRenderById(documentModel.getUnitId())
?.with(DocSkeletonManagerService).getSkeleton()?.skeleton;
?.with(DocSkeletonManagerService).getSkeleton();

if (e.data == null || skeleton == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface IRenderManagerService extends IDisposable {
/** @deprecated */
createRender$: Observable<string>;
/** @deprecated this design is very very weird! Remove it. */
create(unitId: Nullable<string>): void;
create(unitId: string): void;

/** @deprecated There will be multi units to render at the same time, so there is no *current*. */
getCurrent(): Nullable<IRender>;
Expand Down Expand Up @@ -127,7 +127,7 @@ export class RenderManagerService extends Disposable implements IRenderManagerSe
return Array.from(this._renderControllers.get(type) ?? []);
}

create(unitId: Nullable<string>) {
create(unitId: string) {
this._createRender$.next(unitId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { LexerTreeBuilder } from '@univerjs/engine-formula';
import { SpreadsheetSkeleton } from '@univerjs/engine-render';
import type { Injector } from '@wendellhu/redi';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { getCellDataByInput } from '../end-edit.controller';
import { getCellDataByInput } from '../editing.render-controller';
import { createTestBed } from './create-test-bed';

const richTextDemo: IDocumentData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class ZenEditorController extends RxDisposable {

const { engine } = editorObject;

const skeleton = this._docSkeletonManagerService.getSkeletonByUnitId(DOCS_ZEN_EDITOR_UNIT_ID_KEY)?.skeleton;
const skeleton = this._renderManagerService.getRenderById(DOCS_ZEN_EDITOR_UNIT_ID_KEY)?.with(DocSkeletonManagerService).getSkeleton();

// Update page size when container resized.
// zenEditorDataModel.updateDocumentDataPageSize(width);
Expand Down Expand Up @@ -220,7 +220,7 @@ export class ZenEditorController extends RxDisposable {
DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
];

const skeleton = this._renderManagerService.getRenderById(unitId)?.with(DocSkeletonManagerService);
const skeleton = this._renderManagerService.getRenderById(unitId)?.with(DocSkeletonManagerService).getSkeleton();
const docDataModel = this._univerInstanceService.getUniverDocInstance(unitId);
const docViewModel = this._docViewModelManagerService.getViewModel(unitId);

Expand All @@ -245,7 +245,6 @@ export class ZenEditorController extends RxDisposable {
docViewModel.reset(docDataModel);

const currentRender = this._getDocObject();

if (currentRender == null) {
return;
}
Expand Down