@lexical/plain-text 0.13.1 → 0.14.1

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.
@@ -0,0 +1,252 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { $insertDataTransferForPlainText, $getHtmlContent } from '@lexical/clipboard';
8
+ import { $shouldOverrideDefaultCharacterSelection, $moveCharacter } from '@lexical/selection';
9
+ import { mergeRegister, objectKlassEquals } from '@lexical/utils';
10
+ import { DELETE_CHARACTER_COMMAND, $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, REMOVE_TEXT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_ENTER_COMMAND, SELECT_ALL_COMMAND, $selectAll, COPY_COMMAND, CUT_COMMAND, PASTE_COMMAND, DROP_COMMAND, DRAGSTART_COMMAND } from 'lexical';
11
+
12
+ /**
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ */
19
+
20
+ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
21
+
22
+ /**
23
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
24
+ *
25
+ * This source code is licensed under the MIT license found in the
26
+ * LICENSE file in the root directory of this source tree.
27
+ *
28
+ */
29
+ 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
+ const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
33
+ const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
34
+ 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
+
37
+ // Keep these in case we need to use them in the future.
38
+ // export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
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
+ const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME;
44
+
45
+ /** @module @lexical/plain-text */
46
+ function onCopyForPlainText(event, editor) {
47
+ editor.update(() => {
48
+ if (event !== null) {
49
+ const clipboardData = objectKlassEquals(event, KeyboardEvent) ? null : event.clipboardData;
50
+ const selection = $getSelection();
51
+ if (selection !== null && clipboardData != null) {
52
+ event.preventDefault();
53
+ const htmlString = $getHtmlContent(editor);
54
+ if (htmlString !== null) {
55
+ clipboardData.setData('text/html', htmlString);
56
+ }
57
+ clipboardData.setData('text/plain', selection.getTextContent());
58
+ }
59
+ }
60
+ });
61
+ }
62
+ function onPasteForPlainText(event, editor) {
63
+ event.preventDefault();
64
+ editor.update(() => {
65
+ const selection = $getSelection();
66
+ const {
67
+ clipboardData
68
+ } = event;
69
+ if (clipboardData != null && $isRangeSelection(selection)) {
70
+ $insertDataTransferForPlainText(clipboardData, selection);
71
+ }
72
+ }, {
73
+ tag: 'paste'
74
+ });
75
+ }
76
+ function onCutForPlainText(event, editor) {
77
+ onCopyForPlainText(event, editor);
78
+ editor.update(() => {
79
+ const selection = $getSelection();
80
+ if ($isRangeSelection(selection)) {
81
+ selection.removeText();
82
+ }
83
+ });
84
+ }
85
+ function registerPlainText(editor) {
86
+ const removeListener = mergeRegister(editor.registerCommand(DELETE_CHARACTER_COMMAND, isBackward => {
87
+ const selection = $getSelection();
88
+ if (!$isRangeSelection(selection)) {
89
+ return false;
90
+ }
91
+ selection.deleteCharacter(isBackward);
92
+ return true;
93
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DELETE_WORD_COMMAND, isBackward => {
94
+ const selection = $getSelection();
95
+ if (!$isRangeSelection(selection)) {
96
+ return false;
97
+ }
98
+ selection.deleteWord(isBackward);
99
+ return true;
100
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DELETE_LINE_COMMAND, isBackward => {
101
+ const selection = $getSelection();
102
+ if (!$isRangeSelection(selection)) {
103
+ return false;
104
+ }
105
+ selection.deleteLine(isBackward);
106
+ return true;
107
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(CONTROLLED_TEXT_INSERTION_COMMAND, eventOrText => {
108
+ const selection = $getSelection();
109
+ if (!$isRangeSelection(selection)) {
110
+ return false;
111
+ }
112
+ if (typeof eventOrText === 'string') {
113
+ selection.insertText(eventOrText);
114
+ } else {
115
+ const dataTransfer = eventOrText.dataTransfer;
116
+ if (dataTransfer != null) {
117
+ $insertDataTransferForPlainText(dataTransfer, selection);
118
+ } else {
119
+ const data = eventOrText.data;
120
+ if (data) {
121
+ selection.insertText(data);
122
+ }
123
+ }
124
+ }
125
+ return true;
126
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(REMOVE_TEXT_COMMAND, () => {
127
+ const selection = $getSelection();
128
+ if (!$isRangeSelection(selection)) {
129
+ return false;
130
+ }
131
+ selection.removeText();
132
+ return true;
133
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(INSERT_LINE_BREAK_COMMAND, selectStart => {
134
+ const selection = $getSelection();
135
+ if (!$isRangeSelection(selection)) {
136
+ return false;
137
+ }
138
+ selection.insertLineBreak(selectStart);
139
+ return true;
140
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(INSERT_PARAGRAPH_COMMAND, () => {
141
+ const selection = $getSelection();
142
+ if (!$isRangeSelection(selection)) {
143
+ return false;
144
+ }
145
+ selection.insertLineBreak();
146
+ return true;
147
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_ARROW_LEFT_COMMAND, payload => {
148
+ const selection = $getSelection();
149
+ if (!$isRangeSelection(selection)) {
150
+ return false;
151
+ }
152
+ const event = payload;
153
+ const isHoldingShift = event.shiftKey;
154
+ if ($shouldOverrideDefaultCharacterSelection(selection, true)) {
155
+ event.preventDefault();
156
+ $moveCharacter(selection, isHoldingShift, true);
157
+ return true;
158
+ }
159
+ return false;
160
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_ARROW_RIGHT_COMMAND, payload => {
161
+ const selection = $getSelection();
162
+ if (!$isRangeSelection(selection)) {
163
+ return false;
164
+ }
165
+ const event = payload;
166
+ const isHoldingShift = event.shiftKey;
167
+ if ($shouldOverrideDefaultCharacterSelection(selection, false)) {
168
+ event.preventDefault();
169
+ $moveCharacter(selection, isHoldingShift, false);
170
+ return true;
171
+ }
172
+ return false;
173
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_BACKSPACE_COMMAND, event => {
174
+ const selection = $getSelection();
175
+ if (!$isRangeSelection(selection)) {
176
+ return false;
177
+ }
178
+ event.preventDefault();
179
+ return editor.dispatchCommand(DELETE_CHARACTER_COMMAND, true);
180
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_DELETE_COMMAND, event => {
181
+ const selection = $getSelection();
182
+ if (!$isRangeSelection(selection)) {
183
+ return false;
184
+ }
185
+ event.preventDefault();
186
+ return editor.dispatchCommand(DELETE_CHARACTER_COMMAND, false);
187
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(KEY_ENTER_COMMAND, event => {
188
+ const selection = $getSelection();
189
+ if (!$isRangeSelection(selection)) {
190
+ return false;
191
+ }
192
+ if (event !== null) {
193
+ // If we have beforeinput, then we can avoid blocking
194
+ // the default behavior. This ensures that the iOS can
195
+ // intercept that we're actually inserting a paragraph,
196
+ // and autocomplete, autocapitalize etc work as intended.
197
+ // This can also cause a strange performance issue in
198
+ // Safari, where there is a noticeable pause due to
199
+ // preventing the key down of enter.
200
+ if ((IS_IOS || IS_SAFARI || IS_APPLE_WEBKIT) && CAN_USE_BEFORE_INPUT) {
201
+ return false;
202
+ }
203
+ event.preventDefault();
204
+ }
205
+ return editor.dispatchCommand(INSERT_LINE_BREAK_COMMAND, false);
206
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(SELECT_ALL_COMMAND, () => {
207
+ $selectAll();
208
+ return true;
209
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(COPY_COMMAND, event => {
210
+ const selection = $getSelection();
211
+ if (!$isRangeSelection(selection)) {
212
+ return false;
213
+ }
214
+ onCopyForPlainText(event, editor);
215
+ return true;
216
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(CUT_COMMAND, event => {
217
+ const selection = $getSelection();
218
+ if (!$isRangeSelection(selection)) {
219
+ return false;
220
+ }
221
+ onCutForPlainText(event, editor);
222
+ return true;
223
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(PASTE_COMMAND, event => {
224
+ const selection = $getSelection();
225
+ if (!$isRangeSelection(selection)) {
226
+ return false;
227
+ }
228
+ onPasteForPlainText(event, editor);
229
+ return true;
230
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DROP_COMMAND, event => {
231
+ const selection = $getSelection();
232
+ if (!$isRangeSelection(selection)) {
233
+ return false;
234
+ }
235
+
236
+ // TODO: Make drag and drop work at some point.
237
+ event.preventDefault();
238
+ return true;
239
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DRAGSTART_COMMAND, event => {
240
+ const selection = $getSelection();
241
+ if (!$isRangeSelection(selection)) {
242
+ return false;
243
+ }
244
+
245
+ // TODO: Make drag and drop work at some point.
246
+ event.preventDefault();
247
+ return true;
248
+ }, COMMAND_PRIORITY_EDITOR));
249
+ return removeListener;
250
+ }
251
+
252
+ export { registerPlainText };
@@ -34,20 +34,21 @@ CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
34
34
  const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
35
35
  const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
36
36
  const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
37
- CAN_USE_DOM && /Android/.test(navigator.userAgent);
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
42
  // export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
43
43
 
44
+ CAN_USE_DOM && IS_ANDROID && IS_CHROME;
44
45
  const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME;
45
46
 
46
47
  /** @module @lexical/plain-text */
47
48
  function onCopyForPlainText(event, editor) {
48
49
  editor.update(() => {
49
50
  if (event !== null) {
50
- const clipboardData = event instanceof KeyboardEvent ? null : event.clipboardData;
51
+ const clipboardData = utils.objectKlassEquals(event, KeyboardEvent) ? null : event.clipboardData;
51
52
  const selection = lexical.$getSelection();
52
53
  if (selection !== null && clipboardData != null) {
53
54
  event.preventDefault();
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import * as modDev from './LexicalPlainText.dev.esm.js';
8
+ import * as modProd from './LexicalPlainText.prod.esm.js';
9
+ const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
10
+ export const registerPlainText = mod.registerPlainText;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict'
8
- const LexicalPlainText = process.env.NODE_ENV === 'development' ? require('./LexicalPlainText.dev.js') : require('./LexicalPlainText.prod.js')
8
+ const LexicalPlainText = process.env.NODE_ENV === 'development' ? require('./LexicalPlainText.dev.js') : require('./LexicalPlainText.prod.js');
9
9
  module.exports = LexicalPlainText;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
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};
@@ -4,14 +4,14 @@
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
- '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;k&&/Android/.test(navigator.userAgent);let r=k&&/^(?=.*Chrome).*/i.test(navigator.userAgent),t=k&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!r;
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
- function w(d,b){u(d,b);b.update(()=>{let c=h.$getSelection();h.$isRangeSelection(c)&&c.removeText()})}
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()})}
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,
13
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,
14
14
  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||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();
16
- 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=>
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
17
  {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))}
package/package.json CHANGED
@@ -7,17 +7,19 @@
7
7
  "plain-text"
8
8
  ],
9
9
  "license": "MIT",
10
- "version": "0.13.1",
10
+ "version": "0.14.1",
11
11
  "main": "LexicalPlainText.js",
12
12
  "peerDependencies": {
13
- "lexical": "0.13.1",
14
- "@lexical/utils": "0.13.1",
15
- "@lexical/selection": "0.13.1",
16
- "@lexical/clipboard": "0.13.1"
13
+ "lexical": "0.14.1",
14
+ "@lexical/utils": "0.14.1",
15
+ "@lexical/selection": "0.14.1",
16
+ "@lexical/clipboard": "0.14.1"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
20
20
  "url": "https://github.com/facebook/lexical",
21
21
  "directory": "packages/lexical-plain-text"
22
- }
22
+ },
23
+ "module": "LexicalPlainText.esm.js",
24
+ "sideEffects": false
23
25
  }