Skip to content

Commit 628ff2c

Browse files
authored
Merge pull request #134 from PasteBar/zh-CN-es-ES-uk-languages-support
Adding es-ES, uk, it and zh-CH languages support, new requested features and bug fixes
2 parents 058e310 + 0417fac commit 628ff2c

File tree

144 files changed

+9840
-3001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+9840
-3001
lines changed

.changeset/four-cameras-tease.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'pastebar-app-ui': minor
3+
---
4+
5+
Added support for zhCN Simplified Chinese language translation (thanks to @katelya77)
6+
Added support for UK Ukrainian language with auto-generated translation (seeking help to improve)
7+
Added support for esES Spanish language with auto-generated translation (seeking help to improve)
8+
Added support for IT Italian language with auto-generated translation (seeking help to improve)
9+
Added data-fn locale for each language
10+
Added global hotkeys for show/hide the main app window option
11+
Added global hotkeys for show/hide Quick Paste window near user's current cursor position
12+
Added hide the app dock icon (macOS) option
13+
Added "The app starts with main window hidden" option
14+
Added "Show navbar elements on hover only" option
15+
Added "Hide collections name on the navbar" option
16+
Added PasteBar Quick Paste window with keyboard navigation, Enter or Ctrl + [number] to paste, Ctrl + F to search
17+
Added Ctrl + click or Cmd + click to multi select/deselect history items
18+
Fixed a bug where the contact form used an invalid link on Windows (#125)
19+
Fixed a bug causing a markdown undefined error on window

.env

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
DATABASE_URL=sqlite://local.pastebar-db.data
2-
VITE_ENABLE_REACT_QUERY_DEVTOOLS=
3-
VITE_DISABLE_SAVE_TRANSLATIONS=
4-
VITE_DISABLE_LANGUAGE_FALLBACK=
52
MISSING_TRANSLATION_SAVE_PATH=../packages/pastebar-app-ui/src/locales/lang

.env.sample

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
DATABASE_URL=
2-
VITE_ENABLE_REACT_QUERY_DEVTOOLS=
3-
VITE_DISABLE_SAVE_TRANSLATIONS=
4-
VITE_DISABLE_LANGUAGE_FALLBACK=
52
MISSING_TRANSLATION_SAVE_PATH=

migrations/2023-08-05-230732_seeds/up.sql

+9
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ VALUES ('isAutoMaskWordsListEnabled', NULL, false, NULL);
7575
INSERT INTO settings (name, value_text, value_bool, value_int)
7676
VALUES ('isAutoPreviewLinkCardsEnabled', NULL, true, NULL);
7777

78+
INSERT INTO settings (name, value_text, value_bool, value_int)
79+
VALUES ('isHideMacOSDockIcon', NULL, false, NULL);
80+
81+
INSERT INTO settings (name, value_text, value_bool, value_int)
82+
VALUES ('hotKeysShowHideMainAppWindow', '', NULL, NULL);
83+
84+
INSERT INTO settings (name, value_text, value_bool, value_int)
85+
VALUES ('hotKeysShowHideQuickPasteWindow', '', NULL, NULL);
86+
7887
INSERT INTO settings (name, value_text, value_bool, value_int)
7988
VALUES ('isAutoFavoriteOnDoubleCopyEnabled', NULL, true, NULL);
8089

packages/pastebar-app-ui/.env.sample

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
VITE_ENABLE_REACT_QUERY_DEVTOOLS=
22
VITE_DISABLE_SAVE_TRANSLATIONS=
33
VITE_DISABLE_LANGUAGE_FALLBACK=
4-
VITE_ENABLE_DEV_AUTO_UPDATER=
5-
PASTEBAR_APP_PATH=../..
4+
VITE_CONTACT_SERVER_URL=https://contact.pastebar.app
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<!-- react-debugger, run on dev: npx react-devtools -->
6+
<!-- <script src="http://localhost:8097"></script> -->
7+
<link rel="preload" href="src/assets/SourceCodePro-Regular.otf.woff2" as="font" type="font/woff2" crossorigin />
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9+
<title>PasteBar App</title>
10+
</head>
11+
<body class="bg-transparent">
12+
<div id="root"></div>
13+
<script>
14+
window.isHistoryWindow = false;
15+
window.isQuickPasteWindow = true;
16+
window.isMainWindow = false;
17+
</script>
18+
<script type="module" src="src/quickpaste-main.tsx"></script>
19+
<script>
20+
function handleDrop(e) {
21+
e.preventDefault();
22+
}
23+
24+
window.addEventListener("dragover", handleDrop, false);
25+
window.addEventListener("drop", handleDrop, false);
26+
</script>
27+
</body>
28+
</html>

packages/pastebar-app-ui/src/App.tsx

+55-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useCallback, useEffect, useRef } from 'react'
22
import { useQueryClient } from '@tanstack/react-query'
33
import { listen } from '@tauri-apps/api/event'
4+
import { register, unregisterAll } from '@tauri-apps/api/globalShortcut'
45
import { type } from '@tauri-apps/api/os'
56
import { invoke } from '@tauri-apps/api/tauri'
67
import { appWindow, LogicalSize, WebviewWindow } from '@tauri-apps/api/window'
@@ -77,9 +78,7 @@ function App() {
7778
}, [isAppLocked.value])
7879

