rn-rich-text-editor 1.3.2 → 1.3.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-rich-text-editor",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "A rich text editor component for React Native",
5
5
  "keywords": [
6
6
  "react-native",
@@ -675,15 +675,25 @@ function createHTML(options = {}) {
675
675
  addEventListener(content, 'blur', handleBlur);
676
676
  addEventListener(content, 'focus', handleFocus);
677
677
  addEventListener(content, 'paste', function (e) {
678
- // get text representation of clipboard
679
- var text = (e.originalEvent || e).clipboardData.getData('text/plain');
678
+ var clipboardData = (e.originalEvent || e).clipboardData;
679
+ var text = clipboardData.getData('text/plain');
680
+ var html = clipboardData.getData('text/html');
680
681
 
681
- ${pasteListener} && postAction({type: 'CONTENT_PASTED', data: text});
682
+ ${pasteListener} && postAction({type: 'CONTENT_PASTED', data: text || html});
682
683
  if (${pasteAsPlainText}) {
683
- // cancel paste
684
684
  e.preventDefault();
685
- // insert text manually
686
685
  exec("insertText", text);
686
+ } else if (html && html.trim() !== '') {
687
+ e.preventDefault();
688
+ exec("insertHTML", html);
689
+ } else if (text && (text.indexOf('&lt;') !== -1 || text.indexOf('<') !== -1)) {
690
+ var htmlFromText = text.indexOf('&lt;') !== -1
691
+ ? text.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"')
692
+ : text;
693
+ if (htmlFromText.indexOf('<') !== -1) {
694
+ e.preventDefault();
695
+ exec("insertHTML", htmlFromText);
696
+ }
687
697
  }
688
698
  });
689
699
  addEventListener(content, 'compositionstart', function(event){