@lexical/plain-text 0.14.5 → 0.16.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.
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  'use strict';
8
10
 
9
11
  var clipboard = require('@lexical/clipboard');
@@ -28,20 +30,15 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
28
30
  * LICENSE file in the root directory of this source tree.
29
31
  *
30
32
  */
33
+
31
34
  const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
32
- CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
33
- CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
34
35
  const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
35
36
  const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
36
37
  const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
37
- const IS_ANDROID = CAN_USE_DOM && /Android/.test(navigator.userAgent);
38
38
 
39
39
  // Keep these in case we need to use them in the future.
40
40
  // export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
41
41
  const IS_CHROME = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
42
- // export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
43
-
44
- CAN_USE_DOM && IS_ANDROID && IS_CHROME;
45
42
  const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME;
46
43
 
47
44
  /**
@@ -51,6 +48,7 @@ const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.user
51
48
  * LICENSE file in the root directory of this source tree.
52
49
  *
53
50
  */
51
+
54
52
  function onCopyForPlainText(event, editor) {
55
53
  editor.update(() => {
56
54
  if (event !== null) {
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import { $insertDataTransferForPlainText, $getHtmlContent } from '@lexical/clipboard';
8
10
  import { $shouldOverrideDefaultCharacterSelection, $moveCharacter } from '@lexical/selection';
9
11
  import { mergeRegister, objectKlassEquals } from '@lexical/utils';
@@ -26,20 +28,15 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
26
28
  * LICENSE file in the root directory of this source tree.
27
29
  *
28
30
  */
31
+
29
32
  const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
30
- CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
31
- CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
32
33
  const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
33
34
  const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
34
35
  const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
35
- const IS_ANDROID = CAN_USE_DOM && /Android/.test(navigator.userAgent);
36
36
 
37
37
  // Keep these in case we need to use them in the future.
38
38
  // export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
39
39
  const IS_CHROME = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
40
- // export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
41
-
42
- CAN_USE_DOM && IS_ANDROID && IS_CHROME;
43
40
  const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME;
44
41
 
45
42
  /**
@@ -49,6 +46,7 @@ const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.user
49
46
  * LICENSE file in the root directory of this source tree.
50
47
  *
51
48
  */
49
+
52
50
  function onCopyForPlainText(event, editor) {
53
51
  editor.update(() => {
54
52
  if (event !== null) {
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  'use strict'
8
10
  const LexicalPlainText = process.env.NODE_ENV === 'development' ? require('./LexicalPlainText.dev.js') : require('./LexicalPlainText.prod.js');
9
11
  module.exports = LexicalPlainText;
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import * as modDev from './LexicalPlainText.dev.mjs';
8
10
  import * as modProd from './LexicalPlainText.prod.mjs';
9
11
  const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalPlainText.dev.mjs') : import('./LexicalPlainText.prod.mjs'));
8
10
  export const registerPlainText = mod.registerPlainText;
@@ -3,15 +3,17 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
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,l=k&&"documentMode"in document?document.documentMode:null;k&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);k&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
8
- let m=k&&"InputEvent"in window&&!l?"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&&/Android/.test(navigator.userAgent),t=k&&/^(?=.*Chrome).*/i.test(navigator.userAgent);k&&r&&t;let u=k&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!t;
9
- function v(d,b){b.update(()=>{if(null!==d){let c=g.objectKlassEquals(d,KeyboardEvent)?null:d.clipboardData,e=h.$getSelection();if(null!==e&&null!=c){d.preventDefault();let n=a.$getHtmlContent(b);null!==n&&c.setData("text/html",n);c.setData("text/plain",e.getTextContent())}}})}function w(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
- function x(d,b){v(d,b);b.update(()=>{let c=h.$getSelection();h.$isRangeSelection(c)&&c.removeText()})}
8
+
9
+ 'use strict';var a=require("@lexical/clipboard"),f=require("@lexical/selection"),g=require("@lexical/utils"),h=require("lexical");
10
+ let k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,l=k&&"documentMode"in document?document.documentMode:null,n=k&&"InputEvent"in window&&!l?"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;
11
+ function u(d,b){b.update(()=>{if(null!==d){let c=g.objectKlassEquals(d,KeyboardEvent)?null:d.clipboardData,e=h.$getSelection();if(null!==e&&null!=c){d.preventDefault();let m=a.$getHtmlContent(b);null!==m&&c.setData("text/html",m);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"})}
12
+ function w(d,b){u(d,b);b.update(()=>{let c=h.$getSelection();h.$isRangeSelection(c)&&c.removeText()})}
11
13
  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
14
  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,
13
15
  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,
14
16
  e,!0),!0):!1},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.KEY_ARROW_RIGHT_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;const e=b.shiftKey;return f.$shouldOverrideDefaultCharacterSelection(c,!1)?(b.preventDefault(),f.$moveCharacter(c,e,!1),!0):!1},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.KEY_BACKSPACE_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;b.preventDefault();return d.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!0)},h.COMMAND_PRIORITY_EDITOR),
15
- d.registerCommand(h.KEY_DELETE_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;b.preventDefault();return d.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!1)},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.KEY_ENTER_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;if(null!==b){if((q||p||u)&&m)return!1;b.preventDefault()}return d.dispatchCommand(h.INSERT_LINE_BREAK_COMMAND,!1)},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.SELECT_ALL_COMMAND,()=>{h.$selectAll();
16
- return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.COPY_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;v(b,d);return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.CUT_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;x(b,d);return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.PASTE_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;w(b,d);return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.DROP_COMMAND,b=>
17
+ d.registerCommand(h.KEY_DELETE_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;b.preventDefault();return d.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!1)},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.KEY_ENTER_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;if(null!==b){if((q||p||t)&&n)return!1;b.preventDefault()}return d.dispatchCommand(h.INSERT_LINE_BREAK_COMMAND,!1)},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.SELECT_ALL_COMMAND,()=>{h.$selectAll();
18
+ return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.COPY_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;u(b,d);return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.CUT_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;w(b,d);return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.PASTE_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;v(b,d);return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.DROP_COMMAND,b=>
17
19
  {const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;b.preventDefault();return!0},h.COMMAND_PRIORITY_EDITOR),d.registerCommand(h.DRAGSTART_COMMAND,b=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;b.preventDefault();return!0},h.COMMAND_PRIORITY_EDITOR))}
