New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/rich-text

Package Overview
Dependencies
Maintainers
8
Versions
279
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.12.2 to 0.12.3

203

LexicalRichText.dev.js

@@ -21,22 +21,20 @@ /**

*/
function caretFromPoint(x, y) {
if (typeof document.caretRangeFromPoint !== 'undefined') {
const range = document.caretRangeFromPoint(x, y);
if (range === null) {
return null;
}
return {
node: range.startContainer,
offset: range.startOffset
}; // @ts-ignore
};
// @ts-ignore
} else if (document.caretPositionFromPoint !== 'undefined') {
// @ts-ignore FF - no types
const range = document.caretPositionFromPoint(x, y);
if (range === null) {
return null;
}
return {

@@ -59,2 +57,3 @@ node: range.offsetNode,

*/
const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';

@@ -74,7 +73,10 @@

const IS_SAFARI = 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.
const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
CAN_USE_DOM && /Android/.test(navigator.userAgent);
// Keep these in case we need to use them in the future.
// export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
const IS_CHROME = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
// export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
const IS_CHROME = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent); // export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME;

@@ -84,3 +86,2 @@

const DRAG_DROP_PASTE = lexical.createCommand('DRAG_DROP_PASTE_FILE');
/** @noInheritDoc */

@@ -91,11 +92,10 @@ class QuoteNode extends lexical.ElementNode {

}
static clone(node) {
return new QuoteNode(node.__key);
}
constructor(key) {
super(key);
} // View
}
// View

