Skip to content

Commit 6c1afd5

Browse files
committed
Rename paste text callbacks to on_paste_long_text and adjust long text detection logic
- use consistent wording 'handle paste long text' - should save pasted long text if it has line breaks OR is longer than 100 characters
1 parent 9ea58ee commit 6c1afd5

6 files changed

Lines changed: 20 additions & 42 deletions

File tree

‎apps/editor/src/views/panel/frontend/Main/Main.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ type Props = {
6666
on_open_website: (url: string) => void
6767
on_paste_image: (base64_content: string) => void
6868
on_open_image: (hash: string) => void
69-
on_paste_text: (text: string) => void
69+
on_paste_long_text: (text: string) => void
7070
on_open_pasted_text: (hash: string) => void
7171
on_paste_url: (url: string) => void
7272
is_recording: boolean
@@ -710,7 +710,7 @@ export const Main: React.FC<Props> = (props) => {
710710
on_open_website={props.on_open_website}
711711
on_paste_image={props.on_paste_image}
712712
on_open_image={props.on_open_image}
713-
on_paste_text={props.on_paste_text}
713+
on_paste_long_text={props.on_paste_long_text}
714714
on_open_pasted_text={props.on_open_pasted_text}
715715
on_paste_url={props.on_paste_url}
716716
is_recording={props.is_recording}

‎apps/editor/src/views/panel/frontend/Main/MainView/MainView.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ type Props = {
109109
are_keyboard_shortcuts_disabled: boolean
110110
on_paste_image: (base64_content: string) => void
111111
on_open_image: (hash: string) => void
112-
on_paste_text: (text: string) => void
112+
on_paste_long_text: (text: string) => void
113113
on_open_pasted_text: (hash: string) => void
114114
on_paste_url: (url: string) => void
115115
is_recording: boolean
@@ -416,7 +416,7 @@ export const MainView: React.FC<Props> = (props) => {
416416
on_invocation_count_change={handle_invocation_count_change}
417417
on_paste_image={props.on_paste_image}
418418
on_open_image={props.on_open_image}
419-
on_paste_pasted_text={props.on_paste_text}
419+
on_paste_long_text={props.on_paste_long_text}
420420
on_open_pasted_text={props.on_open_pasted_text}
421421
on_paste_url={props.on_paste_url}
422422
is_recording={props.is_recording}

‎apps/editor/src/views/panel/frontend/Panel.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ export const Panel = () => {
410410
on_open_website={handle_open_website}
411411
on_paste_image={handle_paste_image}
412412
on_open_image={handle_open_image}
413-
on_paste_text={handle_paste_long_text}
413+
on_paste_long_text={handle_paste_long_text}
414414
on_open_pasted_text={handle_open_pasted_text}
415415
on_paste_url={handle_paste_url}
416416
is_recording={is_recording}

‎packages/ui/src/components/editor/panel/prompts/PromptField/PromptField.stories.tsx‎

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ export const Empty = () => (
3434
on_open_url={(url) => console.log('Open URL:', url)}
3535
on_open_website={(url) => console.log('Open website:', url)}
3636
on_paste_image={(content) => console.log('Paste image:', content)}
37-
on_paste_pasted_text={(content) =>
38-
console.log('Paste pasted text:', content)
39-
}
37+
on_paste_long_text={(content) => console.log('Paste long text:', content)}
4038
on_open_image={(hash) => console.log('Open image:', hash)}
4139
on_open_pasted_text={(hash) => console.log('Open pasted text:', hash)}
4240
on_paste_url={(url) => console.log('Paste URL:', url)}
@@ -88,9 +86,7 @@ export const WithText = () => (
8886
on_open_url={(url) => console.log('Open URL:', url)}
8987
on_open_website={(url) => console.log('Open website:', url)}
9088
on_paste_image={(content) => console.log('Paste image:', content)}
91-
on_paste_pasted_text={(content) =>
92-
console.log('Paste pasted text:', content)
93-
}
89+
on_paste_long_text={(content) => console.log('Paste long text:', content)}
9490
on_open_image={(hash) => console.log('Open image:', hash)}
9591
on_open_pasted_text={(hash) => console.log('Open pasted text:', hash)}
9692
on_paste_url={(url) => console.log('Paste URL:', url)}
@@ -142,9 +138,7 @@ export const LongText = () => (
142138
on_open_url={(url) => console.log('Open URL:', url)}
143139
on_open_website={(url) => console.log('Open website:', url)}
144140
on_paste_image={(content) => console.log('Paste image:', content)}
145-
on_paste_pasted_text={(content) =>
146-
console.log('Paste pasted text:', content)
147-
}
141+
on_paste_long_text={(content) => console.log('Paste long text:', content)}
148142
on_open_image={(hash) => console.log('Open image:', hash)}
149143
on_open_pasted_text={(hash) => console.log('Open pasted text:', hash)}
150144
on_paste_url={(url) => console.log('Paste URL:', url)}
@@ -196,9 +190,7 @@ export const WithPlaceholderSavedContext = () => (
196190
on_open_url={(url) => console.log('Open URL:', url)}
197191
on_open_website={(url) => console.log('Open website:', url)}
198192
on_paste_image={(content) => console.log('Paste image:', content)}
199-
on_paste_pasted_text={(content) =>
200-
console.log('Paste pasted text:', content)
201-
}
193+
on_paste_long_text={(content) => console.log('Paste long text:', content)}
202194
on_open_image={(hash) => console.log('Open image:', hash)}
203195
on_open_pasted_text={(hash) => console.log('Open pasted text:', hash)}
204196
on_paste_url={(url) => console.log('Paste URL:', url)}
@@ -256,9 +248,7 @@ export const WithPlaceholderSelection = () => (
256248
on_open_url={(url) => console.log('Open URL:', url)}
257249
on_open_website={(url) => console.log('Open website:', url)}
258250
on_paste_image={(content) => console.log('Paste image:', content)}
259-
on_paste_pasted_text={(content) =>
260-
console.log('Paste pasted text:', content)
261-
}
251+
on_paste_long_text={(content) => console.log('Paste long text:', content)}
262252
on_open_image={(hash) => console.log('Open image:', hash)}
263253
on_open_pasted_text={(hash) => console.log('Open pasted text:', hash)}
264254
on_paste_url={(url) => console.log('Paste URL:', url)}
@@ -310,9 +300,7 @@ export const WithCommit = () => (
310300
on_open_url={(url) => console.log('Open URL:', url)}
311301
on_open_website={(url) => console.log('Open website:', url)}
312302
on_paste_image={(content) => console.log('Paste image:', content)}
313-
on_paste_pasted_text={(content) =>
314-
console.log('Paste pasted text:', content)
315-
}
303+
on_paste_long_text={(content) => console.log('Paste long text:', content)}
316304
on_open_image={(hash) => console.log('Open image:', hash)}
317305
on_open_pasted_text={(hash) => console.log('Open pasted text:', hash)}
318306
on_paste_url={(url) => console.log('Paste URL:', url)}
@@ -364,9 +352,7 @@ export const WithCommitWithQuotes = () => (
364352
on_open_url={(url) => console.log('Open URL:', url)}
365353
on_open_website={(url) => console.log('Open website:', url)}
366354
on_paste_image={(content) => console.log('Paste image:', content)}
367-
on_paste_pasted_text={(content) =>
368-
console.log('Paste pasted text:', content)
369-
}
355+
on_paste_long_text={(content) => console.log('Paste long text:', content)}
370356
on_open_image={(hash) => console.log('Open image:', hash)}
371357
on_open_pasted_text={(hash) => console.log('Open pasted text:', hash)}
372358
on_paste_url={(url) => console.log('Paste URL:', url)}
@@ -417,9 +403,7 @@ export const WithContextAtCommit = () => (
417403
on_open_url={(url) => console.log('Open URL:', url)}
418404
on_open_website={(url) => console.log('Open website:', url)}
419405
on_paste_image={(content) => console.log('Paste image:', content)}
420-
on_paste_pasted_text={(content) =>
421-
console.log('Paste pasted text:', content)
422-
}
406+
on_paste_long_text={(content) => console.log('Paste long text:', content)}
423407
on_open_image={(hash) => console.log('Open image:', hash)}
424408
on_open_pasted_text={(hash) => console.log('Open pasted text:', hash)}
425409
on_paste_url={(url) => console.log('Paste URL:', url)}
@@ -475,9 +459,7 @@ export const WithEditFormatSelector = () => {
475459
on_open_url={(url) => console.log('Open URL:', url)}
476460
on_open_website={(url) => console.log('Open website:', url)}
477461
on_paste_image={(content) => console.log('Paste image:', content)}
478-
on_paste_pasted_text={(content) =>
479-
console.log('Paste pasted text:', content)
480-
}
462+
on_paste_long_text={(content) => console.log('Paste long text:', content)}
481463
on_open_image={(hash) => console.log('Open image:', hash)}
482464
on_open_pasted_text={(hash) => console.log('Open pasted text:', hash)}
483465
on_paste_url={(url) => console.log('Paste URL:', url)}
@@ -530,9 +512,7 @@ export const WithFilePaths = () => (
530512
on_open_url={(url) => console.log('Open URL:', url)}
531513
on_open_website={(url) => console.log('Open website:', url)}
532514
on_paste_image={(content) => console.log('Paste image:', content)}
533-
on_paste_pasted_text={(content) =>
534-
console.log('Paste pasted text:', content)
535-
}
515+
on_paste_long_text={(content) => console.log('Paste long text:', content)}
536516
on_open_image={(hash) => console.log('Open image:', hash)}
537517
on_open_pasted_text={(hash) => console.log('Open pasted text:', hash)}
538518
on_paste_url={(url) => console.log('Paste URL:', url)}
@@ -612,9 +592,7 @@ export const WithTabs = () => {
612592
on_open_url={(url) => console.log('Open URL:', url)}
613593
on_open_website={(url) => console.log('Open website:', url)}
614594
on_paste_image={(content) => console.log('Paste image:', content)}
615-
on_paste_pasted_text={(content) =>
616-
console.log('Paste pasted text:', content)
617-
}
595+
on_paste_long_text={(content) => console.log('Paste long text:', content)}
618596
on_open_image={(hash) => console.log('Open image:', hash)}
619597
on_open_pasted_text={(hash) => console.log('Open pasted text:', hash)}
620598
on_paste_url={(url) => console.log('Paste URL:', url)}
@@ -665,7 +643,7 @@ export const WithWarning = () => (
665643
on_open_url={() => {}}
666644
on_open_website={() => {}}
667645
on_paste_image={() => {}}
668-
on_paste_pasted_text={() => {}}
646+
on_paste_long_text={() => {}}
669647
on_open_image={() => {}}
670648
on_open_pasted_text={() => {}}
671649
on_paste_url={() => {}}

‎packages/ui/src/components/editor/panel/prompts/PromptField/PromptField.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export type PromptFieldProps = {
6464
on_paste_image: (base64_content: string) => void
6565
on_open_website: (url: string) => void
6666
on_open_image: (hash: string) => void
67-
on_paste_pasted_text: (text: string) => void
67+
on_paste_long_text: (text: string) => void
6868
on_open_pasted_text: (hash: string) => void
6969
on_paste_url: (url: string) => void
7070
is_recording: boolean

‎packages/ui/src/components/editor/panel/prompts/PromptField/hooks/use-handlers/handle-paste.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export const create_handle_paste =
120120

121121
if (
122122
!refs.is_shift_pressed_ref.current &&
123-
text.includes('\n') &&
123+
(text.includes('\n') || text.length > 100) &&
124124
!is_fragment_paste &&
125125
!has_symbols
126126
) {
@@ -162,7 +162,7 @@ export const create_handle_paste =
162162
refs.raw_caret_pos_ref.current = raw_start
163163
}
164164
}
165-
props.on_paste_pasted_text(text)
165+
props.on_paste_long_text(text)
166166
return
167167
}
168168

0 commit comments

Comments
 (0)