Skip to content

Commit

Permalink
fix(zen): fix zen editor cannot be opened (#3699)
Browse files Browse the repository at this point in the history
  • Loading branch information
wzhudev authored Oct 10, 2024
1 parent 9e98122 commit 405a715
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
23 changes: 15 additions & 8 deletions packages/ui/src/services/zen-zone/desktop-zen-zone.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
* limitations under the License.
*/

import type { ComponentType } from '../../common/component-manager';
import type { IZenZoneService } from './zen-zone.service';
import { toDisposable } from '@univerjs/core';
import { type IDisposable, Inject } from '@univerjs/core';
import { BehaviorSubject, Subject } from 'rxjs';
import type { ForwardRefExoticComponent } from 'react';

import { type IDisposable, Inject } from '@univerjs/core';
import { BehaviorSubject, ReplaySubject } from 'rxjs';
import { ComponentManager } from '../../common/component-manager';
import type { IZenZoneService } from './zen-zone.service';

export class DesktopZenZoneService implements IZenZoneService {
readonly visible$ = new Subject<boolean>();
readonly componentKey$ = new Subject<string>();
export class DesktopZenZoneService implements IZenZoneService, IDisposable {
readonly visible$ = new BehaviorSubject<boolean>(false);
readonly componentKey$ = new ReplaySubject<string>();

private readonly _temporaryHidden$ = new BehaviorSubject<boolean>(false);
readonly temporaryHidden$ = this._temporaryHidden$.asObservable();
Expand All @@ -42,6 +42,13 @@ export class DesktopZenZoneService implements IZenZoneService {
// super
}

dispose(): void {
this.visible$.next(false);
this.visible$.complete();

this.componentKey$.complete();
}

hide(): void {
this._temporaryHidden$.next(true);
}
Expand All @@ -50,7 +57,7 @@ export class DesktopZenZoneService implements IZenZoneService {
this._temporaryHidden$.next(false);
}

set(key: string, component: ForwardRefExoticComponent<any>): IDisposable {
set(key: string, component: ComponentType): IDisposable {
this._componentManager.register(key, component);
this.componentKey$.next(key);

Expand Down
11 changes: 6 additions & 5 deletions packages/ui/src/services/zen-zone/zen-zone.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@
* limitations under the License.
*/

import { createIdentifier } from '@univerjs/core';
import type { IDisposable } from '@univerjs/core';
import type { Observable, Subject } from 'rxjs';
import type { BehaviorSubject, Observable, ReplaySubject } from 'rxjs';
import type { ComponentType } from '../../common/component-manager';
import { createIdentifier } from '@univerjs/core';

export const IZenZoneService = createIdentifier<IZenZoneService>('univer.zen-zone-service');

export interface IZenZoneService {
readonly visible$: Subject<boolean>;
readonly componentKey$: Subject<string>;
readonly visible$: BehaviorSubject<boolean>;
readonly componentKey$: ReplaySubject<string>;
readonly temporaryHidden$: Observable<boolean>;

readonly visible: boolean;
readonly temporaryHidden: boolean;

set(key: string, component: any): IDisposable;
set(key: string, component: ComponentType): IDisposable;

open(): void;

Expand Down

0 comments on commit 405a715

Please sign in to comment.