Skip to content

The swiss army knife of lossless video/audio editing

truncate long text

Mikael Finstad25050672980c
diff --git a/src/renderer/src/components/Settings.tsx b/src/renderer/src/components/Settings.tsx
index ee25bcbf..dd51cb95 100644
--- a/src/renderer/src/components/Settings.tsx
+++ b/src/renderer/src/components/Settings.tsx
@@ -17,6 +17,7 @@ import Select from './Select';
import { getModifierKeyNames } from '../hooks/useTimelineScroll';
import { TunerType } from '../types';
+import Truncated from './Truncated';
const Row = (props: HTMLMotionProps<'tr'>) => (
@@ -185,7 +186,7 @@ function Settings({
<Button iconBefore={CogIcon} onClick={changeCustomFfPath}>
{customFfPath ? t('Using external ffmpeg') : t('Using built-in ffmpeg')}
</Button>
- <div>{customFfPath}</div>
+ <Truncated maxWidth="15em">{customFfPath}</Truncated>
</td>
</Row>
)}
@@ -237,7 +238,7 @@ function Settings({
</div>
</KeyCell>
<td>
- <div>{customOutDir}</div>
+ <Truncated maxWidth="15em">{customOutDir}</Truncated>
<Button iconBefore={customOutDir ? FolderCloseIcon : DocumentIcon} onClick={changeOutDir}>
{customOutDir ? t('Custom working directory') : t('Same directory as input file')}...
</Button>
diff --git a/src/renderer/src/components/Truncated.tsx b/src/renderer/src/components/Truncated.tsx
new file mode 100644
index 00000000..0783dfd1
--- /dev/null
+++ b/src/renderer/src/components/Truncated.tsx
@@ -0,0 +1,18 @@
+import { CSSProperties, DetailedHTMLProps, HTMLAttributes } from 'react';
+
+export default function Truncated({ maxWidth, style, ...props }: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & { maxWidth: CSSProperties['maxWidth'] }) {
+ return (
+ <div
+ title={props.title ?? (typeof props.children === 'string' ? props.children : undefined)}
+ style={{
+ maxWidth,
+ whiteSpace: 'nowrap',
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ ...style,
+ }}
+ // eslint-disable-next-line react/jsx-props-no-spreading
+ {...props}
+ />
+ );
+}