Socket
Socket
Sign inDemoInstall

@lexical/dragon

Package Overview
Dependencies
Maintainers
7
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/dragon - npm Package Compare versions

Comparing version 0.8.1 to 0.9.0

28

LexicalDragon.dev.js

@@ -14,2 +14,3 @@ /**

const origin = window.location.origin;
const handler = event => {

@@ -19,9 +20,14 @@ if (event.origin !== origin) {

}
const rootElement = editor.getRootElement();
if (document.activeElement !== rootElement) {
return;
}
const data = event.data;
if (typeof data === 'string') {
let parsedData;
try {

@@ -32,10 +38,14 @@ parsedData = JSON.parse(data);

}
if (parsedData && parsedData.protocol === 'nuanria_messaging' && parsedData.type === 'request') {
const payload = parsedData.payload;
if (payload && payload.functionId === 'makeChanges') {
const args = payload.args;
if (args) {
const [elementStart, elementLength, text, selStart, selLength, formatCommand] = args;
const [elementStart, elementLength, text, selStart, selLength, formatCommand] = args; // TODO: we should probably handle formatCommand somehow?
editor.update(() => {
const selection = lexical.$getSelection();
if (lexical.$isRangeSelection(selection)) {

@@ -46,2 +56,3 @@ const anchor = selection.anchor;

let setSelEnd = 0;
if (lexical.$isTextNode(anchorNode)) {

@@ -51,7 +62,8 @@ // set initial selection

setSelStart = elementStart;
setSelEnd = elementStart + elementLength;
// If the offset is more than the end, make it the end
setSelEnd = elementStart + elementLength; // If the offset is more than the end, make it the end
selection.setTextNodeRange(anchorNode, setSelStart, anchorNode, setSelEnd);
}
}
if (setSelStart !== setSelEnd || text !== '') {

@@ -61,2 +73,3 @@ selection.insertRawText(text);

}
if (lexical.$isTextNode(anchorNode)) {

@@ -66,10 +79,10 @@ // set final selection

setSelEnd = selStart + selLength;
const anchorNodeTextLength = anchorNode.getTextContentSize();
// If the offset is more than the end, make it the end
const anchorNodeTextLength = anchorNode.getTextContentSize(); // If the offset is more than the end, make it the end
setSelStart = setSelStart > anchorNodeTextLength ? anchorNodeTextLength : setSelStart;
setSelEnd = setSelEnd > anchorNodeTextLength ? anchorNodeTextLength : setSelEnd;
selection.setTextNodeRange(anchorNode, setSelStart, anchorNode, setSelEnd);
}
} // block the chrome extension from handling this event
// block the chrome extension from handling this event
event.stopImmediatePropagation();

@@ -83,2 +96,3 @@ }

};
window.addEventListener('message', handler, true);

@@ -85,0 +99,0 @@ return () => {

@@ -12,6 +12,6 @@ {

"license": "MIT",
"version": "0.8.1",
"version": "0.9.0",
"main": "LexicalDragon.js",
"peerDependencies": {
"lexical": "0.8.1"
"lexical": "0.9.0"
},

@@ -18,0 +18,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