react-input-emoji 5.6.3 → 5.6.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.es.js +50 -40
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +50 -40
- package/dist/index.js.map +1 -1
- package/dist/src/index.d.ts +19 -19
- package/dist/src/types/types.d.ts +32 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
@@ -600,6 +600,24 @@ function replaceAllTextEmojiToString(html) {
|
|
600
600
|
|
601
601
|
// @ts-check
|
602
602
|
|
603
|
+
/**
|
604
|
+
* Handle copy of current selected text
|
605
|
+
* @param {React.ClipboardEvent} event
|
606
|
+
*/
|
607
|
+
function handleCopy(event) {
|
608
|
+
var selectedText = window.getSelection();
|
609
|
+
if (selectedText === null) {
|
610
|
+
return;
|
611
|
+
}
|
612
|
+
var container = document.createElement("div");
|
613
|
+
for (var i = 0, len = selectedText.rangeCount; i < len; ++i) {
|
614
|
+
container.appendChild(selectedText.getRangeAt(i).cloneContents());
|
615
|
+
}
|
616
|
+
container = replaceEmojiToString(container);
|
617
|
+
event.clipboardData.setData("text", container.innerText);
|
618
|
+
event.preventDefault();
|
619
|
+
}
|
620
|
+
|
603
621
|
/**
|
604
622
|
*
|
605
623
|
* @param {string} html
|
@@ -639,6 +657,19 @@ function handlePasteHtmlAtCaret(html) {
|
|
639
657
|
}
|
640
658
|
}
|
641
659
|
|
660
|
+
/**
|
661
|
+
* Replace emoji img to its string value
|
662
|
+
* @param {HTMLDivElement} container
|
663
|
+
* @return {HTMLDivElement}
|
664
|
+
*/
|
665
|
+
function replaceEmojiToString(container) {
|
666
|
+
var images = Array.prototype.slice.call(container.querySelectorAll("img"));
|
667
|
+
images.forEach(function (image) {
|
668
|
+
image.outerHTML = image.dataset.emoji;
|
669
|
+
});
|
670
|
+
return container;
|
671
|
+
}
|
672
|
+
|
642
673
|
/**
|
643
674
|
*
|
644
675
|
* @param {{text: string, html: string}} props
|
@@ -4324,26 +4355,26 @@ function usePollute() {
|
|
4324
4355
|
* @typedef {object} Props
|
4325
4356
|
* @property {string} value
|
4326
4357
|
* @property {(value: string) => void} onChange
|
4327
|
-
* @property {"light" | "dark" | "auto"} theme
|
4328
|
-
* @property {boolean} cleanOnEnter
|
4329
|
-
* @property {(text: string) => void} onEnter
|
4330
|
-
* @property {string} placeholder
|
4331
|
-
* @property {(size: {width: number, height: number}) => void} onResize
|
4332
|
-
* @property {() => void} onClick
|
4333
|
-
* @property {() => void} onFocus
|
4358
|
+
* @property {"light" | "dark" | "auto"=} theme
|
4359
|
+
* @property {boolean=} cleanOnEnter
|
4360
|
+
* @property {(text: string) => void=} onEnter
|
4361
|
+
* @property {string=} placeholder
|
4362
|
+
* @property {(size: {width: number, height: number}) => void=} onResize
|
4363
|
+
* @property {() => void=} onClick
|
4364
|
+
* @property {() => void=} onFocus
|
4334
4365
|
* @property {() => void=} onBlur
|
4335
|
-
* @property {boolean} shouldReturn
|
4336
|
-
* @property {number} maxLength
|
4337
|
-
* @property {boolean} keepOpened
|
4338
|
-
* @property {(event: KeyboardEvent) => void} onKeyDown
|
4339
|
-
* @property {string} inputClass
|
4340
|
-
* @property {boolean} disableRecent
|
4341
|
-
* @property {number} tabIndex
|
4342
|
-
* @property {number} height
|
4343
|
-
* @property {number} borderRadius
|
4344
|
-
* @property {string} borderColor
|
4345
|
-
* @property {number} fontSize
|
4346
|
-
* @property {string} fontFamily
|
4366
|
+
* @property {boolean=} shouldReturn
|
4367
|
+
* @property {number=} maxLength
|
4368
|
+
* @property {boolean=} keepOpened
|
4369
|
+
* @property {(event: KeyboardEvent) => void=} onKeyDown
|
4370
|
+
* @property {string=} inputClass
|
4371
|
+
* @property {boolean=} disableRecent
|
4372
|
+
* @property {number=} tabIndex
|
4373
|
+
* @property {number=} height
|
4374
|
+
* @property {number=} borderRadius
|
4375
|
+
* @property {string=} borderColor
|
4376
|
+
* @property {number=} fontSize
|
4377
|
+
* @property {string=} fontFamily
|
4347
4378
|
* @property {{id: string; name: string; emojis: {id: string; name: string; keywords: string[], skins: {src: string}[]}}[]=} customEmojis
|
4348
4379
|
* @property {import('./types/types').Languages=} language
|
4349
4380
|
* @property {(text: string) => Promise<MetionUser[]>=} searchMention
|
@@ -4515,27 +4546,6 @@ function InputEmoji(props, ref) {
|
|
4515
4546
|
}
|
4516
4547
|
}
|
4517
4548
|
|
4518
|
-
/**
|
4519
|
-
* Handle copy of current selected text
|
4520
|
-
* @param {React.ClipboardEvent} event
|
4521
|
-
*/
|
4522
|
-
function handleCopy(event) {
|
4523
|
-
var selection = window.getSelection();
|
4524
|
-
if (selection !== null) {
|
4525
|
-
var selectedText = '';
|
4526
|
-
if (selection.anchorNode && selection.anchorNode.nodeType === Node.ELEMENT_NODE) {
|
4527
|
-
// @ts-ignore
|
4528
|
-
selectedText = selection.anchorNode.innerHTML;
|
4529
|
-
} else if (selection.anchorNode && selection.anchorNode.nodeType === Node.TEXT_NODE) {
|
4530
|
-
var _selection$anchorNode;
|
4531
|
-
selectedText = (_selection$anchorNode = selection.anchorNode.textContent) !== null && _selection$anchorNode !== void 0 ? _selection$anchorNode : '';
|
4532
|
-
}
|
4533
|
-
var text = replaceAllTextEmojiToString(selectedText);
|
4534
|
-
event.clipboardData.setData("text", text);
|
4535
|
-
event.preventDefault();
|
4536
|
-
}
|
4537
|
-
}
|
4538
|
-
|
4539
4549
|
/**
|
4540
4550
|
* Handle past on input
|
4541
4551
|
* @param {React.ClipboardEvent} event
|