react-mention-input 1.1.12 → 1.1.13
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.d.ts +3 -0
- package/dist/MentionInput.js +3 -3
- package/package.json +1 -1
- package/src/MentionInput.tsx +13 -2
package/dist/MentionInput.d.ts
CHANGED
|
@@ -13,7 +13,10 @@ interface MentionInputProps {
|
|
|
13
13
|
sendBtnClassName?: string;
|
|
14
14
|
suggestionListClassName?: string;
|
|
15
15
|
suggestionItemClassName?: string;
|
|
16
|
+
imgClassName?: string;
|
|
17
|
+
imgStyle?: React.CSSProperties;
|
|
16
18
|
sendButtonIcon?: ReactNode;
|
|
19
|
+
attachmentButtonIcon?: ReactNode;
|
|
17
20
|
onSendMessage?: (obj: {
|
|
18
21
|
messageText: string;
|
|
19
22
|
messageHTML: string;
|
package/dist/MentionInput.js
CHANGED
|
@@ -39,7 +39,7 @@ import ReactDOM from "react-dom";
|
|
|
39
39
|
import "./MentionInput.css";
|
|
40
40
|
var MentionInput = function (_a) {
|
|
41
41
|
var _b, _c;
|
|
42
|
-
var users = _a.users, _d = _a.placeholder, placeholder = _d === void 0 ? "Type a message... (or drag & drop an image)" : _d, containerClassName = _a.containerClassName, inputContainerClassName = _a.inputContainerClassName, inputClassName = _a.inputClassName, sendBtnClassName = _a.sendBtnClassName, suggestionListClassName = _a.suggestionListClassName, suggestionItemClassName = _a.suggestionItemClassName, sendButtonIcon = _a.sendButtonIcon, onSendMessage = _a.onSendMessage, _e = _a.suggestionPosition, suggestionPosition = _e === void 0 ? 'bottom' : _e, onImageUpload = _a.onImageUpload;
|
|
42
|
+
var users = _a.users, _d = _a.placeholder, placeholder = _d === void 0 ? "Type a message... (or drag & drop an image)" : _d, containerClassName = _a.containerClassName, inputContainerClassName = _a.inputContainerClassName, inputClassName = _a.inputClassName, sendBtnClassName = _a.sendBtnClassName, suggestionListClassName = _a.suggestionListClassName, suggestionItemClassName = _a.suggestionItemClassName, imgClassName = _a.imgClassName, imgStyle = _a.imgStyle, sendButtonIcon = _a.sendButtonIcon, attachmentButtonIcon = _a.attachmentButtonIcon, onSendMessage = _a.onSendMessage, _e = _a.suggestionPosition, suggestionPosition = _e === void 0 ? 'bottom' : _e, onImageUpload = _a.onImageUpload;
|
|
43
43
|
var _f = useState(""), inputValue = _f[0], setInputValue = _f[1]; // Plain text
|
|
44
44
|
var _g = useState([]), suggestions = _g[0], setSuggestions = _g[1];
|
|
45
45
|
var _h = useState(false), showSuggestions = _h[0], setShowSuggestions = _h[1];
|
|
@@ -339,14 +339,14 @@ var MentionInput = function (_a) {
|
|
|
339
339
|
console.log(inputValue, (_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.innerText.trim(), "inputValue====");
|
|
340
340
|
return (React.createElement("div", { className: "mention-container ".concat(containerClassName || "") },
|
|
341
341
|
imageUrl && selectedImage && (React.createElement("div", { className: "image-preview-card" },
|
|
342
|
-
React.createElement("img", { src: imageUrl, alt: "Preview" }),
|
|
342
|
+
React.createElement("img", { src: imageUrl, alt: "Preview", className: imgClassName || "", style: imgStyle }),
|
|
343
343
|
React.createElement("button", { onClick: removeImage, className: "remove-image-btn", "aria-label": "Remove image" }, "\u00D7"))),
|
|
344
344
|
React.createElement("div", { className: "mention-input-container ".concat(inputContainerClassName || "", " ").concat(isDraggingOver ? 'dragging-over' : ''), onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDragEnd: function () { return setIsDraggingOver(false); }, onDrop: handleDrop },
|
|
345
345
|
isDraggingOver && (React.createElement("div", { className: "drag-overlay" },
|
|
346
346
|
React.createElement("div", { className: "drag-message" },
|
|
347
347
|
React.createElement("span", null, "Drop to upload")))),
|
|
348
348
|
React.createElement("button", { onClick: function () { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, className: "attachment-button", type: "button", "aria-label": "Attach image" },
|
|
349
|
-
React.createElement("span", { className: "attachment-icon" }, "
|
|
349
|
+
React.createElement("span", { className: "attachment-icon" }, attachmentButtonIcon || "📷")),
|
|
350
350
|
React.createElement("div", { className: "mention-input-wrapper" },
|
|
351
351
|
(!inputValue || !inputRef.current || ((_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.innerText.trim()) === "") && (React.createElement("span", { className: "placeholder" }, placeholder)),
|
|
352
352
|
React.createElement("div", { ref: inputRef, contentEditable: true, suppressContentEditableWarning: true, className: "mention-input ".concat(inputClassName || ""), onInput: handleInputChange, onKeyDown: handleKeyDown, onFocus: function () { return document.execCommand('styleWithCSS', false, 'false'); } })),
|
package/package.json
CHANGED
package/src/MentionInput.tsx
CHANGED
|
@@ -16,7 +16,10 @@ interface MentionInputProps {
|
|
|
16
16
|
sendBtnClassName?: string;
|
|
17
17
|
suggestionListClassName?: string;
|
|
18
18
|
suggestionItemClassName?: string;
|
|
19
|
+
imgClassName?: string; // New prop for image CSS class
|
|
20
|
+
imgStyle?: React.CSSProperties; // New prop for inline image styles
|
|
19
21
|
sendButtonIcon?: ReactNode; // Button icon (MUI icon or image path)
|
|
22
|
+
attachmentButtonIcon?: ReactNode; // New prop for attachment button icon
|
|
20
23
|
onSendMessage?: (obj: {
|
|
21
24
|
messageText: string;
|
|
22
25
|
messageHTML: string;
|
|
@@ -38,7 +41,10 @@ const MentionInput: React.FC<MentionInputProps> = ({
|
|
|
38
41
|
sendBtnClassName,
|
|
39
42
|
suggestionListClassName,
|
|
40
43
|
suggestionItemClassName,
|
|
44
|
+
imgClassName,
|
|
45
|
+
imgStyle,
|
|
41
46
|
sendButtonIcon,
|
|
47
|
+
attachmentButtonIcon,
|
|
42
48
|
onSendMessage,
|
|
43
49
|
suggestionPosition = 'bottom',
|
|
44
50
|
onImageUpload,
|
|
@@ -390,7 +396,12 @@ const MentionInput: React.FC<MentionInputProps> = ({
|
|
|
390
396
|
<div className={`mention-container ${containerClassName || ""}`}>
|
|
391
397
|
{imageUrl && selectedImage && (
|
|
392
398
|
<div className="image-preview-card">
|
|
393
|
-
<img
|
|
399
|
+
<img
|
|
400
|
+
src={imageUrl}
|
|
401
|
+
alt="Preview"
|
|
402
|
+
className={imgClassName || ""}
|
|
403
|
+
style={imgStyle}
|
|
404
|
+
/>
|
|
394
405
|
<button onClick={removeImage} className="remove-image-btn" aria-label="Remove image">
|
|
395
406
|
×
|
|
396
407
|
</button>
|
|
@@ -418,7 +429,7 @@ const MentionInput: React.FC<MentionInputProps> = ({
|
|
|
418
429
|
type="button"
|
|
419
430
|
aria-label="Attach image"
|
|
420
431
|
>
|
|
421
|
-
<span className="attachment-icon"
|
|
432
|
+
<span className="attachment-icon">{attachmentButtonIcon || "📷"}</span>
|
|
422
433
|
</button>
|
|
423
434
|
|
|
424
435
|
<div className="mention-input-wrapper">
|