@lexical/plain-text 0.1.17
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.
- package/LICENSE +21 -0
- package/LexicalPlainText.d.ts +15 -0
- package/LexicalPlainText.dev.js +306 -0
- package/LexicalPlainText.js +9 -0
- package/LexicalPlainText.js.flow +15 -0
- package/LexicalPlainText.prod.js +15 -0
- package/README.md +3 -0
- package/package.json +23 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
import type {EditorState, LexicalEditor} from 'lexical';
|
|
10
|
+
export type InitialEditorStateType = null | string | EditorState | (() => void);
|
|
11
|
+
|
|
12
|
+
declare function registerPlainText(
|
|
13
|
+
editor: LexicalEditor,
|
|
14
|
+
initialEditorState?: InitialEditorStateType,
|
|
15
|
+
): () => void;
|
|
@@ -0,0 +1,306 @@
|
|
|
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
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var clipboard = require('@lexical/clipboard');
|
|
10
|
+
var selection = require('@lexical/selection');
|
|
11
|
+
var utils = require('@lexical/utils');
|
|
12
|
+
var lexical = require('lexical');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the MIT license found in the
|
|
18
|
+
* LICENSE file in the root directory of this source tree.
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
// Convoluted logic to make this work with Flow. Order matters.
|
|
23
|
+
const options = {
|
|
24
|
+
tag: 'history-merge'
|
|
25
|
+
};
|
|
26
|
+
const setEditorOptions = options;
|
|
27
|
+
const updateOptions = options;
|
|
28
|
+
|
|
29
|
+
function onCopyForPlainText(event, editor) {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
editor.update(() => {
|
|
32
|
+
const clipboardData = event.clipboardData;
|
|
33
|
+
const selection = lexical.$getSelection();
|
|
34
|
+
|
|
35
|
+
if (selection !== null) {
|
|
36
|
+
if (clipboardData != null) {
|
|
37
|
+
const htmlString = clipboard.getHtmlContent(editor);
|
|
38
|
+
|
|
39
|
+
if (htmlString !== null) {
|
|
40
|
+
clipboardData.setData('text/html', htmlString);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
clipboardData.setData('text/plain', selection.getTextContent());
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function onPasteForPlainText(event, editor) {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
editor.update(() => {
|
|
52
|
+
const selection = lexical.$getSelection();
|
|
53
|
+
const clipboardData = event.clipboardData;
|
|
54
|
+
|
|
55
|
+
if (clipboardData != null && lexical.$isRangeSelection(selection)) {
|
|
56
|
+
clipboard.$insertDataTransferForPlainText(clipboardData, selection);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function onCutForPlainText(event, editor) {
|
|
62
|
+
onCopyForPlainText(event, editor);
|
|
63
|
+
editor.update(() => {
|
|
64
|
+
const selection = lexical.$getSelection();
|
|
65
|
+
|
|
66
|
+
if (lexical.$isRangeSelection(selection)) {
|
|
67
|
+
selection.removeText();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function initializeEditor(editor, initialEditorState) {
|
|
73
|
+
if (initialEditorState === null) {
|
|
74
|
+
return;
|
|
75
|
+
} else if (initialEditorState === undefined) {
|
|
76
|
+
editor.update(() => {
|
|
77
|
+
const root = lexical.$getRoot();
|
|
78
|
+
const firstChild = root.getFirstChild();
|
|
79
|
+
|
|
80
|
+
if (firstChild === null) {
|
|
81
|
+
const paragraph = lexical.$createParagraphNode();
|
|
82
|
+
root.append(paragraph);
|
|
83
|
+
const activeElement = document.activeElement;
|
|
84
|
+
|
|
85
|
+
if (lexical.$getSelection() !== null || activeElement !== null && activeElement === editor.getRootElement()) {
|
|
86
|
+
paragraph.select();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, updateOptions);
|
|
90
|
+
} else if (initialEditorState !== null) {
|
|
91
|
+
switch (typeof initialEditorState) {
|
|
92
|
+
case 'string':
|
|
93
|
+
{
|
|
94
|
+
const parsedEditorState = editor.parseEditorState(initialEditorState);
|
|
95
|
+
editor.setEditorState(parsedEditorState, setEditorOptions);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
case 'object':
|
|
100
|
+
{
|
|
101
|
+
editor.setEditorState(initialEditorState, setEditorOptions);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
case 'function':
|
|
106
|
+
{
|
|
107
|
+
editor.update(initialEditorState, updateOptions);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function registerPlainText(editor, initialEditorState) {
|
|
115
|
+
const removeListener = utils.mergeRegister(editor.registerCommand(lexical.DELETE_CHARACTER_COMMAND, isBackward => {
|
|
116
|
+
const selection = lexical.$getSelection();
|
|
117
|
+
|
|
118
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
selection.deleteCharacter(isBackward);
|
|
123
|
+
return true;
|
|
124
|
+
}, 0), editor.registerCommand(lexical.DELETE_WORD_COMMAND, isBackward => {
|
|
125
|
+
const selection = lexical.$getSelection();
|
|
126
|
+
|
|
127
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
selection.deleteWord(isBackward);
|
|
132
|
+
return true;
|
|
133
|
+
}, 0), editor.registerCommand(lexical.DELETE_LINE_COMMAND, isBackward => {
|
|
134
|
+
const selection = lexical.$getSelection();
|
|
135
|
+
|
|
136
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
selection.deleteLine(isBackward);
|
|
141
|
+
return true;
|
|
142
|
+
}, 0), editor.registerCommand(lexical.INSERT_TEXT_COMMAND, eventOrText => {
|
|
143
|
+
const selection = lexical.$getSelection();
|
|
144
|
+
|
|
145
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (typeof eventOrText === 'string') {
|
|
150
|
+
selection.insertText(eventOrText);
|
|
151
|
+
} else {
|
|
152
|
+
const dataTransfer = eventOrText.dataTransfer;
|
|
153
|
+
|
|
154
|
+
if (dataTransfer != null) {
|
|
155
|
+
clipboard.$insertDataTransferForPlainText(dataTransfer, selection);
|
|
156
|
+
} else {
|
|
157
|
+
const data = eventOrText.data;
|
|
158
|
+
|
|
159
|
+
if (data) {
|
|
160
|
+
selection.insertText(data);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return true;
|
|
166
|
+
}, 0), editor.registerCommand(lexical.REMOVE_TEXT_COMMAND, payload => {
|
|
167
|
+
const selection = lexical.$getSelection();
|
|
168
|
+
|
|
169
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
selection.removeText();
|
|
174
|
+
return true;
|
|
175
|
+
}, 0), editor.registerCommand(lexical.INSERT_LINE_BREAK_COMMAND, selectStart => {
|
|
176
|
+
const selection = lexical.$getSelection();
|
|
177
|
+
|
|
178
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
selection.insertLineBreak(selectStart);
|
|
183
|
+
return true;
|
|
184
|
+
}, 0), editor.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND, payload => {
|
|
185
|
+
const selection = lexical.$getSelection();
|
|
186
|
+
|
|
187
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
selection.insertLineBreak();
|
|
192
|
+
return true;
|
|
193
|
+
}, 0), editor.registerCommand(lexical.KEY_ARROW_LEFT_COMMAND, payload => {
|
|
194
|
+
const selection$1 = lexical.$getSelection();
|
|
195
|
+
|
|
196
|
+
if (!lexical.$isRangeSelection(selection$1)) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const event = payload;
|
|
201
|
+
const isHoldingShift = event.shiftKey;
|
|
202
|
+
|
|
203
|
+
if (selection.$shouldOverrideDefaultCharacterSelection(selection$1, true)) {
|
|
204
|
+
event.preventDefault();
|
|
205
|
+
selection.$moveCharacter(selection$1, isHoldingShift, true);
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return false;
|
|
210
|
+
}, 0), editor.registerCommand(lexical.KEY_ARROW_RIGHT_COMMAND, payload => {
|
|
211
|
+
const selection$1 = lexical.$getSelection();
|
|
212
|
+
|
|
213
|
+
if (!lexical.$isRangeSelection(selection$1)) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const event = payload;
|
|
218
|
+
const isHoldingShift = event.shiftKey;
|
|
219
|
+
|
|
220
|
+
if (selection.$shouldOverrideDefaultCharacterSelection(selection$1, false)) {
|
|
221
|
+
event.preventDefault();
|
|
222
|
+
selection.$moveCharacter(selection$1, isHoldingShift, false);
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return false;
|
|
227
|
+
}, 0), editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, event => {
|
|
228
|
+
const selection = lexical.$getSelection();
|
|
229
|
+
|
|
230
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
event.preventDefault();
|
|
235
|
+
return editor.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND, true);
|
|
236
|
+
}, 0), editor.registerCommand(lexical.KEY_DELETE_COMMAND, event => {
|
|
237
|
+
const selection = lexical.$getSelection();
|
|
238
|
+
|
|
239
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
event.preventDefault();
|
|
244
|
+
return editor.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND, false);
|
|
245
|
+
}, 0), editor.registerCommand(lexical.KEY_ENTER_COMMAND, event => {
|
|
246
|
+
const selection = lexical.$getSelection();
|
|
247
|
+
|
|
248
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
event.preventDefault();
|
|
253
|
+
return editor.dispatchCommand(lexical.INSERT_LINE_BREAK_COMMAND);
|
|
254
|
+
}, 0), editor.registerCommand(lexical.COPY_COMMAND, event => {
|
|
255
|
+
const selection = lexical.$getSelection();
|
|
256
|
+
|
|
257
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
onCopyForPlainText(event, editor);
|
|
262
|
+
return true;
|
|
263
|
+
}, 0), editor.registerCommand(lexical.CUT_COMMAND, event => {
|
|
264
|
+
const selection = lexical.$getSelection();
|
|
265
|
+
|
|
266
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
onCutForPlainText(event, editor);
|
|
271
|
+
return true;
|
|
272
|
+
}, 0), editor.registerCommand(lexical.PASTE_COMMAND, event => {
|
|
273
|
+
const selection = lexical.$getSelection();
|
|
274
|
+
|
|
275
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
onPasteForPlainText(event, editor);
|
|
280
|
+
return true;
|
|
281
|
+
}, 0), editor.registerCommand(lexical.DROP_COMMAND, event => {
|
|
282
|
+
const selection = lexical.$getSelection();
|
|
283
|
+
|
|
284
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
285
|
+
return false;
|
|
286
|
+
} // TODO: Make drag and drop work at some point.
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
event.preventDefault();
|
|
290
|
+
return true;
|
|
291
|
+
}, 0), editor.registerCommand(lexical.DRAGSTART_COMMAND, event => {
|
|
292
|
+
const selection = lexical.$getSelection();
|
|
293
|
+
|
|
294
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
295
|
+
return false;
|
|
296
|
+
} // TODO: Make drag and drop work at some point.
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
event.preventDefault();
|
|
300
|
+
return true;
|
|
301
|
+
}, 0));
|
|
302
|
+
initializeEditor(editor, initialEditorState);
|
|
303
|
+
return removeListener;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
exports.registerPlainText = registerPlainText;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
'use strict'
|
|
8
|
+
const LexicalPlainText = process.env.NODE_ENV === 'development' ? require('./LexicalPlainText.dev.js') : require('./LexicalPlainText.prod.js')
|
|
9
|
+
module.exports = LexicalPlainText;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
import type {EditorState, LexicalEditor} from 'lexical';
|
|
10
|
+
export type InitialEditorStateType = null | string | EditorState | (() => void);
|
|
11
|
+
|
|
12
|
+
declare export function registerPlainText(
|
|
13
|
+
editor: LexicalEditor,
|
|
14
|
+
initialEditorState?: InitialEditorStateType,
|
|
15
|
+
): () => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
var a=require("@lexical/clipboard"),h=require("@lexical/selection"),k=require("@lexical/utils"),l=require("lexical");const m={tag:"history-merge"};function n(d,e){d.preventDefault();e.update(()=>{const f=d.clipboardData,b=l.$getSelection();if(null!==b&&null!=f){const c=a.getHtmlContent(e);null!==c&&f.setData("text/html",c);f.setData("text/plain",b.getTextContent())}})}
|
|
8
|
+
function p(d,e){d.preventDefault();e.update(()=>{const f=l.$getSelection(),b=d.clipboardData;null!=b&&l.$isRangeSelection(f)&&a.$insertDataTransferForPlainText(b,f)})}function q(d,e){n(d,e);e.update(()=>{const f=l.$getSelection();l.$isRangeSelection(f)&&f.removeText()})}
|
|
9
|
+
function r(d,e){if(null!==e)if(void 0===e)d.update(()=>{var f=l.$getRoot();if(null===f.getFirstChild()){const b=l.$createParagraphNode();f.append(b);f=document.activeElement;(null!==l.$getSelection()||null!==f&&f===d.getRootElement())&&b.select()}},m);else if(null!==e)switch(typeof e){case "string":e=d.parseEditorState(e);d.setEditorState(e,m);break;case "object":d.setEditorState(e,m);break;case "function":d.update(e,m)}}
|
|
10
|
+
exports.registerPlainText=function(d,e){const f=k.mergeRegister(d.registerCommand(l.DELETE_CHARACTER_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.deleteCharacter(b);return!0},0),d.registerCommand(l.DELETE_WORD_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.deleteWord(b);return!0},0),d.registerCommand(l.DELETE_LINE_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.deleteLine(b);return!0},0),d.registerCommand(l.INSERT_TEXT_COMMAND,
|
|
11
|
+
b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;if("string"===typeof b)c.insertText(b);else{const g=b.dataTransfer;null!=g?a.$insertDataTransferForPlainText(g,c):(b=b.data)&&c.insertText(b)}return!0},0),d.registerCommand(l.REMOVE_TEXT_COMMAND,()=>{const b=l.$getSelection();if(!l.$isRangeSelection(b))return!1;b.removeText();return!0},0),d.registerCommand(l.INSERT_LINE_BREAK_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.insertLineBreak(b);return!0},0),
|
|
12
|
+
d.registerCommand(l.INSERT_PARAGRAPH_COMMAND,()=>{const b=l.$getSelection();if(!l.$isRangeSelection(b))return!1;b.insertLineBreak();return!0},0),d.registerCommand(l.KEY_ARROW_LEFT_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;const g=b.shiftKey;return h.$shouldOverrideDefaultCharacterSelection(c,!0)?(b.preventDefault(),h.$moveCharacter(c,g,!0),!0):!1},0),d.registerCommand(l.KEY_ARROW_RIGHT_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;const g=
|
|
13
|
+
b.shiftKey;return h.$shouldOverrideDefaultCharacterSelection(c,!1)?(b.preventDefault(),h.$moveCharacter(c,g,!1),!0):!1},0),d.registerCommand(l.KEY_BACKSPACE_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.preventDefault();return d.dispatchCommand(l.DELETE_CHARACTER_COMMAND,!0)},0),d.registerCommand(l.KEY_DELETE_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.preventDefault();return d.dispatchCommand(l.DELETE_CHARACTER_COMMAND,!1)},0),d.registerCommand(l.KEY_ENTER_COMMAND,
|
|
14
|
+
b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.preventDefault();return d.dispatchCommand(l.INSERT_LINE_BREAK_COMMAND)},0),d.registerCommand(l.COPY_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;n(b,d);return!0},0),d.registerCommand(l.CUT_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;q(b,d);return!0},0),d.registerCommand(l.PASTE_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;p(b,d);return!0},0),d.registerCommand(l.DROP_COMMAND,
|
|
15
|
+
b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.preventDefault();return!0},0),d.registerCommand(l.DRAGSTART_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.preventDefault();return!0},0));r(d,e);return f};
|
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lexical/plain-text",
|
|
3
|
+
"description": "This package contains plain text helpers for Lexical.",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"lexical",
|
|
6
|
+
"editor",
|
|
7
|
+
"plain-text"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"version": "0.1.17",
|
|
11
|
+
"main": "LexicalPlainText.js",
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"lexical": "0.1.17",
|
|
14
|
+
"@lexical/utils": "0.1.17",
|
|
15
|
+
"@lexical/selection": "0.1.17",
|
|
16
|
+
"@lexical/clipboard": "0.1.17"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/facebook/lexical",
|
|
21
|
+
"directory": "packages/lexical-plain-text"
|
|
22
|
+
}
|
|
23
|
+
}
|