react-input-emoji 5.3.1 → 5.5.1

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/README.md CHANGED
@@ -64,6 +64,7 @@ export default function Example() {
64
64
  | `fontFamily` | string | "sans-serif" | The font family of the placeholder and input container. |
65
65
  | `shouldReturn` | boolean | - | Allows the user to use the `Shift + Enter` or `Ctrl + Enter` keyboard shortcut to create a new line. | |
66
66
  | `buttonElement` | HTMLElement | - | An HTMLElement that, when clicked, triggers the emoji picker. If this prop is provided, the default emoji picker button is removed. |
67
+ | `keepOpened` | boolean | false | If set to true, the emoji picker will remain open after selecting an emoji. Defaults to false. |
67
68
 
68
69
  ## License
69
70
 
package/dist/index.es.js CHANGED
@@ -4899,7 +4899,12 @@ function InputEmoji(props, ref) {
4899
4899
  textInputRef.current.html = replaceAllTextEmojis(nextValue);
4900
4900
  sanitizedTextRef.current = nextValue;
4901
4901
  }, [sanitizedTextRef]);
4902
- var setValue = useCallback(function (value) {
4902
+ var setValue = useCallback(
4903
+ /**
4904
+ *
4905
+ * @param {string} value
4906
+ */
4907
+ function (value) {
4903
4908
  updateHTML(value);
4904
4909
  }, [updateHTML]);
4905
4910
  var emitChange = useEmit(textInputRef, onResize, onChange);
@@ -4913,10 +4918,10 @@ function InputEmoji(props, ref) {
4913
4918
  if (sanitizedTextRef.current !== value) {
4914
4919
  setValue(value);
4915
4920
  }
4916
- }, [sanitizedTextRef, setValue, value]);
4917
- useEffect(function () {
4918
- updateHTML();
4919
- }, [updateHTML]);
4921
+ }, [sanitizedTextRef, setValue, value]); // useEffect(() => {
4922
+ // updateHTML();
4923
+ // }, [updateHTML]);
4924
+
4920
4925
  useEffect(function () {
4921
4926
  /**
4922
4927
  * Handle keydown event
@@ -4997,7 +5002,10 @@ function InputEmoji(props, ref) {
4997
5002
 
4998
5003
  function handleTextInputChange(html) {
4999
5004
  sanitize(html);
5000
- emitChange(sanitizedTextRef.current);
5005
+
5006
+ if (value !== sanitizedTextRef.current) {
5007
+ emitChange(sanitizedTextRef.current);
5008
+ }
5001
5009
  }
5002
5010
  /**
5003
5011
  *
@@ -5021,8 +5029,24 @@ function InputEmoji(props, ref) {
5021
5029
 
5022
5030
 
5023
5031
  function handleCopy(event) {
5024
- event.clipboardData.setData("text", sanitizedTextRef.current);
5025
- event.preventDefault();
5032
+ var selection = window.getSelection();
5033
+
5034
+ if (selection !== null) {
5035
+ var selectedText = '';
5036
+
5037
+ if (selection.anchorNode && selection.anchorNode.nodeType === Node.ELEMENT_NODE) {
5038
+ // @ts-ignore
5039
+ selectedText = selection.anchorNode.innerHTML;
5040
+ } else if (selection.anchorNode && selection.anchorNode.nodeType === Node.TEXT_NODE) {
5041
+ var _selection$anchorNode;
5042
+
5043
+ selectedText = (_selection$anchorNode = selection.anchorNode.textContent) !== null && _selection$anchorNode !== void 0 ? _selection$anchorNode : '';
5044
+ }
5045
+
5046
+ var text = replaceAllTextEmojiToString(selectedText);
5047
+ event.clipboardData.setData("text", text);
5048
+ event.preventDefault();
5049
+ }
5026
5050
  }
5027
5051
  /**
5028
5052
  * Handle past on input