Skip to content

Commit

Permalink
fix: switch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs committed Nov 30, 2024
1 parent a3c63f7 commit 3e7e49b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type { IRichTextEditingMutationParams } from '@univerjs/docs';
import { CommandType, DocumentFlavor, ICommandService, IUniverInstanceService, JSONX, ObjectRelativeFromV } from '@univerjs/core';
import { DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation } from '@univerjs/docs';
import { IRenderManagerService } from '@univerjs/engine-render';
import { DocPageLayoutService } from '../../services/doc-page-layout.service';
import { DocSelectionRenderService } from '../../services/selection/doc-selection-render.service';

export interface ISwitchDocModeCommandParams { }
Expand All @@ -33,7 +34,6 @@ export const SwitchDocModeCommand: ICommand<ISwitchDocModeCommandParams> = {
const commandService = accessor.get(ICommandService);
const renderManagerService = accessor.get(IRenderManagerService);
const docSelectionManagerService = accessor.get(DocSelectionManagerService);

const univerInstanceService = accessor.get(IUniverInstanceService);
const docDataModel = univerInstanceService.getCurrentUniverDocInstance();

Expand All @@ -43,6 +43,8 @@ export const SwitchDocModeCommand: ICommand<ISwitchDocModeCommandParams> = {

const unitId = docDataModel.getUnitId();

const docPageLayoutService = renderManagerService.getRenderById(unitId)?.with(DocPageLayoutService);

const skeleton = renderManagerService.getRenderById(unitId)
?.with(DocSkeletonManagerService)
.getSkeleton();
Expand Down Expand Up @@ -165,6 +167,8 @@ export const SwitchDocModeCommand: ICommand<ISwitchDocModeCommandParams> = {
IRichTextEditingMutationParams
>(doMutation.id, doMutation.params);

docPageLayoutService?.calculatePagePosition();

return Boolean(result);
},
};
2 changes: 2 additions & 0 deletions packages/engine-render/src/components/docs/layout/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ const DEFAULT_MODERN_DOCUMENT_STYLE: IDocumentStyle = {
width: ptToPixel(595),
height: Number.POSITIVE_INFINITY,
},
pageOrient: PageOrientType.PORTRAIT,
marginTop: ptToPixel(50),
marginBottom: ptToPixel(50),
marginRight: ptToPixel(50),
Expand All @@ -1011,6 +1012,7 @@ const DEFAULT_MODERN_DOCUMENT_STYLE: IDocumentStyle = {
const DEFAULT_MODERN_SECTION_BREAK: Partial<ISectionBreak> = {
columnProperties: [],
columnSeparatorType: ColumnSeparatorType.NONE,
equalWidth: BooleanNumber.FALSE,
sectionType: SectionType.SECTION_TYPE_UNSPECIFIED,
};

Expand Down

0 comments on commit 3e7e49b

Please sign in to comment.