diff --git a/src/element/stream-editor/index.tsx b/src/element/stream-editor/index.tsx
index ab8705f..733c6ea 100644
--- a/src/element/stream-editor/index.tsx
+++ b/src/element/stream-editor/index.tsx
@@ -168,17 +168,16 @@ export function StreamEditor({ ev, onFinish, options }: StreamEditorProps) {
)}
{(options?.canSetSummary ?? true) && (
}>
- setSummary(e.target.value)}
- />
+ onChange={e => setSummary(e.target.value)} />
)}
{(options?.canSetImage ?? true) && (
}>
- {image &&
}
+ {image &&
}
setImage(e.target.value)} />
setImage(v ?? "")} onError={e => setError(e.toString())} />
diff --git a/src/element/stream/summary.tsx b/src/element/stream/summary.tsx
index 7bbee79..b5e39f9 100644
--- a/src/element/stream/summary.tsx
+++ b/src/element/stream/summary.tsx
@@ -1,24 +1,38 @@
import { useState } from "react";
import { FormattedMessage } from "react-intl";
+import { Text } from "../text";
export function StreamSummary({ text }: { text: string }) {
const [expand, setExpand] = useState(false);
- const cutOff = 100;
+ const cutOff = Math.min(100, [...text].reduce((acc, v, i) => {
+ if (v === '\n' && acc[0] < 3) {
+ acc[0] += 1;
+ acc[1] = i;
+ }
+ return acc;
+ }, [0, 0])[1]);
const shouldExpand = text.length > cutOff;
return (
- {shouldExpand && !expand ? text.slice(0, cutOff) : text}
- {shouldExpand && (
+ {shouldExpand && !expand ? text.slice(0, cutOff) :
}
+ {shouldExpand && <>
{
setExpand(x => !x);
}}>
- {expand && }
+
{!expand && }
- )}
+ {expand &&
{
+ setExpand(x => !x);
+ }}>
+
+
}
+ >
+ }
);
}