Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/mark

Package Overview
Dependencies
Maintainers
6
Versions
179
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.5.1-next.1 to 0.5.1-next.2

2

index.d.ts

@@ -13,4 +13,4 @@ /** @module @lexical/mark */

export declare function $unwrapMarkNode(node: MarkNode): void;
export declare function $wrapSelectionInMarkNode(selection: RangeSelection, isBackward: boolean, id: string): void;
export declare function $wrapSelectionInMarkNode(selection: RangeSelection, isBackward: boolean, id: string, createNode?: (ids: Array<string>) => MarkNode): void;
export declare function $getMarkIDs(node: TextNode, offset: number): null | Array<string>;
export { $createMarkNode, $isMarkNode, MarkNode, SerializedMarkNode };

@@ -209,3 +209,3 @@ /**

}
function $wrapSelectionInMarkNode(selection, isBackward, id) {
function $wrapSelectionInMarkNode(selection, isBackward, id, createNode) {
const nodes = selection.getNodes();

@@ -281,3 +281,4 @@ const anchorOffset = selection.anchor.offset;

// If we don't have a created mark node, we can make one
lastCreatedMarkNode = $createMarkNode([id]);
const createMarkNode = createNode || $createMarkNode;
lastCreatedMarkNode = createMarkNode([id]);
targetNode.insertBefore(lastCreatedMarkNode);

@@ -284,0 +285,0 @@ } // Add the target node to be wrapped in the latest created mark node

@@ -7,9 +7,9 @@ /**

*/
'use strict';var l=require("lexical"),m=require("@lexical/utils");
class n extends l.ElementNode{static getType(){return"mark"}static clone(a){return new n(Array.from(a.__ids),a.__key)}static importDOM(){return null}static importJSON(a){let b=p(a.ids);b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}exportJSON(){return{...super.exportJSON(),ids:this.getIDs(),type:"mark",version:1}}constructor(a,b){super(b);this.__ids=a||[]}createDOM(a){let b=document.createElement("mark");m.addClassNamesToElement(b,a.theme.mark);1<this.__ids.length&&
m.addClassNamesToElement(b,a.theme.markOverlap);return b}updateDOM(a,b,c){a=a.__ids.length;let e=this.__ids.length;c=c.theme.markOverlap;a!==e&&(1===a?2===e&&m.addClassNamesToElement(b,c):1===e&&m.removeClassNamesFromElement(b,c));return!1}hasID(a){let b=this.getIDs();for(let c=0;c<b.length;c++)if(a===b[c])return!0;return!1}getIDs(){let a=this.getLatest();return q(a)?a.__ids:[]}addID(a){var b=this.getWritable();if(q(b)){let c=b.__ids;b.__ids=c;for(b=0;b<c.length;b++)if(a===c[b])return;c.push(a)}}deleteID(a){var b=
this.getWritable();if(q(b)){let c=b.__ids;b.__ids=c;for(b=0;b<c.length;b++)if(a===c[b]){c.splice(b,1);break}}}insertNewAfter(a){a=this.getParentOrThrow().insertNewAfter(a);if(l.$isElementNode(a)){let b=p(this.__ids);a.append(b);return b}return null}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(a,b,c){if(!l.$isRangeSelection(b)||"html"===c)return!1;let e=b.anchor,d=b.focus;a=e.getNode();c=d.getNode();b=b.isBackward()?e.offset-
d.offset:d.offset-e.offset;return this.isParentOf(a)&&this.isParentOf(c)&&this.getTextContent().length===b}excludeFromCopy(a){return"clone"!==a}}function p(a){return new n(a)}function q(a){return a instanceof n}exports.$createMarkNode=p;exports.$getMarkIDs=function(a,b){for(;null!==a;){if(q(a))return a.getIDs();if(l.$isTextNode(a)&&b===a.getTextContentSize()){let c=a.getNextSibling();if(q(c))return c.getIDs()}a=a.getParent()}return null};exports.$isMarkNode=q;
exports.$unwrapMarkNode=function(a){let b=a.getChildren(),c=null;for(let e=0;e<b.length;e++){let d=b[e];null===c?a.insertBefore(d):c.insertAfter(d);c=d}a.remove()};
exports.$wrapSelectionInMarkNode=function(a,b,c){let e=a.getNodes();var d=a.anchor.offset,h=a.focus.offset;a=e.length;let w=b?h:d;b=b?d:h;let r,k;for(d=0;d<a;d++){var f=e[d];if(l.$isElementNode(k)&&k.isParentOf(f))continue;h=0===d;let u=d===a-1;var g=null;if(l.$isTextNode(f)){g=f.getTextContentSize();let v=h?w:0,t=u?b:g;if(0===v&&0===t)continue;f=f.splitText(v,t);g=1<f.length&&(3===f.length||h&&!u||t===g)?f[1]:f[0]}else if(q(f))continue;else l.$isElementNode(f)&&f.isInline()&&(g=f);null!==g?g&&g.is(r)||
(h=g.getParent(),null!=h&&h.is(r)||(k=void 0),r=h,void 0===k&&(k=p([c]),g.insertBefore(k)),k.append(g)):k=r=void 0}};exports.MarkNode=n
'use strict';var m=require("lexical"),n=require("@lexical/utils");
class p extends m.ElementNode{static getType(){return"mark"}static clone(a){return new p(Array.from(a.__ids),a.__key)}static importDOM(){return null}static importJSON(a){let b=q(a.ids);b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}exportJSON(){return{...super.exportJSON(),ids:this.getIDs(),type:"mark",version:1}}constructor(a,b){super(b);this.__ids=a||[]}createDOM(a){let b=document.createElement("mark");n.addClassNamesToElement(b,a.theme.mark);1<this.__ids.length&&
n.addClassNamesToElement(b,a.theme.markOverlap);return b}updateDOM(a,b,c){a=a.__ids.length;let d=this.__ids.length;c=c.theme.markOverlap;a!==d&&(1===a?2===d&&n.addClassNamesToElement(b,c):1===d&&n.removeClassNamesFromElement(b,c));return!1}hasID(a){let b=this.getIDs();for(let c=0;c<b.length;c++)if(a===b[c])return!0;return!1}getIDs(){let a=this.getLatest();return r(a)?a.__ids:[]}addID(a){var b=this.getWritable();if(r(b)){let c=b.__ids;b.__ids=c;for(b=0;b<c.length;b++)if(a===c[b])return;c.push(a)}}deleteID(a){var b=
this.getWritable();if(r(b)){let c=b.__ids;b.__ids=c;for(b=0;b<c.length;b++)if(a===c[b]){c.splice(b,1);break}}}insertNewAfter(a){a=this.getParentOrThrow().insertNewAfter(a);if(m.$isElementNode(a)){let b=q(this.__ids);a.append(b);return b}return null}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(a,b,c){if(!m.$isRangeSelection(b)||"html"===c)return!1;let d=b.anchor,g=b.focus;a=d.getNode();c=g.getNode();b=b.isBackward()?d.offset-
g.offset:g.offset-d.offset;return this.isParentOf(a)&&this.isParentOf(c)&&this.getTextContent().length===b}excludeFromCopy(a){return"clone"!==a}}function q(a){return new p(a)}function r(a){return a instanceof p}exports.$createMarkNode=q;exports.$getMarkIDs=function(a,b){for(;null!==a;){if(r(a))return a.getIDs();if(m.$isTextNode(a)&&b===a.getTextContentSize()){let c=a.getNextSibling();if(r(c))return c.getIDs()}a=a.getParent()}return null};exports.$isMarkNode=r;
exports.$unwrapMarkNode=function(a){let b=a.getChildren(),c=null;for(let d=0;d<b.length;d++){let g=b[d];null===c?a.insertBefore(g):c.insertAfter(g);c=g}a.remove()};
exports.$wrapSelectionInMarkNode=function(a,b,c,d){let g=a.getNodes();var k=a.anchor.offset,h=a.focus.offset;a=g.length;let x=b?h:k;b=b?k:h;let t,l;for(k=0;k<a;k++){var e=g[k];if(m.$isElementNode(l)&&l.isParentOf(e))continue;h=0===k;let v=k===a-1;var f=null;if(m.$isTextNode(e)){f=e.getTextContentSize();let w=h?x:0,u=v?b:f;if(0===w&&0===u)continue;e=e.splitText(w,u);f=1<e.length&&(3===e.length||h&&!v||u===f)?e[1]:e[0]}else if(r(e))continue;else m.$isElementNode(e)&&e.isInline()&&(f=e);null!==f?f&&
f.is(t)||(h=f.getParent(),null!=h&&h.is(t)||(l=void 0),t=h,void 0===l&&(l=(d||q)([c]),f.insertBefore(l)),l.append(f)):l=t=void 0}};exports.MarkNode=p

@@ -11,9 +11,9 @@ {

"license": "MIT",
"version": "0.5.1-next.1",
"version": "0.5.1-next.2",
"main": "LexicalMark.js",
"peerDependencies": {
"lexical": "0.5.1-next.1"
"lexical": "0.5.1-next.2"
},
"dependencies": {
"@lexical/utils": "0.5.1-next.1"
"@lexical/utils": "0.5.1-next.2"
},

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

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