diff --git a/src/app/AppConfig.ts b/src/app/AppConfig.ts index dd51aa21..c4d3fcc8 100644 --- a/src/app/AppConfig.ts +++ b/src/app/AppConfig.ts @@ -83,6 +83,11 @@ export type AppConfig = { * Default: 1. */ zoomFactor: number + /** + * User-provided CSS injected into desktop app windows. + * Default: empty string. + */ + customCss: string // ---------------- // Privacy settings @@ -143,6 +148,7 @@ const defaultAppConfig: AppConfig = { systemTitleBar: false, monochromeTrayIcon: isMac, zoomFactor: 1, + customCss: '', playSoundChat: 'respect-dnd', playSoundCall: 'respect-dnd', enableCallbox: 'respect-dnd', diff --git a/src/shared/setupWebPage.js b/src/shared/setupWebPage.js index 6c533968..55eef721 100644 --- a/src/shared/setupWebPage.js +++ b/src/shared/setupWebPage.js @@ -8,7 +8,7 @@ import { isRTL, register } from '@nextcloud/l10n' import { appData } from '../app/AppData.js' import { refetchAppData } from '../app/appData.service.js' import { TITLE_BAR_HEIGHT } from '../constants.js' -import { initAppConfig } from './appConfig.service.ts' +import { getAppConfigValue, initAppConfig } from './appConfig.service.ts' import { BUILD_CONFIG } from './build.config.ts' import { initGlobals } from './globals/globals.js' import { setupInitialState } from './initialState.service.js' @@ -242,6 +242,23 @@ function applyHeaderHeight() { document.body.style.setProperty('--header-height', `${TITLE_BAR_HEIGHT}px`) document.documentElement.style.setProperty('--header-height', `${TITLE_BAR_HEIGHT}px`) } +/** + * Apply custom user CSS from the desktop settings. + */ +function applyCustomCss(css = getAppConfigValue('customCss')) { + let style = document.getElementById('talk-desktop-custom-css') + if (!style) { + style = document.createElement('style') + style.id = 'talk-desktop-custom-css' + document.head.appendChild(style) + } + style.textContent = typeof css === 'string' ? css : '' + window.TALK_DESKTOP.onAppConfigChange((_event, { key, value }) => { + if (key === 'customCss') { + style.textContent = typeof value === 'string' ? value : '' + } + }) +} /** * Handle download links @@ -267,6 +284,7 @@ export async function setupWebPage() { initGlobals() applyUserData() applyHeaderHeight() + applyCustomCss() applyAxiosInterceptors() applyDownloadLinkHandler() diff --git a/src/talk/renderer/Settings/DesktopSettingsSection.vue b/src/talk/renderer/Settings/DesktopSettingsSection.vue index c4a75b38..8c405466 100644 --- a/src/talk/renderer/Settings/DesktopSettingsSection.vue +++ b/src/talk/renderer/Settings/DesktopSettingsSection.vue @@ -31,6 +31,7 @@ const theme = useAppConfigValue('theme') const systemTitleBar = useAppConfigValue('systemTitleBar') const monochromeTrayIcon = useAppConfigValue('monochromeTrayIcon') const zoomFactor = useAppConfigValue('zoomFactor') +const customCss = useAppConfigValue('customCss') const playSoundChat = useAppConfigValue('playSoundChat') const playSoundCall = useAppConfigValue('playSoundCall') @@ -80,6 +81,13 @@ const secondarySpeakerDevice = useAppConfigValue('secondarySpeakerDevice') + +