Socket
Socket
Sign inDemoInstall

@lexical/rich-text

Package Overview
Dependencies
Maintainers
6
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.5.0 to 0.5.1-next.0

65

LexicalRichText.dev.js

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

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;

@@ -294,50 +302,19 @@ CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);

function onCopyForRichText(event, editor) {
const selection = lexical.$getSelection();
async function onCutForRichText(event, editor) {
const selection = editor.getEditorState().read(() => lexical.$getSelection());
if (selection !== null) {
event.preventDefault();
const clipboardData = event instanceof KeyboardEvent ? null : event.clipboardData;
const htmlString = clipboard.$getHtmlContent(editor);
const lexicalString = clipboard.$getLexicalContent(editor);
if (selection == null) {
return;
}
if (clipboardData != null) {
if (htmlString !== null) {
clipboardData.setData('text/html', htmlString);
}
if (lexicalString !== null) {
clipboardData.setData('application/x-lexical-editor', lexicalString);
}
const plainString = selection.getTextContent();
clipboardData.setData('text/plain', plainString);
} else {
const clipboard = navigator.clipboard;
if (clipboard != null) {
// Most browsers only support a single item in the clipboard at one time.
// So we optimize by only putting in HTML.
const data = [new ClipboardItem({
'text/html': new Blob([htmlString], {
type: 'text/html'
})
})];
clipboard.write(data);
}
await clipboard.copyToClipboard__EXPERIMENTAL(editor, event instanceof ClipboardEvent ? event : null);
editor.update(() => {
if (lexical.$isRangeSelection(selection)) {
selection.removeText();
} else if (lexical.$isNodeSelection(selection)) {
selection.getNodes().forEach(node => node.remove());
}
}
});
}
function onCutForRichText(event, editor) {
onCopyForRichText(event, editor);
const selection = lexical.$getSelection();
if (lexical.$isRangeSelection(selection)) {
selection.removeText();
} else if (lexical.$isNodeSelection(selection)) {
selection.getNodes().forEach(node => node.remove());
}
}
function handleIndentAndOutdent(insertTab, indentOrOutdent) {

@@ -710,3 +687,3 @@ const selection = lexical.$getSelection();

}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.COPY_COMMAND, event => {
onCopyForRichText(event, editor);
clipboard.copyToClipboard__EXPERIMENTAL(editor, event instanceof ClipboardEvent ? event : null);
return true;

@@ -713,0 +690,0 @@ }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.CUT_COMMAND, event => {

@@ -7,23 +7,23 @@ /**

*/
'use strict';var b=require("@lexical/clipboard"),f=require("@lexical/selection"),g=require("@lexical/utils"),h=require("lexical");let l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,m=l&&"documentMode"in document?document.documentMode:null;l&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);l&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
'use strict';var a=require("@lexical/clipboard"),f=require("@lexical/selection"),g=require("@lexical/utils"),h=require("lexical");let l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,m=l&&"documentMode"in document?document.documentMode:null;l&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);l&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
let n=l&&"InputEvent"in window&&!m?"getTargetRanges"in new window.InputEvent("input"):!1,p=l&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),q=l&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;
class r extends h.ElementNode{static getType(){return"quote"}static clone(a){return new r(a.__key)}constructor(a){super(a)}createDOM(a){let c=document.createElement("blockquote");g.addClassNamesToElement(c,a.theme.quote);return c}updateDOM(){return!1}static importDOM(){return{blockquote:()=>({conversion:t,priority:0})}}static importJSON(a){let c=w();c.setFormat(a.format);c.setIndent(a.indent);c.setDirection(a.direction);return c}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(){let a=
h.$createParagraphNode(),c=this.getDirection();a.setDirection(c);this.insertAfter(a);return a}collapseAtStart(){let a=h.$createParagraphNode();this.getChildren().forEach(c=>a.append(c));this.replace(a);return!0}}function w(){return new r}
class x extends h.ElementNode{static getType(){return"heading"}static clone(a){return new x(a.__tag,a.__key)}constructor(a,c){super(c);this.__tag=a}getTag(){return this.__tag}createDOM(a){let c=this.__tag,d=document.createElement(c);a=a.theme.heading;void 0!==a&&g.addClassNamesToElement(d,a[c]);return d}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:y,priority:0}),h2:()=>({conversion:y,priority:0}),h3:()=>({conversion:y,priority:0}),h4:()=>({conversion:y,priority:0}),h5:()=>({conversion:y,
priority:0}),h6:()=>({conversion:y,priority:0}),p:a=>{a=a.firstChild;return null!==a&&z(a)?{conversion:()=>({node:null}),priority:3}:null},span:a=>z(a)?{conversion:()=>({node:A("h1")}),priority:3}:null}}static importJSON(a){let c=A(a.tag);c.setFormat(a.format);c.setIndent(a.indent);c.setDirection(a.direction);return c}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(){let a=h.$createParagraphNode(),c=this.getDirection();a.setDirection(c);this.insertAfter(a);
return a}collapseAtStart(){let a=h.$createParagraphNode();this.getChildren().forEach(c=>a.append(c));this.replace(a);return!0}extractWithChild(){return!0}}function z(a){return"span"===a.nodeName.toLowerCase()?"26pt"===a.style.fontSize:!1}function y(a){a=a.nodeName.toLowerCase();let c=null;if("h1"===a||"h2"===a||"h3"===a||"h4"===a||"h5"===a||"h6"===a)c=A(a);return{node:c}}function t(){return{node:w()}}function A(a){return new x(a)}
function B(a,c){a.preventDefault();c.update(()=>{let d=h.$getSelection(),e=a instanceof InputEvent||a instanceof KeyboardEvent?null:a.clipboardData;null!=e&&(h.$isRangeSelection(d)||h.DEPRECATED_$isGridSelection(d))&&b.$insertDataTransferForRichText(e,d,c)},{tag:"paste"})}
function C(a,c){var d=h.$getSelection();if(null!==d){a.preventDefault();a=a instanceof KeyboardEvent?null:a.clipboardData;let e=b.$getHtmlContent(c);c=b.$getLexicalContent(c);null!=a?(null!==e&&a.setData("text/html",e),null!==c&&a.setData("application/x-lexical-editor",c),d=d.getTextContent(),a.setData("text/plain",d)):(d=navigator.clipboard,null!=d&&(a=[new ClipboardItem({"text/html":new Blob([e],{type:"text/html"})})],d.write(a)))}}
function D(a,c){C(a,c);a=h.$getSelection();h.$isRangeSelection(a)?a.removeText():h.$isNodeSelection(a)&&a.getNodes().forEach(d=>d.remove())}function E(a,c){var d=h.$getSelection();if(h.$isRangeSelection(d)){var e=new Set;d=d.getNodes();for(let u=0;u<d.length;u++){let v=d[u];var k=v.getKey();e.has(k)||(e.add(k),k=g.$getNearestBlockElementAncestorOrThrow(v),k.canInsertTab()?a(v):k.canIndent()&&c(k))}}}function F(a){a=h.$getNearestNodeFromDOMNode(a);return h.$isDecoratorNode(a)}
exports.$createHeadingNode=A;exports.$createQuoteNode=w;exports.$isHeadingNode=function(a){return a instanceof x};exports.$isQuoteNode=function(a){return a instanceof r};exports.HeadingNode=x;exports.QuoteNode=r;
exports.registerRichText=function(a){return g.mergeRegister(a.registerCommand(h.CLICK_COMMAND,()=>{const c=h.$getSelection();return h.$isNodeSelection(c)?(c.clear(),!0):!1},0),a.registerCommand(h.DELETE_CHARACTER_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.deleteCharacter(c);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.DELETE_WORD_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.deleteWord(c);return!0},h.COMMAND_PRIORITY_EDITOR),
a.registerCommand(h.DELETE_LINE_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.deleteLine(c);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.CONTROLLED_TEXT_INSERTION_COMMAND,c=>{const d=h.$getSelection();if("string"===typeof c)h.$isRangeSelection(d)?d.insertText(c):h.DEPRECATED_$isGridSelection(d);else{if(!h.$isRangeSelection(d)&&!h.DEPRECATED_$isGridSelection(d))return!1;const e=c.dataTransfer;null!=e?b.$insertDataTransferForRichText(e,d,a):h.$isRangeSelection(d)&&
(c=c.data)&&d.insertText(c)}return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.REMOVE_TEXT_COMMAND,()=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;c.removeText();return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.FORMAT_TEXT_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.formatText(c);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.FORMAT_ELEMENT_COMMAND,c=>{var d=h.$getSelection();if(!h.$isRangeSelection(d)&&!h.$isNodeSelection(d))return!1;
d=d.getNodes();for(const e of d)g.$getNearestBlockElementAncestorOrThrow(e).setFormat(c);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.INSERT_LINE_BREAK_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.insertLineBreak(c);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.INSERT_PARAGRAPH_COMMAND,()=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;c.insertParagraph();return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.INDENT_CONTENT_COMMAND,
()=>{E(()=>{a.dispatchCommand(h.CONTROLLED_TEXT_INSERTION_COMMAND,"\t")},c=>{const d=c.getIndent();10!==d&&c.setIndent(d+1)});return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.OUTDENT_CONTENT_COMMAND,()=>{E(c=>{h.$isTextNode(c)&&(c=c.getTextContent(),"\t"===c[c.length-1]&&a.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!0))},c=>{const d=c.getIndent();0!==d&&c.setIndent(d-1)});return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_ARROW_UP_COMMAND,c=>{const d=h.$getSelection();return h.$isNodeSelection(d)&&
!F(c.target)&&(c=d.getNodes(),0<c.length)?(c[0].selectPrevious(),!0):!1},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_ARROW_DOWN_COMMAND,()=>{var c=h.$getSelection();return h.$isNodeSelection(c)&&(c=c.getNodes(),0<c.length)?(c[0].selectNext(0,0),!0):!1},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_ARROW_LEFT_COMMAND,c=>{const d=h.$getSelection();if(h.$isNodeSelection(d)){var e=d.getNodes();if(0<e.length)return c.preventDefault(),e[0].selectPrevious(),!0}return h.$isRangeSelection(d)?f.$shouldOverrideDefaultCharacterSelection(d,
!0)?(e=c.shiftKey,c.preventDefault(),f.$moveCharacter(d,e,!0),!0):!1:!1},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_ARROW_RIGHT_COMMAND,c=>{const d=h.$getSelection();if(h.$isNodeSelection(d)&&!F(c.target)){var e=d.getNodes();if(0<e.length)return c.preventDefault(),e[0].selectNext(0,0),!0}if(!h.$isRangeSelection(d))return!1;e=c.shiftKey;return f.$shouldOverrideDefaultCharacterSelection(d,!1)?(c.preventDefault(),f.$moveCharacter(d,e,!1),!0):!1},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_BACKSPACE_COMMAND,
c=>{if(F(c.target))return!1;const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;c.preventDefault();({anchor:c}=d);const e=c.getNode();return d.isCollapsed()&&0===c.offset&&!h.$isRootNode(e)&&0<g.$getNearestBlockElementAncestorOrThrow(e).getIndent()?a.dispatchCommand(h.OUTDENT_CONTENT_COMMAND,void 0):a.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!0)},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_DELETE_COMMAND,c=>{if(F(c.target))return!1;const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;
c.preventDefault();return a.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!1)},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_ENTER_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;if(null!==c){if((q||p)&&n)return!1;c.preventDefault();if(c.shiftKey)return a.dispatchCommand(h.INSERT_LINE_BREAK_COMMAND,!1)}return a.dispatchCommand(h.INSERT_PARAGRAPH_COMMAND,void 0)},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_TAB_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;
c.preventDefault();return a.dispatchCommand(c.shiftKey?h.OUTDENT_CONTENT_COMMAND:h.INDENT_CONTENT_COMMAND,void 0)},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_ESCAPE_COMMAND,()=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;a.blur();return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.DROP_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;c.preventDefault();return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.DRAGSTART_COMMAND,c=>{const d=h.$getSelection();
if(!h.$isRangeSelection(d))return!1;c.preventDefault();return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.COPY_COMMAND,c=>{C(c,a);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.CUT_COMMAND,c=>{D(c,a);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.PASTE_COMMAND,c=>{const d=h.$getSelection();return h.$isRangeSelection(d)||h.DEPRECATED_$isGridSelection(d)?(B(c,a),!0):!1},h.COMMAND_PRIORITY_EDITOR))}
class r extends h.ElementNode{static getType(){return"quote"}static clone(c){return new r(c.__key)}constructor(c){super(c)}createDOM(c){let b=document.createElement("blockquote");g.addClassNamesToElement(b,c.theme.quote);return b}updateDOM(){return!1}static importDOM(){return{blockquote:()=>({conversion:t,priority:0})}}static importJSON(c){let b=w();b.setFormat(c.format);b.setIndent(c.indent);b.setDirection(c.direction);return b}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(){let c=
h.$createParagraphNode(),b=this.getDirection();c.setDirection(b);this.insertAfter(c);return c}collapseAtStart(){let c=h.$createParagraphNode();this.getChildren().forEach(b=>c.append(b));this.replace(c);return!0}}function w(){return new r}
class x extends h.ElementNode{static getType(){return"heading"}static clone(c){return new x(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&&g.addClassNamesToElement(d,c[b]);return d}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:y,priority:0}),h2:()=>({conversion:y,priority:0}),h3:()=>({conversion:y,priority:0}),h4:()=>({conversion:y,priority:0}),h5:()=>({conversion:y,
priority:0}),h6:()=>({conversion:y,priority:0}),p:c=>{c=c.firstChild;return null!==c&&z(c)?{conversion:()=>({node:null}),priority:3}:null},span:c=>z(c)?{conversion:()=>({node:A("h1")}),priority:3}:null}}static importJSON(c){let b=A(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=h.$createParagraphNode(),b=this.getDirection();c.setDirection(b);this.insertAfter(c);
return c}collapseAtStart(){let c=h.$createParagraphNode();this.getChildren().forEach(b=>c.append(b));this.replace(c);return!0}extractWithChild(){return!0}}function z(c){return"span"===c.nodeName.toLowerCase()?"26pt"===c.style.fontSize:!1}function y(c){c=c.nodeName.toLowerCase();let b=null;if("h1"===c||"h2"===c||"h3"===c||"h4"===c||"h5"===c||"h6"===c)b=A(c);return{node:b}}function t(){return{node:w()}}function A(c){return new x(c)}
function B(c,b){c.preventDefault();b.update(()=>{let d=h.$getSelection(),e=c instanceof InputEvent||c instanceof KeyboardEvent?null:c.clipboardData;null!=e&&(h.$isRangeSelection(d)||h.DEPRECATED_$isGridSelection(d))&&a.$insertDataTransferForRichText(e,d,b)},{tag:"paste"})}
async function C(c,b){let d=b.getEditorState().read(()=>h.$getSelection());null!=d&&(await a.copyToClipboard__EXPERIMENTAL(b,c instanceof ClipboardEvent?c:null),b.update(()=>{h.$isRangeSelection(d)?d.removeText():h.$isNodeSelection(d)&&d.getNodes().forEach(e=>e.remove())}))}
function D(c,b){var d=h.$getSelection();if(h.$isRangeSelection(d)){var e=new Set;d=d.getNodes();for(let u=0;u<d.length;u++){let v=d[u];var k=v.getKey();e.has(k)||(e.add(k),k=g.$getNearestBlockElementAncestorOrThrow(v),k.canInsertTab()?c(v):k.canIndent()&&b(k))}}}function E(c){c=h.$getNearestNodeFromDOMNode(c);return h.$isDecoratorNode(c)}exports.$createHeadingNode=A;exports.$createQuoteNode=w;exports.$isHeadingNode=function(c){return c instanceof x};
exports.$isQuoteNode=function(c){return c instanceof r};exports.HeadingNode=x;exports.QuoteNode=r;
exports.registerRichText=function(c){return g.mergeRegister(c.registerCommand(h.CLICK_COMMAND,()=>{const b=h.$getSelection();return h.$isNodeSelection(b)?(b.clear(),!0):!1},0),c.registerCommand(h.DELETE_CHARACTER_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.deleteCharacter(b);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.DELETE_WORD_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.deleteWord(b);return!0},h.COMMAND_PRIORITY_EDITOR),
c.registerCommand(h.DELETE_LINE_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.deleteLine(b);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.CONTROLLED_TEXT_INSERTION_COMMAND,b=>{const d=h.$getSelection();if("string"===typeof b)h.$isRangeSelection(d)?d.insertText(b):h.DEPRECATED_$isGridSelection(d);else{if(!h.$isRangeSelection(d)&&!h.DEPRECATED_$isGridSelection(d))return!1;const e=b.dataTransfer;null!=e?a.$insertDataTransferForRichText(e,d,c):h.$isRangeSelection(d)&&
(b=b.data)&&d.insertText(b)}return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.REMOVE_TEXT_COMMAND,()=>{const b=h.$getSelection();if(!h.$isRangeSelection(b))return!1;b.removeText();return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.FORMAT_TEXT_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.formatText(b);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.FORMAT_ELEMENT_COMMAND,b=>{var d=h.$getSelection();if(!h.$isRangeSelection(d)&&!h.$isNodeSelection(d))return!1;
d=d.getNodes();for(const e of d)g.$getNearestBlockElementAncestorOrThrow(e).setFormat(b);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.INSERT_LINE_BREAK_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.insertLineBreak(b);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.INSERT_PARAGRAPH_COMMAND,()=>{const b=h.$getSelection();if(!h.$isRangeSelection(b))return!1;b.insertParagraph();return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.INDENT_CONTENT_COMMAND,
()=>{D(()=>{c.dispatchCommand(h.CONTROLLED_TEXT_INSERTION_COMMAND,"\t")},b=>{const d=b.getIndent();10!==d&&b.setIndent(d+1)});return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.OUTDENT_CONTENT_COMMAND,()=>{D(b=>{h.$isTextNode(b)&&(b=b.getTextContent(),"\t"===b[b.length-1]&&c.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!0))},b=>{const d=b.getIndent();0!==d&&b.setIndent(d-1)});return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_ARROW_UP_COMMAND,b=>{const d=h.$getSelection();return h.$isNodeSelection(d)&&
!E(b.target)&&(b=d.getNodes(),0<b.length)?(b[0].selectPrevious(),!0):!1},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_ARROW_DOWN_COMMAND,()=>{var b=h.$getSelection();return h.$isNodeSelection(b)&&(b=b.getNodes(),0<b.length)?(b[0].selectNext(0,0),!0):!1},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_ARROW_LEFT_COMMAND,b=>{const d=h.$getSelection();if(h.$isNodeSelection(d)){var e=d.getNodes();if(0<e.length)return b.preventDefault(),e[0].selectPrevious(),!0}return h.$isRangeSelection(d)?f.$shouldOverrideDefaultCharacterSelection(d,
!0)?(e=b.shiftKey,b.preventDefault(),f.$moveCharacter(d,e,!0),!0):!1:!1},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_ARROW_RIGHT_COMMAND,b=>{const d=h.$getSelection();if(h.$isNodeSelection(d)&&!E(b.target)){var e=d.getNodes();if(0<e.length)return b.preventDefault(),e[0].selectNext(0,0),!0}if(!h.$isRangeSelection(d))return!1;e=b.shiftKey;return f.$shouldOverrideDefaultCharacterSelection(d,!1)?(b.preventDefault(),f.$moveCharacter(d,e,!1),!0):!1},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_BACKSPACE_COMMAND,
b=>{if(E(b.target))return!1;const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;b.preventDefault();({anchor:b}=d);const e=b.getNode();return d.isCollapsed()&&0===b.offset&&!h.$isRootNode(e)&&0<g.$getNearestBlockElementAncestorOrThrow(e).getIndent()?c.dispatchCommand(h.OUTDENT_CONTENT_COMMAND,void 0):c.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!0)},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_DELETE_COMMAND,b=>{if(E(b.target))return!1;const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;
b.preventDefault();return c.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!1)},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_ENTER_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;if(null!==b){if((q||p)&&n)return!1;b.preventDefault();if(b.shiftKey)return c.dispatchCommand(h.INSERT_LINE_BREAK_COMMAND,!1)}return c.dispatchCommand(h.INSERT_PARAGRAPH_COMMAND,void 0)},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_TAB_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;
b.preventDefault();return c.dispatchCommand(b.shiftKey?h.OUTDENT_CONTENT_COMMAND:h.INDENT_CONTENT_COMMAND,void 0)},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_ESCAPE_COMMAND,()=>{const b=h.$getSelection();if(!h.$isRangeSelection(b))return!1;c.blur();return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.DROP_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;b.preventDefault();return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.DRAGSTART_COMMAND,b=>{const d=h.$getSelection();
if(!h.$isRangeSelection(d))return!1;b.preventDefault();return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.COPY_COMMAND,b=>{a.copyToClipboard__EXPERIMENTAL(c,b instanceof ClipboardEvent?b:null);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.CUT_COMMAND,b=>{C(b,c);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.PASTE_COMMAND,b=>{const d=h.$getSelection();return h.$isRangeSelection(d)||h.DEPRECATED_$isGridSelection(d)?(B(b,c),!0):!1},h.COMMAND_PRIORITY_EDITOR))}

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

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

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