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
200
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.3 to 0.6.4

4

index.d.ts

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

*/
import type { DOMConversionMap, EditorConfig, LexicalCommand, LexicalEditor, LexicalNode, NodeKey, ParagraphNode, PasteCommandType, SerializedElementNode, Spread } from 'lexical';
import type { DOMConversionMap, EditorConfig, LexicalCommand, LexicalEditor, LexicalNode, NodeKey, ParagraphNode, PasteCommandType, RangeSelection, SerializedElementNode, Spread } from 'lexical';
import { ElementNode } from 'lexical';

@@ -51,3 +51,3 @@ export declare type SerializedHeadingNode = Spread<{

exportJSON(): SerializedHeadingNode;
insertNewAfter(): ParagraphNode;
insertNewAfter(selection?: RangeSelection): ParagraphNode | HeadingNode;
collapseAtStart(): true;

@@ -54,0 +54,0 @@ extractWithChild(): boolean;

@@ -250,4 +250,5 @@ /**

insertNewAfter() {
const newElement = lexical.$createParagraphNode();
insertNewAfter(selection) {
const selectionOffset = selection ? selection.anchor.offset : 0;
const newElement = selectionOffset < this.getTextContentSize() && selectionOffset > 0 ? $createHeadingNode(this.getTag()) : lexical.$createParagraphNode();
const direction = this.getDirection();

@@ -260,6 +261,8 @@ newElement.setDirection(direction);

collapseAtStart() {
const paragraph = lexical.$createParagraphNode();
const previousSibling = this.getPreviousSibling();
const isPreviouSiblingEmpty = !previousSibling || previousSibling && previousSibling.getTextContentSize() === 0;
const newElement = isPreviouSiblingEmpty ? $createHeadingNode(this.getTag()) : lexical.$createParagraphNode();
const children = this.getChildren();
children.forEach(child => paragraph.append(child));
this.replace(paragraph);
children.forEach(child => newElement.append(child));
this.replace(newElement);
return true;

@@ -266,0 +269,0 @@ }

@@ -7,12 +7,12 @@ /**

*/
'use strict';var a=require("@lexical/clipboard"),g=require("@lexical/selection"),h=require("@lexical/utils"),k=require("lexical");let m="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,q=m&&"documentMode"in document?document.documentMode:null;m&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);m&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
let r=m&&"InputEvent"in window&&!q?"getTargetRanges"in new window.InputEvent("input"):!1,t=m&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),u=m&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,v=k.createCommand("DRAG_DROP_PASTE_FILE");
'use strict';var a=require("@lexical/clipboard"),g=require("@lexical/selection"),h=require("@lexical/utils"),k=require("lexical");let l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,n=l&&"documentMode"in document?document.documentMode:null;l&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);l&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
let r=l&&"InputEvent"in window&&!n?"getTargetRanges"in new window.InputEvent("input"):!1,t=l&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),u=l&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,v=k.createCommand("DRAG_DROP_PASTE_FILE");
class y extends k.ElementNode{static getType(){return"quote"}static clone(c){return new y(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:z,priority:0})}}static importJSON(c){let b=A();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 A(){return k.$applyNodeReplacement(new y)}
class B extends k.ElementNode{static getType(){return"heading"}static clone(c){return new B(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:C,priority:0}),h2:()=>({conversion:C,priority:0}),h3:()=>({conversion:C,priority:0}),h4:()=>({conversion:C,priority:0}),h5:()=>({conversion:C,
priority:0}),h6:()=>({conversion:C,priority:0}),p:c=>{c=c.firstChild;return null!==c&&D(c)?{conversion:()=>({node:null}),priority:3}:null},span:c=>D(c)?{conversion:()=>({node:E("h1")}),priority:3}:null}}static importJSON(c){let b=E(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 D(c){return"span"===c.nodeName.toLowerCase()?"26pt"===c.style.fontSize:!1}function C(c){c=c.nodeName.toLowerCase();let b=null;if("h1"===c||"h2"===c||"h3"===c||"h4"===c||"h5"===c||"h6"===c)b=E(c);return{node:b}}function z(){return{node:A()}}function E(c){return k.$applyNodeReplacement(new B(c))}
function F(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"})}
priority:0}),h6:()=>({conversion:C,priority:0}),p:c=>{c=c.firstChild;return null!==c&&D(c)?{conversion:()=>({node:null}),priority:3}:null},span:c=>D(c)?{conversion:()=>({node:E("h1")}),priority:3}:null}}static importJSON(c){let b=E(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(c){c=c?c.anchor.offset:0;c=c<this.getTextContentSize()&&0<c?E(this.getTag()):k.$createParagraphNode();
let b=this.getDirection();c.setDirection(b);this.insertAfter(c);return c}collapseAtStart(){let c=this.getPreviousSibling(),b=!c||c&&0===c.getTextContentSize()?E(this.getTag()):k.$createParagraphNode();this.getChildren().forEach(d=>b.append(d));this.replace(b);return!0}extractWithChild(){return!0}}function D(c){return"span"===c.nodeName.toLowerCase()?"26pt"===c.style.fontSize:!1}
function C(c){c=c.nodeName.toLowerCase();let b=null;if("h1"===c||"h2"===c||"h3"===c||"h4"===c||"h5"===c||"h6"===c)b=E(c);return{node:b}}function z(){return{node:A()}}function E(c){return k.$applyNodeReplacement(new B(c))}function F(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 G(c,b){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 H(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 I(c,b){var d=k.$getSelection();if(k.$isRangeSelection(d)){var e=new Set;d=d.getNodes();for(let f=0;f<d.length;f++){let n=d[f],w=n.getKey();if(e.has(w))continue;let l=h.$getNearestBlockElementAncestorOrThrow(n),x=l.getKey();l.canInsertTab()?(c(n),e.add(w)):l.canIndent()&&!e.has(x)&&(e.add(x),b(l))}}}function J(c){c=k.$getNearestNodeFromDOMNode(c);return k.$isDecoratorNode(c)}exports.$createHeadingNode=E;exports.$createQuoteNode=A;exports.$isHeadingNode=function(c){return c instanceof B};
function I(c,b){var d=k.$getSelection();if(k.$isRangeSelection(d)){var e=new Set;d=d.getNodes();for(let f=0;f<d.length;f++){let p=d[f],w=p.getKey();if(e.has(w))continue;let m=h.$getNearestBlockElementAncestorOrThrow(p),x=m.getKey();m.canInsertTab()?(c(p),e.add(w)):m.canIndent()&&!e.has(x)&&(e.add(x),b(m))}}}function J(c){c=k.$getNearestNodeFromDOMNode(c);return k.$isDecoratorNode(c)}exports.$createHeadingNode=E;exports.$createQuoteNode=A;exports.$isHeadingNode=function(c){return c instanceof B};
exports.$isQuoteNode=function(c){return c instanceof y};exports.DRAG_DROP_PASTE=v;exports.HeadingNode=B;exports.QuoteNode=y;exports.eventFiles=H;

@@ -29,4 +29,4 @@ exports.registerRichText=function(c){return h.mergeRegister(c.registerCommand(k.CLICK_COMMAND,()=>{const b=k.$getSelection();return k.$isNodeSelection(b)?(b.clear(),!0):!1},0),c.registerCommand(k.DELETE_CHARACTER_COMMAND,b=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteCharacter(b);return!0},k.COMMAND_PRIORITY_EDITOR),c.registerCommand(k.DELETE_WORD_COMMAND,b=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteWord(b);return!0},k.COMMAND_PRIORITY_EDITOR),

b.preventDefault();return c.dispatchCommand(b.shiftKey?k.OUTDENT_CONTENT_COMMAND:k.INDENT_CONTENT_COMMAND,void 0)},k.COMMAND_PRIORITY_EDITOR),c.registerCommand(k.KEY_ESCAPE_COMMAND,()=>{const b=k.$getSelection();if(!k.$isRangeSelection(b))return!1;c.blur();return!0},k.COMMAND_PRIORITY_EDITOR),c.registerCommand(k.DROP_COMMAND,b=>{const [,d]=H(b);if(0<d.length){var e=b.clientX;var f=b.clientY;e="undefined"!==typeof document.caretRangeFromPoint?document.caretRangeFromPoint(e,f):"undefined"!==document.caretPositionFromPoint?
document.caretPositionFromPoint(e,f):null;if(null!==e){const {startOffset:n,endOffset:w,startContainer:l,endContainer:x}=e;e=k.$getNearestNodeFromDOMNode(l);f=k.$getNearestNodeFromDOMNode(x);if(null!==e&&null!==f){const p=k.$createRangeSelection();k.$isTextNode(e)?p.anchor.set(e.getKey(),n,"text"):p.anchor.set(e.getParentOrThrow().getKey(),e.getIndexWithinParent()+1,"element");k.$isTextNode(f)?p.focus.set(f.getKey(),w,"text"):p.focus.set(f.getParentOrThrow().getKey(),f.getIndexWithinParent()+1,"element");
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]=H(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]=H(b),e=k.$getSelection();if(d&&!k.$isRangeSelection(e))return!1;b.preventDefault();
document.caretPositionFromPoint(e,f):null;if(null!==e){const {startOffset:p,endOffset:w,startContainer:m,endContainer:x}=e;e=k.$getNearestNodeFromDOMNode(m);f=k.$getNearestNodeFromDOMNode(x);if(null!==e&&null!==f){const q=k.$createRangeSelection();k.$isTextNode(e)?q.anchor.set(e.getKey(),p,"text"):q.anchor.set(e.getParentOrThrow().getKey(),e.getIndexWithinParent()+1,"element");k.$isTextNode(f)?q.focus.set(f.getKey(),w,"text"):q.focus.set(f.getParentOrThrow().getKey(),f.getIndexWithinParent()+1,"element");
e=k.$normalizeSelection__EXPERIMENTAL(q);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]=H(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]=H(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=>{G(b,c);return!0},k.COMMAND_PRIORITY_EDITOR),c.registerCommand(k.PASTE_COMMAND,b=>{const [,d,e]=H(b);if(0<d.length&&!e)return c.dispatchCommand(v,d),!0;const f=k.$getSelection();return k.$isRangeSelection(f)||k.DEPRECATED_$isGridSelection(f)?(F(b,c),!0):!1},k.COMMAND_PRIORITY_EDITOR))}

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

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

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