Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/rich-text

Package Overview
Dependencies
Maintainers
6
Versions
203
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.6.1-next.0 to 0.6.2

2

index.d.ts

@@ -56,3 +56,3 @@ /** @module @lexical/rich-text */

export declare function $isHeadingNode(node: LexicalNode | null | undefined): node is HeadingNode;
export declare function eventFiles(event: DragEvent | PasteCommandType): [boolean, Array<File>];
export declare function eventFiles(event: DragEvent | PasteCommandType): [boolean, Array<File>, boolean];
export declare function registerRichText(editor: LexicalEditor): () => void;

@@ -129,3 +129,3 @@ /**

function $createQuoteNode() {
return new QuoteNode();
return lexical.$applyNodeReplacement(new QuoteNode());
}

@@ -302,3 +302,3 @@ function $isQuoteNode(node) {

function $createHeadingNode(headingTag) {
return new HeadingNode(headingTag);
return lexical.$applyNodeReplacement(new HeadingNode(headingTag));
}

@@ -353,6 +353,9 @@ function $isHeadingNode(node) {

if (dataTransfer === null) {
return [false, []];
return [false, [], false];
}
return [dataTransfer.types.includes('Files'), Array.from(dataTransfer.files)];
const types = dataTransfer.types;
const hasFiles = types.includes('Files');
const hasContent = types.includes('text/html') || types.includes('text/plain');
return [hasFiles, Array.from(dataTransfer.files), hasContent];
}

@@ -786,5 +789,5 @@

}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.PASTE_COMMAND, event => {
const [, files] = eventFiles(event);
const [, files, hasTextContent] = eventFiles(event);
if (files !== null && files.length > 0) {
if (files.length > 0 && !hasTextContent) {
editor.dispatchCommand(DRAG_DROP_PASTE, files);

@@ -791,0 +794,0 @@ return true;

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

class w extends k.ElementNode{static getType(){return"quote"}static clone(c){return new w(c.__key)}constructor(c){super(c)}createDOM(c){let b=document.createElement("blockquote");h.addClassNamesToElement(b,c.theme.quote);return b}updateDOM(){return!1}static importDOM(){return{blockquote:()=>({conversion:x,priority:0})}}static importJSON(c){let b=y();b.setFormat(c.format);b.setIndent(c.indent);b.setDirection(c.direction);return b}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(){let c=
k.$createParagraphNode(),b=this.getDirection();c.setDirection(b);this.insertAfter(c);return c}collapseAtStart(){let c=k.$createParagraphNode();this.getChildren().forEach(b=>c.append(b));this.replace(c);return!0}}function y(){return new w}
k.$createParagraphNode(),b=this.getDirection();c.setDirection(b);this.insertAfter(c);return c}collapseAtStart(){let c=k.$createParagraphNode();this.getChildren().forEach(b=>c.append(b));this.replace(c);return!0}}function y(){return k.$applyNodeReplacement(new w)}
class z extends k.ElementNode{static getType(){return"heading"}static clone(c){return new z(c.__tag,c.__key)}constructor(c,b){super(b);this.__tag=c}getTag(){return this.__tag}createDOM(c){let b=this.__tag,d=document.createElement(b);c=c.theme.heading;void 0!==c&&h.addClassNamesToElement(d,c[b]);return d}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:A,priority:0}),h2:()=>({conversion:A,priority:0}),h3:()=>({conversion:A,priority:0}),h4:()=>({conversion:A,priority:0}),h5:()=>({conversion:A,
priority:0}),h6:()=>({conversion:A,priority:0}),p:c=>{c=c.firstChild;return null!==c&&B(c)?{conversion:()=>({node:null}),priority:3}:null},span:c=>B(c)?{conversion:()=>({node:C("h1")}),priority:3}:null}}static importJSON(c){let b=C(c.tag);b.setFormat(c.format);b.setIndent(c.indent);b.setDirection(c.direction);return b}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(){let c=k.$createParagraphNode(),b=this.getDirection();c.setDirection(b);this.insertAfter(c);
return c}collapseAtStart(){let c=k.$createParagraphNode();this.getChildren().forEach(b=>c.append(b));this.replace(c);return!0}extractWithChild(){return!0}}function B(c){return"span"===c.nodeName.toLowerCase()?"26pt"===c.style.fontSize:!1}function A(c){c=c.nodeName.toLowerCase();let b=null;if("h1"===c||"h2"===c||"h3"===c||"h4"===c||"h5"===c||"h6"===c)b=C(c);return{node:b}}function x(){return{node:y()}}function C(c){return new z(c)}
return c}collapseAtStart(){let c=k.$createParagraphNode();this.getChildren().forEach(b=>c.append(b));this.replace(c);return!0}extractWithChild(){return!0}}function B(c){return"span"===c.nodeName.toLowerCase()?"26pt"===c.style.fontSize:!1}function A(c){c=c.nodeName.toLowerCase();let b=null;if("h1"===c||"h2"===c||"h3"===c||"h4"===c||"h5"===c||"h6"===c)b=C(c);return{node:b}}function x(){return{node:y()}}function C(c){return k.$applyNodeReplacement(new z(c))}
function D(c,b){c.preventDefault();b.update(()=>{let d=k.$getSelection(),e=c instanceof InputEvent||c instanceof KeyboardEvent?null:c.clipboardData;null!=e&&(k.$isRangeSelection(d)||k.DEPRECATED_$isGridSelection(d))&&a.$insertDataTransferForRichText(e,d,b)},{tag:"paste"})}
async function E(c,b){null!=b.getEditorState().read(()=>k.$getSelection())&&(await a.copyToClipboard__EXPERIMENTAL(b,c instanceof ClipboardEvent?c:null),b.update(()=>{let d=k.$getSelection();k.$isRangeSelection(d)?d.removeText():k.$isNodeSelection(d)&&d.getNodes().forEach(e=>e.remove())}))}function F(c){let b=null;c instanceof DragEvent?b=c.dataTransfer:c instanceof ClipboardEvent&&(b=c.clipboardData);return null===b?[!1,[]]:[b.types.includes("Files"),Array.from(b.files)]}
async function E(c,b){null!=b.getEditorState().read(()=>k.$getSelection())&&(await a.copyToClipboard__EXPERIMENTAL(b,c instanceof ClipboardEvent?c:null),b.update(()=>{let d=k.$getSelection();k.$isRangeSelection(d)?d.removeText():k.$isNodeSelection(d)&&d.getNodes().forEach(e=>e.remove())}))}
function F(c){let b=null;c instanceof DragEvent?b=c.dataTransfer:c instanceof ClipboardEvent&&(b=c.clipboardData);if(null===b)return[!1,[],!1];var d=b.types;c=d.includes("Files");d=d.includes("text/html")||d.includes("text/plain");return[c,Array.from(b.files),d]}
function G(c,b){var d=k.$getSelection();if(k.$isRangeSelection(d)){var e=new Set;d=d.getNodes();for(let m=0;m<d.length;m++){let n=d[m];var f=n.getKey();e.has(f)||(e.add(f),f=h.$getNearestBlockElementAncestorOrThrow(n),f.canInsertTab()?c(n):f.canIndent()&&b(f))}}}function H(c){c=k.$getNearestNodeFromDOMNode(c);return k.$isDecoratorNode(c)}exports.$createHeadingNode=C;exports.$createQuoteNode=y;exports.$isHeadingNode=function(c){return c instanceof z};

@@ -31,2 +32,2 @@ exports.$isQuoteNode=function(c){return c instanceof w};exports.DRAG_DROP_PASTE=v;exports.HeadingNode=z;exports.QuoteNode=w;exports.eventFiles=F;

e=k.$normalizeSelection__EXPERIMENTAL(p);k.$setSelection(e)}c.dispatchCommand(v,d)}b.preventDefault();return!0}b=k.$getSelection();return k.$isRangeSelection(b)?!0:!1},k.COMMAND_PRIORITY_EDITOR),c.registerCommand(k.DRAGSTART_COMMAND,b=>{const [d]=F(b),e=k.$getSelection();if(d&&!k.$isRangeSelection(e))return!1;b.preventDefault();return!0},k.COMMAND_PRIORITY_EDITOR),c.registerCommand(k.DRAGOVER_COMMAND,b=>{const [d]=F(b),e=k.$getSelection();if(d&&!k.$isRangeSelection(e))return!1;b.preventDefault();
return!0},k.COMMAND_PRIORITY_EDITOR),c.registerCommand(k.COPY_COMMAND,b=>{a.copyToClipboard__EXPERIMENTAL(c,b instanceof ClipboardEvent?b:null);return!0},k.COMMAND_PRIORITY_EDITOR),c.registerCommand(k.CUT_COMMAND,b=>{E(b,c);return!0},k.COMMAND_PRIORITY_EDITOR),c.registerCommand(k.PASTE_COMMAND,b=>{var [,d]=F(b);if(null!==d&&0<d.length)return c.dispatchCommand(v,d),!0;d=k.$getSelection();return k.$isRangeSelection(d)||k.DEPRECATED_$isGridSelection(d)?(D(b,c),!0):!1},k.COMMAND_PRIORITY_EDITOR))}
return!0},k.COMMAND_PRIORITY_EDITOR),c.registerCommand(k.COPY_COMMAND,b=>{a.copyToClipboard__EXPERIMENTAL(c,b instanceof ClipboardEvent?b:null);return!0},k.COMMAND_PRIORITY_EDITOR),c.registerCommand(k.CUT_COMMAND,b=>{E(b,c);return!0},k.COMMAND_PRIORITY_EDITOR),c.registerCommand(k.PASTE_COMMAND,b=>{const [,d,e]=F(b);if(0<d.length&&!e)return c.dispatchCommand(v,d),!0;const f=k.$getSelection();return k.$isRangeSelection(f)||k.DEPRECATED_$isGridSelection(f)?(D(b,c),!0):!1},k.COMMAND_PRIORITY_EDITOR))}

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

"license": "MIT",
"version": "0.6.1-next.0",
"version": "0.6.2",
"main": "LexicalRichText.js",
"peerDependencies": {
"lexical": "0.6.1-next.0",
"@lexical/selection": "0.6.1-next.0",
"@lexical/clipboard": "0.6.1-next.0",
"@lexical/utils": "0.6.1-next.0"
"lexical": "0.6.2",
"@lexical/selection": "0.6.2",
"@lexical/clipboard": "0.6.2",
"@lexical/utils": "0.6.2"
},

@@ -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