@react-fabric/lexical 1.0.0-beta.57 → 1.0.0-beta.58

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.
Files changed (48) hide show
  1. package/css/_lexical.css +4 -0
  2. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +33 -1
  3. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +11 -11
  4. package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +525 -194
  5. package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +26 -23
  6. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +3 -3
  7. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
  8. package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +95 -38
  9. package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +11 -10
  10. package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +387 -124
  11. package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +22 -18
  12. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +54 -29
  13. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +10 -10
  14. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +107 -8
  15. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +4 -0
  16. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +23 -20
  17. package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +420 -137
  18. package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +50 -45
  19. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +61 -65
  20. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +2 -0
  21. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +47 -46
  22. package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +3 -1
  23. package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +20 -10
  24. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +34 -2
  25. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +3 -3
  26. package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +524 -196
  27. package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +3 -3
  28. package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +4 -4
  29. package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
  30. package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +96 -40
  31. package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +3 -3
  32. package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +387 -127
  33. package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +5 -4
  34. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +56 -31
  35. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +4 -4
  36. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +106 -10
  37. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +3 -1
  38. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +3 -3
  39. package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +417 -139
  40. package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +3 -3
  41. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +62 -67
  42. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +2 -1
  43. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +3 -3
  44. package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +3 -1
  45. package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +20 -10
  46. package/package.json +12 -12
  47. package/src/hooks/useFormatWatcher.ts +3 -1
  48. package/src/plugins/ToolbarPlugin.tsx +5 -10
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import { isHTMLElement, $getRoot, $isElementNode, $getChildCaret, $getSiblingCaret, $getAdjacentChildCaret, $getChildCaretOrSelf, makeStepwiseIterator, $isChildCaret, $cloneWithProperties, $setSelection, $getSelection, $getPreviousSelection, $isRangeSelection, $isRootOrShadowRoot, $getChildCaretAtIndex, $isTextNode, $splitNode, $createParagraphNode, $isSiblingCaret, $rewindSiblingCaret, $getState, $setState, getDOMTextNode } from 'lexical';
3
+ import { isHTMLElement, $getRoot, $isElementNode, $getChildCaret, $getSiblingCaret, $getAdjacentChildCaret, $getChildCaretOrSelf, makeStepwiseIterator, $isChildCaret, $cloneWithProperties, $setSelection, $getSelection, $getPreviousSelection, $isRangeSelection, $caretFromPoint, $createParagraphNode, $normalizeCaret, $setSelectionFromCaretRange, $getCollapsedCaretRange, $getCaretInDirection, $splitAtPointCaretNext, $isTextPointCaret, $isSiblingCaret, $rewindSiblingCaret, $getState, $setState, getDOMTextNode } from 'lexical';
4
4
  export { $splitNode, isBlockDomNode, isHTMLAnchorElement, isHTMLElement, isInlineDomNode } from 'lexical';
5
5
  import { createRectsFromDOMRange } from '../selection/LexicalSelection.js';
6
6
 
@@ -12,6 +12,6 @@ import { createRectsFromDOMRange } from '../selection/LexicalSelection.js';
12
12
  *
13
13
  */
14
14
 
