react-mention-input 1.1.4 → 1.1.5
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.
- package/dist/MentionInput.js +7 -1
- package/package.json +1 -1
- package/src/MentionInput.tsx +8 -0
package/dist/MentionInput.js
CHANGED
|
@@ -146,9 +146,15 @@ var MentionInput = function (_a) {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
|
+
var handleKeyDown = function (event) {
|
|
150
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
151
|
+
event.preventDefault(); // Prevent newline in content-editable
|
|
152
|
+
handleSendMessage(); // Trigger the same function as the Send button
|
|
153
|
+
}
|
|
154
|
+
};
|
|
149
155
|
return (React.createElement("div", { className: "mention-container ".concat(containerClassName || "") },
|
|
150
156
|
React.createElement("div", { className: "mention-input-container ".concat(inputContainerClassName || "") },
|
|
151
|
-
React.createElement("div", { ref: inputRef, contentEditable: true, suppressContentEditableWarning: true, className: "mention-input ".concat(inputClassName || ""), onInput: handleInputChange }),
|
|
157
|
+
React.createElement("div", { ref: inputRef, contentEditable: true, suppressContentEditableWarning: true, className: "mention-input ".concat(inputClassName || ""), onInput: handleInputChange, onKeyDown: handleKeyDown }),
|
|
152
158
|
React.createElement("button", { onClick: handleSendMessage, className: "send-button ".concat(sendBtnClassName || "") }, sendButtonIcon || "➤")),
|
|
153
159
|
renderSuggestions()));
|
|
154
160
|
};
|
package/package.json
CHANGED
package/src/MentionInput.tsx
CHANGED
|
@@ -229,6 +229,13 @@ const MentionInput: React.FC<MentionInputProps> = ({
|
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
231
|
|
|
232
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
233
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
234
|
+
event.preventDefault(); // Prevent newline in content-editable
|
|
235
|
+
handleSendMessage(); // Trigger the same function as the Send button
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
232
239
|
|
|
233
240
|
|
|
234
241
|
return (
|
|
@@ -240,6 +247,7 @@ const MentionInput: React.FC<MentionInputProps> = ({
|
|
|
240
247
|
suppressContentEditableWarning
|
|
241
248
|
className={`mention-input ${inputClassName || ""}`}
|
|
242
249
|
onInput={handleInputChange}
|
|
250
|
+
onKeyDown={handleKeyDown} // Add keydown listener
|
|
243
251
|
></div>
|
|
244
252
|
<button
|
|
245
253
|
onClick={handleSendMessage}
|