Socket
Socket
Sign inDemoInstall

@lexical/rich-text

Package Overview
Dependencies
Maintainers
5
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.3.0 to 0.3.1

64

LexicalRichText.dev.js

@@ -302,18 +302,30 @@ /**

event.preventDefault();
editor.update(() => {
const selection = lexical.$getSelection();
if (selection !== null) {
const clipboardData = event.clipboardData;
const selection = lexical.$getSelection();
const htmlString = clipboard.$getHtmlContent(editor);
if (selection !== null) {
if (clipboardData != null) {
const htmlString = clipboard.$getHtmlContent(editor);
if (clipboardData != null) {
if (htmlString !== null) {
clipboardData.setData('text/html', htmlString);
}
if (htmlString !== null) {
clipboardData.setData('text/html', htmlString);
}
const plainString = selection.getTextContent();
clipboardData.setData('text/plain', plainString);
} else {
const clipboard = navigator.clipboard;
clipboardData.setData('text/plain', selection.getTextContent());
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);
}
}
});
}
}

@@ -323,9 +335,9 @@

onCopyForRichText(event, editor);
editor.update(() => {
const selection = lexical.$getSelection();
const selection = lexical.$getSelection();
if (lexical.$isRangeSelection(selection)) {
selection.removeText();
}
});
if (lexical.$isRangeSelection(selection)) {
selection.removeText();
} else if (lexical.$isNodeSelection(selection)) {
selection.getNodes().forEach(node => node.remove());
}
}

@@ -633,19 +645,7 @@

}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.COPY_COMMAND, event => {
const selection = lexical.$getSelection();
if (lexical.$isRangeSelection(selection) || lexical.$isGridSelection(selection)) {
onCopyForRichText(event, editor);
return true;
}
return false;
onCopyForRichText(event, editor);
return true;
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.CUT_COMMAND, event => {
const selection = lexical.$getSelection();
if (lexical.$isRangeSelection(selection) || lexical.$isGridSelection(selection)) {
onCutForRichText(event, editor);
return true;
}
return false;
onCutForRichText(event, editor);
return true;
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.PASTE_COMMAND, event => {

@@ -652,0 +652,0 @@ const selection = lexical.$getSelection();

@@ -15,5 +15,5 @@ /**

function B(b,e){if(null!==e)if(void 0===e)b.update(()=>{var f=l.$getRoot();if(null===f.getFirstChild()){let c=l.$createParagraphNode();f.append(c);f=document.activeElement;(null!==l.$getSelection()||null!==f&&f===b.getRootElement())&&c.select()}},t);else if(null!==e)switch(typeof e){case "string":e=b.parseEditorState(e);b.setEditorState(e,t);break;case "object":b.setEditorState(e,t);break;case "function":b.update(e,t)}}
function C(b,e){b.preventDefault();e.update(()=>{let f=l.$getSelection(),c=b.clipboardData;null!=c&&(l.$isRangeSelection(f)||l.$isGridSelection(f))&&a.$insertDataTransferForRichText(c,f,e)})}function D(b,e){b.preventDefault();e.update(()=>{let f=b.clipboardData,c=l.$getSelection();if(null!==c&&null!=f){let d=a.$getHtmlContent(e);null!==d&&f.setData("text/html",d);f.setData("text/plain",c.getTextContent())}})}
function E(b,e){D(b,e);e.update(()=>{let f=l.$getSelection();l.$isRangeSelection(f)&&f.removeText()})}function F(b,e){var f=l.$getSelection();if(l.$isRangeSelection(f)){var c=new Set;f=f.getNodes();for(let g=0;g<f.length;g++){let v=f[g];var d=v.getKey();c.has(d)||(c.add(d),d=k.$getNearestBlockElementAncestorOrThrow(v),d.canInsertTab()?b(v):d.canIndent()&&e(d))}}}exports.$createHeadingNode=A;exports.$createQuoteNode=x;exports.$isHeadingNode=function(b){return b instanceof y};
exports.$isQuoteNode=function(b){return b instanceof u};exports.HeadingNode=y;exports.QuoteNode=u;
function C(b,e){b.preventDefault();e.update(()=>{let f=l.$getSelection(),c=b.clipboardData;null!=c&&(l.$isRangeSelection(f)||l.$isGridSelection(f))&&a.$insertDataTransferForRichText(c,f,e)})}
function D(b,e){b.preventDefault();var f=l.$getSelection();null!==f&&(b=b.clipboardData,e=a.$getHtmlContent(e),null!=b?(null!==e&&b.setData("text/html",e),f=f.getTextContent(),b.setData("text/plain",f)):(f=navigator.clipboard,null!=f&&(b=[new ClipboardItem({"text/html":new Blob([e],{type:"text/html"})})],f.write(b))))}function E(b,e){D(b,e);b=l.$getSelection();l.$isRangeSelection(b)?b.removeText():l.$isNodeSelection(b)&&b.getNodes().forEach(f=>f.remove())}
function F(b,e){var f=l.$getSelection();if(l.$isRangeSelection(f)){var c=new Set;f=f.getNodes();for(let g=0;g<f.length;g++){let v=f[g];var d=v.getKey();c.has(d)||(c.add(d),d=k.$getNearestBlockElementAncestorOrThrow(v),d.canInsertTab()?b(v):d.canIndent()&&e(d))}}}exports.$createHeadingNode=A;exports.$createQuoteNode=x;exports.$isHeadingNode=function(b){return b instanceof y};exports.$isQuoteNode=function(b){return b instanceof u};exports.HeadingNode=y;exports.QuoteNode=u;
exports.registerRichText=function(b,e){let 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),

@@ -27,3 +27,3 @@ 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.CONTROLLED_TEXT_INSERTION_COMMAND,c=>{const d=l.$getSelection();if("string"===typeof c)l.$isRangeSelection(d)?d.insertText(c):l.$isGridSelection(d);else{if(!l.$isRangeSelection(d)&&!l.$isGridSelection(d))return!1;const g=c.dataTransfer;null!=g?a.$insertDataTransferForRichText(g,d,b):l.$isRangeSelection(d)&&(c=c.data)&&d.insertText(c)}return!0},

if(null!==c){if((r||q)&&p)return!1;c.preventDefault();if(c.shiftKey)return b.dispatchCommand(l.INSERT_LINE_BREAK_COMMAND,!1)}return b.dispatchCommand(l.INSERT_PARAGRAPH_COMMAND,void 0)},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,void 0)},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)?(D(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)?(E(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)?(C(c,b),!0):!1},l.COMMAND_PRIORITY_EDITOR));B(b,e);return f}
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=>{D(c,b);return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.CUT_COMMAND,
c=>{E(c,b);return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.PASTE_COMMAND,c=>{const d=l.$getSelection();return l.$isRangeSelection(d)||l.$isGridSelection(d)?(C(c,b),!0):!1},l.COMMAND_PRIORITY_EDITOR));B(b,e);return f}

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

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

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