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 {