react-input-emoji 5.6.3 → 5.6.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/index.js CHANGED
@@ -607,6 +607,24 @@ function replaceAllTextEmojiToString(html) {
607
607
 
608
608
  // @ts-check
609
609
 
610
+ /**
611
+ * Handle copy of current selected text
612
+ * @param {React.ClipboardEvent} event
613
+ */
614
+ function handleCopy(event) {
615
+ var selectedText = window.getSelection();
616
+ if (selectedText === null) {
617
+ return;
618
+ }
619
+ var container = document.createElement("div");
620
+ for (var i = 0, len = selectedText.rangeCount; i < len; ++i) {
621
+ container.appendChild(selectedText.getRangeAt(i).cloneContents());
622
+ }
623
+ container = replaceEmojiToString(container);
624
+ event.clipboardData.setData("text", container.innerText);
625
+ event.preventDefault();
626
+ }
627
+
610
628
  /**
611
629
  *
612
630
  * @param {string} html
@@ -646,6 +664,19 @@ function handlePasteHtmlAtCaret(html) {
646
664
  }
647
665
  }
648
666
 
667
+ /**
668
+ * Replace emoji img to its string value
669
+ * @param {HTMLDivElement} container
670
+ * @return {HTMLDivElement}
671
+ */
672
+ function replaceEmojiToString(container) {
673
+ var images = Array.prototype.slice.call(container.querySelectorAll("img"));
674
+ images.forEach(function (image) {
675
+ image.outerHTML = image.dataset.emoji;
676
+ });
677
+ return container;
678
+ }
679
+
649
680
  /**
650
681
  *
651
682
  * @param {{text: string, html: string}} props
@@ -4331,26 +4362,26 @@ function usePollute() {
4331
4362
  * @typedef {object} Props
4332
4363
  * @property {string} value
4333
4364
  * @property {(value: string) => void} onChange
4334
- * @property {"light" | "dark" | "auto"} theme
4335
- * @property {boolean} cleanOnEnter
4336
- * @property {(text: string) => void} onEnter
4337
- * @property {string} placeholder
4338
- * @property {(size: {width: number, height: number}) => void} onResize
4339
- * @property {() => void} onClick
4340
- * @property {() => void} onFocus
4365
+ * @property {"light" | "dark" | "auto"=} theme
4366
+ * @property {boolean=} cleanOnEnter
4367
+ * @property {(text: string) => void=} onEnter
4368
+ * @property {string=} placeholder
4369
+ * @property {(size: {width: number, height: number}) => void=} onResize
4370
+ * @property {() => void=} onClick
4371
+ * @property {() => void=} onFocus
4341
4372
  * @property {() => void=} onBlur
4342
- * @property {boolean} shouldReturn
4343
- * @property {number} maxLength
4344
- * @property {boolean} keepOpened
4345
- * @property {(event: KeyboardEvent) => void} onKeyDown
4346
- * @property {string} inputClass
4347
- * @property {boolean} disableRecent
4348
- * @property {number} tabIndex
4349
- * @property {number} height
4350
- * @property {number} borderRadius
4351
- * @property {string} borderColor
4352
- * @property {number} fontSize
4353
- * @property {string} fontFamily
4373
+ * @property {boolean=} shouldReturn
4374
+ * @property {number=} maxLength
4375
+ * @property {boolean=} keepOpened
4376
+ * @property {(event: KeyboardEvent) => void=} onKeyDown
4377
+ * @property {string=} inputClass
4378
+ * @property {boolean=} disableRecent
4379
+ * @property {number=} tabIndex
4380
+ * @property {number=} height
4381
+ * @property {number=} borderRadius
4382
+ * @property {string=} borderColor
4383
+ * @property {number=} fontSize
4384
+ * @property {string=} fontFamily
4354
4385
  * @property {{id: string; name: string; emojis: {id: string; name: string; keywords: string[], skins: {src: string}[]}}[]=} customEmojis
4355
4386
  * @property {import('./types/types').Languages=} language
4356
4387
  * @property {(text: string) => Promise<MetionUser[]>=} searchMention
@@ -4522,27 +4553,6 @@ function InputEmoji(props, ref) {
4522
4553
  }
4523
4554
  }
4524
4555
 
4525
- /**
4526
- * Handle copy of current selected text
4527
- * @param {React.ClipboardEvent} event
4528
- */
4529
- function handleCopy(event) {
4530
- var selection = window.getSelection();
4531
- if (selection !== null) {
4532
- var selectedText = '';
4533
- if (selection.anchorNode && selection.anchorNode.nodeType === Node.ELEMENT_NODE) {
4534
- // @ts-ignore
4535
- selectedText = selection.anchorNode.innerHTML;
4536
- } else if (selection.anchorNode && selection.anchorNode.nodeType === Node.TEXT_NODE) {
4537
- var _selection$anchorNode;
4538
- selectedText = (_selection$anchorNode = selection.anchorNode.textContent) !== null && _selection$anchorNode !== void 0 ? _selection$anchorNode : '';
4539
- }
4540
- var text = replaceAllTextEmojiToString(selectedText);
4541
- event.clipboardData.setData("text", text);
4542
- event.preventDefault();
4543
- }
4544
- }
4545
-
4546
4556
  /**
4547
4557
  * Handle past on input
4548
4558
  * @param {React.ClipboardEvent} event