@pmate/chat-sdk 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -213,11 +213,14 @@ function DesktopInner(props) {
|
|
|
213
213
|
flexDirection: "column",
|
|
214
214
|
gap: 12,
|
|
215
215
|
}, children: [_jsx(TextComposer, { ref: textComposerRef, tokens: tokens, value: state.text, rows: 3, placeholder: "Message PMate", onPaste: handlePaste, onDrop: props.onDrop, onKeyDown: (event) => {
|
|
216
|
-
if (event.key
|
|
217
|
-
event.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
216
|
+
if (event.key !== "Enter" ||
|
|
217
|
+
event.shiftKey ||
|
|
218
|
+
event.nativeEvent.isComposing ||
|
|
219
|
+
event.keyCode === 229)
|
|
220
|
+
return;
|
|
221
|
+
event.preventDefault();
|
|
222
|
+
if (state.text.trim() || state.attachments.length > 0)
|
|
223
|
+
void onSend();
|
|
221
224
|
}, onChange: (event) => {
|
|
222
225
|
state.setText(event.target.value);
|
|
223
226
|
state.setStatus(event.target.value.trim() ? "typing" : "idle");
|
|
@@ -280,7 +283,9 @@ function DesktopInner(props) {
|
|
|
280
283
|
display: "flex",
|
|
281
284
|
alignItems: "center",
|
|
282
285
|
}, children: _jsx(TextComposer, { ref: textComposerRef, tokens: tokens, value: state.text, rows: 1, placeholder: "Message PMate", onPaste: handlePaste, onDrop: props.onDrop, onKeyDown: (event) => {
|
|
283
|
-
if (event.key !== "Enter"
|
|
286
|
+
if (event.key !== "Enter" ||
|
|
287
|
+
event.nativeEvent.isComposing ||
|
|
288
|
+
event.keyCode === 229) {
|
|
284
289
|
return;
|
|
285
290
|
}
|
|
286
291
|
const shouldSend = props.submitShortcut === "meta-enter" ? event.metaKey || event.ctrlKey : !event.shiftKey;
|
|
@@ -553,7 +553,10 @@ function MobileInner(props) {
|
|
|
553
553
|
setRecordingChoice("send");
|
|
554
554
|
voice.cancelRecording();
|
|
555
555
|
} }) })) : (_jsx(TextComposer, { ref: textComposerRef, tokens: tokens, value: state.text, rows: 1, wrap: "off", placeholder: "Message", enterKeyHint: "send", onPaste: handlePaste, onDrop: props.onDrop, onKeyDown: (event) => {
|
|
556
|
-
if (event.key === "Enter" &&
|
|
556
|
+
if (event.key === "Enter" &&
|
|
557
|
+
!event.shiftKey &&
|
|
558
|
+
!event.nativeEvent.isComposing &&
|
|
559
|
+
event.keyCode !== 229) {
|
|
557
560
|
event.preventDefault();
|
|
558
561
|
if (state.text.trim()) {
|
|
559
562
|
void onSend();
|
package/lib/types/chatInput.d.ts
CHANGED
|
@@ -141,5 +141,6 @@ export type ChatInputMobileProps = ChatInputBaseProps & {
|
|
|
141
141
|
voiceModeDefault?: ChatInputMode;
|
|
142
142
|
};
|
|
143
143
|
export type ChatInputDesktopProps = ChatInputBaseProps & {
|
|
144
|
+
/** Defaults to Enter to send and Shift+Enter to insert a newline. */
|
|
144
145
|
submitShortcut?: "enter" | "meta-enter";
|
|
145
146
|
};
|