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

@lexical/offset

Package Overview
Dependencies
Maintainers
5
Versions
269
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/offset - npm Package Compare versions

Comparing version 0.14.5 to 0.15.0

4

index.d.ts

@@ -49,4 +49,6 @@ /**

}
export declare function createChildrenArray(element: ElementNode, nodeMap: null | NodeMap): Array<NodeKey>;
export declare function $createChildrenArray(element: ElementNode, nodeMap: null | NodeMap): Array<NodeKey>;
/** @deprecated renamed to {@link $createChildrenArray} by @lexical/eslint-plugin rules-of-lexical */
export declare const createChildrenArray: typeof $createChildrenArray;
export declare function $createOffsetView(editor: LexicalEditor, blockOffsetSize?: number, editorState?: EditorState | null): OffsetView;
export {};

@@ -6,3 +6,5 @@ /**

* LICENSE file in the root directory of this source tree.
*
*/
'use strict';

@@ -19,2 +21,3 @@

*/
class OffsetView {

@@ -249,3 +252,3 @@ constructor(offsetMap, firstNode, blockOffsetSize = 1) {

if (lexical.$isElementNode(node)) {
const childKeys = createChildrenArray(node, nodeMap);
const childKeys = $createChildrenArray(node, nodeMap);
const blockIsEmpty = childKeys.length === 0;

@@ -294,3 +297,3 @@ const child = blockIsEmpty ? null : $createOffsetChild(state, childKeys, null, nodeMap, offsetMap, blockOffsetSize);

}
function createChildrenArray(element, nodeMap) {
function $createChildrenArray(element, nodeMap) {
const children = [];

@@ -302,3 +305,3 @@ let nodeKey = element.__first;

{
throw Error(`createChildrenArray: node does not exist in nodeMap`);
throw Error(`$createChildrenArray: node does not exist in nodeMap`);
}

@@ -311,2 +314,4 @@ }

}
/** @deprecated renamed to {@link $createChildrenArray} by @lexical/eslint-plugin rules-of-lexical */
const createChildrenArray = $createChildrenArray;
function $createOffsetView(editor, blockOffsetSize = 1, editorState) {

@@ -321,8 +326,9 @@ const targetEditorState = editorState || editor._pendingEditorState || editor._editorState;

};
const node = $createOffsetChild(state, createChildrenArray(root, nodeMap), null, nodeMap, offsetMap, blockOffsetSize);
const node = $createOffsetChild(state, $createChildrenArray(root, nodeMap), null, nodeMap, offsetMap, blockOffsetSize);
return new OffsetView(offsetMap, node, blockOffsetSize);
}
exports.$createChildrenArray = $createChildrenArray;
exports.$createOffsetView = $createOffsetView;
exports.OffsetView = OffsetView;
exports.createChildrenArray = createChildrenArray;

@@ -6,5 +6,7 @@ /**

* LICENSE file in the root directory of this source tree.
*
*/
'use strict'
const LexicalOffset = process.env.NODE_ENV === 'development' ? require('./LexicalOffset.dev.js') : require('./LexicalOffset.prod.js');
module.exports = LexicalOffset;

@@ -6,11 +6,13 @@ /**

* LICENSE file in the root directory of this source tree.
*
*/
'use strict';var p=require("lexical");function t(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
class y{constructor(a,b,c=1){this._offsetMap=a;this._firstNode=b;this._blockOffsetSize=c}createSelectionFromOffsets(a,b,c){var d=this._firstNode;if(null===d)return null;var f=z(d,a,this._blockOffsetSize);let h=z(d,b,this._blockOffsetSize);void 0!==c&&(a=A(a,f,c,this,this._blockOffsetSize),f=z(d,a,this._blockOffsetSize),b=A(b,h,c,this,this._blockOffsetSize),h=z(d,b,this._blockOffsetSize));if(null===f||null===h)return null;c=f.key;d=h.key;let m=p.$getNodeByKey(c),k=p.$getNodeByKey(d);if(null===m||null===
'use strict';var p=require("lexical"),t;function u(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}t=u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u["default"]:u;
class w{constructor(a,b,c=1){this._offsetMap=a;this._firstNode=b;this._blockOffsetSize=c}createSelectionFromOffsets(a,b,c){var d=this._firstNode;if(null===d)return null;var f=x(d,a,this._blockOffsetSize);let h=x(d,b,this._blockOffsetSize);void 0!==c&&(a=B(a,f,c,this,this._blockOffsetSize),f=x(d,a,this._blockOffsetSize),b=B(b,h,c,this,this._blockOffsetSize),h=x(d,b,this._blockOffsetSize));if(null===f||null===h)return null;c=f.key;d=h.key;let m=p.$getNodeByKey(c),k=p.$getNodeByKey(d);if(null===m||null===
k)return null;let l=0,e=0,g="element",n="element";"text"===f.type?(l=a-f.start,g="text",f=m.getNextSibling(),a!==b&&l===m.getTextContentSize()&&p.$isTextNode(f)&&(l=0,c=f.__key)):"inline"===f.type&&(c=m.getParentOrThrow().getKey(),l=b>f.start?f.end:f.start);"text"===h.type?(e=b-h.start,n="text"):"inline"===h.type&&(d=k.getParentOrThrow().getKey(),e=b>h.start?h.end:h.start);a=p.$createRangeSelection();if(null===a)return null;a.anchor.set(c,l,g);a.focus.set(d,e,n);return a}getOffsetsFromSelection(a){var b=
a.anchor,c=a.focus,d=this._offsetMap;let f=b.offset;var h=c.offset;let m=a=-1;if("text"===b.type)b=d.get(b.key),void 0!==b&&(a=b.start+f);else if(b=b.getNode().getDescendantByIndex(f),null!==b){let k=d.get(b.getKey());void 0!==k&&(a=b.getIndexWithinParent()!==f?k.end:k.start)}"text"===c.type?(h=d.get(c.key),void 0!==h&&(m=h.start+c.offset)):(c=c.getNode().getDescendantByIndex(h),null!==c&&(d=d.get(c.getKey()),void 0!==d&&(m=c.getIndexWithinParent()!==h?d.end:d.start)));return[a,m]}}
function A(a,b,c,d,f){let h=c._offsetMap;d=d._offsetMap;let m=new Set,k=a;for(;null!==b;){var l=b.key,e=h.get(l),g=b.end-b.start;m.add(l);void 0===e?k+=g:(l=e.end-e.start,l!==g&&(k+=g-l));g=b.prev;if(null!==g)b=g;else{for(b=b.parent;null!==b;)e=b.prev,null!==e&&(g=e.key,l=h.get(g),e=e.end-e.start,m.add(g),void 0===l?k+=e:(g=l.end-l.start,g!==e&&(k+=e-g))),b=b.parent;break}}c=c._firstNode;if(null!==c){b=z(c,a,f);for(a=!1;null!==b;){if(!m.has(b.key)){a=!0;break}b=b.parent}if(!a)for(;null!==b;)a=b.key,
m.has(a)||(f=d.get(a),a=b.end-b.start,void 0===f?k-=a:(f=f.end-f.start,a!==f&&(k+=f-a))),b=b.prev}return k}function z(a,b,c){for(;null!==a;){if(b<a.end+("element"!==a.type||0===c?1:0)){let d=a.child;if(null!==d){a=d;continue}return a}a=a.next;if(null===a)break}return null}
function B(a,b,c,d,f,h){let m=null,k=null,l=b.length;for(let v=0;v<l;v++){{var e=a;var g=b[v];var n=c,q=d,w=f,u=h,r=q.get(g);void 0===r&&t(3);let x=e.offset;if(p.$isElementNode(r)){let D=C(r,q);q=(r=0===D.length)?null:B(e,D,null,q,w,u);if(!e.prevIsBlock||r)e.prevIsBlock=!0,e.offset+=u;n={child:q,end:x,key:g,next:null,parent:n,prev:null,start:x,type:"element"};null!==q&&(q.parent=n);n.end=e.offset;w.set(g,n);g=n}else e.prevIsBlock=!1,u=p.$isTextNode(r),e={child:null,end:e.offset+=u?r.__text.length:
1,key:g,next:null,parent:n,prev:null,start:x,type:u?"text":"inline"},w.set(g,e),g=e}null===k?m=g:(g.prev=k,k.next=g);k=g}return m}function C(a,b){let c=[];for(a=a.__first;null!==a;){let d=null===b?p.$getNodeByKey(a):b.get(a);null!==d&&void 0!==d||t(101);c.push(a);a=d.__next}return c}exports.$createOffsetView=function(a,b=1,c){c=(c||a._pendingEditorState||a._editorState)._nodeMap;let d=c.get("root");a=new Map;c=B({offset:0,prevIsBlock:!1},C(d,c),null,c,a,b);return new y(a,c,b)};
exports.OffsetView=y;exports.createChildrenArray=C
function B(a,b,c,d,f){let h=c._offsetMap;d=d._offsetMap;let m=new Set,k=a;for(;null!==b;){var l=b.key,e=h.get(l),g=b.end-b.start;m.add(l);void 0===e?k+=g:(l=e.end-e.start,l!==g&&(k+=g-l));g=b.prev;if(null!==g)b=g;else{for(b=b.parent;null!==b;)e=b.prev,null!==e&&(g=e.key,l=h.get(g),e=e.end-e.start,m.add(g),void 0===l?k+=e:(g=l.end-l.start,g!==e&&(k+=e-g))),b=b.parent;break}}c=c._firstNode;if(null!==c){b=x(c,a,f);for(a=!1;null!==b;){if(!m.has(b.key)){a=!0;break}b=b.parent}if(!a)for(;null!==b;)a=b.key,
m.has(a)||(f=d.get(a),a=b.end-b.start,void 0===f?k-=a:(f=f.end-f.start,a!==f&&(k+=f-a))),b=b.prev}return k}function x(a,b,c){for(;null!==a;){if(b<a.end+("element"!==a.type||0===c?1:0)){let d=a.child;if(null!==d){a=d;continue}return a}a=a.next;if(null===a)break}return null}
function C(a,b,c,d,f,h){let m=null,k=null,l=b.length;for(let y=0;y<l;y++){{var e=a;var g=b[y];var n=c,q=d,z=f,v=h,r=q.get(g);void 0===r&&t(3);let A=e.offset;if(p.$isElementNode(r)){let E=D(r,q);q=(r=0===E.length)?null:C(e,E,null,q,z,v);if(!e.prevIsBlock||r)e.prevIsBlock=!0,e.offset+=v;n={child:q,end:A,key:g,next:null,parent:n,prev:null,start:A,type:"element"};null!==q&&(q.parent=n);n.end=e.offset;z.set(g,n);g=n}else e.prevIsBlock=!1,v=p.$isTextNode(r),e={child:null,end:e.offset+=v?r.__text.length:
1,key:g,next:null,parent:n,prev:null,start:A,type:v?"text":"inline"},z.set(g,e),g=e}null===k?m=g:(g.prev=k,k.next=g);k=g}return m}function D(a,b){let c=[];for(a=a.__first;null!==a;){let d=null===b?p.$getNodeByKey(a):b.get(a);null!==d&&void 0!==d||t(174);c.push(a);a=d.__next}return c}let F=D;exports.$createChildrenArray=D;
exports.$createOffsetView=function(a,b=1,c){c=(c||a._pendingEditorState||a._editorState)._nodeMap;let d=c.get("root");a=new Map;c=C({offset:0,prevIsBlock:!1},D(d,c),null,c,a,b);return new w(a,c,b)};exports.OffsetView=w;exports.createChildrenArray=F

@@ -11,3 +11,3 @@ {

"license": "MIT",
"version": "0.14.5",
"version": "0.15.0",
"main": "LexicalOffset.js",

@@ -40,4 +40,4 @@ "types": "index.d.ts",

"dependencies": {
"lexical": "0.14.5"
"lexical": "0.15.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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