TagSpaces is an offline, open source, document manager with tagging support
feat: hede electron titlebar on mac
Ilian Sapundshieve908584a01ff
diff --git a/src/main/main.ts b/src/main/main.tsindex 4379f520c..6bb04fa19 100644--- a/src/main/main.ts+++ b/src/main/main.ts@@ -9,7 +9,14 @@* `./src/main.js` using webpack. This gives us some performance wins.*/import path from 'path';-import { app, BrowserWindow, shell, ipcMain, globalShortcut } from 'electron';+import {+ app,+ BrowserWindow,+ shell,+ ipcMain,+ globalShortcut,+ BrowserWindowConstructorOptions,+} from 'electron';import { autoUpdater } from 'electron-updater';import log from 'electron-log';import pm2 from '@elife/pm2';@@ -97,6 +104,26 @@ process.argv.forEach((arg, count) => {// app.commandLine.appendSwitch('--allow-file-access-from-files');// }+const browserWindowOptions: BrowserWindowConstructorOptions = {+ show: false,+ center: true,+ autoHideMenuBar: true,+ titleBarStyle: isMacLike ? 'hidden' : 'default',+ trafficLightPosition: { x: 3, y: 3 },+ webPreferences: {+ spellcheck: true,+ preload:+ app.isPackaged || !isDebug+ ? path.join(__dirname, 'preload.js')+ : path.join(__dirname, '../../.erb/dll/preload.js'),+ },+};++const defaultAppSize = {+ defaultWidth: 1280,+ defaultHeight: 800,+};+const installExtensions = async () => {const installer = require('electron-devtools-installer');const forceDownload = !!process.env.UPGRADE_EXTENSIONS;@@ -125,96 +152,112 @@ function openLocationManagerPanel() {mainWindow.webContents.send('cmd', 'open-location-manager-panel');}}+function openTagLibraryPanel() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'open-tag-library-panel');}}+function goBack() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'go-back');}}+function goForward() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'go-forward');}}+function setZoomResetApp() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'set-zoom-reset-app');}}+function setZoomInApp() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'set-zoom-in-app');}}+function setZoomOutApp() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'set-zoom-out-app');}}+function exitFullscreen() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'exit-fullscreen');}}+function toggleSettingsDialog() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'toggle-settings-dialog');}}+function openHelpFeedbackPanel() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'open-help-feedback-panel');}}+function toggleKeysDialog() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'toggle-keys-dialog');}}+function toggleOnboardingDialog() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'toggle-onboarding-dialog');}}+function openURLExternally(data) {if (mainWindow) {showApp();mainWindow.webContents.send('open-url-externally', data);}}+function toggleLicenseDialog() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'toggle-license-dialog');}}+function toggleThirdPartyLibsDialog() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'toggle-third-party-libs-dialog');}}+function toggleAboutDialog() {if (mainWindow) {showApp();mainWindow.webContents.send('cmd', 'toggle-about-dialog');}}+function showSearch() {if (mainWindow) {showApp();@@ -273,32 +316,24 @@ function createNewWindowInstance(url?) {return;}- const mainWindowState = windowStateKeeper({- defaultWidth: 1280,- defaultHeight: 800,- });+ const mainWindowState = windowStateKeeper(defaultAppSize);- const mainWindowInstance = new BrowserWindow({- show: true,- center: true,+ const newWindowInstance = new BrowserWindow({+ ...browserWindowOptions,width: mainWindowState.width,height: mainWindowState.height,- webPreferences: {- spellcheck: true,- // webviewTag: true,- preload:- app.isPackaged || !isDebug- ? path.join(__dirname, 'preload.js')- : path.join(__dirname, '../../.erb/dll/preload.js'),- },+ x: mainWindowState.x,+ y: mainWindowState.y,+ show: true,+ center: true,});- mainWindowInstance.setMenuBarVisibility(false);- mainWindowInstance.setAutoHideMenuBar(true);+ newWindowInstance.setMenuBarVisibility(false);+if (url) {- mainWindowInstance.loadURL(url);+ newWindowInstance.loadURL(url);} else {- mainWindowInstance.loadURL(resolveHtmlPath('index.html'));+ newWindowInstance.loadURL(resolveHtmlPath('index.html'));}}@@ -360,7 +395,8 @@ const getAssetPath = (...paths: string[]): string => {return path.join(RESOURCES_PATH, ...paths);};*/-function startWS(port = undefined) {+function startWS() {+ const port = isDebug ? 2000 : undefined;try {let filepath;let script;@@ -446,32 +482,16 @@ const createWindow = async (i18n) => {await installExtensions();}- const mainWindowState = windowStateKeeper({- defaultWidth: 1280,- defaultHeight: 800,- });+ const mainWindowState = windowStateKeeper(defaultAppSize);mainWindow = new BrowserWindow({- show: false,- x: mainWindowState.x,- y: mainWindowState.y,+ ...browserWindowOptions,width: mainWindowState.width,height: mainWindowState.height,- //icon: getAssetPath('icon.png'),- webPreferences: {- //nodeIntegrationInSubFrames: true,- //webSecurity: app.isPackaged, // todo https://www.electronjs.org/docs/latest/tutorial/security#6-do-not-disable-websecurity- spellcheck: true,- //nodeIntegration: true,- //webviewTag: true,- //contextIsolation: false,- preload:- app.isPackaged || !isDebug- ? path.join(__dirname, 'preload.js')- : path.join(__dirname, '../../.erb/dll/preload.js'),- },});+ mainWindow.setMenuBarVisibility(false);+const winUserAgent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36';const testWinOnUnix = false; // set to true to simulate windows os, useful for testing s3 handling@@ -595,7 +615,7 @@ app.on('web-contents-created', (event, contents) => {});});-startWS(isDebug ? 2000 : undefined);+startWS();let appI18N;diff --git a/src/renderer/components/CustomLogo.tsx b/src/renderer/components/CustomLogo.tsxindex 9e4c9cf23..61f9dd772 100644--- a/src/renderer/components/CustomLogo.tsx+++ b/src/renderer/components/CustomLogo.tsx@@ -47,9 +47,14 @@ function CustomLogo() {}, []);return (- <Box+ <divonClick={() => dispatch(actions.toggleAboutDialog())}- style={{ width: '100%', textAlign: 'center' }}+ style={{+ width: '100%',+ textAlign: 'center',+ // @ts-ignore+ WebkitAppRegion: 'drag',+ }}><Tooltip title={t('core:aboutTitle')}><IconButton style={{ padding: 0 }}>@@ -57,6 +62,8 @@ function CustomLogo() {style={{width: 30,height: 30,+ // @ts-ignore+ WebkitAppRegion: 'no-drag',}}src={LogoIcon}alt="TagSpaces Logo"@@ -69,7 +76,12 @@ function CustomLogo() {data-tid="aboutTagSpaces"><img- style={{ maxHeight: 26, maxWidth: 200 }}+ style={{+ maxHeight: 26,+ maxWidth: 200,+ // @ts-ignore+ WebkitAppRegion: 'no-drag',+ }}src={logo}alt="TagSpaces"/>@@ -82,6 +94,8 @@ function CustomLogo() {fontSize: '10px',marginLeft: 3,lineHeight: '40px',+ // @ts-ignore+ WebkitAppRegion: 'no-drag',}}>{'v' + versionMeta.version}@@ -94,12 +108,14 @@ function CustomLogo() {fontSize: '10px',marginLeft: -25,lineHeight: '40px',+ // @ts-ignore+ WebkitAppRegion: 'no-drag',}}>{tsType}</Typography></sub>- </Box>+ </div>);}diff --git a/src/renderer/components/FolderContainer.tsx b/src/renderer/components/FolderContainer.tsxindex fb55230cf..e33d1c112 100644--- a/src/renderer/components/FolderContainer.tsx+++ b/src/renderer/components/FolderContainer.tsx@@ -240,14 +240,17 @@ function FolderContainer(props: Props) {display: 'flex',alignItems: 'center',minHeight: 50,+ // @ts-ignore+ WebkitAppRegion: 'drag',}}><IconButtonid="mobileMenuButton"- // style={{- // transform: drawerOpened ? 'rotate(0deg)' : 'rotate(180deg)',- // width: 50- // }}+ style={{+ // @ts-ignore+ WebkitAppRegion: 'no-drag',+ // transform: drawerOpened ? 'rotate(0deg)' : 'rotate(180deg)',+ }}onClick={toggleDrawer}><MainMenuIcon />@@ -261,6 +264,10 @@ function FolderContainer(props: Props) {id="goBackButton"disabled={window.history.length < 2}onClick={goBack}+ style={{+ // @ts-ignore+ WebkitAppRegion: 'no-drag',+ }}><GoBackIcon /></IconButton>@@ -271,6 +278,10 @@ function FolderContainer(props: Props) {id="goForwardButton"disabled={window.history.length < 2}onClick={goForward}+ style={{+ // @ts-ignore+ WebkitAppRegion: 'no-drag',+ }}><GoForwardIcon /></IconButton>@@ -288,33 +299,15 @@ function FolderContainer(props: Props) {flexDirection: 'column',}}/>- {/* <MainSearchField- fullWidth- data-tid="toggleSearch"- defaultValue=""- variant="outlined"- size="small"- style={{- minWidth: 40,- width: isEntryOpened ? 40 : 220,- marginRight: 10- }}- onKeyDown={toggleSearchMode}- onClick={toggleSearchMode}- margin="dense"- placeholder={t('core:searchTitle') + openSearchKeyBinding}- InputProps={{- startAdornment: (- <InputAdornment position="start" style={{ marginRight: 0 }}>- <IconButton size="small" edge="end">- <SearchIcon />- </IconButton>- </InputAdornment>- )- }}- /> */}<Tooltip title={t('core:searchTitle') + openSearchKeyBinding}>- <IconButton data-tid="toggleSearch" onClick={openSearchMode}>+ <IconButton+ data-tid="toggleSearch"+ onClick={openSearchMode}+ style={{+ // @ts-ignore+ WebkitAppRegion: 'no-drag',+ }}+ ><SearchIcon /></IconButton></Tooltip>@@ -328,6 +321,8 @@ function FolderContainer(props: Props) {position: 'relative',padding: '8px 12px 6px 8px',margin: '0',+ // @ts-ignore+ WebkitAppRegion: 'no-drag',}}><CircularProgressWithLabel value={getProgressValue()} />diff --git a/src/renderer/components/PathBreadcrumbs.tsx b/src/renderer/components/PathBreadcrumbs.tsxindex d188016e5..d1d888918 100644--- a/src/renderer/components/PathBreadcrumbs.tsx+++ b/src/renderer/components/PathBreadcrumbs.tsx@@ -209,6 +209,8 @@ function PathBreadcrumbs(props: Props) {style={{overflowX: 'scroll',marginTop: 8,+ // @ts-ignore+ WebkitAppRegion: 'no-drag',}}maxItems={isDesktopMode ? 2 : 1}itemsAfterCollapse={isDesktopMode ? 1 : 1}diff --git a/src/renderer/components/SearchAutocomplete.tsx b/src/renderer/components/SearchAutocomplete.tsxindex c167b40d0..64ec6d673 100644--- a/src/renderer/components/SearchAutocomplete.tsx+++ b/src/renderer/components/SearchAutocomplete.tsx@@ -1245,6 +1245,8 @@ function SearchAutocomplete(props: Props) {whiteSpace: 'nowrap',display: 'flex',alignItems: 'center',+ // @ts-ignore+ WebkitAppRegion: 'no-drag',}}><style>diff --git a/src/renderer/components/SearchBox.tsx b/src/renderer/components/SearchBox.tsxindex 70ead3c3f..8103d4a27 100644--- a/src/renderer/components/SearchBox.tsx+++ b/src/renderer/components/SearchBox.tsx@@ -46,35 +46,37 @@ function SearchBox(props: Props) {setAnchorSearch={setAnchorSearch}/>{props.open && (- <>- <Popover- open={Boolean(anchorSearch)}- anchorEl={anchorSearch}- onClose={() => setAnchorSearch(null)}- anchorOrigin={{- vertical: 'bottom',- horizontal: 'right',- }}- slotProps={{- paper: {- style: {- overflow: 'hidden',- height: 720,- },+ <Popover+ open={Boolean(anchorSearch)}+ anchorEl={anchorSearch}+ onClose={() => setAnchorSearch(null)}+ anchorOrigin={{+ vertical: 'bottom',+ horizontal: 'right',+ }}+ slotProps={{+ paper: {+ style: {+ overflow: 'hidden',+ height: 720,},- }}- transformOrigin={{- vertical: 'top',- horizontal: 'right',- }}- >- <SearchPopover- onClose={() => setAnchorSearch(null)}- textQuery={textQuery}- setTextQuery={setTextQuery}- />- </Popover>- </>+ },+ }}+ transformOrigin={{+ vertical: 'top',+ horizontal: 'right',+ }}+ style={{+ // @ts-ignore+ WebkitAppRegion: 'no-drag',+ }}+ >+ <SearchPopover+ onClose={() => setAnchorSearch(null)}+ textQuery={textQuery}+ setTextQuery={setTextQuery}+ />+ </Popover>)}</>);diff --git a/src/renderer/components/SearchPopover.tsx b/src/renderer/components/SearchPopover.tsxindex 3f84f198a..0e71c26d1 100644--- a/src/renderer/components/SearchPopover.tsx+++ b/src/renderer/components/SearchPopover.tsx@@ -490,6 +490,8 @@ function SearchPopover(props: Props) {style={{maxWidth: 400,height: '100%',+ // @ts-ignore+ WebkitAppRegion: 'no-drag',}}><div className={classes.toolbar}>