-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
1,020 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/frontend/core/src/modules/peek-view/entities/peek-view.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { BlockElement } from '@blocksuite/block-std'; | ||
import type { AffineReference } from '@blocksuite/blocks'; | ||
import { Entity, LiveData } from '@toeverything/infra'; | ||
|
||
export type ActivePeekView = { | ||
target: | ||
| HTMLElement | ||
| BlockElement | ||
| AffineReference | ||
| HTMLAnchorElement | ||
| { docId: string; blockId?: string }; | ||
}; | ||
|
||
export class PeekViewEntity extends Entity { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
private readonly _active$ = new LiveData<ActivePeekView | null>(null); | ||
private readonly _show$ = new LiveData<boolean>(false); | ||
|
||
active$ = this._active$.distinctUntilChanged(); | ||
show$ = this._show$ | ||
.map(show => show && this._active$.value !== null) | ||
.distinctUntilChanged(); | ||
|
||
open = (target: ActivePeekView['target']) => { | ||
this._active$.next({ target }); | ||
this._show$.next(true); | ||
}; | ||
|
||
close = () => { | ||
this._show$.next(false); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { Framework } from '@toeverything/infra'; | ||
|
||
import { PeekViewEntity } from './entities/peek-view'; | ||
import { PeekViewService } from './services/peek-view'; | ||
|
||
export function configurePeekViewModule(framework: Framework) { | ||
framework.service(PeekViewService).entity(PeekViewEntity); | ||
} | ||
|
||
export { PeekViewEntity, PeekViewService }; | ||
export { useInsidePeekView } from './view'; |
9 changes: 9 additions & 0 deletions
9
packages/frontend/core/src/modules/peek-view/services/peek-view.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { OnEvent, Service } from '@toeverything/infra'; | ||
|
||
import { WorkbenchLocationChanged } from '../../workbench/services/workbench'; | ||
import { PeekViewEntity } from '../entities/peek-view'; | ||
|
||
@OnEvent(WorkbenchLocationChanged, e => e.peekView.close) | ||
export class PeekViewService extends Service { | ||
public readonly peekView = this.framework.createEntity(PeekViewEntity); | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/frontend/core/src/modules/peek-view/view/doc-peek-controls.css.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { cssVar } from '@toeverything/theme'; | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const root = style({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
height: '100%', | ||
gap: 8, | ||
}); | ||
|
||
export const button = style({ | ||
color: cssVar('iconColor'), | ||
boxShadow: cssVar('shadow2'), | ||
borderRadius: 8, | ||
fontSize: '20px !important', | ||
':hover': { | ||
background: cssVar('hoverColorFilled'), | ||
}, | ||
pointerEvents: 'auto', | ||
}); |
Oops, something went wrong.