diff --git a/.changeset/auto-trim-spaces.md b/.changeset/auto-trim-spaces.md new file mode 100644 index 00000000..3905ae8d --- /dev/null +++ b/.changeset/auto-trim-spaces.md @@ -0,0 +1,6 @@ +--- +'pastebar-app-ui': patch +--- + +Added Trim Spaces option for the Clip +Added Auto Trim Spaces option for the History Capture 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/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 e9062751..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 trimmedValue: string = clipboard?.value?.trim() ?? '' + 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(trimmedValue) && + !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(trimmedValue, searchTerm) - : hyperlinkText(trimmedValue, clipboard.arrLinks)} + ? highlightWithPreviewMatchedText(textValue, searchTerm) + : hyperlinkText(textValue, clipboard.arrLinks)} ) : clipboard.isLink && clipboard.isVideo ? ( - + {searchTerm - ? highlightWithPreviewMatchedText(trimmedValue, searchTerm) - : hyperlinkText(trimmedValue, 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(trimmedValue, searchTerm) - : hyperlinkText(trimmedValue, clipboard.arrLinks)} + ? highlightMatchedText(textValue, searchTerm) + : hyperlinkText(textValue, clipboard.arrLinks)} {clipboard.valueMorePreviewChars && ( {'\u00A0'} )} @@ -625,11 +625,11 @@ export function ClipboardHistoryQuickPasteRowComponent({ ) : ( {searchTerm - ? highlightWithPreviewMatchedText(trimmedValue ?? '', 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(trimmedValue) + : isEmailNotUrl(textValue) ? 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..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 trimmedValue: string = value?.trim() + const textValue: 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: textValue }) .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 = 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(trimmedValue, 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 ? trimmedValue : valuePreview} + value={isExpanded.value ? textValue : valuePreview} language={detectedLanguage} /> @@ -368,7 +368,7 @@ export function ClipCardBody({ isShowMore={true} isWrapped={isWrapText.value} autoHideScrollbar={true} - value={trimmedValue} + value={textValue} language="shell" /> {commandRequestOutput && ( @@ -423,7 +423,7 @@ export function ClipCardBody({ isLargeView={isLargeView} isShowMore={true} isWrapped={isWrapText.value} - value={trimmedValue} + value={textValue} autoHideScrollbar={true} webRequestMethod={ isWebRequest ? webrequestLocalOptions.value.method : 'URL' @@ -503,7 +503,7 @@ export function ClipCardBody({ hasLinkCard={hasLinkCard} metadataLinkByItemId={metadataLinkByItemId} isImage={isImage} - trimmedValue={trimmedValue} + textValue={textValue} valuePreview={valuePreview} morePreviewLines={morePreviewLines} isDark={isDark} @@ -601,7 +601,7 @@ export function ClipCardBody({ ) : isMp3 ? ( {isVideo ? t('Type:::Video', { ns: 'common' }) - : isEmailNotUrl(trimmedValue) + : 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 3ecdbfb3..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 @@ -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 = itemLocalOptions.value?.autoTrimSpaces === false ? clipValue.value : clipValue.value.trim() 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..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).trim() + '...' - : value?.trim() || 'No content', + isImageData && value ? value.substring(0, 200) + '...' : value || 'No content', morePreviewLines: null, morePreviewChars: null, } @@ -208,7 +206,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,25 +215,24 @@ 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, } } 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, } 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..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 trimmedValue: string = value?.trim() + 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: trimmedValue }) + invoke('check_path', { path: textValue }) .then(() => { pathTypeCheck.value = pathType }) @@ -118,7 +118,7 @@ export function MenuCardViewBody({ } }, [isPath]) - const isEmptyBody = trimmedValue.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(trimmedValue, 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 ? trimmedValue : valuePreview} + value={isExpanded.value ? textValue : valuePreview} language={detectedLanguage} /> @@ -258,7 +258,7 @@ export function MenuCardViewBody({ isMasked={isMasked} isImage={isImage} isDark={isDark} - trimmedValue={trimmedValue} + textValue={textValue} valuePreview={valuePreview} hasLinkCard={hasLinkCard} metadataLinkByItemId={metadataLinkByItemId} @@ -413,7 +413,7 @@ export function MenuCardViewBody({ > {isVideo ? t('Type:::Video', { ns: 'common' }) - : isEmailNotUrl(trimmedValue) + : 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 e23fe2c3..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 trimmedValue: string = value?.trim() + const textValue: 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: textValue }) .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 = 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(trimmedValue, 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 ? trimmedValue : valuePreview} + value={isExpanded.value ? textValue : valuePreview} language={detectedLanguage} /> @@ -300,7 +300,7 @@ export function MenuClipCardViewBody({ isShowMore={true} isWrapped={isWrapText.value} autoHideScrollbar={true} - value={trimmedValue} + value={textValue} language="shell" /> {commandRequestOutput && ( @@ -354,7 +354,7 @@ export function MenuClipCardViewBody({ isLargeView={isLargeView} isShowMore={true} isWrapped={isWrapText.value} - value={trimmedValue} + value={textValue} autoHideScrollbar={true} webRequestMethod={ isWebRequest ? webrequestLocalOptions.value.method : 'URL' @@ -428,7 +428,7 @@ export function MenuClipCardViewBody({ isCode={isCode} isMasked={isMasked} isImage={isImage} - trimmedValue={trimmedValue} + textValue={textValue} valuePreview={valuePreview} isDark={isDark} hasLinkCard={hasLinkCard} @@ -636,7 +636,7 @@ export function MenuClipCardViewBody({ > {isVideo ? t('Type:::Video', { ns: 'common' }) - : isEmailNotUrl(trimmedValue) + : isEmailNotUrl(textValue) ? t('Type:::Email', { ns: 'common' }) : t('Type:::Link', { ns: 'common' })} 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() {