@blocksuite/affine-shared
Advanced tools
Comparing version 0.0.0-canary-20241031001416 to 0.0.0-canary-20241031062423
# @blocksuite/affine-shared | ||
## 0.0.0-canary-20241031001416 | ||
## 0.0.0-canary-20241031062423 | ||
@@ -16,7 +16,7 @@ ### Patch Changes | ||
- Updated dependencies [39a840a] | ||
- @blocksuite/affine-model@0.0.0-canary-20241031001416 | ||
- @blocksuite/block-std@0.0.0-canary-20241031001416 | ||
- @blocksuite/global@0.0.0-canary-20241031001416 | ||
- @blocksuite/inline@0.0.0-canary-20241031001416 | ||
- @blocksuite/store@0.0.0-canary-20241031001416 | ||
- @blocksuite/affine-model@0.0.0-canary-20241031062423 | ||
- @blocksuite/block-std@0.0.0-canary-20241031062423 | ||
- @blocksuite/global@0.0.0-canary-20241031062423 | ||
- @blocksuite/inline@0.0.0-canary-20241031062423 | ||
- @blocksuite/store@0.0.0-canary-20241031062423 | ||
@@ -23,0 +23,0 @@ ## 0.17.23 |
@@ -18,2 +18,4 @@ import { type Color, ColorScheme } from '@blocksuite/affine-model'; | ||
edgeless$: Signal<ColorScheme>; | ||
get appTheme(): ColorScheme; | ||
get edgelessTheme(): ColorScheme; | ||
get theme(): ColorScheme; | ||
@@ -61,4 +63,11 @@ get theme$(): Signal<ColorScheme>; | ||
} | ||
export declare class ThemeObserver { | ||
private observer; | ||
theme$: Signal<ColorScheme>; | ||
constructor(); | ||
destroy(): void; | ||
} | ||
export declare const getThemeObserver: () => ThemeObserver; | ||
export declare const lightToolbarStyles: string[]; | ||
export declare const darkToolbarStyles: string[]; | ||
//# sourceMappingURL=theme-service.d.ts.map |
@@ -19,6 +19,12 @@ import { ColorScheme } from '@blocksuite/affine-model'; | ||
export class ThemeService extends Extension { | ||
get appTheme() { | ||
return this.app$.peek(); | ||
} | ||
get edgelessTheme() { | ||
return this.edgeless$.peek(); | ||
} | ||
get theme() { | ||
return this.docMode.getEditorMode() === 'page' | ||
? this.app$.peek() | ||
: this.edgeless$.peek(); | ||
? this.appTheme | ||
: this.edgelessTheme; | ||
} | ||
@@ -33,4 +39,5 @@ get theme$() { | ||
const extension = this.std.getOptional(ThemeExtensionIdentifier); | ||
this.app$ = extension?.getAppTheme?.() || themeObserver.theme$; | ||
this.edgeless$ = extension?.getEdgelessTheme?.() || themeObserver.theme$; | ||
this.app$ = extension?.getAppTheme?.() || getThemeObserver().theme$; | ||
this.edgeless$ = | ||
extension?.getEdgelessTheme?.() || getThemeObserver().theme$; | ||
} | ||
@@ -104,3 +111,3 @@ static setup(di) { | ||
? TRANSPARENT | ||
: this.getCssVariableColor(result); | ||
: this.getCssVariableColor(result, theme); | ||
} | ||
@@ -123,3 +130,3 @@ return result ?? TRANSPARENT; | ||
} | ||
class ThemeObserver { | ||
export class ThemeObserver { | ||
constructor() { | ||
@@ -147,3 +154,11 @@ this.theme$ = signal(ColorScheme.Light); | ||
} | ||
const themeObserver = new ThemeObserver(); | ||
export const getThemeObserver = (function () { | ||
let observer; | ||
return function () { | ||
if (observer) | ||
return observer; | ||
observer = new ThemeObserver(); | ||
return observer; | ||
}; | ||
})(); | ||
const toolbarColorKeys = [ | ||
@@ -150,0 +165,0 @@ '--affine-background-overlay-panel-color', |
{ | ||
"name": "@blocksuite/affine-shared", | ||
"version": "0.0.0-canary-20241031001416", | ||
"version": "0.0.0-canary-20241031062423", | ||
"description": "Default BlockSuite editable blocks.", | ||
@@ -22,7 +22,7 @@ "type": "module", | ||
"dependencies": { | ||
"@blocksuite/affine-model": "0.0.0-canary-20241031001416", | ||
"@blocksuite/block-std": "0.0.0-canary-20241031001416", | ||
"@blocksuite/global": "0.0.0-canary-20241031001416", | ||
"@blocksuite/inline": "0.0.0-canary-20241031001416", | ||
"@blocksuite/store": "0.0.0-canary-20241031001416", | ||
"@blocksuite/affine-model": "0.0.0-canary-20241031062423", | ||
"@blocksuite/block-std": "0.0.0-canary-20241031062423", | ||
"@blocksuite/global": "0.0.0-canary-20241031062423", | ||
"@blocksuite/inline": "0.0.0-canary-20241031062423", | ||
"@blocksuite/store": "0.0.0-canary-20241031062423", | ||
"@floating-ui/dom": "^1.6.10", | ||
@@ -29,0 +29,0 @@ "@lit/context": "^1.1.2", |
@@ -47,6 +47,14 @@ import { type Color, ColorScheme } from '@blocksuite/affine-model'; | ||
get appTheme() { | ||
return this.app$.peek(); | ||
} | ||
get edgelessTheme() { | ||
return this.edgeless$.peek(); | ||
} | ||
get theme() { | ||
return this.docMode.getEditorMode() === 'page' | ||
? this.app$.peek() | ||
: this.edgeless$.peek(); | ||
? this.appTheme | ||
: this.edgelessTheme; | ||
} | ||
@@ -64,4 +72,5 @@ | ||
const extension = this.std.getOptional(ThemeExtensionIdentifier); | ||
this.app$ = extension?.getAppTheme?.() || themeObserver.theme$; | ||
this.edgeless$ = extension?.getEdgelessTheme?.() || themeObserver.theme$; | ||
this.app$ = extension?.getAppTheme?.() || getThemeObserver().theme$; | ||
this.edgeless$ = | ||
extension?.getEdgelessTheme?.() || getThemeObserver().theme$; | ||
} | ||
@@ -148,3 +157,3 @@ | ||
? TRANSPARENT | ||
: this.getCssVariableColor(result); | ||
: this.getCssVariableColor(result, theme); | ||
} | ||
@@ -171,3 +180,3 @@ | ||
class ThemeObserver { | ||
export class ThemeObserver { | ||
private observer: MutationObserver; | ||
@@ -198,3 +207,10 @@ | ||
const themeObserver = new ThemeObserver(); | ||
export const getThemeObserver = (function () { | ||
let observer: ThemeObserver; | ||
return function () { | ||
if (observer) return observer; | ||
observer = new ThemeObserver(); | ||
return observer; | ||
}; | ||
})(); | ||
@@ -201,0 +217,0 @@ const toolbarColorKeys: Array<keyof AffineCssVariables> = [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
787066
13782
213
213
+ Added@blocksuite/affine-model@0.0.0-canary-20241031062423(transitive)
+ Added@blocksuite/block-std@0.0.0-canary-20241031062423(transitive)
+ Added@blocksuite/global@0.0.0-canary-20241031062423(transitive)
+ Added@blocksuite/inline@0.0.0-canary-20241031062423(transitive)
+ Added@blocksuite/store@0.0.0-canary-20241031062423(transitive)
+ Added@blocksuite/sync@0.0.0-canary-20241031062423(transitive)
- Removed@blocksuite/affine-model@0.0.0-canary-20241031001416(transitive)
- Removed@blocksuite/block-std@0.0.0-canary-20241031001416(transitive)
- Removed@blocksuite/global@0.0.0-canary-20241031001416(transitive)
- Removed@blocksuite/inline@0.0.0-canary-20241031001416(transitive)
- Removed@blocksuite/store@0.0.0-canary-20241031001416(transitive)
- Removed@blocksuite/sync@0.0.0-canary-20241031001416(transitive)