@lexical/plain-text 0.11.0 → 0.11.2

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.
@@ -43,18 +43,20 @@ const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.user
43
43
 
44
44
  function onCopyForPlainText(event, editor) {
45
45
  editor.update(() => {
46
- const clipboardData = event instanceof KeyboardEvent ? null : event.clipboardData;
47
- const selection = lexical.$getSelection();
46
+ if (event !== null) {
47
+ const clipboardData = event instanceof KeyboardEvent ? null : event.clipboardData;
48
+ const selection = lexical.$getSelection();
48
49
 
49
- if (selection !== null && clipboardData != null) {
50
- event.preventDefault();
51
- const htmlString = clipboard.$getHtmlContent(editor);
50
+ if (selection !== null && clipboardData != null) {
51
+ event.preventDefault();
52
+ const htmlString = clipboard.$getHtmlContent(editor);
52
53
 
53
- if (htmlString !== null) {
54
- clipboardData.setData('text/html', htmlString);
55
- }
54
+ if (htmlString !== null) {
55
+ clipboardData.setData('text/html', htmlString);
56
+ }
56
57
 
57
- clipboardData.setData('text/plain', selection.getTextContent());
58
+ clipboardData.setData('text/plain', selection.getTextContent());
59
+ }
58
60
  }
59
61
  });
60
62
  }
@@ -63,7 +65,9 @@ function onPasteForPlainText(event, editor) {
63
65
  event.preventDefault();
64
66
  editor.update(() => {
65
67
  const selection = lexical.$getSelection();
66
- const clipboardData = event instanceof InputEvent || event instanceof KeyboardEvent ? null : event.clipboardData;
68
+ const {
69
+ clipboardData
70
+ } = event;
67
71
 
68
72
  if (clipboardData != null && lexical.$isRangeSelection(selection)) {
69
73
  clipboard.$insertDataTransferForPlainText(clipboardData, selection);
@@ -6,7 +6,7 @@
6
6
  */
7
7
  'use strict';var a=require("@lexical/clipboard"),f=require("@lexical/selection"),g=require("@lexical/utils"),h=require("lexical");let k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,m=k&&"documentMode"in document?document.documentMode:null;k&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);k&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
8
8
  let n=k&&"InputEvent"in window&&!m?"getTargetRanges"in new window.InputEvent("input"):!1,p=k&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),q=k&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,r=k&&/^(?=.*Chrome).*/i.test(navigator.userAgent),t=k&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!r;
9
- function u(d,b){b.update(()=>{let c=d instanceof KeyboardEvent?null:d.clipboardData,e=h.$getSelection();if(null!==e&&null!=c){d.preventDefault();let l=a.$getHtmlContent(b);null!==l&&c.setData("text/html",l);c.setData("text/plain",e.getTextContent())}})}function v(d,b){d.preventDefault();b.update(()=>{let c=h.$getSelection(),e=d instanceof InputEvent||d instanceof KeyboardEvent?null:d.clipboardData;null!=e&&h.$isRangeSelection(c)&&a.$insertDataTransferForPlainText(e,c)},{tag:"paste"})}
9
+ function u(d,b){b.update(()=>{if(null!==d){let c=d instanceof KeyboardEvent?null:d.clipboardData,e=h.$getSelection();if(null!==e&&null!=c){d.preventDefault();let l=a.$getHtmlContent(b);null!==l&&c.setData("text/html",l);c.setData("text/plain",e.getTextContent())}}})}function v(d,b){d.preventDefault();b.update(()=>{let c=h.$getSelection(),{clipboardData:e}=d;null!=e&&h.$isRangeSelection(c)&&a.$insertDataTransferForPlainText(e,c)},{tag:"paste"})}
10
10
  function w(d,b){u(d,b);b.update(()=>{let c=h.$getSelection();h.$isRangeSelection(c)&&c.removeText()})}
11
11
  exports.registerPlainText=function(d){return g.mergeRegister(d.registerCommand(h.DELETE_CHARACTER_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;c.deleteCharacter(b);return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.DELETE_WORD_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;c.deleteWord(b);return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.DELETE_LINE_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;c.deleteLine(b);
12
12
  return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.CONTROLLED_TEXT_INSERTION_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;if("string"===typeof b)c.insertText(b);else{const e=b.dataTransfer;null!=e?a.$insertDataTransferForPlainText(e,c):(b=b.data)&&c.insertText(b)}return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.REMOVE_TEXT_COMMAND,()=>{const b=h.$getSelection();if(!h.$isRangeSelection(b))return!1;b.removeText();return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.INSERT_LINE_BREAK_COMMAND,
package/package.json CHANGED
@@ -7,13 +7,13 @@
7
7
  "plain-text"
8
8
  ],
9
9
  "license": "MIT",
10
- "version": "0.11.0",
10
+ "version": "0.11.2",
11
11
  "main": "LexicalPlainText.js",
12
12
  "peerDependencies": {
13
- "lexical": "0.11.0",
14
- "@lexical/utils": "0.11.0",
15
- "@lexical/selection": "0.11.0",
16
- "@lexical/clipboard": "0.11.0"
13
+ "lexical": "0.11.2",
14
+ "@lexical/utils": "0.11.2",
15
+ "@lexical/selection": "0.11.2",
16
+ "@lexical/clipboard": "0.11.2"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",