Socket
Socket
Sign inDemoInstall

@lexical/rich-text

Package Overview
Dependencies
Maintainers
3
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/rich-text - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

36

LexicalRichText.dev.js

@@ -22,2 +22,30 @@ /**

*/
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
CAN_USE_DOM && /Version\/[\d\.]+.*Safari/.test(navigator.userAgent);
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.
// export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
// export const IS_CHROME: boolean = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
// export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/
// Convoluted logic to make this work with Flow. Order matters.

@@ -510,2 +538,10 @@ const options = {

if (event !== null) {
// If we have beforeinput, then we can avoid blocking
// the default behavior. This ensures that the iOS can
// intercept that we're actually inserting a paragraph,
// and autocomplete, autocapitialize etc work as intended.
if (IS_IOS) {
return false;
}
event.preventDefault();

@@ -512,0 +548,0 @@

23

LexicalRichText.prod.js

@@ -7,9 +7,10 @@ /**

*/
var a=require("@lexical/clipboard"),h=require("@lexical/selection"),k=require("@lexical/utils"),l=require("lexical");const m={tag:"history-merge"};
class n extends l.ElementNode{static getType(){return"quote"}static clone(b){return new n(b.__key)}constructor(b){super(b)}createDOM(b){const e=document.createElement("blockquote");k.addClassNamesToElement(e,b.theme.quote);return e}updateDOM(){return!1}insertNewAfter(){const b=l.$createParagraphNode(),e=this.getDirection();b.setDirection(e);this.insertAfter(b);return b}collapseAtStart(){const b=l.$createParagraphNode();this.getChildren().forEach(e=>b.append(e));this.replace(b);return!0}}
class p extends l.ElementNode{static getType(){return"heading"}static clone(b){return new p(b.__tag,b.__key)}constructor(b,e){super(e);this.__tag=b}getTag(){return this.__tag}createDOM(b){const e=this.__tag,f=document.createElement(e);b=b.theme.heading;void 0!==b&&k.addClassNamesToElement(f,b[e]);return f}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:q,priority:0}),h2:()=>({conversion:q,priority:0}),h3:()=>({conversion:q,priority:0}),h4:()=>({conversion:q,priority:0}),h5:()=>
({conversion:q,priority:0})}}insertNewAfter(){const b=l.$createParagraphNode(),e=this.getDirection();b.setDirection(e);this.insertAfter(b);return b}collapseAtStart(){const b=l.$createParagraphNode();this.getChildren().forEach(e=>b.append(e));this.replace(b);return!0}}function q(b){b=b.nodeName.toLowerCase();let e=null;if("h1"===b||"h2"===b||"h3"===b||"h4"===b||"h5"===b)e=r(b);return{node:e}}function r(b){return new p(b)}
function t(b,e){if(null!==e)if(void 0===e)b.update(()=>{var f=l.$getRoot();if(null===f.getFirstChild()){const c=l.$createParagraphNode();f.append(c);f=document.activeElement;(null!==l.$getSelection()||null!==f&&f===b.getRootElement())&&c.select()}},m);else if(null!==e)switch(typeof e){case "string":e=b.parseEditorState(e);b.setEditorState(e,m);break;case "object":b.setEditorState(e,m);break;case "function":b.update(e,m)}}
function u(b,e){b.preventDefault();e.update(()=>{const f=l.$getSelection(),c=b.clipboardData;null!=c&&l.$isRangeSelection(f)&&a.$insertDataTransferForRichText(c,f,e)})}function v(b,e){b.preventDefault();e.update(()=>{const f=b.clipboardData,c=l.$getSelection();if(null!==c&&null!=f){const d=a.getHtmlContent(e),g=a.$getLexicalContent(e);null!==d&&f.setData("text/html",d);null!==g&&f.setData("application/x-lexical-editor",g);f.setData("text/plain",c.getTextContent())}})}
function w(b,e){v(b,e);e.update(()=>{const f=l.$getSelection();l.$isRangeSelection(f)&&f.removeText()})}exports.$createHeadingNode=r;exports.$createQuoteNode=function(){return new n};exports.$isHeadingNode=function(b){return b instanceof p};exports.$isQuoteNode=function(b){return b instanceof n};exports.HeadingNode=p;exports.QuoteNode=n;
var a=require("@lexical/clipboard"),h=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);m&&"InputEvent"in window&&!n?"getTargetRanges"in new window.InputEvent("input"):!1;
m&&/Version\/[\d\.]+.*Safari/.test(navigator.userAgent);const p=m&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,q={tag:"history-merge"};
class r extends l.ElementNode{static getType(){return"quote"}static clone(b){return new r(b.__key)}constructor(b){super(b)}createDOM(b){const e=document.createElement("blockquote");k.addClassNamesToElement(e,b.theme.quote);return e}updateDOM(){return!1}insertNewAfter(){const b=l.$createParagraphNode(),e=this.getDirection();b.setDirection(e);this.insertAfter(b);return b}collapseAtStart(){const b=l.$createParagraphNode();this.getChildren().forEach(e=>b.append(e));this.replace(b);return!0}}
class t extends l.ElementNode{static getType(){return"heading"}static clone(b){return new t(b.__tag,b.__key)}constructor(b,e){super(e);this.__tag=b}getTag(){return this.__tag}createDOM(b){const e=this.__tag,f=document.createElement(e);b=b.theme.heading;void 0!==b&&k.addClassNamesToElement(f,b[e]);return f}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:u,priority:0}),h2:()=>({conversion:u,priority:0}),h3:()=>({conversion:u,priority:0}),h4:()=>({conversion:u,priority:0}),h5:()=>
({conversion:u,priority:0})}}insertNewAfter(){const b=l.$createParagraphNode(),e=this.getDirection();b.setDirection(e);this.insertAfter(b);return b}collapseAtStart(){const b=l.$createParagraphNode();this.getChildren().forEach(e=>b.append(e));this.replace(b);return!0}}function u(b){b=b.nodeName.toLowerCase();let e=null;if("h1"===b||"h2"===b||"h3"===b||"h4"===b||"h5"===b)e=v(b);return{node:e}}function v(b){return new t(b)}
function w(b,e){if(null!==e)if(void 0===e)b.update(()=>{var f=l.$getRoot();if(null===f.getFirstChild()){const c=l.$createParagraphNode();f.append(c);f=document.activeElement;(null!==l.$getSelection()||null!==f&&f===b.getRootElement())&&c.select()}},q);else if(null!==e)switch(typeof e){case "string":e=b.parseEditorState(e);b.setEditorState(e,q);break;case "object":b.setEditorState(e,q);break;case "function":b.update(e,q)}}
function x(b,e){b.preventDefault();e.update(()=>{const f=l.$getSelection(),c=b.clipboardData;null!=c&&l.$isRangeSelection(f)&&a.$insertDataTransferForRichText(c,f,e)})}function y(b,e){b.preventDefault();e.update(()=>{const f=b.clipboardData,c=l.$getSelection();if(null!==c&&null!=f){const d=a.getHtmlContent(e),g=a.$getLexicalContent(e);null!==d&&f.setData("text/html",d);null!==g&&f.setData("application/x-lexical-editor",g);f.setData("text/plain",c.getTextContent())}})}
function z(b,e){y(b,e);e.update(()=>{const f=l.$getSelection();l.$isRangeSelection(f)&&f.removeText()})}exports.$createHeadingNode=v;exports.$createQuoteNode=function(){return new r};exports.$isHeadingNode=function(b){return b instanceof t};exports.$isQuoteNode=function(b){return b instanceof r};exports.HeadingNode=t;exports.QuoteNode=r;
exports.registerRichText=function(b,e){const f=k.mergeRegister(b.registerCommand(l.CLICK_COMMAND,()=>{const c=l.$getSelection();return l.$isNodeSelection(c)?(c.clear(),!0):!1},0),b.registerCommand(l.DELETE_CHARACTER_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;d.deleteCharacter(c);return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.DELETE_WORD_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;d.deleteWord(c);return!0},l.COMMAND_PRIORITY_EDITOR),

@@ -22,5 +23,5 @@ b.registerCommand(l.DELETE_LINE_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;d.deleteLine(c);return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.INSERT_TEXT_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;if("string"===typeof c)d.insertText(c);else{const g=c.dataTransfer;null!=g?a.$insertDataTransferForRichText(g,d,b):(c=c.data)&&d.insertText(c)}return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.REMOVE_TEXT_COMMAND,()=>{const c=l.$getSelection();

g,!1),!0):!1},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_BACKSPACE_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();({anchor:c}=d);return d.isCollapsed()&&0===c.offset&&0<k.$getNearestBlockElementAncestorOrThrow(c.getNode()).getIndent()?b.dispatchCommand(l.OUTDENT_CONTENT_COMMAND):b.dispatchCommand(l.DELETE_CHARACTER_COMMAND,!0)},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_DELETE_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;
c.preventDefault();return b.dispatchCommand(l.DELETE_CHARACTER_COMMAND,!1)},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_ENTER_COMMAND,c=>{const d=l.$getSelection();return l.$isRangeSelection(d)?null!==c&&(c.preventDefault(),c.shiftKey)?b.dispatchCommand(l.INSERT_LINE_BREAK_COMMAND):b.dispatchCommand(l.INSERT_PARAGRAPH_COMMAND):!1},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_TAB_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();return b.dispatchCommand(c.shiftKey?
l.OUTDENT_CONTENT_COMMAND:l.INDENT_CONTENT_COMMAND)},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.blur();return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.DROP_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.DRAGSTART_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();
return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.COPY_COMMAND,c=>{const d=l.$getSelection();return l.$isRangeSelection(d)||l.$isGridSelection(d)?(v(c,b),!0):!1},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.CUT_COMMAND,c=>{const d=l.$getSelection();return l.$isRangeSelection(d)||l.$isGridSelection(d)?(w(c,b),!0):!1},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.PASTE_COMMAND,c=>{const d=l.$getSelection();return l.$isRangeSelection(d)||l.$isGridSelection(d)?(u(c,b),!0):!1},l.COMMAND_PRIORITY_EDITOR));
t(b,e);return f};
c.preventDefault();return b.dispatchCommand(l.DELETE_CHARACTER_COMMAND,!1)},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_ENTER_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;if(null!==c){if(p)return!1;c.preventDefault();if(c.shiftKey)return b.dispatchCommand(l.INSERT_LINE_BREAK_COMMAND)}return b.dispatchCommand(l.INSERT_PARAGRAPH_COMMAND)},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_TAB_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;
c.preventDefault();return b.dispatchCommand(c.shiftKey?l.OUTDENT_CONTENT_COMMAND:l.INDENT_CONTENT_COMMAND)},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;b.blur();return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.DROP_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.DRAGSTART_COMMAND,c=>{const d=l.$getSelection();
if(!l.$isRangeSelection(d))return!1;c.preventDefault();return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.COPY_COMMAND,c=>{const d=l.$getSelection();return l.$isRangeSelection(d)||l.$isGridSelection(d)?(y(c,b),!0):!1},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.CUT_COMMAND,c=>{const d=l.$getSelection();return l.$isRangeSelection(d)||l.$isGridSelection(d)?(z(c,b),!0):!1},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.PASTE_COMMAND,c=>{const d=l.$getSelection();return l.$isRangeSelection(d)||
l.$isGridSelection(d)?(x(c,b),!0):!1},l.COMMAND_PRIORITY_EDITOR));w(b,e);return f};

@@ -10,9 +10,9 @@ {

"license": "MIT",
"version": "0.2.2",
"version": "0.2.3",
"main": "LexicalRichText.js",
"peerDependencies": {
"lexical": "0.2.2",
"@lexical/selection": "0.2.2",
"@lexical/clipboard": "0.2.2",
"@lexical/utils": "0.2.2"
"lexical": "0.2.3",
"@lexical/selection": "0.2.3",
"@lexical/clipboard": "0.2.3",
"@lexical/utils": "0.2.3"
},

@@ -19,0 +19,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc