@lexical/plain-text 0.6.4 → 0.7.0

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.
@@ -34,8 +34,8 @@ const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentM
34
34
  const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
35
35
  const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; // Keep these in case we need to use them in the future.
36
36
  // export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
37
- // export const IS_CHROME: boolean = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
38
- // export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
37
+
38
+ CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent); // export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
39
39
 
40
40
  /** @module @lexical/plain-text */
41
41
 
@@ -5,8 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
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
- 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;function r(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())}})}
9
- function t(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"})}function u(d,b){r(d,b);b.update(()=>{let c=h.$getSelection();h.$isRangeSelection(c)&&c.removeText()})}
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;k&&/^(?=.*Chrome).*/i.test(navigator.userAgent);
9
+ function r(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 t(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"})}
10
+ function u(d,b){r(d,b);b.update(()=>{let c=h.$getSelection();h.$isRangeSelection(c)&&c.removeText()})}
10
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);
11
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,
12
13
  b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;c.insertLineBreak(b);return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.INSERT_PARAGRAPH_COMMAND,()=>{const b=h.$getSelection();if(!h.$isRangeSelection(b))return!1;b.insertLineBreak();return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.KEY_ARROW_LEFT_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;const e=b.shiftKey;return f.$shouldOverrideDefaultCharacterSelection(c,!0)?(b.preventDefault(),f.$moveCharacter(c,
package/package.json CHANGED
@@ -7,13 +7,13 @@
7
7
  "plain-text"
8
8
  ],
9
9
  "license": "MIT",
10
- "version": "0.6.4",
10
+ "version": "0.7.0",
11
11
  "main": "LexicalPlainText.js",
12
12
  "peerDependencies": {
13
- "lexical": "0.6.4",
14
- "@lexical/utils": "0.6.4",
15
- "@lexical/selection": "0.6.4",
16
- "@lexical/clipboard": "0.6.4"
13
+ "lexical": "0.7.0",
14
+ "@lexical/utils": "0.7.0",
15
+ "@lexical/selection": "0.7.0",
16
+ "@lexical/clipboard": "0.7.0"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",