@lexical/plain-text
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -9,3 +9,7 @@ /** | ||
import type {EditorState, LexicalEditor} from 'lexical'; | ||
export type InitialEditorStateType = null | string | EditorState | (() => void); | ||
export type InitialEditorStateType = | ||
| null | ||
| string | ||
| EditorState | ||
| ((editor: LexicalEditor) => void); | ||
@@ -12,0 +16,0 @@ declare function registerPlainText( |
@@ -97,5 +97,4 @@ /** | ||
const root = lexical.$getRoot(); | ||
const firstChild = root.getFirstChild(); | ||
if (firstChild === null) { | ||
if (root.isEmpty()) { | ||
const paragraph = lexical.$createParagraphNode(); | ||
@@ -127,3 +126,9 @@ root.append(paragraph); | ||
{ | ||
editor.update(initialEditorState, updateOptions); | ||
editor.update(() => { | ||
const root = lexical.$getRoot(); | ||
if (root.isEmpty()) { | ||
initialEditorState(editor); | ||
} | ||
}, updateOptions); | ||
break; | ||
@@ -130,0 +135,0 @@ } |
@@ -8,6 +8,6 @@ /** | ||
'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); | ||
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,e){d.preventDefault();e.update(()=>{let f=d.clipboardData,b=l.$getSelection();if(null!==b&&null!=f){let c=a.$getHtmlContent(e);null!==c&&f.setData("text/html",c);f.setData("text/plain",b.getTextContent())}})} | ||
function v(d,e){d.preventDefault();e.update(()=>{let f=l.$getSelection(),b=d.clipboardData;null!=b&&l.$isRangeSelection(f)&&a.$insertDataTransferForPlainText(b,f)})}function w(d,e){u(d,e);e.update(()=>{let f=l.$getSelection();l.$isRangeSelection(f)&&f.removeText()})} | ||
function x(d,e){if(null!==e)if(void 0===e)d.update(()=>{var f=l.$getRoot();if(null===f.getFirstChild()){let 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)}} | ||
exports.registerPlainText=function(d,e){let 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); | ||
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())}})} | ||
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()})} | ||
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)}} | ||
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); | ||
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, | ||
@@ -18,2 +18,2 @@ 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 h=b.shiftKey;return g.$shouldOverrideDefaultCharacterSelection(c,!0)?(b.preventDefault(),g.$moveCharacter(c, | ||
if(!l.$isRangeSelection(c))return!1;u(b,d);return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.CUT_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;w(b,d);return!0},l.COMMAND_PRIORITY_EDITOR),d.registerCommand(l.PASTE_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;v(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,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.preventDefault();return!0},l.COMMAND_PRIORITY_EDITOR));x(d,e);return f} | ||
d.registerCommand(l.DRAGSTART_COMMAND,b=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.preventDefault();return!0},l.COMMAND_PRIORITY_EDITOR));x(d,f);return e} |
@@ -10,9 +10,9 @@ { | ||
"license": "MIT", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"main": "LexicalPlainText.js", | ||
"peerDependencies": { | ||
"lexical": "0.3.2", | ||
"@lexical/utils": "0.3.2", | ||
"@lexical/selection": "0.3.2", | ||
"@lexical/clipboard": "0.3.2" | ||
"lexical": "0.3.3", | ||
"@lexical/utils": "0.3.3", | ||
"@lexical/selection": "0.3.3", | ||
"@lexical/clipboard": "0.3.3" | ||
}, | ||
@@ -19,0 +19,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19246
334