7980
useEffect(() => {
80-
const appReadyResponse = appReady()
81-
82-
appReadyResponse.then(res => {
81+
appReady().then(res => {
8382
if (res === null) return
8483

8584
try {
@@ -110,6 +109,10 @@ function App() {
110109
appDataDir: import.meta.env.TAURI_DEBUG ? appDevDataDir : appDataDir,
111110
appLastUpdateVersion: settings.appLastUpdateVersion?.valueText,
112111
appLastUpdateDate: settings.appLastUpdateDate?.valueText,
112+
isHideMacOSDockIcon: settings.isHideMacOSDockIcon?.valueBool,
113+
hotKeysShowHideMainAppWindow: settings.hotKeysShowHideMainAppWindow?.valueText,
114+
hotKeysShowHideQuickPasteWindow:
115+
settings.hotKeysShowHideQuickPasteWindow?.valueText,
113116
isFirstRun: settings.isFirstRun?.valueBool,
114117
isFirstRunAfterUpdate: settings.isFirstRunAfterUpdate?.valueBool,
115118
isHistoryDetectLanguageEnabled:
@@ -118,6 +121,8 @@ function App() {
118121
historyExclusionList: settings.historyExclusionList?.valueText,
119122
historyExclusionAppList: settings.historyExclusionAppList?.valueText,
120123
isExclusionListEnabled: settings.isExclusionListEnabled?.valueBool,
124+
isKeepMainWindowClosedOnRestartEnabled:
125+
settings.isKeepMainWindowClosedOnRestartEnabled?.valueBool,
121126
isExclusionAppListEnabled: settings.isExclusionAppListEnabled?.valueBool,
122127
isAutoMaskWordsListEnabled: settings.isAutoMaskWordsListEnabled?.valueBool,
123128
autoMaskWordsList: settings.autoMaskWordsList?.valueText,
@@ -168,6 +173,8 @@ function App() {
168173
isSearchNameOrLabelOnly: settings.isSearchNameOrLabelOnly?.valueBool,
169174
isSkipAutoStartPrompt: settings.isSkipAutoStartPrompt?.valueBool,
170175
isShowCollectionNameOnNavBar: settings.isShowCollectionNameOnNavBar?.valueBool,
176+
isHideCollectionsOnNavBar: settings.isHideCollectionsOnNavBar?.valueBool,
177+
isShowNavBarItemsOnHoverOnly: settings.isShowNavBarItemsOnHoverOnly?.valueBool,
171178
isShowDisabledCollectionsOnNavBarMenu:
172179
settings.isShowDisabledCollectionsOnNavBarMenu?.valueBool,
173180
userSelectedLanguage: settings.userSelectedLanguage?.valueText,
@@ -203,6 +210,37 @@ function App() {
203210
isAppLocked.value = true
204211
}
205212

213+
if (settings.hotKeysShowHideMainAppWindow?.valueText) {
214+
try {
215+
register(settings.hotKeysShowHideMainAppWindow?.valueText, async () => {
216+
if (document.hasFocus()) {
217+
await appWindow.hide()
218+
} else {
219+
await appWindow.show()
220+
await appWindow.setFocus()
221+
}
222+
}).catch(e => {
223+
console.error(e)
224+
})
225+
} catch (e) {
226+
console.error(e)
227+
}
228+
}
229+
230+
if (settings.hotKeysShowHideQuickPasteWindow?.valueText) {
231+
try {
232+
register(settings.hotKeysShowHideQuickPasteWindow?.valueText, async () => {
233+
await uiStore.toggleHistoryQuickPasteWindow(
234+
t('PasteBar Quick Paste', { ns: 'settings2' })
235+
)
236+
}).catch(e => {
237+
console.error(e)
238+
})
239+
} catch (e) {
240+
console.error(e)
241+
}
242+
}
243+
206244
if (
207245
!settings.appToursCompletedList?.valueText
208246
.split(',')
@@ -419,6 +457,10 @@ function App() {
419457
})
420458

421459
return () => {
460+
if (window.isMainWindow) {
461+
unregisterAll()
462+
}
463+
422464
listenToNavigateUnlisten.then(unlisten => {
423465
unlisten()
424466
})
@@ -479,11 +521,14 @@ function App() {
479521
}, [uiState.fontSize])
480522

481523
useEffect(() => {
482-
if (uiState.isSplitPanelView && window.isMainWindow) {
524+
if (uiState.isSplitPanelView && window.isMainWindow && settingsStore.isAppReady) {
483525
const openHistoryWindow = async () => {
484-
invoke('open_history_window', { width: 0 }).then(() => {
526+
invoke('open_history_window').then(() => {
485527
historyWindowOpening.value = false
486528
setTimeout(() => {
529+
if (settingsStore.isKeepMainWindowClosedOnRestartEnabled) {
530+
appWindow.hide()
531+
}
487532
historyWindow?.setFocus()
488533
}, 300)
489534
})
@@ -497,7 +542,11 @@ function App() {
497542
historyWindow?.setFocus()
498543
}, 300)
499544
}
500-
}, [uiState.isSplitPanelView])
545+
}, [
546+
uiState.isSplitPanelView,
547+
settingsStore.isAppReady,
548+
settingsStore.isKeepMainWindowClosedOnRestartEnabled,
549+
])
501550

502551
return (
503552
<>

0 commit comments

Comments
 (0)