15
- function L(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.`)}const N="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,P=N&&"documentMode"in document?document.documentMode:null,b=N&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),T=N&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),M=!(!N||!("InputEvent"in window)||P)&&"getTargetRanges"in new window.InputEvent("input"),R=N&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),B=N&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,_=N&&/Android/.test(navigator.userAgent),O=N&&/^(?=.*Chrome).*/i.test(navigator.userAgent),k=N&&_&&O,K=N&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!O;function H(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function $(...t){return ()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0;}}function D(t){return `${t}px`}const I={attributes:!0,characterData:!0,childList:!0,subtree:!0};function j(e,n,o){let r=null,i=null,l=null,s=[];const u=document.createElement("div");function c(){null===r&&L(182),null===i&&L(183);const{left:t,top:l}=i.getBoundingClientRect(),c=createRectsFromDOMRange(e,n);var f,a;u.isConnected||(a=u,(f=i).insertBefore(a,f.firstChild));let d=!1;for(let e=0;e<c.length;e++){const n=c[e],o=s[e]||document.createElement("div"),r=o.style;"absolute"!==r.position&&(r.position="absolute",d=!0);const i=D(n.left-t);r.left!==i&&(r.left=i,d=!0);const f=D(n.top-l);r.top!==f&&(o.style.top=f,d=!0);const a=D(n.width);r.width!==a&&(o.style.width=a,d=!0);const g=D(n.height);r.height!==g&&(o.style.height=g,d=!0),o.parentNode!==u&&(u.append(o),d=!0),s[e]=o;}for(;s.length>c.length;)s.pop();d&&o(s);}function f(){i=null,r=null,null!==l&&l.disconnect(),l=null,u.remove();for(const t of s)t.remove();s=[];}u.style.position="relative";const a=e.registerRootListener((function n(){const o=e.getRootElement();if(null===o)return f();const s=o.parentElement;if(!isHTMLElement(s))return f();f(),r=o,i=s,l=new MutationObserver((t=>{const o=e.getRootElement(),l=o&&o.parentElement;if(o!==r||l!==i)return n();for(const e of t)if(!u.contains(e.target))return c()})),l.observe(s,I),c();}));return ()=>{a(),f();}}function U(t,e,n){if("text"!==t.type&&$isElementNode(e)){const o=e.getDOMSlot(n);return [o.element,o.getFirstChildOffset()+t.offset]}return [getDOMTextNode(n)||n,t.offset]}function z(t,o){let r=null,i=null,l=null,s=null,u=null,c=null,f=()=>{};function a(a){a.read((()=>{const a=$getSelection();if(!$isRangeSelection(a))return r=null,l=null,s=null,c=null,f(),void(f=()=>{});const{anchor:d,focus:g}=a,p=d.getNode(),m=p.getKey(),h=d.offset,v=g.getNode(),y=v.getKey(),w=g.offset,x=t.getElementByKey(m),E=t.getElementByKey(y),S=null===r||x!==i||h!==l||m!==r.getKey(),A=null===s||E!==u||w!==c||y!==s.getKey();if((S||A)&&null!==x&&null!==E){const e=function(t,e,n,o,r,i,l){const s=(t._window?t._window.document:document).createRange();return i.isBefore(n)?(s.setStart(...U(r,i,l)),s.setEnd(...U(e,n,o))):(s.setStart(...U(e,n,o)),s.setEnd(...U(r,i,l))),s}(t,d,p,x,g,v,E);f(),f=j(t,e,(t=>{if(void 0===o)for(const e of t){const t=e.style;"Highlight"!==t.background&&(t.background="Highlight"),"HighlightText"!==t.color&&(t.color="HighlightText"),t.marginTop!==D(-1.5)&&(t.marginTop=D(-1.5)),t.paddingTop!==D(4)&&(t.paddingTop=D(4)),t.paddingBottom!==D(0)&&(t.paddingBottom=D(0));}else o(t);}));}r=p,i=x,l=h,s=v,u=E,c=w;}));}return a(t.getEditorState()),$(t.registerUpdateListener((({editorState:t})=>a(t))),(()=>{f();}))}function F(t){let e=null;const n=()=>{const n=getSelection(),o=n&&n.anchorNode,r=t.getRootElement();null!==o&&null!==r&&r.contains(o)?null!==e&&(e(),e=null):null===e&&(e=z(t));};return document.addEventListener("selectionchange",n),()=>{null!==e&&e(),document.removeEventListener("selectionchange",n);}}const W=M,V=N,G=_,q=k,J=b,Q=K,X=O,Y=T,Z=B,tt=R;function et(t,...e){const n=H(...e);n.length>0&&t.classList.add(...n);}function nt(t,...e){const n=H(...e);n.length>0&&t.classList.remove(...n);}function ot(t,e){for(const n of e)if(t.type.startsWith(n))return !0;return !1}function rt(t,e){const n=t[Symbol.iterator]();return new Promise(((t,o)=>{const r=[],i=()=>{const{done:l,value:s}=n.next();if(l)return t(r);const u=new FileReader;u.addEventListener("error",o),u.addEventListener("load",(()=>{const t=u.result;"string"==typeof t&&r.push({file:s,result:t}),i();})),ot(s,e)?u.readAsDataURL(s):i();};i();}))}function it(t,e){return Array.from(ut(t,e))}function lt(t){return t?t.getAdjacentCaret():null}function st(t,e){return Array.from(gt(t,e))}function ut(t,e){return ct("next",t,e)}function ct(t,e,n){const r=$getRoot(),d=e||r,g=$isElementNode(d)?$getChildCaret(d,t):$getSiblingCaret(d,t),p=at(d),m=n?$getAdjacentChildCaret($getChildCaretOrSelf($getSiblingCaret(n,t))):function(t,e){const n=Ot($getSiblingCaret(t,e));return n&&n[0]}(d,t);let h=p;return makeStepwiseIterator({hasNext:t=>null!==t,initial:g,map:t=>({depth:h,node:t.origin}),step:t=>{if(t.isSameNodeCaret(m))return null;$isChildCaret(t)&&h++;const e=Ot(t);return !e||e[0].isSameNodeCaret(m)?null:(h+=e[1],e[0])}})}function ft(t){const e=Ot($getSiblingCaret(t,"next"));return e&&[e[0].origin,e[1]]}function at(t){let e=-1;for(let n=t;null!==n;n=n.getParent())e++;return e}function dt(t){const e=Ot($getChildCaretOrSelf($getSiblingCaret(t,"previous")),"root");return e&&e[0].origin}function gt(t,e){return ct("previous",t,e)}function pt(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent();}return null}function mt(t){const e=ht(t,(t=>$isElementNode(t)&&!t.isInline()));return $isElementNode(e)||L(4,t.__key),e}const ht=(t,e)=>{let n=t;for(;n!==$getRoot()&&null!=n;){if(e(n))return n;n=n.getParent();}return null};function vt(t,e,n,o){const r=t=>t instanceof e;return t.registerNodeTransform(e,(t=>{const e=(t=>{const e=t.getChildren();for(let t=0;t<e.length;t++){const n=e[t];if(r(n))return null}let n=t,o=t;for(;null!==n;)if(o=n,n=n.getParent(),r(n))return {child:o,parent:n};return null})(t);if(null!==e){const{child:r,parent:i}=e;if(r.is(t)){o(i,t);const e=r.getNextSiblings(),l=e.length;if(i.insertAfter(r),0!==l){const t=n(i);r.insertAfter(t);for(let n=0;n<l;n++)t.append(e[n]);}i.canBeEmpty()||0!==i.getChildrenSize()||i.remove();}}}))}function yt(t,e){const n=new Map,o=t._pendingEditorState;for(const[t,o]of e._nodeMap)n.set(t,$cloneWithProperties(o));o&&(o._nodeMap=n),t._dirtyType=2;const r=e._selection;$setSelection(null===r?null:r.clone());}function wt(t){const o=$getSelection()||$getPreviousSelection();if($isRangeSelection(o)){const{focus:e}=o,n=e.getNode(),r=e.offset;if($isRootOrShadowRoot(n))$getChildCaretAtIndex(n,r,"next").insert(t),t.selectNext();else {let e,o;$isTextNode(n)?(e=n.getParentOrThrow(),o=n.getIndexWithinParent(),r>0&&(o+=1,n.splitText(r))):(e=n,o=r);const[,i]=$splitNode(e,o);i.insertBefore(t),i.selectStart();}}else {if(null!=o){const e=o.getNodes();e[e.length-1].getTopLevelElementOrThrow().insertAfter(t);}else $getRoot().append(t);const e=$createParagraphNode();t.insertAfter(e),e.select();}return t.getLatest()}function xt(t,e){const n=e();return t.replace(n),n.append(t),n}function Et(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function St(t,e){const n=[];for(let o=0;o<t.length;o++){const r=e(t[o]);null!==r&&n.push(r);}return n}function At(t,e){$getChildCaret(t,"next").insert(e);}let Ct=!(Y||!V)&&void 0;function Lt(t){let e=1;if(function(){if(void 0===Ct){const t=document.createElement("div");t.style.cssText="position: absolute; opacity: 0; width: 100px; left: -1000px;",document.body.appendChild(t);const e=t.getBoundingClientRect();t.style.setProperty("zoom","2"),Ct=t.getBoundingClientRect().width===e.width,document.body.removeChild(t);}return Ct}())for(;t;)e*=Number(window.getComputedStyle(t).getPropertyValue("zoom")),t=t.parentElement;return e}function Nt(t){return null!==t._parentEditor}function Pt(t,e){return bt(t,e,null)}function bt(t,e,n){let r=!1;for(const i of Rt(t))e(i)?null!==n&&n(i):(r=!0,$isElementNode(i)&&bt(i,e,n||(t=>i.insertAfter(t))),i.remove());return r}function Tt(t,e){const n=[],r=Array.from(t).reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(e(t))n.push(t);else if($isElementNode(t))for(const e of Rt(t))r.push(e);return n}function Mt(t){return Bt($getChildCaret(t,"next"))}function Rt(t){return Bt($getChildCaret(t,"previous"))}function Bt(t){return makeStepwiseIterator({hasNext:$isSiblingCaret,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function _t(t){$rewindSiblingCaret($getSiblingCaret(t,"next")).splice(1,t.getChildren());}function Ot(t,e="root"){let n=0,o=t,r=$getAdjacentChildCaret(o);for(;null===r;){if(n--,r=o.getParentCaret(e),!r)return null;o=r,r=$getAdjacentChildCaret(o);}return r&&[r,n]}function kt(t){const e=e=>$getState(e,t),n=(e,n)=>$setState(e,t,n);return {$get:e,$set:n,accessors:[e,n],makeGetterMethod:()=>function(){return e(this)},makeSetterMethod:()=>function(t){return n(this,t)},stateConfig:t}}
15
+ function N(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.`)}const M="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,R=M&&"documentMode"in document?document.documentMode:null,T=M&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),B=M&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),_=!(!M||!("InputEvent"in window)||R)&&"getTargetRanges"in new window.InputEvent("input"),k=M&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),K=M&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,H=M&&/Android/.test(navigator.userAgent),O=M&&/^(?=.*Chrome).*/i.test(navigator.userAgent),$=M&&H&&O,D=M&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!O;function I(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function j(...t){return ()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0;}}function F(t){return `${t}px`}const U={attributes:!0,characterData:!0,childList:!0,subtree:!0};function z(e,n,o){let r=null,i=null,l=null,u=[];const s=document.createElement("div");function c(){null===r&&N(182),null===i&&N(183);const{left:t,top:l}=i.getBoundingClientRect(),c=createRectsFromDOMRange(e,n);var f,a;s.isConnected||(a=s,(f=i).insertBefore(a,f.firstChild));let d=!1;for(let e=0;e<c.length;e++){const n=c[e],o=u[e]||document.createElement("div"),r=o.style;"absolute"!==r.position&&(r.position="absolute",d=!0);const i=F(n.left-t);r.left!==i&&(r.left=i,d=!0);const f=F(n.top-l);r.top!==f&&(o.style.top=f,d=!0);const a=F(n.width);r.width!==a&&(o.style.width=a,d=!0);const g=F(n.height);r.height!==g&&(o.style.height=g,d=!0),o.parentNode!==s&&(s.append(o),d=!0),u[e]=o;}for(;u.length>c.length;)u.pop();d&&o(u);}function f(){i=null,r=null,null!==l&&l.disconnect(),l=null,s.remove();for(const t of u)t.remove();u=[];}s.style.position="relative";const a=e.registerRootListener((function n(){const o=e.getRootElement();if(null===o)return f();const u=o.parentElement;if(!isHTMLElement(u))return f();f(),r=o,i=u,l=new MutationObserver((t=>{const o=e.getRootElement(),l=o&&o.parentElement;if(o!==r||l!==i)return n();for(const e of t)if(!s.contains(e.target))return c()})),l.observe(u,U),c();}));return ()=>{a(),f();}}function V(t,e,n){if("text"!==t.type&&$isElementNode(e)){const o=e.getDOMSlot(n);return [o.element,o.getFirstChildOffset()+t.offset]}return [getDOMTextNode(n)||n,t.offset]}function W(t,o){let r=null,i=null,l=null,u=null,s=null,c=null,f=()=>{};function a(a){a.read((()=>{const a=$getSelection();if(!$isRangeSelection(a))return r=null,l=null,u=null,c=null,f(),void(f=()=>{});const[d,g]=function(t){const e=t.getStartEndPoints();return t.isBackward()?[e[1],e[0]]:e}(a),p=d.getNode(),m=p.getKey(),h=d.offset,v=g.getNode(),y=v.getKey(),w=g.offset,x=t.getElementByKey(m),E=t.getElementByKey(y),S=null===r||x!==i||h!==l||m!==r.getKey(),A=null===u||E!==s||w!==c||y!==u.getKey();if((S||A)&&null!==x&&null!==E){const e=function(t,e,n,o,r,i,l){const u=(t._window?t._window.document:document).createRange();return u.setStart(...V(e,n,o)),u.setEnd(...V(r,i,l)),u}(t,d,p,x,g,v,E);f(),f=z(t,e,(t=>{if(void 0===o)for(const e of t){const t=e.style;"Highlight"!==t.background&&(t.background="Highlight"),"HighlightText"!==t.color&&(t.color="HighlightText"),t.marginTop!==F(-1.5)&&(t.marginTop=F(-1.5)),t.paddingTop!==F(4)&&(t.paddingTop=F(4)),t.paddingBottom!==F(0)&&(t.paddingBottom=F(0));}else o(t);}));}r=p,i=x,l=h,u=v,s=E,c=w;}));}return a(t.getEditorState()),j(t.registerUpdateListener((({editorState:t})=>a(t))),(()=>{f();}))}function G(t){let e=null;const n=()=>{const n=getSelection(),o=n&&n.anchorNode,r=t.getRootElement();null!==o&&null!==r&&r.contains(o)?null!==e&&(e(),e=null):null===e&&(e=W(t));};return document.addEventListener("selectionchange",n),()=>{null!==e&&e(),document.removeEventListener("selectionchange",n);}}const q=_,J=M,Q=H,X=$,Y=T,Z=D,tt=O,et=B,nt=K,ot=k;function rt(t,...e){const n=I(...e);n.length>0&&t.classList.add(...n);}function it(t,...e){const n=I(...e);n.length>0&&t.classList.remove(...n);}function lt(t,e){for(const n of e)if(t.type.startsWith(n))return !0;return !1}function ut(t,e){const n=t[Symbol.iterator]();return new Promise(((t,o)=>{const r=[],i=()=>{const{done:l,value:u}=n.next();if(l)return t(r);const s=new FileReader;s.addEventListener("error",o),s.addEventListener("load",(()=>{const t=s.result;"string"==typeof t&&r.push({file:u,result:t}),i();})),lt(u,e)?s.readAsDataURL(u):i();};i();}))}function st(t,e){return Array.from(at(t,e))}function ct(t){return t?t.getAdjacentCaret():null}function ft(t,e){return Array.from(ht(t,e))}function at(t,e){return dt("next",t,e)}function dt(t,e,n){const r=$getRoot(),d=e||r,g=$isElementNode(d)?$getChildCaret(d,t):$getSiblingCaret(d,t),p=pt(d),m=n?$getAdjacentChildCaret($getChildCaretOrSelf($getSiblingCaret(n,t))):function(t,e){const n=$t($getSiblingCaret(t,e));return n&&n[0]}(d,t);let h=p;return makeStepwiseIterator({hasNext:t=>null!==t,initial:g,map:t=>({depth:h,node:t.origin}),step:t=>{if(t.isSameNodeCaret(m))return null;$isChildCaret(t)&&h++;const e=$t(t);return !e||e[0].isSameNodeCaret(m)?null:(h+=e[1],e[0])}})}function gt(t){const e=$t($getSiblingCaret(t,"next"));return e&&[e[0].origin,e[1]]}function pt(t){let e=-1;for(let n=t;null!==n;n=n.getParent())e++;return e}function mt(t){const e=$t($getChildCaretOrSelf($getSiblingCaret(t,"previous")),"root");return e&&e[0].origin}function ht(t,e){return dt("previous",t,e)}function vt(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent();}return null}function yt(t){const e=wt(t,(t=>$isElementNode(t)&&!t.isInline()));return $isElementNode(e)||N(4,t.__key),e}const wt=(t,e)=>{let n=t;for(;n!==$getRoot()&&null!=n;){if(e(n))return n;n=n.getParent();}return null};function xt(t,e,n,o){const r=t=>t instanceof e;return t.registerNodeTransform(e,(t=>{const e=(t=>{const e=t.getChildren();for(let t=0;t<e.length;t++){const n=e[t];if(r(n))return null}let n=t,o=t;for(;null!==n;)if(o=n,n=n.getParent(),r(n))return {child:o,parent:n};return null})(t);if(null!==e){const{child:r,parent:i}=e;if(r.is(t)){o(i,t);const e=r.getNextSiblings(),l=e.length;if(i.insertAfter(r),0!==l){const t=n(i);r.insertAfter(t);for(let n=0;n<l;n++)t.append(e[n]);}i.canBeEmpty()||0!==i.getChildrenSize()||i.remove();}}}))}function Et(t,e){const n=new Map,o=t._pendingEditorState;for(const[t,o]of e._nodeMap)n.set(t,$cloneWithProperties(o));o&&(o._nodeMap=n),t._dirtyType=2;const r=e._selection;$setSelection(null===r?null:r.clone());}function St(t){const o=$getSelection()||$getPreviousSelection();let r;if($isRangeSelection(o))r=$caretFromPoint(o.focus,"next");else {if(null!=o){const t=o.getNodes(),e=t[t.length-1];e&&(r=$getSiblingCaret(e,"next"));}r=r||$getChildCaret($getRoot(),"previous").getFlipped().insert($createParagraphNode());}const c=At(t,r),f=$getAdjacentChildCaret(c),d=$isChildCaret(f)?$normalizeCaret(f):c;return $setSelectionFromCaretRange($getCollapsedCaretRange(d)),t.getLatest()}function At(t,e,n){let o=$getCaretInDirection(e,"next");for(let t=o;t;t=$splitAtPointCaretNext(t,n))o=t;return $isTextPointCaret(o)&&N(283),o.insert(t.isInline()?$createParagraphNode().append(t):t),$getCaretInDirection($getSiblingCaret(t.getLatest(),"next"),e.direction)}function Ct(t,e){const n=e();return t.replace(n),n.append(t),n}function Lt(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function Pt(t,e){const n=[];for(let o=0;o<t.length;o++){const r=e(t[o]);null!==r&&n.push(r);}return n}function bt(t,e){$getChildCaret(t,"next").insert(e);}let Nt=!(et||!J)&&void 0;function Mt(t){let e=1;if(function(){if(void 0===Nt){const t=document.createElement("div");t.style.cssText="position: absolute; opacity: 0; width: 100px; left: -1000px;",document.body.appendChild(t);const e=t.getBoundingClientRect();t.style.setProperty("zoom","2"),Nt=t.getBoundingClientRect().width===e.width,document.body.removeChild(t);}return Nt}())for(;t;)e*=Number(window.getComputedStyle(t).getPropertyValue("zoom")),t=t.parentElement;return e}function Rt(t){return null!==t._parentEditor}function Tt(t,e){return Bt(t,e,null)}function Bt(t,e,n){let r=!1;for(const i of Kt(t))e(i)?null!==n&&n(i):(r=!0,$isElementNode(i)&&Bt(i,e,n||(t=>i.insertAfter(t))),i.remove());return r}function _t(t,e){const n=[],r=Array.from(t).reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(e(t))n.push(t);else if($isElementNode(t))for(const e of Kt(t))r.push(e);return n}function kt(t){return Ht($getChildCaret(t,"next"))}function Kt(t){return Ht($getChildCaret(t,"previous"))}function Ht(t){return makeStepwiseIterator({hasNext:$isSiblingCaret,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function Ot(t){$rewindSiblingCaret($getSiblingCaret(t,"next")).splice(1,t.getChildren());}function $t(t,e="root"){let n=0,o=t,r=$getAdjacentChildCaret(o);for(;null===r;){if(n--,r=o.getParentCaret(e),!r)return null;o=r,r=$getAdjacentChildCaret(o);}return r&&[r,n]}function Dt(t){const e=e=>$getState(e,t),n=(e,n)=>$setState(e,t,n);return {$get:e,$set:n,accessors:[e,n],makeGetterMethod:()=>function(){return e(this)},makeSetterMethod:()=>function(t){return n(this,t)},stateConfig:t}}
16
16
 
