@lexical/offset 0.43.0 → 0.43.1-nightly.20260413.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,7 @@ function formatDevErrorMessage(message) {
24
24
  throw new Error(message);
25
25
  }
26
26
 
27
+ /** @deprecated OffsetView has never worked correctly and will be removed */
27
28
  class OffsetView {
28
29
  _offsetMap;
29
30
  _firstNode;
@@ -300,23 +301,11 @@ function $createOffsetChild(state, children, parent, nodeMap, offsetMap, blockOf
300
301
  }
301
302
  return firstNode;
302
303
  }
303
- function $createChildrenArray(element, nodeMap) {
304
- const children = [];
305
- let nodeKey = element.__first;
306
- while (nodeKey !== null) {
307
- const node = nodeMap === null ? lexical.$getNodeByKey(nodeKey) : nodeMap.get(nodeKey);
308
- if (node === null || node === undefined) {
309
- {
310
- formatDevErrorMessage(`$createChildrenArray: node does not exist in nodeMap`);
311
- }
312
- }
313
- children.push(nodeKey);
314
- nodeKey = node.__next;
315
- }
316
- return children;
317
- }
318
- /** @deprecated renamed to {@link $createChildrenArray} by @lexical/eslint-plugin rules-of-lexical */
319
- const createChildrenArray = $createChildrenArray;
304
+
305
+ /** @deprecated moved to `lexical` */
306
+ const $createChildrenArray = lexical.$createChildrenArray;
307
+
308
+ /** @deprecated OffsetView has never worked correctly and will be removed */
320
309
  function $createOffsetView(editor, blockOffsetSize = 1, editorState) {
321
310
  const targetEditorState = editorState || editor._pendingEditorState || editor._editorState;
322
311
  const nodeMap = targetEditorState._nodeMap;
@@ -333,4 +322,3 @@ function $createOffsetView(editor, blockOffsetSize = 1, editorState) {
333
322
  exports.$createChildrenArray = $createChildrenArray;
334
323
  exports.$createOffsetView = $createOffsetView;
335
324
  exports.OffsetView = OffsetView;
336
- exports.createChildrenArray = createChildrenArray;
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import { $getNodeByKey, $isTextNode, $createRangeSelection, $isElementNode } from 'lexical';
9
+ import { $createChildrenArray as $createChildrenArray$1, $getNodeByKey, $isTextNode, $createRangeSelection, $isElementNode } from 'lexical';
10
10
 
11
11
  /**
12
12
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -22,6 +22,7 @@ function formatDevErrorMessage(message) {
22
22
  throw new Error(message);
23
23
  }
24
24
 
25
+ /** @deprecated OffsetView has never worked correctly and will be removed */
25
26
  class OffsetView {
26
27
  _offsetMap;
27
28
  _firstNode;
@@ -298,23 +299,11 @@ function $createOffsetChild(state, children, parent, nodeMap, offsetMap, blockOf
298
299
  }
299
300
  return firstNode;
300
301
  }
301
- function $createChildrenArray(element, nodeMap) {
302
- const children = [];
303
- let nodeKey = element.__first;
304
- while (nodeKey !== null) {
305
- const node = nodeMap === null ? $getNodeByKey(nodeKey) : nodeMap.get(nodeKey);
306
- if (node === null || node === undefined) {
307
- {
308
- formatDevErrorMessage(`$createChildrenArray: node does not exist in nodeMap`);
309
- }
310
- }
311
- children.push(nodeKey);
312
- nodeKey = node.__next;
313
- }
314
- return children;
315
- }
316
- /** @deprecated renamed to {@link $createChildrenArray} by @lexical/eslint-plugin rules-of-lexical */
317
- const createChildrenArray = $createChildrenArray;
302
+
303
+ /** @deprecated moved to `lexical` */
304
+ const $createChildrenArray = $createChildrenArray$1;
305
+
306
+ /** @deprecated OffsetView has never worked correctly and will be removed */
318
307
  function $createOffsetView(editor, blockOffsetSize = 1, editorState) {
319
308
  const targetEditorState = editorState || editor._pendingEditorState || editor._editorState;
320
309
  const nodeMap = targetEditorState._nodeMap;
@@ -328,4 +317,4 @@ function $createOffsetView(editor, blockOffsetSize = 1, editorState) {
328
317
  return new OffsetView(offsetMap, node, blockOffsetSize);
329
318
  }
330
319
 
331
- export { $createChildrenArray, $createOffsetView, OffsetView, createChildrenArray };
320
+ export { $createChildrenArray, $createOffsetView, OffsetView };
package/LexicalOffset.mjs CHANGED
@@ -11,5 +11,4 @@ import * as modProd from './LexicalOffset.prod.mjs';
11
11
  const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
12
12
  export const $createChildrenArray = mod.$createChildrenArray;
13
13
  export const $createOffsetView = mod.$createOffsetView;
14
- export const OffsetView = mod.OffsetView;
15
- export const createChildrenArray = mod.createChildrenArray;
14
+ export const OffsetView = mod.OffsetView;
@@ -9,5 +9,4 @@
9
9
  const mod = await (process.env.NODE_ENV !== 'production' ? import('./LexicalOffset.dev.mjs') : import('./LexicalOffset.prod.mjs'));
10
10
  export const $createChildrenArray = mod.$createChildrenArray;
11
11
  export const $createOffsetView = mod.$createOffsetView;
12
- export const OffsetView = mod.OffsetView;
13
- export const createChildrenArray = mod.createChildrenArray;
12
+ export const OffsetView = mod.OffsetView;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("lexical");function t(e,...t){const n=new URL("https://lexical.dev/docs/error"),s=new URLSearchParams;s.append("code",e);for(const e of t)s.append("v",e);throw n.search=s.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class n{_offsetMap;_firstNode;_blockOffsetSize;constructor(e,t,n=1){this._offsetMap=e,this._firstNode=t,this._blockOffsetSize=n}createSelectionFromOffsets(t,n,r){const l=this._firstNode;if(null===l)return null;let i=t,f=n,c=o(l,i,this._blockOffsetSize),a=o(l,f,this._blockOffsetSize);if(void 0!==r&&(i=s(i,c,r,this,this._blockOffsetSize),c=o(l,i,this._blockOffsetSize),f=s(f,a,r,this,this._blockOffsetSize),a=o(l,f,this._blockOffsetSize)),null===c||null===a)return null;let u=c.key,d=a.key;const p=e.$getNodeByKey(u),g=e.$getNodeByKey(d);if(null===p||null===g)return null;let h=0,y=0,_="element",x="element";if("text"===c.type){h=i-c.start,_="text";const t=p.getNextSibling();i!==f&&h===p.getTextContentSize()&&e.$isTextNode(t)&&(h=0,u=t.__key)}else"inline"===c.type&&(u=p.getParentOrThrow().getKey(),h=f>c.start?c.end:c.start);"text"===a.type?(y=f-a.start,x="text"):"inline"===a.type&&(d=g.getParentOrThrow().getKey(),y=f>a.start?a.end:a.start);const k=e.$createRangeSelection();return null===k?null:(k.anchor.set(u,h,_),k.focus.set(d,y,x),k)}getOffsetsFromSelection(e){const t=e.anchor,n=e.focus,s=this._offsetMap,o=t.offset,r=n.offset;let l=-1,i=-1;if("text"===t.type){const e=s.get(t.key);void 0!==e&&(l=e.start+o)}else{const e=t.getNode().getDescendantByIndex(o);if(null!==e){const t=s.get(e.getKey());if(void 0!==t){l=e.getIndexWithinParent()!==o?t.end:t.start}}}if("text"===n.type){const e=s.get(n.key);void 0!==e&&(i=e.start+n.offset)}else{const e=n.getNode().getDescendantByIndex(r);if(null!==e){const t=s.get(e.getKey());if(void 0!==t){i=e.getIndexWithinParent()!==r?t.end:t.start}}}return[l,i]}}function s(e,t,n,s,r){const l=n._offsetMap,i=s._offsetMap,f=new Set;let c=e,a=t;for(;null!==a;){const e=a.key,t=l.get(e),n=a.end-a.start;if(f.add(e),void 0===t)c+=n;else{const e=t.end-t.start;e!==n&&(c+=n-e)}const s=a.prev;if(null!==s){a=s;continue}let o=a.parent;for(;null!==o;){let e=o.prev;if(null!==e){const t=e.key,n=l.get(t),s=e.end-e.start;if(f.add(t),void 0===n)c+=s;else{const e=n.end-n.start;e!==s&&(c+=s-e)}e=e.prev}o=o.parent}break}const u=n._firstNode;if(null!==u){a=o(u,e,r);let t=!1;for(;null!==a;){if(!f.has(a.key)){t=!0;break}a=a.parent}if(!t)for(;null!==a;){const e=a.key;if(!f.has(e)){const t=i.get(e),n=a.end-a.start;if(void 0===t)c-=n;else{const e=t.end-t.start;n!==e&&(c+=e-n)}}a=a.prev}}return c}function o(e,t,n){let s=e;for(;null!==s;){if(t<s.end+("element"!==s.type||0===n?1:0)){const e=s.child;if(null!==e){s=e;continue}return s}const e=s.next;if(null===e)break;s=e}return null}function r(e,t,n,s,o,r){return{child:e,end:s,key:o,next:null,parent:r,prev:null,start:n,type:t}}function l(n,s,o,l,c,a){const u=l.get(s);void 0===u&&t(3);const d=n.offset;if(e.$isElementNode(u)){const e=f(u,l),t=0===e.length,p=t?null:i(n,e,null,l,c,a);n.prevIsBlock&&!t||(n.prevIsBlock=!0,n.offset+=a);const g=r(p,"element",d,d,s,o);null!==p&&(p.parent=g);const h=n.offset;return g.end=h,c.set(s,g),g}n.prevIsBlock=!1;const p=e.$isTextNode(u),g=p?u.__text.length:1,h=r(null,p?"text":"inline",d,n.offset+=g,s,o);return c.set(s,h),h}function i(e,t,n,s,o,r){let i=null,f=null;const c=t.length;for(let a=0;a<c;a++){const c=l(e,t[a],n,s,o,r);null===f?i=c:(c.prev=f,f.next=c),f=c}return i}function f(n,s){const o=[];let r=n.__first;for(;null!==r;){const n=null===s?e.$getNodeByKey(r):s.get(r);null==n&&t(174),o.push(r),r=n.__next}return o}const c=f;exports.$createChildrenArray=f,exports.$createOffsetView=function(e,t=1,s){const o=(s||e._pendingEditorState||e._editorState)._nodeMap,r=o.get("root"),l=new Map,c=i({offset:0,prevIsBlock:!1},f(r,o),null,o,l,t);return new n(l,c,t)},exports.OffsetView=n,exports.createChildrenArray=c;
9
+ "use strict";var e=require("lexical");class t{_offsetMap;_firstNode;_blockOffsetSize;constructor(e,t,n=1){this._offsetMap=e,this._firstNode=t,this._blockOffsetSize=n}createSelectionFromOffsets(t,o,r){const l=this._firstNode;if(null===l)return null;let i=t,f=o,c=s(l,i,this._blockOffsetSize),a=s(l,f,this._blockOffsetSize);if(void 0!==r&&(i=n(i,c,r,this,this._blockOffsetSize),c=s(l,i,this._blockOffsetSize),f=n(f,a,r,this,this._blockOffsetSize),a=s(l,f,this._blockOffsetSize)),null===c||null===a)return null;let u=c.key,d=a.key;const p=e.$getNodeByKey(u),g=e.$getNodeByKey(d);if(null===p||null===g)return null;let h=0,y=0,k="element",v="element";if("text"===c.type){h=i-c.start,k="text";const t=p.getNextSibling();i!==f&&h===p.getTextContentSize()&&e.$isTextNode(t)&&(h=0,u=t.__key)}else"inline"===c.type&&(u=p.getParentOrThrow().getKey(),h=f>c.start?c.end:c.start);"text"===a.type?(y=f-a.start,v="text"):"inline"===a.type&&(d=g.getParentOrThrow().getKey(),y=f>a.start?a.end:a.start);const x=e.$createRangeSelection();return null===x?null:(x.anchor.set(u,h,k),x.focus.set(d,y,v),x)}getOffsetsFromSelection(e){const t=e.anchor,n=e.focus,s=this._offsetMap,o=t.offset,r=n.offset;let l=-1,i=-1;if("text"===t.type){const e=s.get(t.key);void 0!==e&&(l=e.start+o)}else{const e=t.getNode().getDescendantByIndex(o);if(null!==e){const t=s.get(e.getKey());if(void 0!==t){l=e.getIndexWithinParent()!==o?t.end:t.start}}}if("text"===n.type){const e=s.get(n.key);void 0!==e&&(i=e.start+n.offset)}else{const e=n.getNode().getDescendantByIndex(r);if(null!==e){const t=s.get(e.getKey());if(void 0!==t){i=e.getIndexWithinParent()!==r?t.end:t.start}}}return[l,i]}}function n(e,t,n,o,r){const l=n._offsetMap,i=o._offsetMap,f=new Set;let c=e,a=t;for(;null!==a;){const e=a.key,t=l.get(e),n=a.end-a.start;if(f.add(e),void 0===t)c+=n;else{const e=t.end-t.start;e!==n&&(c+=n-e)}const s=a.prev;if(null!==s){a=s;continue}let o=a.parent;for(;null!==o;){let e=o.prev;if(null!==e){const t=e.key,n=l.get(t),s=e.end-e.start;if(f.add(t),void 0===n)c+=s;else{const e=n.end-n.start;e!==s&&(c+=s-e)}e=e.prev}o=o.parent}break}const u=n._firstNode;if(null!==u){a=s(u,e,r);let t=!1;for(;null!==a;){if(!f.has(a.key)){t=!0;break}a=a.parent}if(!t)for(;null!==a;){const e=a.key;if(!f.has(e)){const t=i.get(e),n=a.end-a.start;if(void 0===t)c-=n;else{const e=t.end-t.start;n!==e&&(c+=e-n)}}a=a.prev}}return c}function s(e,t,n){let s=e;for(;null!==s;){if(t<s.end+("element"!==s.type||0===n?1:0)){const e=s.child;if(null!==e){s=e;continue}return s}const e=s.next;if(null===e)break;s=e}return null}function o(e,t,n,s,o,r){return{child:e,end:s,key:o,next:null,parent:r,prev:null,start:n,type:t}}function r(t,n,s,r,f,c){const a=r.get(n);void 0===a&&function(e,...t){const n=new URL("https://lexical.dev/docs/error"),s=new URLSearchParams;s.append("code",e);for(const e of t)s.append("v",e);throw n.search=s.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(3);const u=t.offset;if(e.$isElementNode(a)){const e=i(a,r),d=0===e.length,p=d?null:l(t,e,null,r,f,c);t.prevIsBlock&&!d||(t.prevIsBlock=!0,t.offset+=c);const g=o(p,"element",u,u,n,s);null!==p&&(p.parent=g);const h=t.offset;return g.end=h,f.set(n,g),g}t.prevIsBlock=!1;const d=e.$isTextNode(a),p=d?a.__text.length:1,g=o(null,d?"text":"inline",u,t.offset+=p,n,s);return f.set(n,g),g}function l(e,t,n,s,o,l){let i=null,f=null;const c=t.length;for(let a=0;a<c;a++){const c=r(e,t[a],n,s,o,l);null===f?i=c:(c.prev=f,f.next=c),f=c}return i}const i=e.$createChildrenArray;exports.$createChildrenArray=i,exports.$createOffsetView=function(e,n=1,s){const o=(s||e._pendingEditorState||e._editorState)._nodeMap,r=o.get("root"),f=new Map,c=l({offset:0,prevIsBlock:!1},i(r,o),null,o,f,n);return new t(f,c,n)},exports.OffsetView=t;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{$getNodeByKey as t,$isTextNode as e,$createRangeSelection as n,$isElementNode as o}from"lexical";function s(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class l{_offsetMap;_firstNode;_blockOffsetSize;constructor(t,e,n=1){this._offsetMap=t,this._firstNode=e,this._blockOffsetSize=n}createSelectionFromOffsets(o,s,l){const f=this._firstNode;if(null===f)return null;let c=o,u=s,a=i(f,c,this._blockOffsetSize),d=i(f,u,this._blockOffsetSize);if(void 0!==l&&(c=r(c,a,l,this,this._blockOffsetSize),a=i(f,c,this._blockOffsetSize),u=r(u,d,l,this,this._blockOffsetSize),d=i(f,u,this._blockOffsetSize)),null===a||null===d)return null;let p=a.key,g=d.key;const h=t(p),_=t(g);if(null===h||null===_)return null;let k=0,v=0,y="element",x="element";if("text"===a.type){k=c-a.start,y="text";const t=h.getNextSibling();c!==u&&k===h.getTextContentSize()&&e(t)&&(k=0,p=t.__key)}else"inline"===a.type&&(p=h.getParentOrThrow().getKey(),k=u>a.start?a.end:a.start);"text"===d.type?(v=u-d.start,x="text"):"inline"===d.type&&(g=_.getParentOrThrow().getKey(),v=u>d.start?d.end:d.start);const S=n();return null===S?null:(S.anchor.set(p,k,y),S.focus.set(g,v,x),S)}getOffsetsFromSelection(t){const e=t.anchor,n=t.focus,o=this._offsetMap,s=e.offset,l=n.offset;let r=-1,i=-1;if("text"===e.type){const t=o.get(e.key);void 0!==t&&(r=t.start+s)}else{const t=e.getNode().getDescendantByIndex(s);if(null!==t){const e=o.get(t.getKey());if(void 0!==e){r=t.getIndexWithinParent()!==s?e.end:e.start}}}if("text"===n.type){const t=o.get(n.key);void 0!==t&&(i=t.start+n.offset)}else{const t=n.getNode().getDescendantByIndex(l);if(null!==t){const e=o.get(t.getKey());if(void 0!==e){i=t.getIndexWithinParent()!==l?e.end:e.start}}}return[r,i]}}function r(t,e,n,o,s){const l=n._offsetMap,r=o._offsetMap,f=new Set;let c=t,u=e;for(;null!==u;){const t=u.key,e=l.get(t),n=u.end-u.start;if(f.add(t),void 0===e)c+=n;else{const t=e.end-e.start;t!==n&&(c+=n-t)}const o=u.prev;if(null!==o){u=o;continue}let s=u.parent;for(;null!==s;){let t=s.prev;if(null!==t){const e=t.key,n=l.get(e),o=t.end-t.start;if(f.add(e),void 0===n)c+=o;else{const t=n.end-n.start;t!==o&&(c+=o-t)}t=t.prev}s=s.parent}break}const a=n._firstNode;if(null!==a){u=i(a,t,s);let e=!1;for(;null!==u;){if(!f.has(u.key)){e=!0;break}u=u.parent}if(!e)for(;null!==u;){const t=u.key;if(!f.has(t)){const e=r.get(t),n=u.end-u.start;if(void 0===e)c-=n;else{const t=e.end-e.start;n!==t&&(c+=t-n)}}u=u.prev}}return c}function i(t,e,n){let o=t;for(;null!==o;){if(e<o.end+("element"!==o.type||0===n?1:0)){const t=o.child;if(null!==t){o=t;continue}return o}const t=o.next;if(null===t)break;o=t}return null}function f(t,e,n,o,s,l){return{child:t,end:o,key:s,next:null,parent:l,prev:null,start:n,type:e}}function c(t,n,l,r,i,c){const d=r.get(n);void 0===d&&s(3);const p=t.offset;if(o(d)){const e=a(d,r),o=0===e.length,s=o?null:u(t,e,null,r,i,c);t.prevIsBlock&&!o||(t.prevIsBlock=!0,t.offset+=c);const g=f(s,"element",p,p,n,l);null!==s&&(s.parent=g);const h=t.offset;return g.end=h,i.set(n,g),g}t.prevIsBlock=!1;const g=e(d),h=g?d.__text.length:1,_=f(null,g?"text":"inline",p,t.offset+=h,n,l);return i.set(n,_),_}function u(t,e,n,o,s,l){let r=null,i=null;const f=e.length;for(let u=0;u<f;u++){const f=c(t,e[u],n,o,s,l);null===i?r=f:(f.prev=i,i.next=f),i=f}return r}function a(e,n){const o=[];let l=e.__first;for(;null!==l;){const e=null===n?t(l):n.get(l);null==e&&s(174),o.push(l),l=e.__next}return o}const d=a;function p(t,e=1,n){const o=(n||t._pendingEditorState||t._editorState)._nodeMap,s=o.get("root"),r=new Map,i=u({offset:0,prevIsBlock:!1},a(s,o),null,o,r,e);return new l(r,i,e)}export{a as $createChildrenArray,p as $createOffsetView,l as OffsetView,d as createChildrenArray};
9
+ import{$createChildrenArray as t,$getNodeByKey as e,$isTextNode as n,$createRangeSelection as o,$isElementNode as s}from"lexical";class l{_offsetMap;_firstNode;_blockOffsetSize;constructor(t,e,n=1){this._offsetMap=t,this._firstNode=e,this._blockOffsetSize=n}createSelectionFromOffsets(t,s,l){const f=this._firstNode;if(null===f)return null;let c=t,a=s,u=i(f,c,this._blockOffsetSize),d=i(f,a,this._blockOffsetSize);if(void 0!==l&&(c=r(c,u,l,this,this._blockOffsetSize),u=i(f,c,this._blockOffsetSize),a=r(a,d,l,this,this._blockOffsetSize),d=i(f,a,this._blockOffsetSize)),null===u||null===d)return null;let p=u.key,h=d.key;const g=e(p),k=e(h);if(null===g||null===k)return null;let y=0,v=0,_="element",x="element";if("text"===u.type){y=c-u.start,_="text";const t=g.getNextSibling();c!==a&&y===g.getTextContentSize()&&n(t)&&(y=0,p=t.__key)}else"inline"===u.type&&(p=g.getParentOrThrow().getKey(),y=a>u.start?u.end:u.start);"text"===d.type?(v=a-d.start,x="text"):"inline"===d.type&&(h=k.getParentOrThrow().getKey(),v=a>d.start?d.end:d.start);const S=o();return null===S?null:(S.anchor.set(p,y,_),S.focus.set(h,v,x),S)}getOffsetsFromSelection(t){const e=t.anchor,n=t.focus,o=this._offsetMap,s=e.offset,l=n.offset;let r=-1,i=-1;if("text"===e.type){const t=o.get(e.key);void 0!==t&&(r=t.start+s)}else{const t=e.getNode().getDescendantByIndex(s);if(null!==t){const e=o.get(t.getKey());if(void 0!==e){r=t.getIndexWithinParent()!==s?e.end:e.start}}}if("text"===n.type){const t=o.get(n.key);void 0!==t&&(i=t.start+n.offset)}else{const t=n.getNode().getDescendantByIndex(l);if(null!==t){const e=o.get(t.getKey());if(void 0!==e){i=t.getIndexWithinParent()!==l?e.end:e.start}}}return[r,i]}}function r(t,e,n,o,s){const l=n._offsetMap,r=o._offsetMap,f=new Set;let c=t,a=e;for(;null!==a;){const t=a.key,e=l.get(t),n=a.end-a.start;if(f.add(t),void 0===e)c+=n;else{const t=e.end-e.start;t!==n&&(c+=n-t)}const o=a.prev;if(null!==o){a=o;continue}let s=a.parent;for(;null!==s;){let t=s.prev;if(null!==t){const e=t.key,n=l.get(e),o=t.end-t.start;if(f.add(e),void 0===n)c+=o;else{const t=n.end-n.start;t!==o&&(c+=o-t)}t=t.prev}s=s.parent}break}const u=n._firstNode;if(null!==u){a=i(u,t,s);let e=!1;for(;null!==a;){if(!f.has(a.key)){e=!0;break}a=a.parent}if(!e)for(;null!==a;){const t=a.key;if(!f.has(t)){const e=r.get(t),n=a.end-a.start;if(void 0===e)c-=n;else{const t=e.end-e.start;n!==t&&(c+=t-n)}}a=a.prev}}return c}function i(t,e,n){let o=t;for(;null!==o;){if(e<o.end+("element"!==o.type||0===n?1:0)){const t=o.child;if(null!==t){o=t;continue}return o}const t=o.next;if(null===t)break;o=t}return null}function f(t,e,n,o,s,l){return{child:t,end:o,key:s,next:null,parent:l,prev:null,start:n,type:e}}function c(t,e,o,l,r,i){const c=l.get(e);void 0===c&&function(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(3);const d=t.offset;if(s(c)){const n=u(c,l),s=0===n.length,p=s?null:a(t,n,null,l,r,i);t.prevIsBlock&&!s||(t.prevIsBlock=!0,t.offset+=i);const h=f(p,"element",d,d,e,o);null!==p&&(p.parent=h);const g=t.offset;return h.end=g,r.set(e,h),h}t.prevIsBlock=!1;const p=n(c),h=p?c.__text.length:1,g=f(null,p?"text":"inline",d,t.offset+=h,e,o);return r.set(e,g),g}function a(t,e,n,o,s,l){let r=null,i=null;const f=e.length;for(let a=0;a<f;a++){const f=c(t,e[a],n,o,s,l);null===i?r=f:(f.prev=i,i.next=f),i=f}return r}const u=t;function d(t,e=1,n){const o=(n||t._pendingEditorState||t._editorState)._nodeMap,s=o.get("root"),r=new Map,i=a({offset:0,prevIsBlock:!1},u(s,o),null,o,r,e);return new l(r,i,e)}export{u as $createChildrenArray,d as $createOffsetView,l as OffsetView};
package/index.d.ts CHANGED
@@ -5,7 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { EditorState, ElementNode, LexicalEditor, NodeKey, NodeMap, RangeSelection } from 'lexical';
8
+ import type { EditorState, LexicalEditor, NodeKey, RangeSelection } from 'lexical';
9
+ import { $createChildrenArray as $createChildrenArray_ } from 'lexical';
9
10
  type OffsetElementNode = {
10
11
  child: null | OffsetNode;
11
12
  end: number;
@@ -38,6 +39,7 @@ type OffsetInlineNode = {
38
39
  };
39
40
  type OffsetNode = OffsetElementNode | OffsetTextNode | OffsetInlineNode;
40
41
  type OffsetMap = Map<NodeKey, OffsetNode>;
42
+ /** @deprecated OffsetView has never worked correctly and will be removed */
41
43
  export declare class OffsetView {
42
44
  _offsetMap: OffsetMap;
43
45
  _firstNode: null | OffsetNode;
@@ -46,8 +48,8 @@ export declare class OffsetView {
46
48
  createSelectionFromOffsets(originalStart: number, originalEnd: number, diffOffsetView?: OffsetView): null | RangeSelection;
47
49
  getOffsetsFromSelection(selection: RangeSelection): [number, number];
48
50
  }
49
- export declare function $createChildrenArray(element: ElementNode, nodeMap: null | NodeMap): Array<NodeKey>;
50
- /** @deprecated renamed to {@link $createChildrenArray} by @lexical/eslint-plugin rules-of-lexical */
51
- export declare const createChildrenArray: typeof $createChildrenArray;
51
+ /** @deprecated moved to `lexical` */
52
+ export declare const $createChildrenArray: typeof $createChildrenArray_;
53
+ /** @deprecated OffsetView has never worked correctly and will be removed */
52
54
  export declare function $createOffsetView(editor: LexicalEditor, blockOffsetSize?: number, editorState?: EditorState | null): OffsetView;
53
55
  export {};
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "offset"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.43.0",
11
+ "version": "0.43.1-nightly.20260413.0",
12
12
  "main": "LexicalOffset.js",
13
13
  "types": "index.d.ts",
14
14
  "repository": {
@@ -36,6 +36,6 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "lexical": "0.43.0"
39
+ "lexical": "0.43.1-nightly.20260413.0"
40
40
  }
41
41
  }