feat(paste): add large paste placeholder and fix enter-submit on macOS

- Add large paste placeholder feature: when pasting text > 1000 chars,
  show a placeholder like '[Pasted Content 1500 chars]' instead of the
  full content. The full text is stored and expanded on submit.

- Fix enter-submit on macOS: only apply recentPasteTime protection when
  pasteWorkaround is enabled (Windows or Node < 20). On macOS/Linux with
  modern Node, bracketed paste markers work reliably so the protection is
  unnecessary and caused the first Enter after paste to be ignored.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
tanzhenxin 2026-02-04 15:18:20 +08:00
parent 2ed4ae773e
commit c7b681ef5d
2 changed files with 58 additions and 6 deletions

View file

@ -60,6 +60,7 @@ export type KeypressHandler = (key: Key) => void;
interface KeypressContextValue {
subscribe: (handler: KeypressHandler) => void;
unsubscribe: (handler: KeypressHandler) => void;
pasteWorkaround: boolean;
}
const KeypressContext = createContext<KeypressContextValue | undefined>(
@ -799,7 +800,9 @@ export function KeypressProvider({
]);
return (
<KeypressContext.Provider value={{ subscribe, unsubscribe }}>
<KeypressContext.Provider
value={{ subscribe, unsubscribe, pasteWorkaround }}
>
{children}
</KeypressContext.Provider>
);