react-mention-input 1.1.8 → 1.1.9
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 +6 -5
- package/package.json +1 -1
- package/src/MentionInput.tsx +5 -1
package/dist/MentionInput.js
CHANGED
|
@@ -2,10 +2,11 @@ import React, { useState, useRef } from "react";
|
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
3
|
import "./MentionInput.css";
|
|
4
4
|
var MentionInput = function (_a) {
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var _e = useState(
|
|
8
|
-
var _f = useState(
|
|
5
|
+
var _b;
|
|
6
|
+
var users = _a.users, _c = _a.placeholder, placeholder = _c === void 0 ? "Type a message..." : _c, containerClassName = _a.containerClassName, inputContainerClassName = _a.inputContainerClassName, inputClassName = _a.inputClassName, sendBtnClassName = _a.sendBtnClassName, suggestionListClassName = _a.suggestionListClassName, suggestionItemClassName = _a.suggestionItemClassName, sendButtonIcon = _a.sendButtonIcon, onSendMessage = _a.onSendMessage, _d = _a.suggestionPosition, suggestionPosition = _d === void 0 ? 'bottom' : _d;
|
|
7
|
+
var _e = useState(""), inputValue = _e[0], setInputValue = _e[1]; // Plain text
|
|
8
|
+
var _f = useState([]), suggestions = _f[0], setSuggestions = _f[1];
|
|
9
|
+
var _g = useState(false), showSuggestions = _g[0], setShowSuggestions = _g[1];
|
|
9
10
|
var inputRef = useRef(null);
|
|
10
11
|
var suggestionListRef = useRef(null);
|
|
11
12
|
var caretOffsetRef = useRef(0);
|
|
@@ -183,7 +184,7 @@ var MentionInput = function (_a) {
|
|
|
183
184
|
};
|
|
184
185
|
return (React.createElement("div", { className: "mention-container ".concat(containerClassName || "") },
|
|
185
186
|
React.createElement("div", { className: "mention-input-container ".concat(inputContainerClassName || "") },
|
|
186
|
-
React.createElement("div", { ref: inputRef, contentEditable: true, suppressContentEditableWarning: true, className: "mention-input ".concat(inputClassName || ""), onInput: handleInputChange, onKeyDown: handleKeyDown }),
|
|
187
|
+
React.createElement("div", { ref: inputRef, contentEditable: true, suppressContentEditableWarning: true, className: "mention-input ".concat(inputClassName || ""), onInput: handleInputChange, onKeyDown: handleKeyDown }, (!inputValue || !inputRef.current || ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.innerText.trim()) === "") ? (React.createElement("span", { className: "placeholder" }, placeholder)) : null),
|
|
187
188
|
React.createElement("button", { onClick: handleSendMessage, className: "send-button ".concat(sendBtnClassName || "") }, sendButtonIcon || "➤")),
|
|
188
189
|
renderSuggestions()));
|
|
189
190
|
};
|
package/package.json
CHANGED
package/src/MentionInput.tsx
CHANGED
|
@@ -284,7 +284,11 @@ const MentionInput: React.FC<MentionInputProps> = ({
|
|
|
284
284
|
className={`mention-input ${inputClassName || ""}`}
|
|
285
285
|
onInput={handleInputChange}
|
|
286
286
|
onKeyDown={handleKeyDown} // Add keydown listener
|
|
287
|
-
|
|
287
|
+
>
|
|
288
|
+
{(!inputValue || !inputRef.current || inputRef.current?.innerText.trim() === "") ? (
|
|
289
|
+
<span className="placeholder">{placeholder}</span>
|
|
290
|
+
) : null}
|
|
291
|
+
</div>
|
|
288
292
|
<button
|
|
289
293
|
onClick={handleSendMessage}
|
|
290
294
|
className={`send-button ${sendBtnClassName || ""}`}
|