@lexical/plain-text 0.1.21 → 0.2.2
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/LexicalPlainText.dev.js +21 -18
- package/LexicalPlainText.prod.js +7 -6
- package/package.json +5 -5
package/LexicalPlainText.dev.js
CHANGED
|
@@ -121,7 +121,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
121
121
|
|
|
122
122
|
selection.deleteCharacter(isBackward);
|
|
123
123
|
return true;
|
|
124
|
-
},
|
|
124
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.DELETE_WORD_COMMAND, isBackward => {
|
|
125
125
|
const selection = lexical.$getSelection();
|
|
126
126
|
|
|
127
127
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -130,7 +130,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
130
130
|
|
|
131
131
|
selection.deleteWord(isBackward);
|
|
132
132
|
return true;
|
|
133
|
-
},
|
|
133
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.DELETE_LINE_COMMAND, isBackward => {
|
|
134
134
|
const selection = lexical.$getSelection();
|
|
135
135
|
|
|
136
136
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -139,7 +139,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
139
139
|
|
|
140
140
|
selection.deleteLine(isBackward);
|
|
141
141
|
return true;
|
|
142
|
-
},
|
|
142
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.INSERT_TEXT_COMMAND, eventOrText => {
|
|
143
143
|
const selection = lexical.$getSelection();
|
|
144
144
|
|
|
145
145
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -163,7 +163,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
return true;
|
|
166
|
-
},
|
|
166
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.REMOVE_TEXT_COMMAND, payload => {
|
|
167
167
|
const selection = lexical.$getSelection();
|
|
168
168
|
|
|
169
169
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -172,7 +172,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
172
172
|
|
|
173
173
|
selection.removeText();
|
|
174
174
|
return true;
|
|
175
|
-
},
|
|
175
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.INSERT_LINE_BREAK_COMMAND, selectStart => {
|
|
176
176
|
const selection = lexical.$getSelection();
|
|
177
177
|
|
|
178
178
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -181,7 +181,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
181
181
|
|
|
182
182
|
selection.insertLineBreak(selectStart);
|
|
183
183
|
return true;
|
|
184
|
-
},
|
|
184
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND, payload => {
|
|
185
185
|
const selection = lexical.$getSelection();
|
|
186
186
|
|
|
187
187
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -190,7 +190,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
190
190
|
|
|
191
191
|
selection.insertLineBreak();
|
|
192
192
|
return true;
|
|
193
|
-
},
|
|
193
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ARROW_LEFT_COMMAND, payload => {
|
|
194
194
|
const selection$1 = lexical.$getSelection();
|
|
195
195
|
|
|
196
196
|
if (!lexical.$isRangeSelection(selection$1)) {
|
|
@@ -207,7 +207,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
return false;
|
|
210
|
-
},
|
|
210
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ARROW_RIGHT_COMMAND, payload => {
|
|
211
211
|
const selection$1 = lexical.$getSelection();
|
|
212
212
|
|
|
213
213
|
if (!lexical.$isRangeSelection(selection$1)) {
|
|
@@ -224,7 +224,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
return false;
|
|
227
|
-
},
|
|
227
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, event => {
|
|
228
228
|
const selection = lexical.$getSelection();
|
|
229
229
|
|
|
230
230
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -233,7 +233,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
233
233
|
|
|
234
234
|
event.preventDefault();
|
|
235
235
|
return editor.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND, true);
|
|
236
|
-
},
|
|
236
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_DELETE_COMMAND, event => {
|
|
237
237
|
const selection = lexical.$getSelection();
|
|
238
238
|
|
|
239
239
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -242,16 +242,19 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
242
242
|
|
|
243
243
|
event.preventDefault();
|
|
244
244
|
return editor.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND, false);
|
|
245
|
-
},
|
|
245
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ENTER_COMMAND, event => {
|
|
246
246
|
const selection = lexical.$getSelection();
|
|
247
247
|
|
|
248
248
|
if (!lexical.$isRangeSelection(selection)) {
|
|
249
249
|
return false;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
event
|
|
252
|
+
if (event !== null) {
|
|
253
|
+
event.preventDefault();
|
|
254
|
+
}
|
|
255
|
+
|
|
253
256
|
return editor.dispatchCommand(lexical.INSERT_LINE_BREAK_COMMAND);
|
|
254
|
-
},
|
|
257
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.COPY_COMMAND, event => {
|
|
255
258
|
const selection = lexical.$getSelection();
|
|
256
259
|
|
|
257
260
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -260,7 +263,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
260
263
|
|
|
261
264
|
onCopyForPlainText(event, editor);
|
|
262
265
|
return true;
|
|
263
|
-
},
|
|
266
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.CUT_COMMAND, event => {
|
|
264
267
|
const selection = lexical.$getSelection();
|
|
265
268
|
|
|
266
269
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -269,7 +272,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
269
272
|
|
|
270
273
|
onCutForPlainText(event, editor);
|
|
271
274
|
return true;
|
|
272
|
-
},
|
|
275
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.PASTE_COMMAND, event => {
|
|
273
276
|
const selection = lexical.$getSelection();
|
|
274
277
|
|
|
275
278
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -278,7 +281,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
278
281
|
|
|
279
282
|
onPasteForPlainText(event, editor);
|
|
280
283
|
return true;
|
|
281
|
-
},
|
|
284
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.DROP_COMMAND, event => {
|
|
282
285
|
const selection = lexical.$getSelection();
|
|
283
286
|
|
|
284
287
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -288,7 +291,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
288
291
|
|
|
289
292
|
event.preventDefault();
|
|
290
293
|
return true;
|
|
291
|
-
},
|
|
294
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.DRAGSTART_COMMAND, event => {
|
|
292
295
|
const selection = lexical.$getSelection();
|
|
293
296
|
|
|
294
297
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -298,7 +301,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
298
301
|
|
|
299
302
|
event.preventDefault();
|
|
300
303
|
return true;
|
|
301
|
-
},
|
|
304
|
+
}, lexical.COMMAND_PRIORITY_EDITOR));
|
|
302
305
|
initializeEditor(editor, initialEditorState);
|
|
303
306
|
return removeListener;
|
|
304
307
|
}
|
package/LexicalPlainText.prod.js
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
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
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
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},
|
|
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},
|
|
12
|
-
d.registerCommand(l.INSERT_PARAGRAPH_COMMAND,()=>{const b=l.$getSelection();if(!l.$isRangeSelection(b))return!1;b.insertLineBreak();return!0},
|
|
13
|
-
|
|
14
|
-
b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.preventDefault();return d.dispatchCommand(l.
|
|
15
|
-
b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.
|
|
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},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);
|
|
11
|
+
return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.INSERT_TEXT_COMMAND,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},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,
|
|
12
|
+
b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.insertLineBreak(b);return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.INSERT_PARAGRAPH_COMMAND,()=>{const b=l.$getSelection();if(!l.$isRangeSelection(b))return!1;b.insertLineBreak();return!0},l.COMMAND_PRIORITY_EDITOR),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,
|
|
13
|
+
g,!0),!0):!1},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.KEY_ARROW_RIGHT_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;const g=b.shiftKey;return h.$shouldOverrideDefaultCharacterSelection(c,!1)?(b.preventDefault(),h.$moveCharacter(c,g,!1),!0):!1},l.COMMAND_PRIORITY_EDITOR),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)},l.COMMAND_PRIORITY_EDITOR),
|
|
14
|
+
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)},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.KEY_ENTER_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;null!==b&&b.preventDefault();return d.dispatchCommand(l.INSERT_LINE_BREAK_COMMAND)},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.COPY_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;
|
|
15
|
+
n(b,d);return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.CUT_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;q(b,d);return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.PASTE_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;p(b,d);return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.DROP_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.preventDefault();return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.DRAGSTART_COMMAND,
|
|
16
|
+
b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.preventDefault();return!0},l.COMMAND_PRIORITY_EDITOR));r(d,e);return f};
|
package/package.json
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
"plain-text"
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.2.2",
|
|
11
11
|
"main": "LexicalPlainText.js",
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"lexical": "0.
|
|
14
|
-
"@lexical/utils": "0.
|
|
15
|
-
"@lexical/selection": "0.
|
|
16
|
-
"@lexical/clipboard": "0.
|
|
13
|
+
"lexical": "0.2.2",
|
|
14
|
+
"@lexical/utils": "0.2.2",
|
|
15
|
+
"@lexical/selection": "0.2.2",
|
|
16
|
+
"@lexical/clipboard": "0.2.2"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|