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

@lexical/mark

Package Overview
Dependencies
Maintainers
5
Versions
252
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/mark - npm Package Compare versions

Comparing version 0.23.2-nightly.20250205.0 to 0.23.2-nightly.20250206.0

32

LexicalMark.dev.js

@@ -166,11 +166,14 @@ /**

function $wrapSelectionInMarkNode(selection, isBackward, id, createNode) {
const nodes = selection.getNodes();
const anchorOffset = selection.anchor.offset;
const focusOffset = selection.focus.offset;
const nodesLength = nodes.length;
const startOffset = isBackward ? focusOffset : anchorOffset;
const endOffset = isBackward ? anchorOffset : focusOffset;
// Force a forwards selection since append is used, ignore the argument.
// A new selection is used to avoid side-effects of flipping the given
// selection
const forwardSelection = lexical.$createRangeSelection();
const [startPoint, endPoint] = selection.isBackward() ? [selection.focus, selection.anchor] : [selection.anchor, selection.focus];
forwardSelection.anchor.set(startPoint.key, startPoint.offset, startPoint.type);
forwardSelection.focus.set(endPoint.key, endPoint.offset, endPoint.type);
let currentNodeParent;
let lastCreatedMarkNode;
// Note that extract will split text nodes at the boundaries
const nodes = forwardSelection.extract();
// We only want wrap adjacent text nodes, line break nodes

@@ -180,4 +183,3 @@ // and inline element nodes. For decorator nodes and block

// again after, if there are more nodes.
for (let i = 0; i < nodesLength; i++) {
const node = nodes[i];
for (const node of nodes) {
if (lexical.$isElementNode(lastCreatedMarkNode) && lastCreatedMarkNode.isParentOf(node)) {

@@ -187,15 +189,6 @@ // If the current node is a child of the last created mark node, there is nothing to do here

}
const isFirstNode = i === 0;
const isLastNode = i === nodesLength - 1;
let targetNode = null;
if (lexical.$isTextNode(node)) {
// Case 1: The node is a text node and we can split it
const textContentSize = node.getTextContentSize();
const startTextOffset = isFirstNode ? startOffset : 0;
const endTextOffset = isLastNode ? endOffset : textContentSize;
if (startTextOffset === 0 && endTextOffset === 0) {
continue;
}
const splitNodes = node.splitText(startTextOffset, endTextOffset);
targetNode = splitNodes.length > 1 && (splitNodes.length === 3 || isFirstNode && !isLastNode || endTextOffset === textContentSize) ? splitNodes[1] : splitNodes[0];
// Case 1: The node is a text node and we can include it
targetNode = node;
} else if ($isMarkNode(node)) {

@@ -207,3 +200,2 @@ // Case 2: the node is a mark node and we can ignore it as a target,

// codebase.
continue;

@@ -210,0 +202,0 @@ } else if ((lexical.$isElementNode(node) || lexical.$isDecoratorNode(node)) && node.isInline()) {

@@ -9,2 +9,2 @@ /**

"use strict";var e=require("lexical"),t=require("@lexical/utils");const r=[];class n extends e.ElementNode{static getType(){return"mark"}static clone(e){return new n(e.__ids,e.__key)}static importDOM(){return null}static importJSON(e){return s().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setIDs(e.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(e=r,t){super(t),this.__ids=e}createDOM(e){const r=document.createElement("mark");return t.addClassNamesToElement(r,e.theme.mark),this.__ids.length>1&&t.addClassNamesToElement(r,e.theme.markOverlap),r}updateDOM(e,r,n){const s=e.__ids,i=this.__ids,o=s.length,l=i.length,a=n.theme.markOverlap;return o!==l&&(1===o?2===l&&t.addClassNamesToElement(r,a):1===l&&t.removeClassNamesFromElement(r,a)),!1}hasID(e){return this.getIDs().includes(e)}getIDs(){return Array.from(this.getLatest().__ids)}setIDs(e){const t=this.getWritable();return t.__ids=e,t}addID(e){const t=this.getWritable();return t.__ids.includes(e)?t:t.setIDs([...t.__ids,e])}deleteID(e){const t=this.getWritable(),r=t.__ids.indexOf(e);if(-1===r)return t;const n=Array.from(t.__ids);return n.splice(r,1),t.setIDs(n)}insertNewAfter(e,t=!0){const r=s(this.__ids);return this.insertAfter(r,t),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(t,r,n){if(!e.$isRangeSelection(r)||"html"===n)return!1;const s=r.anchor,i=r.focus,o=s.getNode(),l=i.getNode(),a=r.isBackward()?s.offset-i.offset:i.offset-s.offset;return this.isParentOf(o)&&this.isParentOf(l)&&this.getTextContent().length===a}excludeFromCopy(e){return"clone"!==e}}function s(t=r){return e.$applyNodeReplacement(new n(t))}function i(e){return e instanceof n}exports.$createMarkNode=s,exports.$getMarkIDs=function(t,r){let n=t;for(;null!==n;){if(i(n))return n.getIDs();if(e.$isTextNode(n)&&r===n.getTextContentSize()){const e=n.getNextSibling();if(i(e))return e.getIDs()}n=n.getParent()}return null},exports.$isMarkNode=i,exports.$unwrapMarkNode=function(e){const t=e.getChildren();let r=null;for(let n=0;n<t.length;n++){const s=t[n];null===r?e.insertBefore(s):r.insertAfter(s),r=s}e.remove()},exports.$wrapSelectionInMarkNode=function(t,r,n,o){const l=t.getNodes(),a=t.anchor.offset,c=t.focus.offset,u=l.length,d=r?c:a,f=r?a:c;let m,h;for(let t=0;t<u;t++){const r=l[t];if(e.$isElementNode(h)&&h.isParentOf(r))continue;const a=0===t,c=t===u-1;let g=null;if(e.$isTextNode(r)){const e=r.getTextContentSize(),t=a?d:0,n=c?f:e;if(0===t&&0===n)continue;const s=r.splitText(t,n);g=s.length>1&&(3===s.length||a&&!c||n===e)?s[1]:s[0]}else{if(i(r))continue;(e.$isElementNode(r)||e.$isDecoratorNode(r))&&r.isInline()&&(g=r)}if(null!==g){if(g&&g.is(m))continue;const e=g.getParent();if(null!=e&&e.is(m)||(h=void 0),m=e,void 0===h){h=(o||s)([n]),g.insertBefore(h)}h.append(g)}else m=void 0,h=void 0}e.$isElementNode(h)&&(r?h.selectStart():h.selectEnd())},exports.MarkNode=n;
"use strict";var e=require("lexical"),t=require("@lexical/utils");const r=[];class s extends e.ElementNode{static getType(){return"mark"}static clone(e){return new s(e.__ids,e.__key)}static importDOM(){return null}static importJSON(e){return n().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setIDs(e.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(e=r,t){super(t),this.__ids=e}createDOM(e){const r=document.createElement("mark");return t.addClassNamesToElement(r,e.theme.mark),this.__ids.length>1&&t.addClassNamesToElement(r,e.theme.markOverlap),r}updateDOM(e,r,s){const n=e.__ids,i=this.__ids,o=n.length,a=i.length,l=s.theme.markOverlap;return o!==a&&(1===o?2===a&&t.addClassNamesToElement(r,l):1===a&&t.removeClassNamesFromElement(r,l)),!1}hasID(e){return this.getIDs().includes(e)}getIDs(){return Array.from(this.getLatest().__ids)}setIDs(e){const t=this.getWritable();return t.__ids=e,t}addID(e){const t=this.getWritable();return t.__ids.includes(e)?t:t.setIDs([...t.__ids,e])}deleteID(e){const t=this.getWritable(),r=t.__ids.indexOf(e);if(-1===r)return t;const s=Array.from(t.__ids);return s.splice(r,1),t.setIDs(s)}insertNewAfter(e,t=!0){const r=n(this.__ids);return this.insertAfter(r,t),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(t,r,s){if(!e.$isRangeSelection(r)||"html"===s)return!1;const n=r.anchor,i=r.focus,o=n.getNode(),a=i.getNode(),l=r.isBackward()?n.offset-i.offset:i.offset-n.offset;return this.isParentOf(o)&&this.isParentOf(a)&&this.getTextContent().length===l}excludeFromCopy(e){return"clone"!==e}}function n(t=r){return e.$applyNodeReplacement(new s(t))}function i(e){return e instanceof s}exports.$createMarkNode=n,exports.$getMarkIDs=function(t,r){let s=t;for(;null!==s;){if(i(s))return s.getIDs();if(e.$isTextNode(s)&&r===s.getTextContentSize()){const e=s.getNextSibling();if(i(e))return e.getIDs()}s=s.getParent()}return null},exports.$isMarkNode=i,exports.$unwrapMarkNode=function(e){const t=e.getChildren();let r=null;for(let s=0;s<t.length;s++){const n=t[s];null===r?e.insertBefore(n):r.insertAfter(n),r=n}e.remove()},exports.$wrapSelectionInMarkNode=function(t,r,s,o){const a=e.$createRangeSelection(),[l,c]=t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];let u,d;a.anchor.set(l.key,l.offset,l.type),a.focus.set(c.key,c.offset,c.type);const f=a.extract();for(const t of f){if(e.$isElementNode(d)&&d.isParentOf(t))continue;let r=null;if(e.$isTextNode(t))r=t;else{if(i(t))continue;(e.$isElementNode(t)||e.$isDecoratorNode(t))&&t.isInline()&&(r=t)}if(null!==r){if(r&&r.is(u))continue;const e=r.getParent();if(null!=e&&e.is(u)||(d=void 0),u=e,void 0===d){d=(o||n)([s]),r.insertBefore(d)}d.append(r)}else u=void 0,d=void 0}e.$isElementNode(d)&&(r?d.selectStart():d.selectEnd())},exports.MarkNode=s;

@@ -11,8 +11,8 @@ {

"license": "MIT",
"version": "0.23.2-nightly.20250205.0",
"version": "0.23.2-nightly.20250206.0",
"main": "LexicalMark.js",
"types": "index.d.ts",
"dependencies": {
"@lexical/utils": "0.23.2-nightly.20250205.0",
"lexical": "0.23.2-nightly.20250205.0"
"@lexical/utils": "0.23.2-nightly.20250206.0",
"lexical": "0.23.2-nightly.20250206.0"
},

@@ -19,0 +19,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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