From b5378f24c61fe22e940590ccd5bccb0cedde76c1 Mon Sep 17 00:00:00 2001 From: segemun Date: Thu, 16 Jan 2025 22:35:27 +0100 Subject: [PATCH 1/9] add setting for autotrimming spaces in the clip --- .../src/locales/lang/en/common.yaml | 1 + .../ClipboardHistoryQuickPasteRow.tsx | 30 +++++++-------- .../ClipboardHistory/ClipboardHistoryRow.tsx | 38 +++++++++---------- .../Dashboard/components/ClipCardBody.tsx | 28 +++++++------- .../Dashboard/components/ClipEditContent.tsx | 25 +++++++++++- .../components/Dashboard/components/utils.ts | 8 ++-- .../Menu/components/MenuCardViewBody.tsx | 20 +++++----- .../Menu/components/MenuClipCardViewBody.tsx | 24 ++++++------ src-tauri/src/clipboard/mod.rs | 7 +++- src-tauri/src/commands/clipboard_commands.rs | 15 +++++++- 10 files changed, 117 insertions(+), 79 deletions(-) diff --git a/packages/pastebar-app-ui/src/locales/lang/en/common.yaml b/packages/pastebar-app-ui/src/locales/lang/en/common.yaml index 5f08902f..6b26c1a8 100644 --- a/packages/pastebar-app-ui/src/locales/lang/en/common.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/en/common.yaml @@ -289,6 +289,7 @@ Type: Run Auto Fill: Run Auto Fill Scraper: Scraper Secret: Secret + Trim: Trim Spaces Shell Command: Shell Command Submenu: Submenu Template: Template diff --git a/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryQuickPasteRow.tsx b/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryQuickPasteRow.tsx index e9062751..09eafa49 100644 --- a/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryQuickPasteRow.tsx +++ b/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryQuickPasteRow.tsx @@ -263,7 +263,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ clipboard.isPinned, ]) - const trimmedValue: string = clipboard?.value?.trim() ?? '' + const stringValue: string = clipboard?.value ?? '' const hasLinkCard = clipboard?.isLink && clipboard?.linkMetadata?.linkTitle && @@ -277,7 +277,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ !hasLinkCard && clipboard?.isLink && clipboard?.value && - !isEmailNotUrl(trimmedValue) && + !isEmailNotUrl(stringValue) && !hasClipboardHistoryURLErrors && !hasGenerateLinkMetaDataInProgress && isAutoGenerateLinkCardsEnabled @@ -467,7 +467,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ { setBrokenImageItem(clipboard.historyId) @@ -492,7 +492,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ { @@ -508,17 +508,17 @@ export function ClipboardHistoryQuickPasteRowComponent({ {searchTerm - ? highlightWithPreviewMatchedText(trimmedValue, searchTerm) - : hyperlinkText(trimmedValue, clipboard.arrLinks)} + ? highlightWithPreviewMatchedText(stringValue, searchTerm) + : hyperlinkText(stringValue, clipboard.arrLinks)} ) : clipboard.isLink && clipboard.isVideo ? ( - + {searchTerm - ? highlightWithPreviewMatchedText(trimmedValue, searchTerm) - : hyperlinkText(trimmedValue, clipboard.arrLinks)} + ? highlightWithPreviewMatchedText(stringValue, searchTerm) + : hyperlinkText(stringValue, clipboard.arrLinks)} ) : clipboard.isImage && clipboard.imageDataUrl ? ( @@ -545,7 +545,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ > {({ className, style, tokens, getLineProps, getTokenProps }) => { @@ -616,8 +616,8 @@ export function ClipboardHistoryQuickPasteRowComponent({ {isExpanded ? ( {searchTerm - ? highlightMatchedText(trimmedValue, searchTerm) - : hyperlinkText(trimmedValue, clipboard.arrLinks)} + ? highlightMatchedText(stringValue, searchTerm) + : hyperlinkText(stringValue, clipboard.arrLinks)} {clipboard.valueMorePreviewChars && ( {'\u00A0'} )} @@ -625,7 +625,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ ) : ( {searchTerm - ? highlightWithPreviewMatchedText(trimmedValue ?? '', searchTerm) + ? highlightWithPreviewMatchedText(stringValue ?? '', searchTerm) : hyperlinkTextWithPreview({ previewLinkCard: !hasLinkCard && isLinkCardPreviewEnabled, isPreviewError: hasClipboardHistoryURLErrors, @@ -642,7 +642,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ )} {isMp3 && ( {clipboard.isVideo ? t('Type:::Video', { ns: 'common' }) - : isEmailNotUrl(trimmedValue) + : isEmailNotUrl(stringValue) ? t('Type:::Email', { ns: 'common' }) : isMp3 ? t('Type:::Mp3', { ns: 'common' }) diff --git a/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryRow.tsx b/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryRow.tsx index 42f57a6a..48f39ea5 100644 --- a/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryRow.tsx +++ b/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryRow.tsx @@ -259,8 +259,8 @@ export function ClipboardHistoryRowComponent({ clipboard.isFavorite, clipboard.isPinned, ]) - - const trimmedValue: string = clipboard?.value?.trim() ?? '' + + const stringValue: string = clipboard?.value ?? '' const hasLinkCard = clipboard?.isLink && clipboard?.linkMetadata?.linkTitle && @@ -274,7 +274,7 @@ export function ClipboardHistoryRowComponent({ !hasLinkCard && clipboard?.isLink && clipboard?.value && - !isEmailNotUrl(trimmedValue) && + !isEmailNotUrl(stringValue) && !hasClipboardHistoryURLErrors && !hasGenerateLinkMetaDataInProgress && isAutoGenerateLinkCardsEnabled @@ -435,7 +435,7 @@ export function ClipboardHistoryRowComponent({ hoveringHistoryRowId.value = null }} onDoubleClickCapture={e => { - if (!getSelectedText().text.trim()) { + if (!getSelectedText().text) { if (e.altKey || e.metaKey) { onCopyPaste(clipboard.historyId) } else { @@ -478,7 +478,7 @@ export function ClipboardHistoryRowComponent({ { setBrokenImageItem(clipboard.historyId) @@ -503,7 +503,7 @@ export function ClipboardHistoryRowComponent({ { @@ -519,17 +519,17 @@ export function ClipboardHistoryRowComponent({ {searchTerm - ? highlightWithPreviewMatchedText(trimmedValue, searchTerm) - : hyperlinkText(trimmedValue, clipboard.arrLinks)} + ? highlightWithPreviewMatchedText(stringValue, searchTerm) + : hyperlinkText(stringValue, clipboard.arrLinks)} ) : clipboard.isLink && clipboard.isVideo ? ( - + {searchTerm - ? highlightWithPreviewMatchedText(trimmedValue, searchTerm) - : hyperlinkText(trimmedValue, clipboard.arrLinks)} + ? highlightWithPreviewMatchedText(stringValue, searchTerm) + : hyperlinkText(stringValue, clipboard.arrLinks)} ) : clipboard.isImage && clipboard.imageDataUrl ? ( @@ -556,7 +556,7 @@ export function ClipboardHistoryRowComponent({ > {({ className, style, tokens, getLineProps, getTokenProps }) => { @@ -634,23 +634,23 @@ export function ClipboardHistoryRowComponent({ {isExpanded ? ( {searchTerm - ? highlightMatchedText(trimmedValue, searchTerm) - : hyperlinkText(trimmedValue, clipboard.arrLinks)} + ? highlightMatchedText(stringValue, searchTerm) + : hyperlinkText(stringValue, clipboard.arrLinks)} {clipboard.valueMorePreviewChars && ( {'\u00A0'} )} ) : ( - + {searchTerm ? highlightWithPreviewMatchedText( - trimmedValue ?? '', + stringValue ?? '', searchTerm ) : hyperlinkTextWithPreview({ previewLinkCard: !hasLinkCard && isLinkCardPreviewEnabled, isPreviewError: hasClipboardHistoryURLErrors, - value: clipboard.valuePreview?.trim() ?? '', + value: clipboard.valuePreview ?? '', links: clipboard.arrLinks, itemId: null, historyId: clipboard.historyId, @@ -663,7 +663,7 @@ export function ClipboardHistoryRowComponent({ )} {isMp3 && ( {clipboard.isVideo ? t('Type:::Video', { ns: 'common' }) - : isEmailNotUrl(trimmedValue) + : isEmailNotUrl(stringValue) ? t('Type:::Email', { ns: 'common' }) : isMp3 ? t('Type:::Mp3', { ns: 'common' }) diff --git a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipCardBody.tsx b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipCardBody.tsx index 9209cc79..77685d7f 100644 --- a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipCardBody.tsx +++ b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipCardBody.tsx @@ -163,7 +163,7 @@ export function ClipCardBody({ } }, [requestOptions]) - const trimmedValue: string = value?.trim() + const stringValue: string = value || ''; useEffect(() => { if (isExpanded.value) { @@ -173,7 +173,7 @@ export function ClipCardBody({ useEffect(() => { if (isPath) { - invoke('check_path', { path: trimmedValue }) + invoke('check_path', { path: stringValue }) .then(() => { pathTypeCheck.value = pathType }) @@ -190,8 +190,8 @@ export function ClipCardBody({ }, [searchTerm]) const imageMaxHeight = isLargeView ? 'max-h-[600px]' : 'max-h-[300px]' - const isEmptyBody = trimmedValue.length === 0 - const isMp3 = isLink && trimmedValue?.endsWith('.mp3') + const isEmptyBody = stringValue.length === 0 + const isMp3 = isLink && stringValue?.endsWith('.mp3') useEffect(() => { if (isShowLinkedClip) { @@ -225,7 +225,7 @@ export function ClipCardBody({ )} {({ className, style, tokens, getLineProps, getTokenProps }) => { @@ -270,7 +270,7 @@ export function ClipCardBody({ { isBrokenImage.value = true @@ -286,7 +286,7 @@ export function ClipCardBody({ { isBrokenImage.value = true @@ -296,7 +296,7 @@ export function ClipCardBody({ className={`${imageMaxHeight} min-h-10`} /> - {hyperlinkText(trimmedValue, arrLinks)} + {hyperlinkText(stringValue, arrLinks)} ) : isImage ? ( @@ -354,7 +354,7 @@ export function ClipCardBody({ isLargeView={isLargeView} isShowMore={isExpanded.value || morePreviewLines == null} isWrapped={isWrapText.value} - value={isExpanded.value ? trimmedValue : valuePreview} + value={isExpanded.value ? stringValue : valuePreview} language={detectedLanguage} /> @@ -368,7 +368,7 @@ export function ClipCardBody({ isShowMore={true} isWrapped={isWrapText.value} autoHideScrollbar={true} - value={trimmedValue} + value={stringValue} language="shell" /> {commandRequestOutput && ( @@ -423,7 +423,7 @@ export function ClipCardBody({ isLargeView={isLargeView} isShowMore={true} isWrapped={isWrapText.value} - value={trimmedValue} + value={stringValue} autoHideScrollbar={true} webRequestMethod={ isWebRequest ? webrequestLocalOptions.value.method : 'URL' @@ -503,7 +503,7 @@ export function ClipCardBody({ hasLinkCard={hasLinkCard} metadataLinkByItemId={metadataLinkByItemId} isImage={isImage} - trimmedValue={trimmedValue} + trimmedValue={stringValue} valuePreview={valuePreview} morePreviewLines={morePreviewLines} isDark={isDark} @@ -601,7 +601,7 @@ export function ClipCardBody({ ) : isMp3 ? ( {isVideo ? t('Type:::Video', { ns: 'common' }) - : isEmailNotUrl(trimmedValue) + : isEmailNotUrl(stringValue) ? t('Type:::Email', { ns: 'common' }) : isMp3 ? t('Type:::Mp3', { ns: 'common' }) diff --git a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipEditContent.tsx b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipEditContent.tsx index 3ecdbfb3..c32ba014 100644 --- a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipEditContent.tsx +++ b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipEditContent.tsx @@ -175,7 +175,10 @@ export function ClipEditContent({ const itemLocalOptions = useSignal<{ noLinkCard?: boolean | undefined pressKeysAfterPaste?: string | undefined - }>({}) + autoTrimSpaces?: boolean | undefined + }>({ + autoTrimSpaces: true, + }) const webrequestLocalOptions = useSignal({ method: 'GET', headers: [], @@ -475,7 +478,7 @@ export function ClipEditContent({ showPathValidationError.value = undefined webrequestTestOutputObject.value = {} - const saveValue = clipValue.value.trim() + const saveValue = clipValue.value if (!force) { if (isTemplate) { @@ -1957,6 +1960,24 @@ export function ClipEditContent({ )} + + { + e.preventDefault() + itemLocalOptions.value = { + ...itemLocalOptions.value, + autoTrimSpaces: !itemLocalOptions.value.autoTrimSpaces, + } + }} + > + {t('Type:::Trim', { ns: 'common' })} + {itemLocalOptions.value.autoTrimSpaces && ( +
+ +
+ )} +
diff --git a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/utils.ts b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/utils.ts index fa482068..c8d4504d 100644 --- a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/utils.ts +++ b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/utils.ts @@ -191,8 +191,8 @@ export function getValuePreview( return { valuePreview: isImageData && value - ? value.substring(0, 200).trim() + '...' - : value?.trim() || 'No content', + ? value.substring(0, 200) + '...' + : 'No content', morePreviewLines: null, morePreviewChars: null, } @@ -208,7 +208,7 @@ export function getValuePreview( const morePreviewLines = normalizedValue.split('\n').length - 5 return { - valuePreview: bbCode.closeTags(previewLines.trim()), + valuePreview: bbCode.closeTags(previewLines), morePreviewLines: morePreviewLines > 0 ? morePreviewLines : null, morePreviewChars: !morePreviewLines ? normalizedValue.length - 160 : null, } @@ -217,7 +217,7 @@ export function getValuePreview( const morePreviewChars = normalizedValue.length - 60 return { - valuePreview: bbCode.closeTags(normalizedValue.substring(0, 60).trim()) + '...', + valuePreview: bbCode.closeTags(normalizedValue.substring(0, 60)) + '...', morePreviewLines: null, morePreviewChars: morePreviewChars > 0 ? morePreviewChars : null, } diff --git a/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuCardViewBody.tsx b/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuCardViewBody.tsx index fd929b56..2a7afbdc 100644 --- a/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuCardViewBody.tsx +++ b/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuCardViewBody.tsx @@ -91,7 +91,7 @@ export function MenuCardViewBody({ const isWrapText = useSignal(false) const { valuePreview, morePreviewLines, morePreviewChars } = getValuePreview(value) - const trimmedValue: string = value?.trim() + const stringValue: string = value || ''; const isBrokenImage = useSignal(false) const pathTypeCheck = useSignal('') @@ -108,7 +108,7 @@ export function MenuCardViewBody({ useEffect(() => { if (isPath) { - invoke('check_path', { path: trimmedValue }) + invoke('check_path', { path: stringValue }) .then(() => { pathTypeCheck.value = pathType }) @@ -118,7 +118,7 @@ export function MenuCardViewBody({ } }, [isPath]) - const isEmptyBody = trimmedValue.length === 0 + const isEmptyBody = stringValue.length === 0 return ( {({ className, style, tokens, getLineProps, getTokenProps }) => { @@ -176,7 +176,7 @@ export function MenuCardViewBody({ { isBrokenImage.value = true @@ -192,7 +192,7 @@ export function MenuCardViewBody({ { isBrokenImage.value = true @@ -202,7 +202,7 @@ export function MenuCardViewBody({ className="max-h-[200px] min-h-10" /> - {hyperlinkText(trimmedValue, arrLinks ?? '')} + {hyperlinkText(stringValue, arrLinks ?? '')} ) : isImage ? ( @@ -238,7 +238,7 @@ export function MenuCardViewBody({ isLargeView={false} isShowMore={isExpanded.value || morePreviewLines == null} isWrapped={isWrapText.value} - value={isExpanded.value ? trimmedValue : valuePreview} + value={isExpanded.value ? stringValue : valuePreview} language={detectedLanguage} /> @@ -258,7 +258,7 @@ export function MenuCardViewBody({ isMasked={isMasked} isImage={isImage} isDark={isDark} - trimmedValue={trimmedValue} + trimmedValue={stringValue} valuePreview={valuePreview} hasLinkCard={hasLinkCard} metadataLinkByItemId={metadataLinkByItemId} @@ -413,7 +413,7 @@ export function MenuCardViewBody({ > {isVideo ? t('Type:::Video', { ns: 'common' }) - : isEmailNotUrl(trimmedValue) + : isEmailNotUrl(stringValue) ? t('Type:::Email', { ns: 'common' }) : t('Type:::Link', { ns: 'common' })} diff --git a/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuClipCardViewBody.tsx b/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuClipCardViewBody.tsx index e23fe2c3..86ec11bf 100644 --- a/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuClipCardViewBody.tsx +++ b/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuClipCardViewBody.tsx @@ -147,7 +147,7 @@ export function MenuClipCardViewBody({ } }, [requestOptions]) - const trimmedValue: string = value?.trim() + const stringValue: string = value || '' useEffect(() => { if (isExpanded.value) { @@ -157,7 +157,7 @@ export function MenuClipCardViewBody({ useEffect(() => { if (isPath) { - invoke('check_path', { path: trimmedValue }) + invoke('check_path', { path: stringValue }) .then(() => { pathTypeCheck.value = pathType }) @@ -168,7 +168,7 @@ export function MenuClipCardViewBody({ }, [isPath]) const imageMaxHeight = isLargeView ? 'max-h-[600px]' : 'max-h-[300px]' - const isEmptyBody = trimmedValue.length === 0 + const isEmptyBody = stringValue.length === 0 return ( {({ className, style, tokens, getLineProps, getTokenProps }) => { @@ -226,7 +226,7 @@ export function MenuClipCardViewBody({ { isBrokenImage.value = true @@ -242,7 +242,7 @@ export function MenuClipCardViewBody({ { isBrokenImage.value = true @@ -252,7 +252,7 @@ export function MenuClipCardViewBody({ className={`${imageMaxHeight} min-h-10`} /> - {hyperlinkText(trimmedValue, arrLinks)} + {hyperlinkText(stringValue, arrLinks)} ) : isImage ? ( @@ -287,7 +287,7 @@ export function MenuClipCardViewBody({ isLargeView={isLargeView} isShowMore={isExpanded.value || morePreviewLines == null} isWrapped={isWrapText.value} - value={isExpanded.value ? trimmedValue : valuePreview} + value={isExpanded.value ? stringValue : valuePreview} language={detectedLanguage} /> @@ -300,7 +300,7 @@ export function MenuClipCardViewBody({ isShowMore={true} isWrapped={isWrapText.value} autoHideScrollbar={true} - value={trimmedValue} + value={stringValue} language="shell" /> {commandRequestOutput && ( @@ -354,7 +354,7 @@ export function MenuClipCardViewBody({ isLargeView={isLargeView} isShowMore={true} isWrapped={isWrapText.value} - value={trimmedValue} + value={stringValue} autoHideScrollbar={true} webRequestMethod={ isWebRequest ? webrequestLocalOptions.value.method : 'URL' @@ -428,7 +428,7 @@ export function MenuClipCardViewBody({ isCode={isCode} isMasked={isMasked} isImage={isImage} - trimmedValue={trimmedValue} + trimmedValue={stringValue} valuePreview={valuePreview} isDark={isDark} hasLinkCard={hasLinkCard} @@ -636,7 +636,7 @@ export function MenuClipCardViewBody({ > {isVideo ? t('Type:::Video', { ns: 'common' }) - : isEmailNotUrl(trimmedValue) + : isEmailNotUrl(stringValue) ? t('Type:::Email', { ns: 'common' }) : t('Type:::Link', { ns: 'common' })} diff --git a/src-tauri/src/clipboard/mod.rs b/src-tauri/src/clipboard/mod.rs index 683eb14d..47591fc1 100644 --- a/src-tauri/src/clipboard/mod.rs +++ b/src-tauri/src/clipboard/mod.rs @@ -99,9 +99,12 @@ where Ok(active_window) => Some(active_window.app_name), Err(()) => None, }; - if let Ok(mut text) = clipboard_text { - text = text.trim().to_string(); + text = text.to_string(); + + if copied_from_app.as_deref() != Some("PasteBar") { + text = text.trim().to_string(); + } if !text.is_empty() { let mut is_excluded = false; diff --git a/src-tauri/src/commands/clipboard_commands.rs b/src-tauri/src/commands/clipboard_commands.rs index 93230358..6378eb1c 100644 --- a/src-tauri/src/commands/clipboard_commands.rs +++ b/src-tauri/src/commands/clipboard_commands.rs @@ -40,6 +40,7 @@ pub enum ClipFormKeyPress { pub struct ItemField { pub press_keys_after_paste: Option, pub no_link_card: Option, + pub auto_trim_spaces: Option, } #[derive(Debug, Serialize, Deserialize)] @@ -197,7 +198,7 @@ pub async fn copy_clip_item( copy_from_menu: bool, ) -> String { // Fetch the item from the database - let item = match get_item_by_id(item_id.clone()) { + let mut item = match get_item_by_id(item_id.clone()) { Ok(i) => i, Err(e) => { eprintln!("Failed to find item: {}", e); @@ -206,6 +207,18 @@ pub async fn copy_clip_item( }; let mut manager = app_handle.clipboard_manager(); + dbg!(&item); + + let mut auto_trim_spaces = true; + if let Some(item_options) = item.item_options { + if let Ok(item_field) = serde_json::from_str::(&item_options) { + auto_trim_spaces = item_field.auto_trim_spaces.unwrap_or(true); + } + } + + if (auto_trim_spaces) { + item.value = item.value.map(|v| v.trim().to_string()); + } if let (Some(true), true) = (item.is_link, copy_from_menu) { match &item.value { From d96aab3e7b5f0baedb14cbdea9e1d0ea8b3e2bca Mon Sep 17 00:00:00 2001 From: segemun Date: Thu, 16 Jan 2025 22:37:21 +0100 Subject: [PATCH 2/9] remove dbg fn --- src-tauri/src/commands/clipboard_commands.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src-tauri/src/commands/clipboard_commands.rs b/src-tauri/src/commands/clipboard_commands.rs index 6378eb1c..925583a7 100644 --- a/src-tauri/src/commands/clipboard_commands.rs +++ b/src-tauri/src/commands/clipboard_commands.rs @@ -207,8 +207,6 @@ pub async fn copy_clip_item( }; let mut manager = app_handle.clipboard_manager(); - dbg!(&item); - let mut auto_trim_spaces = true; if let Some(item_options) = item.item_options { if let Ok(item_field) = serde_json::from_str::(&item_options) { From 6e105deb07455275471817e32f1abcef800d3042 Mon Sep 17 00:00:00 2001 From: segemun Date: Thu, 16 Jan 2025 22:43:37 +0100 Subject: [PATCH 3/9] add langs for auto trim spaces --- packages/pastebar-app-ui/src/locales/lang/esES/common.yaml | 1 + packages/pastebar-app-ui/src/locales/lang/fr/common.yaml | 1 + packages/pastebar-app-ui/src/locales/lang/it/common.yaml | 1 + packages/pastebar-app-ui/src/locales/lang/ru/common.yaml | 1 + packages/pastebar-app-ui/src/locales/lang/tr/common.yaml | 1 + packages/pastebar-app-ui/src/locales/lang/uk/common.yaml | 1 + packages/pastebar-app-ui/src/locales/lang/zhCN/common.yaml | 1 + 7 files changed, 7 insertions(+) diff --git a/packages/pastebar-app-ui/src/locales/lang/esES/common.yaml b/packages/pastebar-app-ui/src/locales/lang/esES/common.yaml index 839349ac..8e339eba 100644 --- a/packages/pastebar-app-ui/src/locales/lang/esES/common.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/esES/common.yaml @@ -289,6 +289,7 @@ Type: Run Auto Fill: Ejecutar Autocompletar Scraper: Extractor Secret: Secreto + Trim: Recortar Espacios Shell Command: Comando Shell Submenu: Submenú Template: Plantilla diff --git a/packages/pastebar-app-ui/src/locales/lang/fr/common.yaml b/packages/pastebar-app-ui/src/locales/lang/fr/common.yaml index 1bfb5849..432f5119 100644 --- a/packages/pastebar-app-ui/src/locales/lang/fr/common.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/fr/common.yaml @@ -289,6 +289,7 @@ Type: Run Auto Fill: Exécuter le remplissage automatique Scraper: Extracteur Secret: Secret + Trim: Supprimer les espaces Shell Command: Commande Shell Submenu: Sous-menu Template: Modèle diff --git a/packages/pastebar-app-ui/src/locales/lang/it/common.yaml b/packages/pastebar-app-ui/src/locales/lang/it/common.yaml index b28e93b1..be6ee2c1 100644 --- a/packages/pastebar-app-ui/src/locales/lang/it/common.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/it/common.yaml @@ -290,6 +290,7 @@ Type: Run Auto Fill: Esegui Compilazione Automatica Scraper: Scraper Secret: Segreto + Trim: Rimuovi Spazi Shell Command: Comando Shell Template: Modello Template Fill: Compilazione Modello diff --git a/packages/pastebar-app-ui/src/locales/lang/ru/common.yaml b/packages/pastebar-app-ui/src/locales/lang/ru/common.yaml index 58e4b0ef..8af236ed 100644 --- a/packages/pastebar-app-ui/src/locales/lang/ru/common.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/ru/common.yaml @@ -290,6 +290,7 @@ Type: Run Auto Fill: Запустить автозаполнение Scraper: Скрапер Secret: Секрет + Trim: Обрезать пробелы Shell Command: Команда оболочки Template: Шаблон Template Fill: Заполнение шаблона diff --git a/packages/pastebar-app-ui/src/locales/lang/tr/common.yaml b/packages/pastebar-app-ui/src/locales/lang/tr/common.yaml index dcc86280..c1affdc2 100644 --- a/packages/pastebar-app-ui/src/locales/lang/tr/common.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/tr/common.yaml @@ -288,6 +288,7 @@ Type: Run Auto Fill: Otomatik Doldurmayı Çalıştır Scraper: Kazıyıcı Secret: Gizli + Trim: Boşlukları Kırp Shell Command: Kabuk Komutu Submenu: Alt menü Template: Şablon diff --git a/packages/pastebar-app-ui/src/locales/lang/uk/common.yaml b/packages/pastebar-app-ui/src/locales/lang/uk/common.yaml index e86cabac..c13bf390 100644 --- a/packages/pastebar-app-ui/src/locales/lang/uk/common.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/uk/common.yaml @@ -290,6 +290,7 @@ Type: Run Auto Fill: Запустити автозаповнення Scraper: Скрапер Secret: Секрет + Trim: Обрізати пробіли Shell Command: Команда оболонки Template: Шаблон Template Fill: Заповнення шаблону diff --git a/packages/pastebar-app-ui/src/locales/lang/zhCN/common.yaml b/packages/pastebar-app-ui/src/locales/lang/zhCN/common.yaml index d8cb7ec3..92b7c765 100644 --- a/packages/pastebar-app-ui/src/locales/lang/zhCN/common.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/zhCN/common.yaml @@ -287,6 +287,7 @@ Type: Run Auto Fill: 运行自动填充 Scraper: 抓取器 Secret: 密钥 + Trim: 修剪空格 Shell Command: Shell 命令 Submenu: 子菜单 Template: 模板 From a8e3fc88e09c5d3f162d0ba8c21f49e717406d87 Mon Sep 17 00:00:00 2001 From: segemun Date: Thu, 16 Jan 2025 22:47:27 +0100 Subject: [PATCH 4/9] add changeset --- .changeset/auto-trim-spaces.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/auto-trim-spaces.md diff --git a/.changeset/auto-trim-spaces.md b/.changeset/auto-trim-spaces.md new file mode 100644 index 00000000..50c84ad3 --- /dev/null +++ b/.changeset/auto-trim-spaces.md @@ -0,0 +1,5 @@ +--- +'pastebar-app-ui': patch +--- + +Added Trim Spaces option for the Clip From c8ad61176afb575681165a44b2feea1b7a93cac1 Mon Sep 17 00:00:00 2001 From: segemun Date: Sat, 18 Jan 2025 19:07:05 +0100 Subject: [PATCH 5/9] auto trim spaces in the clip on save --- .../components/card-value-viewer/index.tsx | 14 ++++---- .../ClipboardHistoryLargeView.tsx | 22 ++++++------- .../ClipboardHistoryQuickPasteRow.tsx | 32 +++++++++---------- .../Dashboard/components/ClipCardBody.tsx | 28 ++++++++-------- .../Dashboard/components/ClipEditContent.tsx | 2 +- .../Menu/components/MenuCardViewBody.tsx | 20 ++++++------ .../Menu/components/MenuClipCardViewBody.tsx | 24 +++++++------- src-tauri/src/clipboard/mod.rs | 5 --- src-tauri/src/commands/clipboard_commands.rs | 13 +------- 9 files changed, 72 insertions(+), 88 deletions(-) diff --git a/packages/pastebar-app-ui/src/components/card-value-viewer/index.tsx b/packages/pastebar-app-ui/src/components/card-value-viewer/index.tsx index bd07e934..0557c754 100644 --- a/packages/pastebar-app-ui/src/components/card-value-viewer/index.tsx +++ b/packages/pastebar-app-ui/src/components/card-value-viewer/index.tsx @@ -118,7 +118,7 @@ interface CardValueViewerProps { isExpanded: boolean searchTerm: string isDark: boolean - trimmedValue: string + textValue: string } export const CardValueViewer: FC = ({ @@ -133,7 +133,7 @@ export const CardValueViewer: FC = ({ isVideo, isMasked, isLargeView, - trimmedValue, + textValue, hasLinkCard, metadataLinkByItemId, metadataLinkImageWidth = 24, @@ -161,12 +161,12 @@ export const CardValueViewer: FC = ({ }, [valuePreview]) const valueParsed = useMemo(() => { - if (!isImageData && !isCode && !isImage && trimmedValue) { + if (!isImageData && !isCode && !isImage && textValue) { return isMasked - ? maskValue(bbCode.remove(trimmedValue)) - : bbCode.parse(trimmedValue) + ? maskValue(bbCode.remove(textValue)) + : bbCode.parse(textValue) } - }, [trimmedValue]) + }, [textValue]) const highlightedContent = useMemo(() => { if (searchTerm.length > 1) { @@ -222,7 +222,7 @@ export const CardValueViewer: FC = ({ (null) const contextMenuTriggerRef = useRef(null) - const trimmedValue: string = clipboard?.value?.trim() ?? '' + const textValue: string = clipboard?.value ?? '' const hasLinkCard = clipboard?.isLink && clipboard?.linkMetadata?.linkTitle && @@ -138,7 +138,7 @@ export function ClipboardHistoryLargeViewComponent({ {searchTerm - ? highlightMatchedText(trimmedValue, searchTerm) - : hyperlinkText(trimmedValue, clipboard.arrLinks)} + ? highlightMatchedText(textValue, searchTerm) + : hyperlinkText(textValue, clipboard.arrLinks)} ) : clipboard.isImage && clipboard.imagePathFullRes ? ( @@ -194,7 +194,7 @@ export function ClipboardHistoryLargeViewComponent({ > {({ className, style, tokens, getLineProps, getTokenProps }) => { @@ -255,10 +255,10 @@ export function ClipboardHistoryLargeViewComponent({ key={clipboard.historyId} > {clipboard.isVideo ? ( - + ) : isSocialEmbed ? ( {searchTerm - ? highlightMatchedText(trimmedValue, searchTerm) - : hyperlinkText(trimmedValue, clipboard.arrLinks)} + ? highlightMatchedText(textValue, searchTerm) + : hyperlinkText(textValue, clipboard.arrLinks)} {clipboard.valueMorePreviewChars && ( {'\u00A0'} )} diff --git a/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryQuickPasteRow.tsx b/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryQuickPasteRow.tsx index 09eafa49..11454897 100644 --- a/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryQuickPasteRow.tsx +++ b/packages/pastebar-app-ui/src/pages/components/ClipboardHistory/ClipboardHistoryQuickPasteRow.tsx @@ -263,7 +263,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ clipboard.isPinned, ]) - const stringValue: string = clipboard?.value ?? '' + const textValue: string = clipboard?.value ?? '' const hasLinkCard = clipboard?.isLink && clipboard?.linkMetadata?.linkTitle && @@ -277,7 +277,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ !hasLinkCard && clipboard?.isLink && clipboard?.value && - !isEmailNotUrl(stringValue) && + !isEmailNotUrl(textValue) && !hasClipboardHistoryURLErrors && !hasGenerateLinkMetaDataInProgress && isAutoGenerateLinkCardsEnabled @@ -467,7 +467,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ { setBrokenImageItem(clipboard.historyId) @@ -492,7 +492,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ { @@ -508,17 +508,17 @@ export function ClipboardHistoryQuickPasteRowComponent({ {searchTerm - ? highlightWithPreviewMatchedText(stringValue, searchTerm) - : hyperlinkText(stringValue, clipboard.arrLinks)} + ? highlightWithPreviewMatchedText(textValue, searchTerm) + : hyperlinkText(textValue, clipboard.arrLinks)} ) : clipboard.isLink && clipboard.isVideo ? ( - + {searchTerm - ? highlightWithPreviewMatchedText(stringValue, searchTerm) - : hyperlinkText(stringValue, clipboard.arrLinks)} + ? highlightWithPreviewMatchedText(textValue, searchTerm) + : hyperlinkText(textValue, clipboard.arrLinks)} ) : clipboard.isImage && clipboard.imageDataUrl ? ( @@ -545,7 +545,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ > {({ className, style, tokens, getLineProps, getTokenProps }) => { @@ -616,8 +616,8 @@ export function ClipboardHistoryQuickPasteRowComponent({ {isExpanded ? ( {searchTerm - ? highlightMatchedText(stringValue, searchTerm) - : hyperlinkText(stringValue, clipboard.arrLinks)} + ? highlightMatchedText(textValue, searchTerm) + : hyperlinkText(textValue, clipboard.arrLinks)} {clipboard.valueMorePreviewChars && ( {'\u00A0'} )} @@ -625,11 +625,11 @@ export function ClipboardHistoryQuickPasteRowComponent({ ) : ( {searchTerm - ? highlightWithPreviewMatchedText(stringValue ?? '', searchTerm) + ? highlightWithPreviewMatchedText(textValue ?? '', searchTerm) : hyperlinkTextWithPreview({ previewLinkCard: !hasLinkCard && isLinkCardPreviewEnabled, isPreviewError: hasClipboardHistoryURLErrors, - value: clipboard.valuePreview?.trim() ?? '', + value: clipboard.valuePreview ?? '', links: clipboard.arrLinks, itemId: null, historyId: clipboard.historyId, @@ -642,7 +642,7 @@ export function ClipboardHistoryQuickPasteRowComponent({ )} {isMp3 && ( {clipboard.isVideo ? t('Type:::Video', { ns: 'common' }) - : isEmailNotUrl(stringValue) + : isEmailNotUrl(textValue) ? t('Type:::Email', { ns: 'common' }) : isMp3 ? t('Type:::Mp3', { ns: 'common' }) diff --git a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipCardBody.tsx b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipCardBody.tsx index 77685d7f..647c76b9 100644 --- a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipCardBody.tsx +++ b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipCardBody.tsx @@ -163,7 +163,7 @@ export function ClipCardBody({ } }, [requestOptions]) - const stringValue: string = value || ''; + const textValue: string = value || ''; useEffect(() => { if (isExpanded.value) { @@ -173,7 +173,7 @@ export function ClipCardBody({ useEffect(() => { if (isPath) { - invoke('check_path', { path: stringValue }) + invoke('check_path', { path: textValue }) .then(() => { pathTypeCheck.value = pathType }) @@ -190,8 +190,8 @@ export function ClipCardBody({ }, [searchTerm]) const imageMaxHeight = isLargeView ? 'max-h-[600px]' : 'max-h-[300px]' - const isEmptyBody = stringValue.length === 0 - const isMp3 = isLink && stringValue?.endsWith('.mp3') + const isEmptyBody = textValue.length === 0 + const isMp3 = isLink && textValue?.endsWith('.mp3') useEffect(() => { if (isShowLinkedClip) { @@ -225,7 +225,7 @@ export function ClipCardBody({ )} {({ className, style, tokens, getLineProps, getTokenProps }) => { @@ -270,7 +270,7 @@ export function ClipCardBody({ { isBrokenImage.value = true @@ -286,7 +286,7 @@ export function ClipCardBody({ { isBrokenImage.value = true @@ -296,7 +296,7 @@ export function ClipCardBody({ className={`${imageMaxHeight} min-h-10`} /> - {hyperlinkText(stringValue, arrLinks)} + {hyperlinkText(textValue, arrLinks)} ) : isImage ? ( @@ -354,7 +354,7 @@ export function ClipCardBody({ isLargeView={isLargeView} isShowMore={isExpanded.value || morePreviewLines == null} isWrapped={isWrapText.value} - value={isExpanded.value ? stringValue : valuePreview} + value={isExpanded.value ? textValue : valuePreview} language={detectedLanguage} /> @@ -368,7 +368,7 @@ export function ClipCardBody({ isShowMore={true} isWrapped={isWrapText.value} autoHideScrollbar={true} - value={stringValue} + value={textValue} language="shell" /> {commandRequestOutput && ( @@ -423,7 +423,7 @@ export function ClipCardBody({ isLargeView={isLargeView} isShowMore={true} isWrapped={isWrapText.value} - value={stringValue} + value={textValue} autoHideScrollbar={true} webRequestMethod={ isWebRequest ? webrequestLocalOptions.value.method : 'URL' @@ -503,7 +503,7 @@ export function ClipCardBody({ hasLinkCard={hasLinkCard} metadataLinkByItemId={metadataLinkByItemId} isImage={isImage} - trimmedValue={stringValue} + textValue={textValue} valuePreview={valuePreview} morePreviewLines={morePreviewLines} isDark={isDark} @@ -601,7 +601,7 @@ export function ClipCardBody({ ) : isMp3 ? ( {isVideo ? t('Type:::Video', { ns: 'common' }) - : isEmailNotUrl(stringValue) + : isEmailNotUrl(textValue) ? t('Type:::Email', { ns: 'common' }) : isMp3 ? t('Type:::Mp3', { ns: 'common' }) diff --git a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipEditContent.tsx b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipEditContent.tsx index c32ba014..724b660f 100644 --- a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipEditContent.tsx +++ b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/ClipEditContent.tsx @@ -478,7 +478,7 @@ export function ClipEditContent({ showPathValidationError.value = undefined webrequestTestOutputObject.value = {} - const saveValue = clipValue.value + const saveValue = itemLocalOptions.value?.autoTrimSpaces === false ? clipValue.value : clipValue.value.trim() if (!force) { if (isTemplate) { diff --git a/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuCardViewBody.tsx b/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuCardViewBody.tsx index 2a7afbdc..f623293d 100644 --- a/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuCardViewBody.tsx +++ b/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuCardViewBody.tsx @@ -91,7 +91,7 @@ export function MenuCardViewBody({ const isWrapText = useSignal(false) const { valuePreview, morePreviewLines, morePreviewChars } = getValuePreview(value) - const stringValue: string = value || ''; + const textValue: string = value || ''; const isBrokenImage = useSignal(false) const pathTypeCheck = useSignal('') @@ -108,7 +108,7 @@ export function MenuCardViewBody({ useEffect(() => { if (isPath) { - invoke('check_path', { path: stringValue }) + invoke('check_path', { path: textValue }) .then(() => { pathTypeCheck.value = pathType }) @@ -118,7 +118,7 @@ export function MenuCardViewBody({ } }, [isPath]) - const isEmptyBody = stringValue.length === 0 + const isEmptyBody = textValue.length === 0 return ( {({ className, style, tokens, getLineProps, getTokenProps }) => { @@ -176,7 +176,7 @@ export function MenuCardViewBody({ { isBrokenImage.value = true @@ -192,7 +192,7 @@ export function MenuCardViewBody({ { isBrokenImage.value = true @@ -202,7 +202,7 @@ export function MenuCardViewBody({ className="max-h-[200px] min-h-10" /> - {hyperlinkText(stringValue, arrLinks ?? '')} + {hyperlinkText(textValue, arrLinks ?? '')} ) : isImage ? ( @@ -238,7 +238,7 @@ export function MenuCardViewBody({ isLargeView={false} isShowMore={isExpanded.value || morePreviewLines == null} isWrapped={isWrapText.value} - value={isExpanded.value ? stringValue : valuePreview} + value={isExpanded.value ? textValue : valuePreview} language={detectedLanguage} /> @@ -258,7 +258,7 @@ export function MenuCardViewBody({ isMasked={isMasked} isImage={isImage} isDark={isDark} - trimmedValue={stringValue} + textValue={textValue} valuePreview={valuePreview} hasLinkCard={hasLinkCard} metadataLinkByItemId={metadataLinkByItemId} @@ -413,7 +413,7 @@ export function MenuCardViewBody({ > {isVideo ? t('Type:::Video', { ns: 'common' }) - : isEmailNotUrl(stringValue) + : isEmailNotUrl(textValue) ? t('Type:::Email', { ns: 'common' }) : t('Type:::Link', { ns: 'common' })} diff --git a/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuClipCardViewBody.tsx b/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuClipCardViewBody.tsx index 86ec11bf..8d896c7f 100644 --- a/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuClipCardViewBody.tsx +++ b/packages/pastebar-app-ui/src/pages/components/Menu/components/MenuClipCardViewBody.tsx @@ -147,7 +147,7 @@ export function MenuClipCardViewBody({ } }, [requestOptions]) - const stringValue: string = value || '' + const textValue: string = value || '' useEffect(() => { if (isExpanded.value) { @@ -157,7 +157,7 @@ export function MenuClipCardViewBody({ useEffect(() => { if (isPath) { - invoke('check_path', { path: stringValue }) + invoke('check_path', { path: textValue }) .then(() => { pathTypeCheck.value = pathType }) @@ -168,7 +168,7 @@ export function MenuClipCardViewBody({ }, [isPath]) const imageMaxHeight = isLargeView ? 'max-h-[600px]' : 'max-h-[300px]' - const isEmptyBody = stringValue.length === 0 + const isEmptyBody = textValue.length === 0 return ( {({ className, style, tokens, getLineProps, getTokenProps }) => { @@ -226,7 +226,7 @@ export function MenuClipCardViewBody({ { isBrokenImage.value = true @@ -242,7 +242,7 @@ export function MenuClipCardViewBody({ { isBrokenImage.value = true @@ -252,7 +252,7 @@ export function MenuClipCardViewBody({ className={`${imageMaxHeight} min-h-10`} /> - {hyperlinkText(stringValue, arrLinks)} + {hyperlinkText(textValue, arrLinks)} ) : isImage ? ( @@ -287,7 +287,7 @@ export function MenuClipCardViewBody({ isLargeView={isLargeView} isShowMore={isExpanded.value || morePreviewLines == null} isWrapped={isWrapText.value} - value={isExpanded.value ? stringValue : valuePreview} + value={isExpanded.value ? textValue : valuePreview} language={detectedLanguage} /> @@ -300,7 +300,7 @@ export function MenuClipCardViewBody({ isShowMore={true} isWrapped={isWrapText.value} autoHideScrollbar={true} - value={stringValue} + value={textValue} language="shell" /> {commandRequestOutput && ( @@ -354,7 +354,7 @@ export function MenuClipCardViewBody({ isLargeView={isLargeView} isShowMore={true} isWrapped={isWrapText.value} - value={stringValue} + value={textValue} autoHideScrollbar={true} webRequestMethod={ isWebRequest ? webrequestLocalOptions.value.method : 'URL' @@ -428,7 +428,7 @@ export function MenuClipCardViewBody({ isCode={isCode} isMasked={isMasked} isImage={isImage} - trimmedValue={stringValue} + textValue={textValue} valuePreview={valuePreview} isDark={isDark} hasLinkCard={hasLinkCard} @@ -636,7 +636,7 @@ export function MenuClipCardViewBody({ > {isVideo ? t('Type:::Video', { ns: 'common' }) - : isEmailNotUrl(stringValue) + : isEmailNotUrl(textValue) ? t('Type:::Email', { ns: 'common' }) : t('Type:::Link', { ns: 'common' })} diff --git a/src-tauri/src/clipboard/mod.rs b/src-tauri/src/clipboard/mod.rs index 47591fc1..9eb7f2df 100644 --- a/src-tauri/src/clipboard/mod.rs +++ b/src-tauri/src/clipboard/mod.rs @@ -100,11 +100,6 @@ where Err(()) => None, }; if let Ok(mut text) = clipboard_text { - text = text.to_string(); - - if copied_from_app.as_deref() != Some("PasteBar") { - text = text.trim().to_string(); - } if !text.is_empty() { let mut is_excluded = false; diff --git a/src-tauri/src/commands/clipboard_commands.rs b/src-tauri/src/commands/clipboard_commands.rs index 925583a7..93230358 100644 --- a/src-tauri/src/commands/clipboard_commands.rs +++ b/src-tauri/src/commands/clipboard_commands.rs @@ -40,7 +40,6 @@ pub enum ClipFormKeyPress { pub struct ItemField { pub press_keys_after_paste: Option, pub no_link_card: Option, - pub auto_trim_spaces: Option, } #[derive(Debug, Serialize, Deserialize)] @@ -198,7 +197,7 @@ pub async fn copy_clip_item( copy_from_menu: bool, ) -> String { // Fetch the item from the database - let mut item = match get_item_by_id(item_id.clone()) { + let item = match get_item_by_id(item_id.clone()) { Ok(i) => i, Err(e) => { eprintln!("Failed to find item: {}", e); @@ -207,16 +206,6 @@ pub async fn copy_clip_item( }; let mut manager = app_handle.clipboard_manager(); - let mut auto_trim_spaces = true; - if let Some(item_options) = item.item_options { - if let Ok(item_field) = serde_json::from_str::(&item_options) { - auto_trim_spaces = item_field.auto_trim_spaces.unwrap_or(true); - } - } - - if (auto_trim_spaces) { - item.value = item.value.map(|v| v.trim().to_string()); - } if let (Some(true), true) = (item.is_link, copy_from_menu) { match &item.value { From f4928f463aad9e519f875d59fe6fec9dc901a5f5 Mon Sep 17 00:00:00 2001 From: segemun Date: Sat, 18 Jan 2025 19:54:36 +0100 Subject: [PATCH 6/9] fix getValuePreview function --- .../src/pages/components/Dashboard/components/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/utils.ts b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/utils.ts index c8d4504d..0ef9441a 100644 --- a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/utils.ts +++ b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/utils.ts @@ -192,7 +192,7 @@ export function getValuePreview( valuePreview: isImageData && value ? value.substring(0, 200) + '...' - : 'No content', + : value || 'No content', morePreviewLines: null, morePreviewChars: null, } From 1fa0a9c7dd50c78faec7eb70cf7139358b8457b0 Mon Sep 17 00:00:00 2001 From: Sergey Kurdin Date: Sat, 18 Jan 2025 14:27:21 -0500 Subject: [PATCH 7/9] removed trim for clip preview --- .../pages/components/Dashboard/components/utils.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/utils.ts b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/utils.ts index 0ef9441a..00f5b6c2 100644 --- a/packages/pastebar-app-ui/src/pages/components/Dashboard/components/utils.ts +++ b/packages/pastebar-app-ui/src/pages/components/Dashboard/components/utils.ts @@ -190,9 +190,7 @@ export function getValuePreview( if (!value || isLargeView) { return { valuePreview: - isImageData && value - ? value.substring(0, 200) + '...' - : value || 'No content', + isImageData && value ? value.substring(0, 200) + '...' : value || 'No content', morePreviewLines: null, morePreviewChars: null, } @@ -222,20 +220,19 @@ export function getValuePreview( morePreviewChars: morePreviewChars > 0 ? morePreviewChars : null, } } else { - const preview = normalizedValue.trim() - const previewLines = preview.split('\n') + const previewLines = normalizedValue.split('\n') const morePreviewLines = normalizedValue.split('\n').length - previewLines.length if (isImageData) { return { - valuePreview: preview.substring(0, 60) + '...', + valuePreview: normalizedValue.substring(0, 60) + '...', morePreviewLines: null, morePreviewChars: null, } } return { - valuePreview: preview, + valuePreview: normalizedValue, morePreviewLines: morePreviewLines > 0 ? morePreviewLines : null, morePreviewChars: null, } From 07665a81a543822528262504d0e933fdbc104951 Mon Sep 17 00:00:00 2001 From: Sergey Kurdin Date: Sat, 18 Jan 2025 18:32:05 -0500 Subject: [PATCH 8/9] update to add an option to trim spaces on history capture --- migrations/2023-08-05-230732_seeds/up.sql | 3 ++ packages/pastebar-app-ui/src/App.tsx | 2 + .../pastebar-app-ui/src/QuickPasteApp.tsx | 4 ++ .../src/locales/lang/en/settings.yaml | 2 + .../src/locales/lang/esES/settings.yaml | 2 + .../src/locales/lang/fr/settings.yaml | 2 + .../src/locales/lang/it/settings.yaml | 2 + .../src/locales/lang/ru/settings.yaml | 2 + .../src/locales/lang/tr/settings.yaml | 2 + .../src/locales/lang/uk/settings.yaml | 2 + .../src/locales/lang/zhCN/settings.yaml | 2 + .../settings/ClipboardHistorySettings.tsx | 43 +++++++++++++++++-- .../src/store/settingsStore.ts | 14 ++++++ src-tauri/src/clipboard/mod.rs | 8 ++++ 14 files changed, 86 insertions(+), 4 deletions(-) diff --git a/migrations/2023-08-05-230732_seeds/up.sql b/migrations/2023-08-05-230732_seeds/up.sql index 8a1c1809..aaa83dd5 100644 --- a/migrations/2023-08-05-230732_seeds/up.sql +++ b/migrations/2023-08-05-230732_seeds/up.sql @@ -30,6 +30,9 @@ VALUES ('isHistoryEnabled', NULL, true, NULL); INSERT INTO settings (name, value_text, value_bool, value_int) VALUES ('isHistoryAutoUpdateOnCaputureEnabled', NULL, true, NULL); +INSERT INTO settings (name, value_text, value_bool, value_int) +VALUES ('isHistoryAutoTrimOnCaputureEnabled', NULL, true, NULL); + INSERT INTO settings (name, value_text, value_bool, value_int) VALUES ('isHistoryDetectLanguageEnabled', NULL, true, NULL); diff --git a/packages/pastebar-app-ui/src/App.tsx b/packages/pastebar-app-ui/src/App.tsx index 5ac5e5c1..25c6bb17 100644 --- a/packages/pastebar-app-ui/src/App.tsx +++ b/packages/pastebar-app-ui/src/App.tsx @@ -132,6 +132,8 @@ function App() { settings.historyDetectLanguagesEnabledList?.valueText.split(','), appToursCompletedList: settings.appToursCompletedList?.valueText.split(','), appToursSkippedList: settings.appToursSkippedList?.valueText.split(','), + isHistoryAutoTrimOnCaputureEnabled: + settings.isHistoryAutoTrimOnCaputureEnabled?.valueBool, isHistoryAutoUpdateOnCaputureEnabled: settings.isHistoryAutoUpdateOnCaputureEnabled?.valueBool, isHistoryEnabled: settings.isHistoryEnabled?.valueBool, diff --git a/packages/pastebar-app-ui/src/QuickPasteApp.tsx b/packages/pastebar-app-ui/src/QuickPasteApp.tsx index ad815867..4cacbb19 100644 --- a/packages/pastebar-app-ui/src/QuickPasteApp.tsx +++ b/packages/pastebar-app-ui/src/QuickPasteApp.tsx @@ -72,6 +72,8 @@ function QuickPasteApp() { settings.historyDetectLanguagesEnabledList?.valueText.split(','), appToursCompletedList: settings.appToursCompletedList?.valueText.split(','), appToursSkippedList: settings.appToursSkippedList?.valueText.split(','), + isHistoryAutoTrimOnCaputureEnabled: + settings.isHistoryAutoTrimOnCaputureEnabled?.valueBool, isHistoryAutoUpdateOnCaputureEnabled: settings.isHistoryAutoUpdateOnCaputureEnabled?.valueBool, isHistoryEnabled: settings.isHistoryEnabled?.valueBool, @@ -118,6 +120,8 @@ function QuickPasteApp() { isShowDisabledCollectionsOnNavBarMenu: settings.isShowDisabledCollectionsOnNavBarMenu?.valueBool, userSelectedLanguage: settings.userSelectedLanguage?.valueText, + clipTextMinLength: settings.clipTextMinLength?.valueInt, + clipTextMaxLength: settings.clipTextMaxLength?.valueInt, isAppReady: true, }) diff --git a/packages/pastebar-app-ui/src/locales/lang/en/settings.yaml b/packages/pastebar-app-ui/src/locales/lang/en/settings.yaml index 9358160f..f28bc7c7 100644 --- a/packages/pastebar-app-ui/src/locales/lang/en/settings.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/en/settings.yaml @@ -22,6 +22,7 @@ Auto-Clear Settings: Auto-Clear Settings Auto-Generate Link Card Preview: Auto-Generate Link Card Preview Auto-Preview Link on Hover: Auto-Preview Link on Hover Auto-Star on Double Copy: Auto-Star on Double Copy +Auto-Trim Spaces on Capture: Auto-Trim Spaces on Capture Auto-Update on Capture: Auto-Update on Capture Auto-delete clipboard history after: Auto-delete clipboard history after ? Automatically create link card preview in the clipboard history. This allows to quickly view website details without opening or pasting the link. @@ -58,6 +59,7 @@ Enable Clip Title Hover Show with Delay: Enable Clip Title Hover Show with Delay Enable application auto start on system boot: Enable application auto start on system boot Enable auto lock the application screen after a certain period of inactivity, to prevent unauthorized access to your data.: Enable auto lock the application screen after a certain period of inactivity, to prevent unauthorized access to your data. Enable auto lock the application screen when user not active: Enable auto lock the application screen when user not active +Enable auto trim spaces on history capture: Enable auto trim spaces on history capture Enable auto update on capture: Enable auto update on capture Enable history capture: Enable history capture Enable programming language detection: Enable programming language detection diff --git a/packages/pastebar-app-ui/src/locales/lang/esES/settings.yaml b/packages/pastebar-app-ui/src/locales/lang/esES/settings.yaml index 7e69157a..b0535957 100644 --- a/packages/pastebar-app-ui/src/locales/lang/esES/settings.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/esES/settings.yaml @@ -22,6 +22,7 @@ Auto-Clear Settings: Ajustes de Borrado Automático Auto-Generate Link Card Preview: Generar Auto Vista Previa de Tarjeta de Enlace Auto-Preview Link on Hover: Vista Previa Auto de Enlace al Pasar Auto-Star on Double Copy: Estrella Auto al Copiar Dos Veces +Auto-Trim Spaces on Capture: Recortar espacios automáticamente al capturar Auto-Update on Capture: Actualización Auto al Capturar Auto-delete clipboard history after: Borrar auto el historial después de ? Automatically create link card preview in the clipboard history. This allows to quickly view website details without opening or pasting the link. @@ -58,6 +59,7 @@ Enable Clip Title Hover Show with Delay: Habilitar Mostrar Título del Clip al P Enable application auto start on system boot: Habilitar inicio automático de la aplicación al arrancar el sistema Enable auto lock the application screen after a certain period of inactivity, to prevent unauthorized access to your data.: Habilita el bloqueo automático de la pantalla después de un período de inactividad para prevenir acceso no autorizado a tus datos. Enable auto lock the application screen when user not active: Habilitar bloqueo automático de la pantalla cuando el usuario no está activo +Enable auto trim spaces on history capture: Activar recorte automático de espacios al capturar el historial Enable auto update on capture: Habilitar actualización automática al capturar Enable history capture: Habilitar captura de historial Enable programming language detection: Habilitar detección de lenguaje de programación diff --git a/packages/pastebar-app-ui/src/locales/lang/fr/settings.yaml b/packages/pastebar-app-ui/src/locales/lang/fr/settings.yaml index 9720a7db..e01c6fa7 100644 --- a/packages/pastebar-app-ui/src/locales/lang/fr/settings.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/fr/settings.yaml @@ -22,6 +22,7 @@ Auto-Clear Settings: Paramètres d'auto-nettoyage Auto-Generate Link Card Preview: Génération automatique d'un aperçu de la carte de lien Auto-Preview Link on Hover: Lien de prévisualisation automatique au survol Auto-Star on Double Copy: Étoile automatique en cas double copie +Auto-Trim Spaces on Capture: Suppression automatique des espaces à la capture Auto-Update on Capture: Mise à jour automatique à la capture Auto-delete clipboard history after: Suppression automatique de l'historique du presse-papiers après ? Automatically create link card preview in the clipboard history. This allows to quickly view website details without opening or pasting the link. @@ -58,6 +59,7 @@ Enable Clip Title Hover Show with Delay: Activer l'affichage du titre du clip au Enable application auto start on system boot: Activer démarrage auto de l'app au démarrage système Enable auto lock the application screen after a certain period of inactivity, to prevent unauthorized access to your data.: Activez le verrouillage automatique de l'écran de l'application après une certaine période d'inactivité, afin d'empêcher tout accès non autorisé à vos données. Enable auto lock the application screen when user not active: Activer le verrouillage automatique de l'écran de l'application lorsque l'utilisateur n'est pas actif +Enable auto trim spaces on history capture: Activer la suppression automatique des espaces lors de la capture de l'historique Enable auto update on capture: Activer la mise à jour automatique lors de la capture Enable history capture: Activer la capture de l'historique Enable programming language detection: Activer la détection du langage de programmation diff --git a/packages/pastebar-app-ui/src/locales/lang/it/settings.yaml b/packages/pastebar-app-ui/src/locales/lang/it/settings.yaml index d00d8da6..5b11033c 100644 --- a/packages/pastebar-app-ui/src/locales/lang/it/settings.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/it/settings.yaml @@ -22,6 +22,7 @@ Auto-Generate Link Card Preview: Genera Automaticamente l'Anteprima della Scheda Auto-Preview Link on Hover: Anteprima Automatica del Link al Passaggio del Mouse Auto-Star on Double Copy: Stella Automatica al Doppio Copia Auto-Update on Capture: Aggiornamento Automatico alla Cattura +Auto-Trim Spaces on Capture: Rimozione automatica degli spazi alla cattura Auto-delete clipboard history after: Elimina automaticamente la cronologia degli appunti dopo ? Automatically create link card preview in the clipboard history. This allows to quickly view website details without opening or pasting the link. : Crea automaticamente l'anteprima della scheda link nella cronologia degli appunti. Questo permette di visualizzare rapidamente i dettagli del sito web senza aprire o incollare il link. @@ -57,6 +58,7 @@ Enable Clip Title Hover Show with Delay: Abilita Visualizzazione del Titolo del Enable application auto start on system boot: Abilita l'avvio automatico dell'applicazione all'avvio del sistema Enable auto lock the application screen after a certain period of inactivity, to prevent unauthorized access to your data.: Abilita il blocco automatico dello schermo dell'applicazione dopo un certo periodo di inattività, per prevenire l'accesso non autorizzato ai tuoi dati. Enable auto lock the application screen when user not active: Abilita il blocco automatico dello schermo dell'applicazione quando l'utente non è attivo +Enable auto trim spaces on history capture: Attiva la rimozione automatica degli spazi durante la cattura della cronologia Enable auto update on capture: Abilita l'aggiornamento automatico alla cattura Enable history capture: Abilita la cattura della cronologia Enable programming language detection: Abilita il rilevamento del linguaggio di programmazione diff --git a/packages/pastebar-app-ui/src/locales/lang/ru/settings.yaml b/packages/pastebar-app-ui/src/locales/lang/ru/settings.yaml index 4c6baf68..477894a4 100644 --- a/packages/pastebar-app-ui/src/locales/lang/ru/settings.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/ru/settings.yaml @@ -22,6 +22,7 @@ Auto-Preview Link on Hover: Автоматический предварител Auto-Star on Double Copy: Автоматическое добавление в избранное при двойном копировании Auto-Update on Capture: Автоматическое обновление при захвате Auto-delete clipboard history after: Автоматическое удаление истории буфера обмена после +Auto-Trim Spaces on Capture: Автоматическое удаление пробелов при захвате ? Automatically create link card preview in the clipboard history. This allows to quickly view website details without opening or pasting the link. : Автоматически создавать предварительный просмотр ссылок в истории буфера обмена. Это позволяет быстро просматривать детали веб-сайтов без открытия или вставки ссылки. ? Automatically create link preview in the clipboard history. This allows to quickly view website details without opening or pasting the link. @@ -58,6 +59,7 @@ Enable Clip Title Hover Show with Delay: Включить задержку по Enable application auto start on system boot: Включить автозапуск приложения при загрузке системы Enable auto lock the application screen after a certain period of inactivity, to prevent unauthorized access to your data.: Включить автоматическую блокировку экрана приложения после определенного периода бездействия, чтобы предотвратить несанкционированный доступ к вашим данным. Enable auto update on capture: Включить автоматическое обновление при захвате +Enable auto trim spaces on history capture: Включить автоматическое удаление пробелов при захвате истории буфера Enable history capture: Включить захват истории буфера Enable programming language detection: Включить определение языка программирования Enable screen unlock requirement on app launch for enhanced security, safeguarding data from unauthorized access.: Включить требование разблокировки экрана при запуске приложения для повышения безопасности, защиты данных от несанкционированного доступа. diff --git a/packages/pastebar-app-ui/src/locales/lang/tr/settings.yaml b/packages/pastebar-app-ui/src/locales/lang/tr/settings.yaml index d5eea1be..f37eb147 100644 --- a/packages/pastebar-app-ui/src/locales/lang/tr/settings.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/tr/settings.yaml @@ -23,6 +23,7 @@ Auto-Generate Link Card Preview: Otomatik Bağlantı Kartı Önizlemesi Oluştur Auto-Preview Link on Hover: Üzerine gelindiğinde Bağlantıyı Otomatik Önizleme Auto-Star on Double Copy: Çift Kopyalamada Otomatik Favorile Auto-Update on Capture: Yakalamada Otomatik Güncelleme +Auto-Trim Spaces on Capture: Yakalamada Otomatik Boşluk Kaldırma Auto-delete clipboard history after: Panonun geçmişini otomatik olarak sil ? Automatically create link card preview in the clipboard history. This allows to quickly view website details without opening or pasting the link. : Bağlantı kartı önizlemesini pano geçmişinde otomatik olarak oluşturun. Bu, bağlantıyı açmadan veya yapıştırmadan web sitesi ayrıntılarını hızlı bir şekilde görüntülemenizi sağlar. @@ -59,6 +60,7 @@ Enable application auto start on system boot: Sistem açıldığında uygulaman Enable auto lock the application screen after a certain period of inactivity, to prevent unauthorized access to your data.: Verilerinize yetkisiz erişimi önlemek için, belirli bir süre hareketsizlikten sonra uygulama ekranının otomatik olarak kilitlenmesini etkinleştirin. Enable auto lock the application screen when user not active: Kullanıcı aktif olmadığında uygulama ekranının otomatik olarak kilitlenmesini etkinleştirin Enable auto update on capture: Yakalama sırasında otomatik güncellemeyi etkinleştir +Enable auto trim spaces on history capture: Geçmiş yakalamada otomatik boşluk kırpmayı etkinleştir Enable history capture: Geçmiş yakalamayı etkinleştir Enable programming language detection: Programlama dili algılamayı etkinleştir Enable screen unlock requirement on app launch for enhanced security, safeguarding data from unauthorized access.: Gelişmiş güvenlik için uygulama başlatıldığında ekran kilidi açma gereksinimini etkinleştirin ve verileri yetkisiz erişime karşı koruyun. diff --git a/packages/pastebar-app-ui/src/locales/lang/uk/settings.yaml b/packages/pastebar-app-ui/src/locales/lang/uk/settings.yaml index 213d2abe..1b1abd21 100644 --- a/packages/pastebar-app-ui/src/locales/lang/uk/settings.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/uk/settings.yaml @@ -22,6 +22,7 @@ Auto-Preview Link on Hover: Автоматичний попередній пер Auto-Star on Double Copy: Автоматичне додавання до вибраного при подвійному копіюванні Auto-Update on Capture: Автоматичне оновлення при захопленні Auto-delete clipboard history after: Автоматичне видалення історії буфера обміну після +Auto-Trim Spaces on Capture: Автоматичне видалення пробілів при захопленні ? Automatically create link card preview in the clipboard history. This allows to quickly view website details without opening or pasting the link. : Автоматично створювати попередній перегляд посилань в історії буфера обміну. Це дозволяє швидко переглядати деталі веб-сайтів без відкриття або вставки посилання. ? Automatically create link preview in the clipboard history. This allows to quickly view website details without opening or pasting the link. @@ -58,6 +59,7 @@ Enable Clip Title Hover Show with Delay: Увімкнути затримку п Enable application auto start on system boot: Увімкнути автозапуск додатку при завантаженні системи Enable auto lock the application screen after a certain period of inactivity, to prevent unauthorized access to your data.: Увімкнути автоматичне блокування екрану додатку після певного періоду бездіяльності, щоб запобігти несанкціонованому доступу до ваших даних. Enable auto update on capture: Увімкнути автоматичне оновлення при захопленні +Enable auto trim spaces on history capture: Увімкнути автоматичне видалення пробілів при захопленні історії буфера Enable history capture: Увімкнути захоплення історії буфера Enable programming language detection: Увімкнути визначення мови програмування Enable screen unlock requirement on app launch for enhanced security, safeguarding data from unauthorized access.: Увімкнути вимогу розблокування екрану при запуску додатку для підвищення безпеки, захисту даних від несанкціонованого доступу. diff --git a/packages/pastebar-app-ui/src/locales/lang/zhCN/settings.yaml b/packages/pastebar-app-ui/src/locales/lang/zhCN/settings.yaml index 2d6396ae..297eb6a3 100644 --- a/packages/pastebar-app-ui/src/locales/lang/zhCN/settings.yaml +++ b/packages/pastebar-app-ui/src/locales/lang/zhCN/settings.yaml @@ -23,6 +23,7 @@ Auto-Generate Link Card Preview: 自动生成链接卡片预览 Auto-Preview Link on Hover: 悬停时自动预览链接 Auto-Star on Double Copy: 双重复制时自动星标 Auto-Update on Capture: 捕获时自动更新 +Auto-Trim Spaces on Capture: 捕获时自动删除空格 Auto-delete clipboard history after: 自动删除剪贴板历史时间 ? Automatically create link card preview in the clipboard history. This allows to quickly view website details without opening or pasting the link. : 在剪贴板历史中自动创建链接卡片预览。这允许快速查看网站详情,无需打开或粘贴链接。 @@ -59,6 +60,7 @@ Enable application auto start on system boot: 启用系统启动时应用程序 Enable auto lock the application screen after a certain period of inactivity, to prevent unauthorized access to your data.: 启用在一定时间不活动后自动锁定应用程序屏幕,以防止未经授权访问您的数据。 Enable auto lock the application screen when user not active: 用户不活动时启用自动锁定应用程序屏幕 Enable auto update on capture: 启用捕获时自动更新 +Enable auto trim spaces on history capture: 启用历史记录捕获时自动修剪空格 Enable history capture: 启用历史捕获 Enable programming language detection: 启用编程语言检测 Enable screen unlock requirement on app launch for enhanced security, safeguarding data from unauthorized access.: 启用应用启动时的屏幕解锁要求,以增强安全性,保护数据免受未授权访问。 diff --git a/packages/pastebar-app-ui/src/pages/settings/ClipboardHistorySettings.tsx b/packages/pastebar-app-ui/src/pages/settings/ClipboardHistorySettings.tsx index eb2f20e1..2d52c6d8 100644 --- a/packages/pastebar-app-ui/src/pages/settings/ClipboardHistorySettings.tsx +++ b/packages/pastebar-app-ui/src/pages/settings/ClipboardHistorySettings.tsx @@ -88,6 +88,8 @@ export default function ClipboardHistorySettings() { setClipTextMaxLength, setIsHistoryEnabled, isHistoryAutoUpdateOnCaputureEnabled, + setIsHistoryAutoTrimOnCaputureEnabled, + isHistoryAutoTrimOnCaputureEnabled, setIsHistoryAutoUpdateOnCaputureEnabled, setIsExclusionListEnabled, setIsExclusionAppListEnabled, @@ -300,11 +302,10 @@ export default function ClipboardHistorySettings() { onChange={e => { const value = e.target.value if (value === '') { - setClipTextMinLength(0); + setClipTextMinLength(0) } else { const number = parseInt(value) setClipTextMinLength(number) - } }} /> @@ -324,7 +325,7 @@ export default function ClipboardHistorySettings() { onChange={e => { const value = e.target.value if (value === '') { - setClipTextMaxLength(0); + setClipTextMaxLength(0) } else { const number = parseInt(value) setClipTextMaxLength(number) @@ -335,7 +336,9 @@ export default function ClipboardHistorySettings() {