17
- export { Tt as $descendantsMatching, it as $dfs, ut as $dfsIterator, St as $filter, ht as $findMatchingParent, Mt as $firstToLastIterator, lt as $getAdjacentCaret, Ot as $getAdjacentSiblingOrParentSiblingCaret, at as $getDepth, mt as $getNearestBlockElementAncestorOrThrow, pt as $getNearestNodeOfType, dt as $getNextRightPreorderNode, ft as $getNextSiblingOrParentSibling, At as $insertFirst, wt as $insertNodeToNearestRoot, Nt as $isEditorIsNestedEditor, Rt as $lastToFirstIterator, yt as $restoreEditorState, st as $reverseDfs, gt as $reverseDfsIterator, Pt as $unwrapAndFilterDescendants, _t as $unwrapNode, xt as $wrapNodeInElement, W as CAN_USE_BEFORE_INPUT, V as CAN_USE_DOM, G as IS_ANDROID, q as IS_ANDROID_CHROME, J as IS_APPLE, Q as IS_APPLE_WEBKIT, X as IS_CHROME, Y as IS_FIREFOX, Z as IS_IOS, tt as IS_SAFARI, et as addClassNamesToElement, Lt as calculateZoomLevel, ot as isMimeType, kt as makeStateWrapper, z as markSelection, rt as mediaFileReader, $ as mergeRegister, Et as objectKlassEquals, j as positionNodeOnRange, vt as registerNestedElementResolver, nt as removeClassNamesFromElement, F as selectionAlwaysOnDisplay };
17
+ export { _t as $descendantsMatching, st as $dfs, at as $dfsIterator, Pt as $filter, wt as $findMatchingParent, kt as $firstToLastIterator, ct as $getAdjacentCaret, $t as $getAdjacentSiblingOrParentSiblingCaret, pt as $getDepth, yt as $getNearestBlockElementAncestorOrThrow, vt as $getNearestNodeOfType, mt as $getNextRightPreorderNode, gt as $getNextSiblingOrParentSibling, bt as $insertFirst, St as $insertNodeToNearestRoot, At as $insertNodeToNearestRootAtCaret, Rt as $isEditorIsNestedEditor, Kt as $lastToFirstIterator, Et as $restoreEditorState, ft as $reverseDfs, ht as $reverseDfsIterator, Tt as $unwrapAndFilterDescendants, Ot as $unwrapNode, Ct as $wrapNodeInElement, q as CAN_USE_BEFORE_INPUT, J as CAN_USE_DOM, Q as IS_ANDROID, X as IS_ANDROID_CHROME, Y as IS_APPLE, Z as IS_APPLE_WEBKIT, tt as IS_CHROME, et as IS_FIREFOX, nt as IS_IOS, ot as IS_SAFARI, rt as addClassNamesToElement, Mt as calculateZoomLevel, lt as isMimeType, Dt as makeStateWrapper, W as markSelection, ut as mediaFileReader, j as mergeRegister, Lt as objectKlassEquals, z as positionNodeOnRange, xt as registerNestedElementResolver, it as removeClassNamesFromElement, G as selectionAlwaysOnDisplay };
@@ -160,7 +160,9 @@ var useFormatWatcher = function useFormatWatcher() {
160
160
  setIsSubscript(selection.hasFormat("subscript"));
161
161
  setIsSuperscript(selection.hasFormat("superscript"));
162
162
  setIsCode(selection.hasFormat("code"));
163
- setIsRTL($isParentElementRTL(selection));
163
+ editor.read(function () {
164
+ setIsRTL($isParentElementRTL(selection));
165
+ });
164
166
 
165
167
  // Update links
166
168
  var node = getSelectedNode(selection);
@@ -135,9 +135,11 @@ var ToolbarPlugin = function ToolbarPlugin() {
135
135
  variant: "link",
136
136
  children: [/*#__PURE__*/jsx(ButtonWrapper, {
137
137
  value: "start",
138
- rtlFlip: true,
139
138
  label: t("tool.alignStart"),
140
- icon: CoreIcons.alignLeft,
139
+ icon: {
140
+ icon: CoreIcons.alignLeft,
141
+ rtlFlip: true
142
+ },
141
143
  onClick: function onClick() {
142
144
  return watch.activeEditor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "start");
143
145
  }
@@ -150,33 +152,41 @@ var ToolbarPlugin = function ToolbarPlugin() {
150
152
  }
151
153
  }), /*#__PURE__*/jsx(ButtonWrapper, {
152
154
  value: "end",
153
- rtlFlip: true,
154
155
  label: t("tool.alignEnd"),
155
- icon: CoreIcons.alignRight,
156
+ icon: {
157
+ icon: CoreIcons.alignRight,
158
+ rtlFlip: true
159
+ },
156
160
  onClick: function onClick() {
157
161
  return watch.activeEditor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "end");
158
162
  }
159
163
  }), /*#__PURE__*/jsx(ButtonWrapper, {
160
164
  value: "justify",
161
- rtlFlip: true,
162
165
  label: t("tool.alignJustify"),
163
- icon: CoreIcons.alignJustify,
166
+ icon: {
167
+ icon: CoreIcons.alignJustify,
168
+ rtlFlip: true
169
+ },
164
170
  onClick: function onClick() {
165
171
  return watch.activeEditor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "justify");
166
172
  }
167
173
  }), /*#__PURE__*/jsx(ButtonWrapper, {
168
174
  value: "justify",
169
- rtlFlip: true,
170
175
  label: t("tool.indentOut"),
171
- icon: CoreIcons.formatIndentDecrease,
176
+ icon: {
177
+ icon: CoreIcons.formatIndentDecrease,
178
+ rtlFlip: true
179
+ },
172
180
  onClick: function onClick() {
173
181
  return watch.outdent();
174
182
  }
175
183
  }), /*#__PURE__*/jsx(ButtonWrapper, {
176
184
  value: "justify",
177
- rtlFlip: true,
178
185
  label: t("tool.identIn"),
179
- icon: CoreIcons.formatIndentIncrease,
186
+ icon: {
187
+ icon: CoreIcons.formatIndentIncrease,
188
+ rtlFlip: true
189
+ },
180
190
  onClick: function onClick() {
181
191
  return watch.indent();
182
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/lexical",
3
- "version": "1.0.0-beta.57",
3
+ "version": "1.0.0-beta.58",
4
4
  "description": "RUF: Lexical editor",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -35,22 +35,22 @@
35
35
  "watch": "npm-run-all -p watch:rollup watch:dts"
36
36
  },
37
37
  "dependencies": {
38
- "@lexical/react": "^0.27.1",
39
- "@react-fabric/core": "^1.0.0-beta.57",
40
- "@react-fabric/form": "^1.0.0-beta.57",
41
- "@react-fabric/utilities": "^1.0.0-beta.52",
42
- "classnames": "^2.5.1",
43
- "lexical": "^0.27.1"
38
+ "@lexical/react": "~0.35.0",
39
+ "@react-fabric/core": "^1.0.0-beta.58",
40
+ "@react-fabric/form": "^1.0.0-beta.58",
41
+ "@react-fabric/utilities": "^1.0.0-beta.58",
42
+ "classnames": "~2.5.1",
43
+ "lexical": "~0.35.0"
44
44
  },
45
45
  "peerDependencies": {
46
- "i18next": "^25.2.1",
47
- "react": "^19.0.0",
48
- "react-dom": "^19.0.0",
49
- "react-i18next": "^15.5.2"
46
+ "i18next": "~25.6.0",
47
+ "react": "~19.2.0",
48
+ "react-dom": "~19.2.0",
49
+ "react-i18next": "~16.2.1"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=18.12.0",
53
53
  "npm": ">=8.19.0"
54
54
  },
55
- "gitHead": "9b596a0a8d6cecaa8479f80c495b64fb42ce739f"
55
+ "gitHead": "7e66f8c498e37a40e410ecafff2ea6b31505dc1a"
56
56
  }
@@ -167,7 +167,9 @@ export const useFormatWatcher = () => {
167
167
  setIsSubscript(selection.hasFormat("subscript"));
168
168
  setIsSuperscript(selection.hasFormat("superscript"));
169
169
  setIsCode(selection.hasFormat("code"));
170
- setIsRTL($isParentElementRTL(selection));
170
+ editor.read(() => {
171
+ setIsRTL($isParentElementRTL(selection));
172
+ });
171
173
 
172
174
  // Update links
173
175
  const node = getSelectedNode(selection);
@@ -175,9 +175,8 @@ export const ToolbarPlugin = () => {
175
175
  <ButtonGroup variant="link">
176
176
  <ButtonWrapper
177
177
  value="start"
178
- rtlFlip
179
178
  label={t("tool.alignStart")}
180
- icon={CoreIcons.alignLeft}
179
+ icon={{ icon: CoreIcons.alignLeft, rtlFlip: true }}
181
180
  onClick={() =>
182
181
  watch.activeEditor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "start")
183
182
  }
@@ -192,18 +191,16 @@ export const ToolbarPlugin = () => {
192
191
  />
193
192
  <ButtonWrapper
194
193
  value="end"
195
- rtlFlip
196
194
  label={t("tool.alignEnd")}
197
- icon={CoreIcons.alignRight}
195
+ icon={{ icon: CoreIcons.alignRight, rtlFlip: true }}
198
196
  onClick={() =>
199
197
  watch.activeEditor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "end")
200
198
  }
201
199
  />
202
200
  <ButtonWrapper
203
201
  value="justify"
204
- rtlFlip
205
202
  label={t("tool.alignJustify")}
206
- icon={CoreIcons.alignJustify}
203
+ icon={{ icon: CoreIcons.alignJustify, rtlFlip: true }}
207
204
  onClick={() =>
208
205
  watch.activeEditor.dispatchCommand(
209
206
  FORMAT_ELEMENT_COMMAND,
@@ -213,16 +210,14 @@ export const ToolbarPlugin = () => {
213
210
  />
214
211
  <ButtonWrapper
215
212
  value="justify"
216
- rtlFlip
217
213
  label={t("tool.indentOut")}
218
- icon={CoreIcons.formatIndentDecrease}
214
+ icon={{ icon: CoreIcons.formatIndentDecrease, rtlFlip: true }}
219
215
  onClick={() => watch.outdent()}
220
216
  />
221
217
  <ButtonWrapper
222
218
  value="justify"
223
- rtlFlip
224
219
  label={t("tool.identIn")}
225
- icon={CoreIcons.formatIndentIncrease}
220
+ icon={{ icon: CoreIcons.formatIndentIncrease, rtlFlip: true }}
226
221
  onClick={() => watch.indent()}
227
222
  />
228
223
  </ButtonGroup>