@lexical/plain-text 0.3.8 → 0.3.11

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.
@@ -19,14 +19,12 @@ var lexical = require('lexical');
19
19
  *
20
20
  */
21
21
  const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
22
- const documentMode = // @ts-ignore
23
- CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
22
+ const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
24
23
  CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
25
24
  CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
26
25
  const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
27
26
  const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
28
- const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && // @ts-ignore
29
- !window.MSStream; // Keep these in case we need to use them in the future.
27
+ 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.
30
28
  // export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
31
29
  // export const IS_CHROME: boolean = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
32
30
  // export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
@@ -74,6 +72,8 @@ function onPasteForPlainText(event, editor) {
74
72
  if (clipboardData != null && lexical.$isRangeSelection(selection)) {
75
73
  clipboard.$insertDataTransferForPlainText(clipboardData, selection);
76
74
  }
75
+ }, {
76
+ tag: 'paste'
77
77
  });
78
78
  }
79
79
 
@@ -277,7 +277,7 @@ function registerPlainText(editor, initialEditorState) {
277
277
  // If we have beforeinput, then we can avoid blocking
278
278
  // the default behavior. This ensures that the iOS can
279
279
  // intercept that we're actually inserting a paragraph,
280
- // and autocomplete, autocapitialize etc work as intended.
280
+ // and autocomplete, autocapitalize etc work as intended.
281
281
  // This can also cause a strange performance issue in
282
282
  // Safari, where there is a noticeable pause due to
283
283
  // preventing the key down of enter.
@@ -6,7 +6,7 @@
6
6
  */
7
7
  'use strict';var a=require("@lexical/clipboard"),g=require("@lexical/selection"),k=require("@lexical/utils"),l=require("lexical");let m="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,n=m&&"documentMode"in document?document.documentMode:null;m&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);m&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
8
8
  let p=m&&"InputEvent"in window&&!n?"getTargetRanges"in new window.InputEvent("input"):!1,q=m&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),r=m&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,t={tag:"history-merge"};function u(d,f){d.preventDefault();f.update(()=>{let e=d instanceof KeyboardEvent?null:d.clipboardData,b=l.$getSelection();if(null!==b&&null!=e){let c=a.$getHtmlContent(f);null!==c&&e.setData("text/html",c);e.setData("text/plain",b.getTextContent())}})}
9
- function v(d,f){d.preventDefault();f.update(()=>{let e=l.$getSelection(),b=d instanceof InputEvent?null:d.clipboardData;null!=b&&l.$isRangeSelection(e)&&a.$insertDataTransferForPlainText(b,e)})}function w(d,f){u(d,f);f.update(()=>{let e=l.$getSelection();l.$isRangeSelection(e)&&e.removeText()})}
9
+ function v(d,f){d.preventDefault();f.update(()=>{let e=l.$getSelection(),b=d instanceof InputEvent?null:d.clipboardData;null!=b&&l.$isRangeSelection(e)&&a.$insertDataTransferForPlainText(b,e)},{tag:"paste"})}function w(d,f){u(d,f);f.update(()=>{let e=l.$getSelection();l.$isRangeSelection(e)&&e.removeText()})}
10
10
  function x(d,f){if(null!==f)if(void 0===f)d.update(()=>{var e=l.$getRoot();if(e.isEmpty()){let b=l.$createParagraphNode();e.append(b);e=document.activeElement;(null!==l.$getSelection()||null!==e&&e===d.getRootElement())&&b.select()}},t);else if(null!==f)switch(typeof f){case "string":let e=d.parseEditorState(f);d.setEditorState(e,t);break;case "object":d.setEditorState(f,t);break;case "function":d.update(()=>{l.$getRoot().isEmpty()&&f(d)},t)}}
11
11
  exports.registerPlainText=function(d,f){let e=k.mergeRegister(d.registerCommand(l.DELETE_CHARACTER_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.deleteCharacter(b);return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.DELETE_WORD_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.deleteWord(b);return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.DELETE_LINE_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.deleteLine(b);
12
12
  return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.CONTROLLED_TEXT_INSERTION_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;if("string"===typeof b)c.insertText(b);else{const h=b.dataTransfer;null!=h?a.$insertDataTransferForPlainText(h,c):(b=b.data)&&c.insertText(b)}return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.REMOVE_TEXT_COMMAND,()=>{const b=l.$getSelection();if(!l.$isRangeSelection(b))return!1;b.removeText();return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.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.3.8",
10
+ "version": "0.3.11",
11
11
  "main": "LexicalPlainText.js",
12
12
  "peerDependencies": {
13
- "lexical": "0.3.8",
14
- "@lexical/utils": "0.3.8",
15
- "@lexical/selection": "0.3.8",
16
- "@lexical/clipboard": "0.3.8"
13
+ "lexical": "0.3.11",
14
+ "@lexical/utils": "0.3.11",
15
+ "@lexical/selection": "0.3.11",
16
+ "@lexical/clipboard": "0.3.11"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",