@lexical/plain-text 0.3.7 → 0.3.10
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 +7 -7
- package/LexicalPlainText.prod.js +2 -2
- package/README.md +3 -1
- package/package.json +5 -5
package/LexicalPlainText.dev.js
CHANGED
|
@@ -19,14 +19,12 @@ var lexical = require('lexical');
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
22
|
-
const documentMode =
|
|
23
|
-
CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
|
|
22
|
+
const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
|
|
24
23
|
CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
25
24
|
CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
|
|
26
25
|
const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
|
|
27
26
|
const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
|
|
28
|
-
const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && //
|
|
29
|
-
!window.MSStream; // Keep these in case we need to use them in the future.
|
|
27
|
+
const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; // Keep these in case we need to use them in the future.
|
|
30
28
|
// export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
|
|
31
29
|
// export const IS_CHROME: boolean = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
|
|
32
30
|
// export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
|
|
@@ -48,7 +46,7 @@ const updateOptions = options;
|
|
|
48
46
|
function onCopyForPlainText(event, editor) {
|
|
49
47
|
event.preventDefault();
|
|
50
48
|
editor.update(() => {
|
|
51
|
-
const clipboardData = event.clipboardData;
|
|
49
|
+
const clipboardData = event instanceof KeyboardEvent ? null : event.clipboardData;
|
|
52
50
|
const selection = lexical.$getSelection();
|
|
53
51
|
|
|
54
52
|
if (selection !== null) {
|
|
@@ -69,11 +67,13 @@ function onPasteForPlainText(event, editor) {
|
|
|
69
67
|
event.preventDefault();
|
|
70
68
|
editor.update(() => {
|
|
71
69
|
const selection = lexical.$getSelection();
|
|
72
|
-
const clipboardData = event.clipboardData;
|
|
70
|
+
const clipboardData = event instanceof InputEvent ? null : event.clipboardData;
|
|
73
71
|
|
|
74
72
|
if (clipboardData != null && lexical.$isRangeSelection(selection)) {
|
|
75
73
|
clipboard.$insertDataTransferForPlainText(clipboardData, selection);
|
|
76
74
|
}
|
|
75
|
+
}, {
|
|
76
|
+
tag: 'paste'
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -277,7 +277,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
277
277
|
// If we have beforeinput, then we can avoid blocking
|
|
278
278
|
// the default behavior. This ensures that the iOS can
|
|
279
279
|
// intercept that we're actually inserting a paragraph,
|
|
280
|
-
// and autocomplete,
|
|
280
|
+
// and autocomplete, autocapitalize etc work as intended.
|
|
281
281
|
// This can also cause a strange performance issue in
|
|
282
282
|
// Safari, where there is a noticeable pause due to
|
|
283
283
|
// preventing the key down of enter.
|
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)},{tag:"paste"})}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.10",
|
|
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.10",
|
|
14
|
+
"@lexical/utils": "0.3.10",
|
|
15
|
+
"@lexical/selection": "0.3.10",
|
|
16
|
+
"@lexical/clipboard": "0.3.10"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|