@lexical/plain-text 0.3.7 → 0.3.8
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 +2 -2
- package/LexicalPlainText.prod.js +2 -2
- package/README.md +3 -1
- package/package.json +5 -5
package/LexicalPlainText.dev.js
CHANGED
|
@@ -48,7 +48,7 @@ const updateOptions = options;
|
|
|
48
48
|
function onCopyForPlainText(event, editor) {
|
|
49
49
|
event.preventDefault();
|
|
50
50
|
editor.update(() => {
|
|
51
|
-
const clipboardData = event.clipboardData;
|
|
51
|
+
const clipboardData = event instanceof KeyboardEvent ? null : event.clipboardData;
|
|
52
52
|
const selection = lexical.$getSelection();
|
|
53
53
|
|
|
54
54
|
if (selection !== null) {
|
|
@@ -69,7 +69,7 @@ function onPasteForPlainText(event, editor) {
|
|
|
69
69
|
event.preventDefault();
|
|
70
70
|
editor.update(() => {
|
|
71
71
|
const selection = lexical.$getSelection();
|
|
72
|
-
const clipboardData = event.clipboardData;
|
|
72
|
+
const clipboardData = event instanceof InputEvent ? null : event.clipboardData;
|
|
73
73
|
|
|
74
74
|
if (clipboardData != null && lexical.$isRangeSelection(selection)) {
|
|
75
75
|
clipboard.$insertDataTransferForPlainText(clipboardData, selection);
|
package/LexicalPlainText.prod.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
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
|
-
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.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.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()})}
|
|
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()})}
|
|
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/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
# `@lexical/plain-text`
|
|
2
2
|
|
|
3
|
-
This package
|
|
3
|
+
This package provides a starting point for Lexical users by registering listeners for a set of basic commands that cover simple text-editing behavior such as entering text, deleting characters, copy + paste, or changing the selection with arrow keys.
|
|
4
|
+
|
|
5
|
+
You can use this package as a starting point, and then add additional command listeners to customize the functionality of your editor. If you want to add rich-text features, such as headings, blockquotes, or formatted text, you may want to consider using [@lexical/rich-text](https://lexical.dev/docs/api/lexical-rich-text) instead.
|
package/package.json
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
"plain-text"
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "0.3.
|
|
10
|
+
"version": "0.3.8",
|
|
11
11
|
"main": "LexicalPlainText.js",
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"lexical": "0.3.
|
|
14
|
-
"@lexical/utils": "0.3.
|
|
15
|
-
"@lexical/selection": "0.3.
|
|
16
|
-
"@lexical/clipboard": "0.3.
|
|
13
|
+
"lexical": "0.3.8",
|
|
14
|
+
"@lexical/utils": "0.3.8",
|
|
15
|
+
"@lexical/selection": "0.3.8",
|
|
16
|
+
"@lexical/clipboard": "0.3.8"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|