@@ -3,5 +3,7 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
7
- import{$insertDataTransferForPlainText as e,$getHtmlContent as t}from"@lexical/clipboard";import{$shouldOverrideDefaultCharacterSelection as n,$moveCharacter as r}from"@lexical/selection";import{mergeRegister as o,objectKlassEquals as i}from"@lexical/utils";import{DELETE_CHARACTER_COMMAND as a,$getSelection as s,$isRangeSelection as u,COMMAND_PRIORITY_EDITOR as m,DELETE_WORD_COMMAND as d,DELETE_LINE_COMMAND as c,CONTROLLED_TEXT_INSERTION_COMMAND as l,REMOVE_TEXT_COMMAND as g,INSERT_LINE_BREAK_COMMAND as f,INSERT_PARAGRAPH_COMMAND as p,KEY_ARROW_LEFT_COMMAND as C,KEY_ARROW_RIGHT_COMMAND as v,KEY_BACKSPACE_COMMAND as w,KEY_DELETE_COMMAND as x,KEY_ENTER_COMMAND as D,SELECT_ALL_COMMAND as h,$selectAll as A,COPY_COMMAND as T,CUT_COMMAND as y,PASTE_COMMAND as P,DROP_COMMAND as b,DRAGSTART_COMMAND as E}from"lexical";const K="undefined"!=typeof window&&void 0!==window.document&&void 0!==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);const S=!(!K||!("InputEvent"in window)||M)&&"getTargetRanges"in new window.InputEvent("input"),k=K&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),L=K&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,B=(K&&/Android/.test(navigator.userAgent),K&&/^(?=.*Chrome).*/i.test(navigator.userAgent)),I=K&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!B;function W(e,n){n.update((()=>{if(null!==e){const r=i(e,KeyboardEvent)?null:e.clipboardData,o=s();if(null!==o&&null!=r){e.preventDefault();const i=t(n);null!==i&&r.setData("text/html",i),r.setData("text/plain",o.getTextContent())}}}))}function F(t){return o(t.registerCommand(a,(e=>{const t=s();return!!u(t)&&(t.deleteCharacter(e),!0)}),m),t.registerCommand(d,(e=>{const t=s();return!!u(t)&&(t.deleteWord(e),!0)}),m),t.registerCommand(c,(e=>{const t=s();return!!u(t)&&(t.deleteLine(e),!0)}),m),t.registerCommand(l,(t=>{const n=s();if(!u(n))return!1;if("string"==typeof t)n.insertText(t);else{const r=t.dataTransfer;if(null!=r)e(r,n);else{const e=t.data;e&&n.insertText(e)}}return!0}),m),t.registerCommand(g,(()=>{const e=s();return!!u(e)&&(e.removeText(),!0)}),m),t.registerCommand(f,(e=>{const t=s();return!!u(t)&&(t.insertLineBreak(e),!0)}),m),t.registerCommand(p,(()=>{const e=s();return!!u(e)&&(e.insertLineBreak(),!0)}),m),t.registerCommand(C,(e=>{const t=s();if(!u(t))return!1;const o=e,i=o.shiftKey;return!!n(t,!0)&&(o.preventDefault(),r(t,i,!0),!0)}),m),t.registerCommand(v,(e=>{const t=s();if(!u(t))return!1;const o=e,i=o.shiftKey;return!!n(t,!1)&&(o.preventDefault(),r(t,i,!1),!0)}),m),t.registerCommand(w,(e=>{const n=s();return!!u(n)&&(e.preventDefault(),t.dispatchCommand(a,!0))}),m),t.registerCommand(x,(e=>{const n=s();return!!u(n)&&(e.preventDefault(),t.dispatchCommand(a,!1))}),m),t.registerCommand(D,(e=>{const n=s();if(!u(n))return!1;if(null!==e){if((L||k||I)&&S)return!1;e.preventDefault()}return t.dispatchCommand(f,!1)}),m),t.registerCommand(h,(()=>(A(),!0)),m),t.registerCommand(T,(e=>{const n=s();return!!u(n)&&(W(e,t),!0)}),m),t.registerCommand(y,(e=>{const n=s();return!!u(n)&&(function(e,t){W(e,t),t.update((()=>{const e=s();u(e)&&e.removeText()}))}(e,t),!0)}),m),t.registerCommand(P,(n=>{const r=s();return!!u(r)&&(function(t,n){t.preventDefault(),n.update((()=>{const n=s(),{clipboardData:r}=t;null!=r&&u(n)&&e(r,n)}),{tag:"paste"})}(n,t),!0)}),m),t.registerCommand(b,(e=>{const t=s();return!!u(t)&&(e.preventDefault(),!0)}),m),t.registerCommand(E,(e=>{const t=s();return!!u(t)&&(e.preventDefault(),!0)}),m))}export{F as registerPlainText};
8
+
9
+ import{$insertDataTransferForPlainText as e,$getHtmlContent as t}from"@lexical/clipboard";import{$shouldOverrideDefaultCharacterSelection as n,$moveCharacter as r}from"@lexical/selection";import{mergeRegister as o,objectKlassEquals as i}from"@lexical/utils";import{DELETE_CHARACTER_COMMAND as a,$getSelection as s,$isRangeSelection as u,COMMAND_PRIORITY_EDITOR as m,DELETE_WORD_COMMAND as d,DELETE_LINE_COMMAND as c,CONTROLLED_TEXT_INSERTION_COMMAND as l,REMOVE_TEXT_COMMAND as f,INSERT_LINE_BREAK_COMMAND as g,INSERT_PARAGRAPH_COMMAND as p,KEY_ARROW_LEFT_COMMAND as C,KEY_ARROW_RIGHT_COMMAND as v,KEY_BACKSPACE_COMMAND as w,KEY_DELETE_COMMAND as D,KEY_ENTER_COMMAND as x,SELECT_ALL_COMMAND as h,$selectAll as T,COPY_COMMAND as b,CUT_COMMAND as y,PASTE_COMMAND as A,DROP_COMMAND as E,DRAGSTART_COMMAND as K}from"lexical";const L="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,M=L&&"documentMode"in document?document.documentMode:null,P=!(!L||!("InputEvent"in window)||M)&&"getTargetRanges"in new window.InputEvent("input"),S=L&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),k=L&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,B=L&&/^(?=.*Chrome).*/i.test(navigator.userAgent),I=L&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!B;function W(e,n){n.update((()=>{if(null!==e){const r=i(e,KeyboardEvent)?null:e.clipboardData,o=s();if(null!==o&&null!=r){e.preventDefault();const i=t(n);null!==i&&r.setData("text/html",i),r.setData("text/plain",o.getTextContent())}}}))}function R(t){return o(t.registerCommand(a,(e=>{const t=s();return!!u(t)&&(t.deleteCharacter(e),!0)}),m),t.registerCommand(d,(e=>{const t=s();return!!u(t)&&(t.deleteWord(e),!0)}),m),t.registerCommand(c,(e=>{const t=s();return!!u(t)&&(t.deleteLine(e),!0)}),m),t.registerCommand(l,(t=>{const n=s();if(!u(n))return!1;if("string"==typeof t)n.insertText(t);else{const r=t.dataTransfer;if(null!=r)e(r,n);else{const e=t.data;e&&n.insertText(e)}}return!0}),m),t.registerCommand(f,(()=>{const e=s();return!!u(e)&&(e.removeText(),!0)}),m),t.registerCommand(g,(e=>{const t=s();return!!u(t)&&(t.insertLineBreak(e),!0)}),m),t.registerCommand(p,(()=>{const e=s();return!!u(e)&&(e.insertLineBreak(),!0)}),m),t.registerCommand(C,(e=>{const t=s();if(!u(t))return!1;const o=e,i=o.shiftKey;return!!n(t,!0)&&(o.preventDefault(),r(t,i,!0),!0)}),m),t.registerCommand(v,(e=>{const t=s();if(!u(t))return!1;const o=e,i=o.shiftKey;return!!n(t,!1)&&(o.preventDefault(),r(t,i,!1),!0)}),m),t.registerCommand(w,(e=>{const n=s();return!!u(n)&&(e.preventDefault(),t.dispatchCommand(a,!0))}),m),t.registerCommand(D,(e=>{const n=s();return!!u(n)&&(e.preventDefault(),t.dispatchCommand(a,!1))}),m),t.registerCommand(x,(e=>{const n=s();if(!u(n))return!1;if(null!==e){if((k||S||I)&&P)return!1;e.preventDefault()}return t.dispatchCommand(g,!1)}),m),t.registerCommand(h,(()=>(T(),!0)),m),t.registerCommand(b,(e=>{const n=s();return!!u(n)&&(W(e,t),!0)}),m),t.registerCommand(y,(e=>{const n=s();return!!u(n)&&(function(e,t){W(e,t),t.update((()=>{const e=s();u(e)&&e.removeText()}))}(e,t),!0)}),m),t.registerCommand(A,(n=>{const r=s();return!!u(r)&&(function(t,n){t.preventDefault(),n.update((()=>{const n=s(),{clipboardData:r}=t;null!=r&&u(n)&&e(r,n)}),{tag:"paste"})}(n,t),!0)}),m),t.registerCommand(E,(e=>{const t=s();return!!u(t)&&(e.preventDefault(),!0)}),m),t.registerCommand(K,(e=>{const t=s();return!!u(t)&&(e.preventDefault(),!0)}),m))}export{R as registerPlainText};
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "plain-text"
8
8
  ],
9
9
  "license": "MIT",
10
- "version": "0.14.5",
10
+ "version": "0.16.0",
11
11
  "main": "LexicalPlainText.js",
12
12
  "types": "index.d.ts",
13
13
  "repository": {
@@ -35,9 +35,9 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@lexical/clipboard": "0.14.5",
39
- "@lexical/selection": "0.14.5",
40
- "@lexical/utils": "0.14.5",
41
- "lexical": "0.14.5"
38
+ "@lexical/clipboard": "0.16.0",
39
+ "@lexical/selection": "0.16.0",
40
+ "@lexical/utils": "0.16.0",
41
+ "lexical": "0.16.0"
42
42
  }
43
43
  }