@@ -107,7 +107,5 @@ createDOM(config) {

}
updateDOM(prevNode, dom) {
return false;
}
static importDOM() {

@@ -121,3 +119,2 @@ return {

}
exportDOM(editor) {

@@ -127,3 +124,2 @@ const {

} = super.exportDOM(editor);
if (element && utils.isHTMLElement(element)) {

@@ -134,3 +130,2 @@ if (this.isEmpty()) element.append(document.createElement('br'));

const direction = this.getDirection();
if (direction) {

@@ -140,3 +135,2 @@ element.dir = direction;

}
return {

@@ -146,3 +140,2 @@ element

}
static importJSON(serializedNode) {

@@ -155,9 +148,10 @@ const node = $createQuoteNode();

}
exportJSON() {
return { ...super.exportJSON(),
return {
...super.exportJSON(),
type: 'quote'
};
} // Mutation
}
// Mutation

@@ -171,3 +165,2 @@ insertNewAfter(_, restoreSelection) {

}
collapseAtStart() {

@@ -180,3 +173,2 @@ const paragraph = lexical.$createParagraphNode();

}
}

@@ -189,14 +181,12 @@ function $createQuoteNode() {

}
/** @noInheritDoc */
class HeadingNode extends lexical.ElementNode {
/** @internal */
static getType() {
return 'heading';
}
static clone(node) {
return new HeadingNode(node.__tag, node.__key);
}
constructor(tag, key) {

@@ -206,7 +196,7 @@ super(key);

}
getTag() {
return this.__tag;
} // View
}
// View

@@ -218,3 +208,2 @@ createDOM(config) {

const classNames = theme.heading;
if (classNames !== undefined) {

@@ -224,10 +213,7 @@ const className = classNames[tag];

}
return element;
}
updateDOM(prevNode, dom) {
return false;
}
static importDOM() {

@@ -263,3 +249,2 @@ return {

const firstChild = paragraph.firstChild;
if (firstChild !== null && isGoogleDocsTitle(firstChild)) {

@@ -273,3 +258,2 @@ return {

}
return null;

@@ -288,3 +272,2 @@ },

}
return null;

@@ -294,3 +277,2 @@ }

}
exportDOM(editor) {

@@ -300,3 +282,2 @@ const {

} = super.exportDOM(editor);
if (element && utils.isHTMLElement(element)) {

@@ -307,3 +288,2 @@ if (this.isEmpty()) element.append(document.createElement('br'));

const direction = this.getDirection();
if (direction) {

@@ -313,3 +293,2 @@ element.dir = direction;

}
return {

@@ -319,3 +298,2 @@ element

}
static importJSON(serializedNode) {

@@ -328,5 +306,5 @@ const node = $createHeadingNode(serializedNode.tag);

}
exportJSON() {
return { ...super.exportJSON(),
return {
...super.exportJSON(),
tag: this.getTag(),

@@ -336,14 +314,18 @@ type: 'heading',

};
} // Mutation
}
// Mutation
insertNewAfter(selection, restoreSelection = true) {
const anchorOffet = selection ? selection.anchor.offset : 0;
const newElement = anchorOffet > 0 && anchorOffet < this.getTextContentSize() ? $createHeadingNode(this.getTag()) : lexical.$createParagraphNode();
const newElement = anchorOffet === this.getTextContentSize() || !selection ? lexical.$createParagraphNode() : $createHeadingNode(this.getTag());
const direction = this.getDirection();
newElement.setDirection(direction);
this.insertAfter(newElement, restoreSelection);
if (anchorOffet === 0 && !this.isEmpty() && selection) {
const paragraph = lexical.$createParagraphNode();
paragraph.select();
this.replace(paragraph, true);
}
return newElement;
}
collapseAtStart() {

@@ -356,9 +338,6 @@ const newElement = !this.isEmpty() ? $createHeadingNode(this.getTag()) : lexical.$createParagraphNode();

}
extractWithChild() {
return true;
}
}
function isGoogleDocsTitle(domNode) {

@@ -368,13 +347,9 @@ if (domNode.nodeName.toLowerCase() === 'span') {

}
return false;
}
function convertHeadingElement(element) {
const nodeName = element.nodeName.toLowerCase();
let node = null;
if (nodeName === 'h1' || nodeName === 'h2' || nodeName === 'h3' || nodeName === 'h4' || nodeName === 'h5' || nodeName === 'h6') {
node = $createHeadingNode(nodeName);
if (element.style !== null) {

@@ -384,3 +359,2 @@ node.setFormat(element.style.textAlign);

}
return {

@@ -390,10 +364,7 @@ node

}
function convertBlockquoteElement(element) {
const node = $createQuoteNode();
if (element.style !== null) {
node.setFormat(element.style.textAlign);
}
return {

@@ -403,3 +374,2 @@ node

}
function $createHeadingNode(headingTag) {

@@ -411,3 +381,2 @@ return lexical.$applyNodeReplacement(new HeadingNode(headingTag));

}
function onPasteForRichText(event, editor) {

@@ -418,3 +387,2 @@ event.preventDefault();

const clipboardData = event instanceof InputEvent || event instanceof KeyboardEvent ? null : event.clipboardData;
if (clipboardData != null && (lexical.$isRangeSelection(selection) || lexical.DEPRECATED_$isGridSelection(selection))) {

@@ -427,3 +395,2 @@ clipboard.$insertDataTransferForRichText(clipboardData, selection, editor);

}
async function onCutForRichText(event, editor) {

@@ -433,3 +400,2 @@ await clipboard.copyToClipboard(editor, utils.objectKlassEquals(event, ClipboardEvent) ? event : null);

const selection = lexical.$getSelection();
if (lexical.$isRangeSelection(selection)) {

@@ -441,10 +407,9 @@ selection.removeText();

});
} // Clipboard may contain files that we aren't allowed to read. While the event is arguably useless,
// in certain ocassions, we want to know whether it was a file transfer, as opposed to text. We
}
// Clipboard may contain files that we aren't allowed to read. While the event is arguably useless,
// in certain occasions, we want to know whether it was a file transfer, as opposed to text. We
// control this with the first boolean flag.
function eventFiles(event) {
let dataTransfer = null;
if (event instanceof DragEvent) {

@@ -455,7 +420,5 @@ dataTransfer = event.dataTransfer;

}
if (dataTransfer === null) {
return [false, [], false];
}
const types = dataTransfer.types;

@@ -466,24 +429,17 @@ const hasFiles = types.includes('Files');

}
function handleIndentAndOutdent(indentOrOutdent) {
const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
const alreadyHandled = new Set();
const nodes = selection.getNodes();
for (let i = 0; i < nodes.length; i++) {
const node = nodes[i];
const key = node.getKey();
if (alreadyHandled.has(key)) {
continue;
}
const parentBlock = utils.$getNearestBlockElementAncestorOrThrow(node);
const parentKey = parentBlock.getKey();
if (parentBlock.canIndent() && !alreadyHandled.has(parentKey)) {

@@ -494,6 +450,4 @@ alreadyHandled.add(parentKey);

}
return alreadyHandled.size > 0;
}
function $isTargetWithinDecorator(target) {

@@ -503,3 +457,2 @@ const node = lexical.$getNearestNodeFromDOMNode(target);

}
function $isSelectionAtEndOfRoot(selection) {

@@ -509,7 +462,5 @@ const focus = selection.focus;

}
function registerRichText(editor) {
const removeListener = utils.mergeRegister(editor.registerCommand(lexical.CLICK_COMMAND, payload => {
const selection = lexical.$getSelection();
if (lexical.$isNodeSelection(selection)) {

@@ -519,11 +470,8 @@ selection.clear();

}
return false;
}, 0), editor.registerCommand(lexical.DELETE_CHARACTER_COMMAND, isBackward => {
const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
selection.deleteCharacter(isBackward);

@@ -533,7 +481,5 @@ return true;

const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
selection.deleteWord(isBackward);

@@ -543,7 +489,5 @@ return true;

const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
selection.deleteLine(isBackward);

@@ -553,3 +497,2 @@ return true;

const selection = lexical.$getSelection();
if (typeof eventOrText === 'string') {

@@ -563,5 +506,3 @@ if (lexical.$isRangeSelection(selection)) {

}
const dataTransfer = eventOrText.dataTransfer;
if (dataTransfer != null) {

@@ -571,19 +512,14 @@ clipboard.$insertDataTransferForRichText(dataTransfer, selection, editor);

const data = eventOrText.data;
if (data) {
selection.insertText(data);
}
return true;
}
}
return true;
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.REMOVE_TEXT_COMMAND, () => {
const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
selection.removeText();

@@ -593,7 +529,5 @@ return true;

const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
selection.formatText(format);

@@ -603,12 +537,8 @@ return true;

const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection) && !lexical.$isNodeSelection(selection)) {
return false;
}
const nodes = selection.getNodes();
for (const node of nodes) {
const element = utils.$findMatchingParent(node, parentNode => lexical.$isElementNode(parentNode) && !parentNode.isInline());
if (element !== null) {

@@ -618,11 +548,8 @@ element.setFormat(format);

}
return true;
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.INSERT_LINE_BREAK_COMMAND, selectStart => {
const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
selection.insertLineBreak(selectStart);

@@ -632,7 +559,5 @@ return true;

const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
selection.insertParagraph();

@@ -651,3 +576,2 @@ return true;

const indent = block.getIndent();
if (indent > 0) {

@@ -659,3 +583,2 @@ block.setIndent(indent - 1);

const selection = lexical.$getSelection();
if (lexical.$isNodeSelection(selection) && !$isTargetWithinDecorator(event.target)) {

@@ -665,3 +588,2 @@ // If selection is on a node, let's try and move selection

const nodes = selection.getNodes();
if (nodes.length > 0) {

@@ -673,3 +595,2 @@ nodes[0].selectPrevious();

const possibleNode = lexical.$getAdjacentNode(selection.focus, true);
if (!event.shiftKey && lexical.$isDecoratorNode(possibleNode) && !possibleNode.isIsolated() && !possibleNode.isInline()) {

@@ -681,7 +602,5 @@ possibleNode.selectPrevious();

}
return false;
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND, event => {
const selection = lexical.$getSelection();
if (lexical.$isNodeSelection(selection)) {

@@ -691,3 +610,2 @@ // If selection is on a node, let's try and move selection

const nodes = selection.getNodes();
if (nodes.length > 0) {

@@ -702,5 +620,3 @@ nodes[0].selectNext(0, 0);

}
const possibleNode = lexical.$getAdjacentNode(selection.focus, false);
if (!event.shiftKey && lexical.$isDecoratorNode(possibleNode) && !possibleNode.isIsolated() && !possibleNode.isInline()) {

@@ -712,7 +628,5 @@ possibleNode.selectNext();

}
return false;
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ARROW_LEFT_COMMAND, event => {
const selection$1 = lexical.$getSelection();
if (lexical.$isNodeSelection(selection$1)) {

@@ -722,3 +636,2 @@ // If selection is on a node, let's try and move selection

const nodes = selection$1.getNodes();
if (nodes.length > 0) {

@@ -730,7 +643,5 @@ event.preventDefault();

}
if (!lexical.$isRangeSelection(selection$1)) {
return false;
}
if (selection.$shouldOverrideDefaultCharacterSelection(selection$1, true)) {

@@ -742,7 +653,5 @@ const isHoldingShift = event.shiftKey;

}
return false;
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ARROW_RIGHT_COMMAND, event => {
const selection$1 = lexical.$getSelection();
if (lexical.$isNodeSelection(selection$1) && !$isTargetWithinDecorator(event.target)) {

@@ -752,3 +661,2 @@ // If selection is on a node, let's try and move selection

const nodes = selection$1.getNodes();
if (nodes.length > 0) {

@@ -760,9 +668,6 @@ event.preventDefault();

}
if (!lexical.$isRangeSelection(selection$1)) {
return false;
}
const isHoldingShift = event.shiftKey;
if (selection.$shouldOverrideDefaultCharacterSelection(selection$1, false)) {

@@ -773,3 +678,2 @@ event.preventDefault();

}
return false;

@@ -780,9 +684,6 @@ }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, event => {

}
const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
event.preventDefault();

@@ -793,6 +694,4 @@ const {

const anchorNode = anchor.getNode();
if (selection.isCollapsed() && anchor.offset === 0 && !lexical.$isRootNode(anchorNode)) {
const element = utils.$getNearestBlockElementAncestorOrThrow(anchorNode);
if (element.getIndent() > 0) {

@@ -802,3 +701,2 @@ return editor.dispatchCommand(lexical.OUTDENT_CONTENT_COMMAND, undefined);

}
return editor.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND, true);

@@ -809,9 +707,6 @@ }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_DELETE_COMMAND, event => {

}
const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
event.preventDefault();

@@ -821,7 +716,5 @@ return editor.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND, false);

const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
if (event !== null) {

@@ -838,5 +731,3 @@ // If we have beforeinput, then we can avoid blocking

}
event.preventDefault();
if (event.shiftKey) {

@@ -846,11 +737,8 @@ return editor.dispatchCommand(lexical.INSERT_LINE_BREAK_COMMAND, false);

}
return editor.dispatchCommand(lexical.INSERT_PARAGRAPH_COMMAND, undefined);
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ESCAPE_COMMAND, () => {
const selection = lexical.$getSelection();
if (!lexical.$isRangeSelection(selection)) {
return false;
}
editor.blur();

@@ -860,3 +748,2 @@ return true;

const [, files] = eventFiles(event);
if (files.length > 0) {

@@ -866,3 +753,2 @@ const x = event.clientX;

const eventRange = caretFromPoint(x, y);
if (eventRange !== null) {

@@ -874,6 +760,4 @@ const {

const node = lexical.$getNearestNodeFromDOMNode(domNode);
if (node !== null) {
const selection = lexical.$createRangeSelection();
if (lexical.$isTextNode(node)) {

@@ -888,20 +772,14 @@ selection.anchor.set(node.getKey(), domOffset, 'text');

}
const normalizedSelection = lexical.$normalizeSelection__EXPERIMENTAL(selection);
lexical.$setSelection(normalizedSelection);
}
editor.dispatchCommand(DRAG_DROP_PASTE, files);
}
event.preventDefault();
return true;
}
const selection = lexical.$getSelection();
if (lexical.$isRangeSelection(selection)) {
return true;
}
return false;

@@ -911,7 +789,5 @@ }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.DRAGSTART_COMMAND, event => {

const selection = lexical.$getSelection();
if (isFileTransfer && !lexical.$isRangeSelection(selection)) {
return false;
}
return true;

@@ -921,14 +797,10 @@ }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.DRAGOVER_COMMAND, event => {

const selection = lexical.$getSelection();
if (isFileTransfer && !lexical.$isRangeSelection(selection)) {
return false;
}
const x = event.clientX;
const y = event.clientY;
const eventRange = caretFromPoint(x, y);
if (eventRange !== null) {
const node = lexical.$getNearestNodeFromDOMNode(eventRange.node);
if (lexical.$isDecoratorNode(node)) {

@@ -940,3 +812,2 @@ // Show browser caret as the user is dragging the media across the screen. Won't work

}
return true;

@@ -954,15 +825,12 @@ }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.SELECT_ALL_COMMAND, () => {

const [, files, hasTextContent] = eventFiles(event);
if (files.length > 0 && !hasTextContent) {
editor.dispatchCommand(DRAG_DROP_PASTE, files);
return true;
} // if inputs then paste within the input ignore creating a new node on paste event
}
// if inputs then paste within the input ignore creating a new node on paste event
if (lexical.isSelectionCapturedInDecoratorInput(event.target)) {
return false;
}
const selection = lexical.$getSelection();
if (lexical.$isRangeSelection(selection) || lexical.DEPRECATED_$isGridSelection(selection)) {

@@ -972,3 +840,2 @@ onPasteForRichText(event, editor);

}
return false;

@@ -975,0 +842,0 @@ }, lexical.COMMAND_PRIORITY_EDITOR));

8

LexicalRichText.prod.js

@@ -8,4 +8,4 @@ /**

'use strict';var c=require("@lexical/clipboard"),g=require("@lexical/selection"),h=require("@lexical/utils"),k=require("lexical");function l(b,a){return"undefined"!==typeof document.caretRangeFromPoint?(b=document.caretRangeFromPoint(b,a),null===b?null:{node:b.startContainer,offset:b.startOffset}):"undefined"!==document.caretPositionFromPoint?(b=document.caretPositionFromPoint(b,a),null===b?null:{node:b.offsetNode,offset:b.offset}):null}
let n="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,p=n&&"documentMode"in document?document.documentMode:null;n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
let q=n&&"InputEvent"in window&&!p?"getTargetRanges"in new window.InputEvent("input"):!1,r=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),t=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),v=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!u,w=k.createCommand("DRAG_DROP_PASTE_FILE");
let n="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,p=n&&"documentMode"in document?document.documentMode:null;n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);let q=n&&"InputEvent"in window&&!p?"getTargetRanges"in new window.InputEvent("input"):!1,r=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),t=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;
n&&/Android/.test(navigator.userAgent);let u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),v=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!u,w=k.createCommand("DRAG_DROP_PASTE_FILE");
class x extends k.ElementNode{static getType(){return"quote"}static clone(b){return new x(b.__key)}constructor(b){super(b)}createDOM(b){let a=document.createElement("blockquote");h.addClassNamesToElement(a,b.theme.quote);return a}updateDOM(){return!1}static importDOM(){return{blockquote:()=>({conversion:y,priority:0})}}exportDOM(b){({element:b}=super.exportDOM(b));if(b&&h.isHTMLElement(b)){this.isEmpty()&&b.append(document.createElement("br"));var a=this.getFormatType();b.style.textAlign=a;if(a=this.getDirection())b.dir=

@@ -15,4 +15,4 @@ a}return{element:b}}static importJSON(b){let a=z();a.setFormat(b.format);a.setIndent(b.indent);a.setDirection(b.direction);return a}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(b,a){b=k.$createParagraphNode();let d=this.getDirection();b.setDirection(d);this.insertAfter(b,a);return b}collapseAtStart(){let b=k.$createParagraphNode();this.getChildren().forEach(a=>b.append(a));this.replace(b);return!0}}function z(){return k.$applyNodeReplacement(new x)}

priority:0}),h6:()=>({conversion:C,priority:0}),p:b=>{b=b.firstChild;return null!==b&&D(b)?{conversion:()=>({node:null}),priority:3}:null},span:b=>D(b)?{conversion:()=>({node:E("h1")}),priority:3}:null}}exportDOM(b){({element:b}=super.exportDOM(b));if(b&&h.isHTMLElement(b)){this.isEmpty()&&b.append(document.createElement("br"));var a=this.getFormatType();b.style.textAlign=a;if(a=this.getDirection())b.dir=a}return{element:b}}static importJSON(b){let a=E(b.tag);a.setFormat(b.format);a.setIndent(b.indent);
a.setDirection(b.direction);return a}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(b,a=!0){b=b?b.anchor.offset:0;b=0<b&&b<this.getTextContentSize()?E(this.getTag()):k.$createParagraphNode();let d=this.getDirection();b.setDirection(d);this.insertAfter(b,a);return b}collapseAtStart(){let b=this.isEmpty()?k.$createParagraphNode():E(this.getTag());this.getChildren().forEach(a=>b.append(a));this.replace(b);return!0}extractWithChild(){return!0}}
function D(b){return"span"===b.nodeName.toLowerCase()?"26pt"===b.style.fontSize:!1}function C(b){let a=b.nodeName.toLowerCase(),d=null;if("h1"===a||"h2"===a||"h3"===a||"h4"===a||"h5"===a||"h6"===a)d=E(a),null!==b.style&&d.setFormat(b.style.textAlign);return{node:d}}function y(b){let a=z();null!==b.style&&a.setFormat(b.style.textAlign);return{node:a}}function E(b){return k.$applyNodeReplacement(new B(b))}
a.setDirection(b.direction);return a}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(b,a=!0){let d=b?b.anchor.offset:0,e=d!==this.getTextContentSize()&&b?E(this.getTag()):k.$createParagraphNode(),f=this.getDirection();e.setDirection(f);this.insertAfter(e,a);0===d&&!this.isEmpty()&&b&&(b=k.$createParagraphNode(),b.select(),this.replace(b,!0));return e}collapseAtStart(){let b=this.isEmpty()?k.$createParagraphNode():E(this.getTag());this.getChildren().forEach(a=>
b.append(a));this.replace(b);return!0}extractWithChild(){return!0}}function D(b){return"span"===b.nodeName.toLowerCase()?"26pt"===b.style.fontSize:!1}function C(b){let a=b.nodeName.toLowerCase(),d=null;if("h1"===a||"h2"===a||"h3"===a||"h4"===a||"h5"===a||"h6"===a)d=E(a),null!==b.style&&d.setFormat(b.style.textAlign);return{node:d}}function y(b){let a=z();null!==b.style&&a.setFormat(b.style.textAlign);return{node:a}}function E(b){return k.$applyNodeReplacement(new B(b))}
function F(b,a){b.preventDefault();a.update(()=>{let d=k.$getSelection(),e=b instanceof InputEvent||b instanceof KeyboardEvent?null:b.clipboardData;null!=e&&(k.$isRangeSelection(d)||k.DEPRECATED_$isGridSelection(d))&&c.$insertDataTransferForRichText(e,d,a)},{tag:"paste"})}

@@ -19,0 +19,0 @@ async function G(b,a){await c.copyToClipboard(a,h.objectKlassEquals(b,ClipboardEvent)?b:null);a.update(()=>{let d=k.$getSelection();k.$isRangeSelection(d)?d.removeText():k.$isNodeSelection(d)&&d.getNodes().forEach(e=>e.remove())})}function H(b){let a=null;b instanceof DragEvent?a=b.dataTransfer:b instanceof ClipboardEvent&&(a=b.clipboardData);if(null===a)return[!1,[],!1];var d=a.types;b=d.includes("Files");d=d.includes("text/html")||d.includes("text/plain");return[b,Array.from(a.files),d]}

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

"license": "MIT",
"version": "0.12.2",
"version": "0.12.3",
"main": "LexicalRichText.js",
"peerDependencies": {
"lexical": "0.12.2",
"@lexical/selection": "0.12.2",
"@lexical/clipboard": "0.12.2",
"@lexical/utils": "0.12.2"
"lexical": "0.12.3",
"@lexical/selection": "0.12.3",
"@lexical/clipboard": "0.12.3",
"@lexical/utils": "0.12.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