Some checks failed
Build & Test / Analyze (javascript, affine) (push) Failing after 4s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 4s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 3s
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 4s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 3s
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Release / Canary Gate (push) Has been skipped
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Release / Prepare (push) Failing after 2s
Release / Release Cloud (push) Has been skipped
Release / Release Desktop (push) Has been skipped
Release / Release Docker Image (push) Has been skipped
Release / Release Mobile (push) Has been skipped
Copilot Test Automatically / Setup Test (push) Failing after 1s
127 lines
3.5 KiB
TypeScript
127 lines
3.5 KiB
TypeScript
import { EdgelessLegacySlotIdentifier } from '@blocksuite/affine-block-surface';
|
|
import type { FrameBlockModel, RootBlockModel } from '@blocksuite/affine-model';
|
|
import { EditPropsStore } from '@blocksuite/affine-shared/services';
|
|
import { Bound } from '@blocksuite/global/gfx';
|
|
import { WidgetComponent, WidgetViewExtension } from '@blocksuite/std';
|
|
import { GfxControllerIdentifier } from '@blocksuite/std/gfx';
|
|
import { effect } from '@preact/signals-core';
|
|
import { css, html, nothing } from 'lit';
|
|
import { state } from 'lit/decorators.js';
|
|
import { literal, unsafeStatic } from 'lit/static-html.js';
|
|
|
|
import { PresentTool } from '../present-tool';
|
|
|
|
export const EDGELESS_NAVIGATOR_BLACK_BACKGROUND_WIDGET =
|
|
'edgeless-navigator-black-background';
|
|
export class EdgelessNavigatorBlackBackgroundWidget extends WidgetComponent<RootBlockModel> {
|
|
static override styles = css`
|
|
.edgeless-navigator-black-background {
|
|
background-color: black;
|
|
position: absolute;
|
|
z-index: 1;
|
|
background-color: transparent;
|
|
box-shadow: 0 0 0 5000px black;
|
|
pointer-events: none;
|
|
}
|
|
`;
|
|
|
|
private _blackBackground = false;
|
|
|
|
get gfx() {
|
|
return this.std.get(GfxControllerIdentifier);
|
|
}
|
|
|
|
private get _slots() {
|
|
return this.std.get(EdgelessLegacySlotIdentifier);
|
|
}
|
|
|
|
private _tryLoadBlackBackground() {
|
|
const value = this.std
|
|
.get(EditPropsStore)
|
|
.getStorage('presentBlackBackground');
|
|
this._blackBackground = value ?? true;
|
|
}
|
|
|
|
override firstUpdated() {
|
|
const { _disposables, gfx } = this;
|
|
_disposables.add(
|
|
this._slots.navigatorFrameChanged.subscribe(frame => {
|
|
this.frame = frame;
|
|
})
|
|
);
|
|
|
|
_disposables.add(
|
|
this._slots.navigatorSettingUpdated.subscribe(({ blackBackground }) => {
|
|
if (blackBackground !== undefined) {
|
|
this.std
|
|
.get(EditPropsStore)
|
|
.setStorage('presentBlackBackground', blackBackground);
|
|
|
|
this._blackBackground = blackBackground;
|
|
|
|
this.show =
|
|
blackBackground &&
|
|
this.gfx.tool.currentToolOption$.peek().toolType === PresentTool;
|
|
}
|
|
})
|
|
);
|
|
|
|
_disposables.add(
|
|
effect(() => {
|
|
const tool = gfx.tool.currentToolName$.value;
|
|
|
|
if (tool !== 'frameNavigator') {
|
|
this.show = false;
|
|
} else {
|
|
this.show = this._blackBackground;
|
|
}
|
|
})
|
|
);
|
|
|
|
_disposables.add(
|
|
this._slots.fullScreenToggled.subscribe(
|
|
() =>
|
|
setTimeout(() => {
|
|
this.requestUpdate();
|
|
}, 500) // wait for full screen animation
|
|
)
|
|
);
|
|
|
|
this._tryLoadBlackBackground();
|
|
}
|
|
|
|
override render() {
|
|
const { frame, show, gfx } = this;
|
|
|
|
if (!show || !frame) return nothing;
|
|
|
|
const bound = Bound.deserialize(frame.xywh);
|
|
const zoom = gfx.viewport.zoom;
|
|
const width = bound.w * zoom;
|
|
const height = bound.h * zoom;
|
|
const [x, y] = gfx.viewport.toViewCoord(bound.x, bound.y);
|
|
|
|
return html` <style>
|
|
.edgeless-navigator-black-background {
|
|
width: ${width}px;
|
|
height: ${height}px;
|
|
top: ${y}px;
|
|
left: ${x}px;
|
|
}
|
|
</style>
|
|
<div class="edgeless-navigator-black-background"></div>`;
|
|
}
|
|
|
|
@state()
|
|
private accessor frame: FrameBlockModel | undefined = undefined;
|
|
|
|
@state()
|
|
private accessor show = false;
|
|
}
|
|
|
|
export const edgelessNavigatorBgWidget = WidgetViewExtension(
|
|
'affine:page',
|
|
EDGELESS_NAVIGATOR_BLACK_BACKGROUND_WIDGET,
|
|
literal`${unsafeStatic(EDGELESS_NAVIGATOR_BLACK_BACKGROUND_WIDGET)}`
|
|
);
|