@lexical/plain-text 0.2.7 → 0.2.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.d.ts +0 -2
- package/LexicalPlainText.dev.js +7 -16
- package/LexicalPlainText.prod.js +1 -1
- package/package.json +6 -6
package/LexicalPlainText.d.ts
CHANGED
|
@@ -4,9 +4,7 @@
|
|
|
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
|
-
* @flow strict
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import type {EditorState, LexicalEditor} from 'lexical';
|
|
11
9
|
export type InitialEditorStateType = null | string | EditorState | (() => void);
|
|
12
10
|
|
package/LexicalPlainText.dev.js
CHANGED
|
@@ -17,24 +17,16 @@ var lexical = require('lexical');
|
|
|
17
17
|
* This source code is licensed under the MIT license found in the
|
|
18
18
|
* LICENSE file in the root directory of this source tree.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
20
|
*/
|
|
22
21
|
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
26
|
-
*
|
|
27
|
-
* This source code is licensed under the MIT license found in the
|
|
28
|
-
* LICENSE file in the root directory of this source tree.
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
|
|
22
|
+
const documentMode = // @ts-ignore
|
|
23
|
+
CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
|
|
33
24
|
CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
34
25
|
CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
|
|
35
26
|
const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
|
|
36
|
-
const IS_SAFARI = CAN_USE_DOM && /Version\/[\d
|
|
37
|
-
const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) &&
|
|
27
|
+
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) && // @ts-ignore
|
|
29
|
+
!window.MSStream; // Keep these in case we need to use them in the future.
|
|
38
30
|
// export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
|
|
39
31
|
// export const IS_CHROME: boolean = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
|
|
40
32
|
// export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
|
|
@@ -45,7 +37,6 @@ const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !w
|
|
|
45
37
|
* This source code is licensed under the MIT license found in the
|
|
46
38
|
* LICENSE file in the root directory of this source tree.
|
|
47
39
|
*
|
|
48
|
-
*
|
|
49
40
|
*/
|
|
50
41
|
// Convoluted logic to make this work with Flow. Order matters.
|
|
51
42
|
const options = {
|
|
@@ -191,7 +182,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
191
182
|
}
|
|
192
183
|
|
|
193
184
|
return true;
|
|
194
|
-
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.REMOVE_TEXT_COMMAND,
|
|
185
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.REMOVE_TEXT_COMMAND, () => {
|
|
195
186
|
const selection = lexical.$getSelection();
|
|
196
187
|
|
|
197
188
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -209,7 +200,7 @@ function registerPlainText(editor, initialEditorState) {
|
|
|
209
200
|
|
|
210
201
|
selection.insertLineBreak(selectStart);
|
|
211
202
|
return true;
|
|
212
|
-
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND,
|
|
203
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND, () => {
|
|
213
204
|
const selection = lexical.$getSelection();
|
|
214
205
|
|
|
215
206
|
if (!lexical.$isRangeSelection(selection)) {
|
package/LexicalPlainText.prod.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
var a=require("@lexical/clipboard"),g=require("@lexical/selection"),k=require("@lexical/utils"),l=require("lexical");const 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
|
-
const p=m&&"InputEvent"in window&&!n?"getTargetRanges"in new window.InputEvent("input"):!1,q=m&&/Version\/[\d
|
|
8
|
+
const 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,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())}})}
|
|
9
9
|
function v(d,e){d.preventDefault();e.update(()=>{const f=l.$getSelection(),b=d.clipboardData;null!=b&&l.$isRangeSelection(f)&&a.$insertDataTransferForPlainText(b,f)})}function w(d,e){u(d,e);e.update(()=>{const f=l.$getSelection();l.$isRangeSelection(f)&&f.removeText()})}
|
|
10
10
|
function x(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()}},t);else if(null!==e)switch(typeof e){case "string":e=d.parseEditorState(e);d.setEditorState(e,t);break;case "object":d.setEditorState(e,t);break;case "function":d.update(e,t)}}
|
|
11
11
|
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);
|
package/package.json
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
"plain-text"
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "0.2.
|
|
11
|
-
"main": "LexicalPlainText.
|
|
10
|
+
"version": "0.2.8",
|
|
11
|
+
"main": "LexicalPlainText.ts",
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"lexical": "0.2.
|
|
14
|
-
"@lexical/utils": "0.2.
|
|
15
|
-
"@lexical/selection": "0.2.
|
|
16
|
-
"@lexical/clipboard": "0.2.
|
|
13
|
+
"lexical": "0.2.8",
|
|
14
|
+
"@lexical/utils": "0.2.8",
|
|
15
|
+
"@lexical/selection": "0.2.8",
|
|
16
|
+
"@lexical/clipboard": "0.2.8"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|