Skip to content

Commit

Permalink
fix: use editorModeSwitch slot to change mode (toeverything#6380)
Browse files Browse the repository at this point in the history
  • Loading branch information
donteatfriedrice authored Mar 5, 2024
1 parent d30e2ef commit 934469c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ export class FramePanelBody extends WithDisposable(ShadowlessElement) {
@property({ attribute: false })
editorHost!: EditorHost;

@property({ attribute: false })
changeEditorMode!: (mode: 'page' | 'edgeless') => void;

// Store the ids of the selected frames
@state()
private _selected: string[] = [];
Expand Down Expand Up @@ -255,7 +252,7 @@ export class FramePanelBody extends WithDisposable(ShadowlessElement) {

const rootService = this.editorHost.spec.getService('affine:page');
rootService.editSession.setItem('viewport', viewport);
this.changeEditorMode('edgeless');
rootService.slots.editorModeSwitch.emit('edgeless');
} else {
this.edgeless.service.viewport.setViewportByBound(
bound,
Expand Down
6 changes: 0 additions & 6 deletions packages/presets/src/fragments/frame-panel/frame-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ export class FramePanel extends WithDisposable(ShadowlessElement) {
return this.editor.querySelector('affine-edgeless-root');
}

private _changeEditorMode = (mode: 'page' | 'edgeless') => {
this.editor.mode = mode;
};

private _editorDisposables: DisposableGroup | null = null;

private _clearEditorDisposables() {
Expand Down Expand Up @@ -143,15 +139,13 @@ export class FramePanel extends WithDisposable(ShadowlessElement) {
return html`<div class="frame-panel-container">
<frame-panel-header
.edgeless=${this.edgeless}
.changeEditorMode=${this._changeEditorMode}
.editorHost=${this.host}
></frame-panel-header>
<frame-panel-body
class="frame-panel-body"
.edgeless=${this.edgeless}
.doc=${this.doc}
.editorHost=${this.host}
.changeEditorMode=${this._changeEditorMode}
.fitPadding=${this.fitPadding}
></frame-panel-body>
</div>`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ export class FramePanelHeader extends WithDisposable(LitElement) {
@property({ attribute: false })
edgeless!: EdgelessRootBlockComponent | null;

@property({ attribute: false })
changeEditorMode!: (mode: 'page' | 'edgeless') => void;

@state()
private _settingPopperShow = false;

Expand All @@ -127,16 +124,24 @@ export class FramePanelHeader extends WithDisposable(LitElement) {
private _navigatorMode: NavigatorMode = 'fit';
private _edgelessDisposables: DisposableGroup | null = null;

get rootService() {
return this.editorHost.spec.getService('affine:page');
}

private _enterPresentationMode = () => {
if (!this.edgeless) this.changeEditorMode('edgeless');
this.edgeless?.updateComplete
.then(() => {
this.edgeless?.tools.setEdgelessTool({
type: 'frameNavigator',
mode: this._navigatorMode,
});
})
.catch(console.error);
if (!this.edgeless)
this.rootService.slots.editorModeSwitch.emit('edgeless');

setTimeout(() => {
this.edgeless?.updateComplete
.then(() => {
this.edgeless?.tools.setEdgelessTool({
type: 'frameNavigator',
mode: this._navigatorMode,
});
})
.catch(console.error);
}, 100);
};

private _tryLoadNavigatorStateLocalRecord() {
Expand Down

1 comment on commit 934469c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Size Report

Bundles

Entry Size Gzip Brotli
examples/basic 13.9 MB (+3.97 kB) 2.89 MB (+1.36 kB) 1.79 MB (+36 B)

Packages

Name Size Gzip Brotli
blocks 2.19 MB (+930 B) 510 kB (+279 B) 372 kB (+102 B)
editor 84 B 89 B 63 B
store 83 B 88 B 63 B
inline 84 B 88 B 63 B

Please sign in to comment.