init
This commit is contained in:
@@ -17,6 +17,14 @@ function normalizeExternalUrl(raw) {
|
|||||||
return s; // leave as-is (could be relative path on same origin)
|
return s; // leave as-is (could be relative path on same origin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extractFirstHttpUrl(text) {
|
||||||
|
if (!text) return '';
|
||||||
|
const s = String(text);
|
||||||
|
// Capture first http/https URL until whitespace or common terminators.
|
||||||
|
const m = s.match(/https?:\/\/[^\s"'<>]+/i);
|
||||||
|
return m ? m[0] : '';
|
||||||
|
}
|
||||||
|
|
||||||
export default function AiNewsPage({ onNavigate }) {
|
export default function AiNewsPage({ onNavigate }) {
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const [news, setNews] = useState([]);
|
const [news, setNews] = useState([]);
|
||||||
@@ -233,6 +241,14 @@ export default function AiNewsPage({ onNavigate }) {
|
|||||||
onChange={(e) => setNewsUrl(e.target.value)}
|
onChange={(e) => setNewsUrl(e.target.value)}
|
||||||
placeholder="뉴스 URL을 입력하세요"
|
placeholder="뉴스 URL을 입력하세요"
|
||||||
style={{ width: 'calc(100% - 25px)', marginBottom: 8, padding: '10px 12px', borderRadius: 8, border: '1px solid #ffd6c2' }}
|
style={{ width: 'calc(100% - 25px)', marginBottom: 8, padding: '10px 12px', borderRadius: 8, border: '1px solid #ffd6c2' }}
|
||||||
|
onPaste={(e) => {
|
||||||
|
const pasted = e.clipboardData?.getData('text') || '';
|
||||||
|
const url = extractFirstHttpUrl(pasted);
|
||||||
|
if (url) {
|
||||||
|
e.preventDefault();
|
||||||
|
setNewsUrl(url);
|
||||||
|
}
|
||||||
|
}}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user