@lexical/react 0.26.0 → 0.27.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.
@@ -22,6 +22,12 @@ var react = require('react');
22
22
  *
23
23
  */
24
24
 
25
+ // Do not require this module directly! Use normal `invariant` calls.
26
+
27
+ function formatDevErrorMessage(message) {
28
+ throw new Error(message);
29
+ }
30
+
25
31
  function createLinkMatcherWithRegExp(regExp, urlTransformer = text => text) {
26
32
  return text => {
27
33
  const match = regExp.exec(text);
@@ -299,7 +305,7 @@ function useAutoLink(editor, matchers, onChange) {
299
305
  react.useEffect(() => {
300
306
  if (!editor.hasNodes([link.AutoLinkNode])) {
301
307
  {
302
- throw Error(`LexicalAutoLinkPlugin: AutoLinkNode not registered on editor`);
308
+ formatDevErrorMessage(`LexicalAutoLinkPlugin: AutoLinkNode not registered on editor`);
303
309
  }
304
310
  }
305
311
  const onChangeWrapped = (url, prevUrl) => {
@@ -20,6 +20,12 @@ import { useEffect } from 'react';
20
20
  *
21
21
  */
22
22
 
23
+ // Do not require this module directly! Use normal `invariant` calls.
24
+
25
+ function formatDevErrorMessage(message) {
26
+ throw new Error(message);
27
+ }
28
+
23
29
  function createLinkMatcherWithRegExp(regExp, urlTransformer = text => text) {
24
30
  return text => {
25
31
  const match = regExp.exec(text);
@@ -297,7 +303,7 @@ function useAutoLink(editor, matchers, onChange) {
297
303
  useEffect(() => {
298
304
  if (!editor.hasNodes([AutoLinkNode])) {
299
305
  {
300
- throw Error(`LexicalAutoLinkPlugin: AutoLinkNode not registered on editor`);
306
+ formatDevErrorMessage(`LexicalAutoLinkPlugin: AutoLinkNode not registered on editor`);
301
307
  }
302
308
  }
303
309
  const onChangeWrapped = (url, prevUrl) => {
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/link"),t=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/utils"),i=require("lexical"),r=require("react");function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var l=o((function(e){const t=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",e);for(let e=1;e<arguments.length;e++)n.append("v",arguments[e]);throw t.search=n.toString(),Error(`Minified Lexical error #${e}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function s(e,t){for(let n=0;n<t.length;n++){const i=t[n](e);if(i)return i}return null}const u=/[.,;\s]/;function c(e){return u.test(e)}function g(e){return c(e[e.length-1])}function a(e){return c(e[0])}function f(e){let t=e.getPreviousSibling();return i.$isElementNode(t)&&(t=t.getLastDescendant()),null===t||i.$isLineBreakNode(t)||i.$isTextNode(t)&&g(t.getTextContent())}function d(e){let t=e.getNextSibling();return i.$isElementNode(t)&&(t=t.getFirstDescendant()),null===t||i.$isLineBreakNode(t)||i.$isTextNode(t)&&a(t.getTextContent())}function x(e,t,n,i){if(!(e>0?c(n[e-1]):f(i[0])))return!1;return t<n.length?c(n[t]):d(i[i.length-1])}function h(e,t,n){const i=[],r=[],o=[];let l=0,s=0;const u=[...e];for(;u.length>0;){const e=u[0],c=e.getTextContent().length,g=s;s+c<=t?(i.push(e),l+=c):g>=n?o.push(e):r.push(e),s+=c,u.shift()}return[l,i,r,o]}function p(t,n,r,o){const l=e.$createAutoLinkNode(o.url,o.attributes);if(1===t.length){let e,s=t[0];0===n?[e,s]=s.splitText(r):[,e,s]=s.splitText(n,r);const u=i.$createTextNode(o.text);return u.setFormat(e.getFormat()),u.setDetail(e.getDetail()),u.setStyle(e.getStyle()),l.append(u),e.replace(l),s}if(t.length>1){const e=t[0];let o,s=e.getTextContent().length;0===n?o=e:[,o]=e.splitText(n);const u=[];let c;for(let e=1;e<t.length;e++){const n=t[e],i=n.getTextContent().length,o=s;if(o<r)if(s+i<=r)u.push(n);else{const[e,t]=n.splitText(r-o);u.push(e),c=t}s+=i}const g=i.$getSelection(),a=g?g.getNodes().find(i.$isTextNode):void 0,f=i.$createTextNode(o.getTextContent());return f.setFormat(o.getFormat()),f.setDetail(o.getDetail()),f.setStyle(o.getStyle()),l.append(f,...u),a&&a===o&&(i.$isRangeSelection(g)?f.select(g.anchor.offset,g.focus.offset):i.$isNodeSelection(g)&&f.select(0,f.getTextContent().length)),o.replace(l),c}}function T(e,t,n){const r=e.getChildren(),o=r.length;for(let t=0;t<o;t++){const o=r[t];if(!i.$isTextNode(o)||!o.isSimpleText())return N(e),void n(null,e.getURL())}const l=e.getTextContent(),u=s(l,t);if(null===u||u.text!==l)return N(e),void n(null,e.getURL());if(!f(e)||!d(e))return N(e),void n(null,e.getURL());const c=e.getURL();if(c!==u.url&&(e.setURL(u.url),n(u.url,c)),u.attributes){const t=e.getRel();t!==u.attributes.rel&&(e.setRel(u.attributes.rel||null),n(u.attributes.rel||null,t));const i=e.getTarget();i!==u.attributes.target&&(e.setTarget(u.attributes.target||null),n(u.attributes.target||null,i))}}function N(e){const t=e.getChildren();for(let n=t.length-1;n>=0;n--)e.insertAfter(t[n]);return e.remove(),t.map((e=>e.getLatest()))}function L(t,o,u){r.useEffect((()=>{t.hasNodes([e.AutoLinkNode])||l(77);const r=(e,t)=>{u&&u(e,t)};return n.mergeRegister(t.registerNodeTransform(i.TextNode,(t=>{const n=t.getParentOrThrow(),l=t.getPreviousSibling();if(e.$isAutoLinkNode(n)&&!n.getIsUnlinked())T(n,o,r);else if(!e.$isLinkNode(n)){if(t.isSimpleText()&&(a(t.getTextContent())||!e.$isAutoLinkNode(l))){const e=function(e){const t=[e];let n=e.getNextSibling();for(;null!==n&&i.$isTextNode(n)&&n.isSimpleText()&&(t.push(n),!/[\s]/.test(n.getTextContent()));)n=n.getNextSibling();return t}(t);!function(e,t,n){let i=[...e];const r=i.map((e=>e.getTextContent())).join("");let o,l=r,u=0;for(;(o=s(l,t))&&null!==o;){const e=o.index,t=e+o.length;if(x(u+e,u+t,r,i)){const[r,,l,s]=h(i,u+e,u+t),c=p(l,u+e-r,u+t-r,o);i=c?[c,...s]:s,n(o.url,null),u=0}else u+=t;l=l.substring(t)}}(e,o,r)}!function(t,n,i){const r=t.getPreviousSibling(),o=t.getNextSibling(),l=t.getTextContent();var s;!e.$isAutoLinkNode(r)||r.getIsUnlinked()||a(l)&&(s=l,!(r.isEmailURI()?/^\.[a-zA-Z]{2,}/.test(s):/^\.[a-zA-Z0-9]{1,}/.test(s)))||(r.append(t),T(r,n,i),i(null,r.getURL())),!e.$isAutoLinkNode(o)||o.getIsUnlinked()||g(l)||(N(o),T(o,n,i),i(null,o.getURL()))}(t,o,r)}})),t.registerCommand(e.TOGGLE_LINK_COMMAND,(t=>{const n=i.$getSelection();if(null!==t||!i.$isRangeSelection(n))return!1;return n.extract().forEach((t=>{const n=t.getParent();if(e.$isAutoLinkNode(n))return n.setIsUnlinked(!n.getIsUnlinked()),n.markDirty(),!0})),!1}),i.COMMAND_PRIORITY_LOW))}),[t,o,u])}exports.AutoLinkPlugin=function({matchers:e,onChange:n}){const[i]=t.useLexicalComposerContext();return L(i,e,n),null},exports.createLinkMatcherWithRegExp=function(e,t=(e=>e)){return n=>{const i=e.exec(n);return null===i?null:{index:i.index,length:i[0].length,text:i[0],url:t(i[0])}}};
9
+ "use strict";var e=require("@lexical/link"),t=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/utils"),i=require("lexical"),r=require("react");function o(e,t){for(let n=0;n<t.length;n++){const i=t[n](e);if(i)return i}return null}const l=/[.,;\s]/;function s(e){return l.test(e)}function u(e){return s(e[e.length-1])}function g(e){return s(e[0])}function c(e){let t=e.getPreviousSibling();return i.$isElementNode(t)&&(t=t.getLastDescendant()),null===t||i.$isLineBreakNode(t)||i.$isTextNode(t)&&u(t.getTextContent())}function a(e){let t=e.getNextSibling();return i.$isElementNode(t)&&(t=t.getFirstDescendant()),null===t||i.$isLineBreakNode(t)||i.$isTextNode(t)&&g(t.getTextContent())}function f(e,t,n,i){if(!(e>0?s(n[e-1]):c(i[0])))return!1;return t<n.length?s(n[t]):a(i[i.length-1])}function d(e,t,n){const i=[],r=[],o=[];let l=0,s=0;const u=[...e];for(;u.length>0;){const e=u[0],g=e.getTextContent().length,c=s;s+g<=t?(i.push(e),l+=g):c>=n?o.push(e):r.push(e),s+=g,u.shift()}return[l,i,r,o]}function x(t,n,r,o){const l=e.$createAutoLinkNode(o.url,o.attributes);if(1===t.length){let e,s=t[0];0===n?[e,s]=s.splitText(r):[,e,s]=s.splitText(n,r);const u=i.$createTextNode(o.text);return u.setFormat(e.getFormat()),u.setDetail(e.getDetail()),u.setStyle(e.getStyle()),l.append(u),e.replace(l),s}if(t.length>1){const e=t[0];let o,s=e.getTextContent().length;0===n?o=e:[,o]=e.splitText(n);const u=[];let g;for(let e=1;e<t.length;e++){const n=t[e],i=n.getTextContent().length,o=s;if(o<r)if(s+i<=r)u.push(n);else{const[e,t]=n.splitText(r-o);u.push(e),g=t}s+=i}const c=i.$getSelection(),a=c?c.getNodes().find(i.$isTextNode):void 0,f=i.$createTextNode(o.getTextContent());return f.setFormat(o.getFormat()),f.setDetail(o.getDetail()),f.setStyle(o.getStyle()),l.append(f,...u),a&&a===o&&(i.$isRangeSelection(c)?f.select(c.anchor.offset,c.focus.offset):i.$isNodeSelection(c)&&f.select(0,f.getTextContent().length)),o.replace(l),g}}function h(e,t,n){const r=e.getChildren(),l=r.length;for(let t=0;t<l;t++){const o=r[t];if(!i.$isTextNode(o)||!o.isSimpleText())return p(e),void n(null,e.getURL())}const s=e.getTextContent(),u=o(s,t);if(null===u||u.text!==s)return p(e),void n(null,e.getURL());if(!c(e)||!a(e))return p(e),void n(null,e.getURL());const g=e.getURL();if(g!==u.url&&(e.setURL(u.url),n(u.url,g)),u.attributes){const t=e.getRel();t!==u.attributes.rel&&(e.setRel(u.attributes.rel||null),n(u.attributes.rel||null,t));const i=e.getTarget();i!==u.attributes.target&&(e.setTarget(u.attributes.target||null),n(u.attributes.target||null,i))}}function p(e){const t=e.getChildren();for(let n=t.length-1;n>=0;n--)e.insertAfter(t[n]);return e.remove(),t.map((e=>e.getLatest()))}function T(t,l,s){r.useEffect((()=>{t.hasNodes([e.AutoLinkNode])||function(e,...t){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",e);for(const e of t)i.append("v",e);throw n.search=i.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.`)}(77);const r=(e,t)=>{s&&s(e,t)};return n.mergeRegister(t.registerNodeTransform(i.TextNode,(t=>{const n=t.getParentOrThrow(),s=t.getPreviousSibling();if(e.$isAutoLinkNode(n)&&!n.getIsUnlinked())h(n,l,r);else if(!e.$isLinkNode(n)){if(t.isSimpleText()&&(g(t.getTextContent())||!e.$isAutoLinkNode(s))){const e=function(e){const t=[e];let n=e.getNextSibling();for(;null!==n&&i.$isTextNode(n)&&n.isSimpleText()&&(t.push(n),!/[\s]/.test(n.getTextContent()));)n=n.getNextSibling();return t}(t);!function(e,t,n){let i=[...e];const r=i.map((e=>e.getTextContent())).join("");let l,s=r,u=0;for(;(l=o(s,t))&&null!==l;){const e=l.index,t=e+l.length;if(f(u+e,u+t,r,i)){const[r,,o,s]=d(i,u+e,u+t),g=x(o,u+e-r,u+t-r,l);i=g?[g,...s]:s,n(l.url,null),u=0}else u+=t;s=s.substring(t)}}(e,l,r)}!function(t,n,i){const r=t.getPreviousSibling(),o=t.getNextSibling(),l=t.getTextContent();var s;!e.$isAutoLinkNode(r)||r.getIsUnlinked()||g(l)&&(s=l,!(r.isEmailURI()?/^\.[a-zA-Z]{2,}/.test(s):/^\.[a-zA-Z0-9]{1,}/.test(s)))||(r.append(t),h(r,n,i),i(null,r.getURL())),!e.$isAutoLinkNode(o)||o.getIsUnlinked()||u(l)||(p(o),h(o,n,i),i(null,o.getURL()))}(t,l,r)}})),t.registerCommand(e.TOGGLE_LINK_COMMAND,(t=>{const n=i.$getSelection();if(null!==t||!i.$isRangeSelection(n))return!1;return n.extract().forEach((t=>{const n=t.getParent();if(e.$isAutoLinkNode(n))return n.setIsUnlinked(!n.getIsUnlinked()),n.markDirty(),!0})),!1}),i.COMMAND_PRIORITY_LOW))}),[t,l,s])}exports.AutoLinkPlugin=function({matchers:e,onChange:n}){const[i]=t.useLexicalComposerContext();return T(i,e,n),null},exports.createLinkMatcherWithRegExp=function(e,t=(e=>e)){return n=>{const i=e.exec(n);return null===i?null:{index:i.index,length:i[0].length,text:i[0],url:t(i[0])}}};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{AutoLinkNode as t,$isAutoLinkNode as e,$isLinkNode as n,TOGGLE_LINK_COMMAND as r,$createAutoLinkNode as l}from"@lexical/link";import{useLexicalComposerContext as o}from"@lexical/react/LexicalComposerContext";import{mergeRegister as i}from"@lexical/utils";import{TextNode as s,$getSelection as u,$isRangeSelection as g,COMMAND_PRIORITY_LOW as c,$isTextNode as a,$isElementNode as f,$isLineBreakNode as h,$createTextNode as x,$isNodeSelection as p}from"lexical";import{useEffect as d}from"react";function m(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var T=m((function(t){const e=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",t);for(let t=1;t<arguments.length;t++)n.append("v",arguments[t]);throw e.search=n.toString(),Error(`Minified Lexical error #${t}; visit ${e.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function C(t,e=(t=>t)){return n=>{const r=t.exec(n);return null===r?null:{index:r.index,length:r[0].length,text:r[0],url:e(r[0])}}}function b(t,e){for(let n=0;n<e.length;n++){const r=e[n](t);if(r)return r}return null}const S=/[.,;\s]/;function v(t){return S.test(t)}function U(t){return v(t[t.length-1])}function L(t){return v(t[0])}function R(t){let e=t.getPreviousSibling();return f(e)&&(e=e.getLastDescendant()),null===e||h(e)||a(e)&&U(e.getTextContent())}function k(t){let e=t.getNextSibling();return f(e)&&(e=e.getFirstDescendant()),null===e||h(e)||a(e)&&L(e.getTextContent())}function y(t,e,n,r){if(!(t>0?v(n[t-1]):R(r[0])))return!1;return e<n.length?v(n[e]):k(r[r.length-1])}function D(t,e,n){const r=[],l=[],o=[];let i=0,s=0;const u=[...t];for(;u.length>0;){const t=u[0],g=t.getTextContent().length,c=s;s+g<=e?(r.push(t),i+=g):c>=n?o.push(t):l.push(t),s+=g,u.shift()}return[i,r,l,o]}function N(t,e,n,r){const o=l(r.url,r.attributes);if(1===t.length){let l,i=t[0];0===e?[l,i]=i.splitText(n):[,l,i]=i.splitText(e,n);const s=x(r.text);return s.setFormat(l.getFormat()),s.setDetail(l.getDetail()),s.setStyle(l.getStyle()),o.append(s),l.replace(o),i}if(t.length>1){const r=t[0];let l,i=r.getTextContent().length;0===e?l=r:[,l]=r.splitText(e);const s=[];let c;for(let e=1;e<t.length;e++){const r=t[e],l=r.getTextContent().length,o=i;if(o<n)if(i+l<=n)s.push(r);else{const[t,e]=r.splitText(n-o);s.push(t),c=e}i+=l}const f=u(),h=f?f.getNodes().find(a):void 0,d=x(l.getTextContent());return d.setFormat(l.getFormat()),d.setDetail(l.getDetail()),d.setStyle(l.getStyle()),o.append(d,...s),h&&h===l&&(g(f)?d.select(f.anchor.offset,f.focus.offset):p(f)&&d.select(0,d.getTextContent().length)),l.replace(o),c}}function P(t,e,n){const r=t.getChildren(),l=r.length;for(let e=0;e<l;e++){const l=r[e];if(!a(l)||!l.isSimpleText())return w(t),void n(null,t.getURL())}const o=t.getTextContent(),i=b(o,e);if(null===i||i.text!==o)return w(t),void n(null,t.getURL());if(!R(t)||!k(t))return w(t),void n(null,t.getURL());const s=t.getURL();if(s!==i.url&&(t.setURL(i.url),n(i.url,s)),i.attributes){const e=t.getRel();e!==i.attributes.rel&&(t.setRel(i.attributes.rel||null),n(i.attributes.rel||null,e));const r=t.getTarget();r!==i.attributes.target&&(t.setTarget(i.attributes.target||null),n(i.attributes.target||null,r))}}function w(t){const e=t.getChildren();for(let n=e.length-1;n>=0;n--)t.insertAfter(e[n]);return t.remove(),e.map((t=>t.getLatest()))}function I(l,o,f){d((()=>{l.hasNodes([t])||T(77);const h=(t,e)=>{f&&f(t,e)};return i(l.registerNodeTransform(s,(t=>{const r=t.getParentOrThrow(),l=t.getPreviousSibling();if(e(r)&&!r.getIsUnlinked())P(r,o,h);else if(!n(r)){if(t.isSimpleText()&&(L(t.getTextContent())||!e(l))){const e=function(t){const e=[t];let n=t.getNextSibling();for(;null!==n&&a(n)&&n.isSimpleText()&&(e.push(n),!/[\s]/.test(n.getTextContent()));)n=n.getNextSibling();return e}(t);!function(t,e,n){let r=[...t];const l=r.map((t=>t.getTextContent())).join("");let o,i=l,s=0;for(;(o=b(i,e))&&null!==o;){const t=o.index,e=t+o.length;if(y(s+t,s+e,l,r)){const[l,,i,u]=D(r,s+t,s+e),g=N(i,s+t-l,s+e-l,o);r=g?[g,...u]:u,n(o.url,null),s=0}else s+=e;i=i.substring(e)}}(e,o,h)}!function(t,n,r){const l=t.getPreviousSibling(),o=t.getNextSibling(),i=t.getTextContent();var s;!e(l)||l.getIsUnlinked()||L(i)&&(s=i,!(l.isEmailURI()?/^\.[a-zA-Z]{2,}/.test(s):/^\.[a-zA-Z0-9]{1,}/.test(s)))||(l.append(t),P(l,n,r),r(null,l.getURL())),!e(o)||o.getIsUnlinked()||U(i)||(w(o),P(o,n,r),r(null,o.getURL()))}(t,o,h)}})),l.registerCommand(r,(t=>{const n=u();if(null!==t||!g(n))return!1;return n.extract().forEach((t=>{const n=t.getParent();if(e(n))return n.setIsUnlinked(!n.getIsUnlinked()),n.markDirty(),!0})),!1}),c))}),[l,o,f])}function F({matchers:t,onChange:e}){const[n]=o();return I(n,t,e),null}export{F as AutoLinkPlugin,C as createLinkMatcherWithRegExp};
9
+ import{AutoLinkNode as t,$isAutoLinkNode as e,$isLinkNode as n,TOGGLE_LINK_COMMAND as r,$createAutoLinkNode as l}from"@lexical/link";import{useLexicalComposerContext as i}from"@lexical/react/LexicalComposerContext";import{mergeRegister as o}from"@lexical/utils";import{TextNode as s,$getSelection as u,$isRangeSelection as g,COMMAND_PRIORITY_LOW as c,$isTextNode as a,$isElementNode as f,$isLineBreakNode as x,$createTextNode as h,$isNodeSelection as p}from"lexical";import{useEffect as d}from"react";function m(t,e=(t=>t)){return n=>{const r=t.exec(n);return null===r?null:{index:r.index,length:r[0].length,text:r[0],url:e(r[0])}}}function T(t,e){for(let n=0;n<e.length;n++){const r=e[n](t);if(r)return r}return null}const C=/[.,;\s]/;function S(t){return C.test(t)}function b(t){return S(t[t.length-1])}function U(t){return S(t[0])}function v(t){let e=t.getPreviousSibling();return f(e)&&(e=e.getLastDescendant()),null===e||x(e)||a(e)&&b(e.getTextContent())}function L(t){let e=t.getNextSibling();return f(e)&&(e=e.getFirstDescendant()),null===e||x(e)||a(e)&&U(e.getTextContent())}function R(t,e,n,r){if(!(t>0?S(n[t-1]):v(r[0])))return!1;return e<n.length?S(n[e]):L(r[r.length-1])}function k(t,e,n){const r=[],l=[],i=[];let o=0,s=0;const u=[...t];for(;u.length>0;){const t=u[0],g=t.getTextContent().length,c=s;s+g<=e?(r.push(t),o+=g):c>=n?i.push(t):l.push(t),s+=g,u.shift()}return[o,r,l,i]}function D(t,e,n,r){const i=l(r.url,r.attributes);if(1===t.length){let l,o=t[0];0===e?[l,o]=o.splitText(n):[,l,o]=o.splitText(e,n);const s=h(r.text);return s.setFormat(l.getFormat()),s.setDetail(l.getDetail()),s.setStyle(l.getStyle()),i.append(s),l.replace(i),o}if(t.length>1){const r=t[0];let l,o=r.getTextContent().length;0===e?l=r:[,l]=r.splitText(e);const s=[];let c;for(let e=1;e<t.length;e++){const r=t[e],l=r.getTextContent().length,i=o;if(i<n)if(o+l<=n)s.push(r);else{const[t,e]=r.splitText(n-i);s.push(t),c=e}o+=l}const f=u(),x=f?f.getNodes().find(a):void 0,d=h(l.getTextContent());return d.setFormat(l.getFormat()),d.setDetail(l.getDetail()),d.setStyle(l.getStyle()),i.append(d,...s),x&&x===l&&(g(f)?d.select(f.anchor.offset,f.focus.offset):p(f)&&d.select(0,d.getTextContent().length)),l.replace(i),c}}function N(t,e,n){const r=t.getChildren(),l=r.length;for(let e=0;e<l;e++){const l=r[e];if(!a(l)||!l.isSimpleText())return I(t),void n(null,t.getURL())}const i=t.getTextContent(),o=T(i,e);if(null===o||o.text!==i)return I(t),void n(null,t.getURL());if(!v(t)||!L(t))return I(t),void n(null,t.getURL());const s=t.getURL();if(s!==o.url&&(t.setURL(o.url),n(o.url,s)),o.attributes){const e=t.getRel();e!==o.attributes.rel&&(t.setRel(o.attributes.rel||null),n(o.attributes.rel||null,e));const r=t.getTarget();r!==o.attributes.target&&(t.setTarget(o.attributes.target||null),n(o.attributes.target||null,r))}}function I(t){const e=t.getChildren();for(let n=e.length-1;n>=0;n--)t.insertAfter(e[n]);return t.remove(),e.map((t=>t.getLatest()))}function P(l,i,f){d((()=>{l.hasNodes([t])||function(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.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.`)}(77);const x=(t,e)=>{f&&f(t,e)};return o(l.registerNodeTransform(s,(t=>{const r=t.getParentOrThrow(),l=t.getPreviousSibling();if(e(r)&&!r.getIsUnlinked())N(r,i,x);else if(!n(r)){if(t.isSimpleText()&&(U(t.getTextContent())||!e(l))){const e=function(t){const e=[t];let n=t.getNextSibling();for(;null!==n&&a(n)&&n.isSimpleText()&&(e.push(n),!/[\s]/.test(n.getTextContent()));)n=n.getNextSibling();return e}(t);!function(t,e,n){let r=[...t];const l=r.map((t=>t.getTextContent())).join("");let i,o=l,s=0;for(;(i=T(o,e))&&null!==i;){const t=i.index,e=t+i.length;if(R(s+t,s+e,l,r)){const[l,,o,u]=k(r,s+t,s+e),g=D(o,s+t-l,s+e-l,i);r=g?[g,...u]:u,n(i.url,null),s=0}else s+=e;o=o.substring(e)}}(e,i,x)}!function(t,n,r){const l=t.getPreviousSibling(),i=t.getNextSibling(),o=t.getTextContent();var s;!e(l)||l.getIsUnlinked()||U(o)&&(s=o,!(l.isEmailURI()?/^\.[a-zA-Z]{2,}/.test(s):/^\.[a-zA-Z0-9]{1,}/.test(s)))||(l.append(t),N(l,n,r),r(null,l.getURL())),!e(i)||i.getIsUnlinked()||b(o)||(I(i),N(i,n,r),r(null,i.getURL()))}(t,i,x)}})),l.registerCommand(r,(t=>{const n=u();if(null!==t||!g(n))return!1;return n.extract().forEach((t=>{const n=t.getParent();if(e(n))return n.setIsUnlinked(!n.getIsUnlinked()),n.markDirty(),!0})),!1}),c))}),[l,i,f])}function w({matchers:t,onChange:e}){const[n]=i();return P(n,t,e),null}export{w as AutoLinkPlugin,m as createLinkMatcherWithRegExp};
@@ -24,6 +24,12 @@ var jsxRuntime = require('react/jsx-runtime');
24
24
  *
25
25
  */
26
26
 
27
+ // Do not require this module directly! Use normal `invariant` calls.
28
+
29
+ function formatDevErrorMessage(message) {
30
+ throw new Error(message);
31
+ }
32
+
27
33
  function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({})) {
28
34
  const {
29
35
  strlen = input => input.length,
@@ -35,7 +41,7 @@ function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({}))
35
41
  react.useEffect(() => {
36
42
  if (!editor.hasNodes([overflow.OverflowNode])) {
37
43
  {
38
- throw Error(`useCharacterLimit: OverflowNode not registered on editor`);
44
+ formatDevErrorMessage(`useCharacterLimit: OverflowNode not registered on editor`);
39
45
  }
40
46
  }
41
47
  }, [editor]);
@@ -22,6 +22,12 @@ import { jsx } from 'react/jsx-runtime';
22
22
  *
23
23
  */
24
24
 
25
+ // Do not require this module directly! Use normal `invariant` calls.
26
+
27
+ function formatDevErrorMessage(message) {
28
+ throw new Error(message);
29
+ }
30
+
25
31
  function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({})) {
26
32
  const {
27
33
  strlen = input => input.length,
@@ -33,7 +39,7 @@ function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({}))
33
39
  useEffect(() => {
34
40
  if (!editor.hasNodes([OverflowNode])) {
35
41
  {
36
- throw Error(`useCharacterLimit: OverflowNode not registered on editor`);
42
+ formatDevErrorMessage(`useCharacterLimit: OverflowNode not registered on editor`);
37
43
  }
38
44
  }
39
45
  }, [editor]);
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("react"),n=require("@lexical/overflow"),r=require("@lexical/text"),o=require("@lexical/utils"),i=require("lexical"),s=require("react/jsx-runtime");function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c=l((function(e){const t=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",e);for(let e=1;e<arguments.length;e++)n.append("v",arguments[e]);throw t.search=n.toString(),Error(`Minified Lexical error #${e}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function a(e,s,l=Object.freeze({})){const{strlen:a=(e=>e.length),remainingCharacters:u=(()=>{})}=l;t.useEffect((()=>{e.hasNodes([n.OverflowNode])||c(57)}),[e]),t.useEffect((()=>{let t=e.getEditorState().read(r.$rootTextContent),l=0;return o.mergeRegister(e.registerTextContentListener((e=>{t=e})),e.registerUpdateListener((({dirtyLeaves:r,dirtyElements:c})=>{const d=e.isComposing(),h=r.size>0||c.size>0;if(d||!h)return;const m=a(t),x=m>s||null!==l&&l>s;if(u(s-m),null===l||x){const r=function(e,t,n){const r=Intl.Segmenter;let o=0,i=0;if("function"==typeof r){const s=(new r).segment(e);for(const{segment:e}of s){const r=i+n(e);if(r>t)break;i=r,o+=e.length}}else{const r=Array.from(e),s=r.length;for(let e=0;e<s;e++){const s=r[e],l=i+n(s);if(l>t)break;i=l,o+=s.length}}return o}(t,s,a);e.update((()=>{!function(e){const t=o.$dfs(),r=t.length;let s=0;for(let l=0;l<r;l+=1){const{node:r}=t[l];if(n.$isOverflowNode(r)){const t=s;if(s+r.getTextContentSize()<=e){const e=r.getParent(),t=r.getPreviousSibling(),n=r.getNextSibling();o.$unwrapNode(r);const s=i.$getSelection();!i.$isRangeSelection(s)||s.anchor.getNode().isAttached()&&s.focus.getNode().isAttached()||(i.$isTextNode(t)?t.select():i.$isTextNode(n)?n.select():null!==e&&e.select())}else if(t<e){const n=r.getFirstDescendant(),s=t+(null!==n?n.getTextContentSize():0);(i.$isTextNode(n)&&n.isSimpleText()||s<=e)&&o.$unwrapNode(r)}}else if(i.$isLeafNode(r)){const t=s;if(s+=r.getTextContentSize(),s>e&&!n.$isOverflowNode(r.getParent())){const n=i.$getSelection();let o;if(t<e&&i.$isTextNode(r)&&r.isSimpleText()){const[,n]=r.splitText(e-t);o=f(n)}else o=f(r);null!==n&&i.$setSelection(n),g(o)}}}}(r)}),{tag:"history-merge"})}l=m})),e.registerCommand(i.DELETE_CHARACTER_COMMAND,(e=>{const t=i.$getSelection();if(!i.$isRangeSelection(t))return!1;const n=t.anchor.getNode().getParent(),r=n?n.getParent():null,o=r?r.getNextSibling():null;return t.deleteCharacter(e),r&&r.isEmpty()?r.remove():i.$isElementNode(o)&&o.isEmpty()&&o.remove(),!0}),i.COMMAND_PRIORITY_LOW))}),[e,s,u,a])}function f(e){const t=n.$createOverflowNode();return e.replace(t),t.append(e),t}function g(e){const t=e.getPreviousSibling();if(!n.$isOverflowNode(t))return;const r=e.getFirstChild(),o=t.getChildren(),s=o.length;if(null===r)e.append(...o);else for(let e=0;e<s;e++)r.insertBefore(o[e]);const l=i.$getSelection();if(i.$isRangeSelection(l)){const n=l.anchor,r=n.getNode(),o=l.focus,i=n.getNode();r.is(t)?n.set(e.getKey(),n.offset,"element"):r.is(e)&&n.set(e.getKey(),s+n.offset,"element"),i.is(t)?o.set(e.getKey(),o.offset,"element"):i.is(e)&&o.set(e.getKey(),s+o.offset,"element")}t.remove()}let u=null;function d(e){const t=void 0===window.TextEncoder?null:(null===u&&(u=new window.TextEncoder),u);if(null===t){const t=encodeURIComponent(e).match(/%[89ABab]/g);return e.length+(t?t.length:0)}return t.encode(e).length}function h({remainingCharacters:e}){return s.jsx("span",{className:"characters-limit "+(e<0?"characters-limit-exceeded":""),children:e})}exports.CharacterLimitPlugin=function({charset:n="UTF-16",maxLength:r=5,renderer:o=h}){const[i]=e.useLexicalComposerContext(),[s,l]=t.useState(r),c=t.useMemo((()=>({remainingCharacters:l,strlen:e=>{if("UTF-8"===n)return d(e);if("UTF-16"===n)return e.length;throw new Error("Unrecognized charset")}})),[n]);return a(i,r,c),o({remainingCharacters:s})};
9
+ "use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("react"),n=require("@lexical/overflow"),r=require("@lexical/text"),o=require("@lexical/utils"),i=require("lexical"),s=require("react/jsx-runtime");function l(e,s,l=Object.freeze({})){const{strlen:f=(e=>e.length),remainingCharacters:g=(()=>{})}=l;t.useEffect((()=>{e.hasNodes([n.OverflowNode])||function(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.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.`)}(57)}),[e]),t.useEffect((()=>{let t=e.getEditorState().read(r.$rootTextContent),l=0;return o.mergeRegister(e.registerTextContentListener((e=>{t=e})),e.registerUpdateListener((({dirtyLeaves:r,dirtyElements:u})=>{const d=e.isComposing(),m=r.size>0||u.size>0;if(d||!m)return;const h=f(t),x=h>s||null!==l&&l>s;if(g(s-h),null===l||x){const r=function(e,t,n){const r=Intl.Segmenter;let o=0,i=0;if("function"==typeof r){const s=(new r).segment(e);for(const{segment:e}of s){const r=i+n(e);if(r>t)break;i=r,o+=e.length}}else{const r=Array.from(e),s=r.length;for(let e=0;e<s;e++){const s=r[e],l=i+n(s);if(l>t)break;i=l,o+=s.length}}return o}(t,s,f);e.update((()=>{!function(e){const t=o.$dfs(),r=t.length;let s=0;for(let l=0;l<r;l+=1){const{node:r}=t[l];if(n.$isOverflowNode(r)){const t=s;if(s+r.getTextContentSize()<=e){const e=r.getParent(),t=r.getPreviousSibling(),n=r.getNextSibling();o.$unwrapNode(r);const s=i.$getSelection();!i.$isRangeSelection(s)||s.anchor.getNode().isAttached()&&s.focus.getNode().isAttached()||(i.$isTextNode(t)?t.select():i.$isTextNode(n)?n.select():null!==e&&e.select())}else if(t<e){const n=r.getFirstDescendant(),s=t+(null!==n?n.getTextContentSize():0);(i.$isTextNode(n)&&n.isSimpleText()||s<=e)&&o.$unwrapNode(r)}}else if(i.$isLeafNode(r)){const t=s;if(s+=r.getTextContentSize(),s>e&&!n.$isOverflowNode(r.getParent())){const n=i.$getSelection();let o;if(t<e&&i.$isTextNode(r)&&r.isSimpleText()){const[,n]=r.splitText(e-t);o=c(n)}else o=c(r);null!==n&&i.$setSelection(n),a(o)}}}}(r)}),{tag:"history-merge"})}l=h})),e.registerCommand(i.DELETE_CHARACTER_COMMAND,(e=>{const t=i.$getSelection();if(!i.$isRangeSelection(t))return!1;const n=t.anchor.getNode().getParent(),r=n?n.getParent():null,o=r?r.getNextSibling():null;return t.deleteCharacter(e),r&&r.isEmpty()?r.remove():i.$isElementNode(o)&&o.isEmpty()&&o.remove(),!0}),i.COMMAND_PRIORITY_LOW))}),[e,s,g,f])}function c(e){const t=n.$createOverflowNode();return e.replace(t),t.append(e),t}function a(e){const t=e.getPreviousSibling();if(!n.$isOverflowNode(t))return;const r=e.getFirstChild(),o=t.getChildren(),s=o.length;if(null===r)e.append(...o);else for(let e=0;e<s;e++)r.insertBefore(o[e]);const l=i.$getSelection();if(i.$isRangeSelection(l)){const n=l.anchor,r=n.getNode(),o=l.focus,i=n.getNode();r.is(t)?n.set(e.getKey(),n.offset,"element"):r.is(e)&&n.set(e.getKey(),s+n.offset,"element"),i.is(t)?o.set(e.getKey(),o.offset,"element"):i.is(e)&&o.set(e.getKey(),s+o.offset,"element")}t.remove()}let f=null;function g(e){const t=void 0===window.TextEncoder?null:(null===f&&(f=new window.TextEncoder),f);if(null===t){const t=encodeURIComponent(e).match(/%[89ABab]/g);return e.length+(t?t.length:0)}return t.encode(e).length}function u({remainingCharacters:e}){return s.jsx("span",{className:"characters-limit "+(e<0?"characters-limit-exceeded":""),children:e})}exports.CharacterLimitPlugin=function({charset:n="UTF-16",maxLength:r=5,renderer:o=u}){const[i]=e.useLexicalComposerContext(),[s,c]=t.useState(r),a=t.useMemo((()=>({remainingCharacters:c,strlen:e=>{if("UTF-8"===n)return g(e);if("UTF-16"===n)return e.length;throw new Error("Unrecognized charset")}})),[n]);return l(i,r,a),o({remainingCharacters:s})};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useEffect as t,useState as n,useMemo as r}from"react";import{OverflowNode as o,$isOverflowNode as i,$createOverflowNode as s}from"@lexical/overflow";import{$rootTextContent as l}from"@lexical/text";import{mergeRegister as c,$dfs as a,$unwrapNode as f}from"@lexical/utils";import{DELETE_CHARACTER_COMMAND as g,$getSelection as u,$isRangeSelection as m,$isElementNode as d,COMMAND_PRIORITY_LOW as h,$isTextNode as p,$isLeafNode as x,$setSelection as C}from"lexical";import{jsx as v}from"react/jsx-runtime";function w(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S=w((function(e){const t=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",e);for(let e=1;e<arguments.length;e++)n.append("v",arguments[e]);throw t.search=n.toString(),Error(`Minified Lexical error #${e}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function y(e,n,r=Object.freeze({})){const{strlen:s=(e=>e.length),remainingCharacters:v=(()=>{})}=r;t((()=>{e.hasNodes([o])||S(57)}),[e]),t((()=>{let t=e.getEditorState().read(l),r=0;return c(e.registerTextContentListener((e=>{t=e})),e.registerUpdateListener((({dirtyLeaves:o,dirtyElements:l})=>{const c=e.isComposing(),g=o.size>0||l.size>0;if(c||!g)return;const d=s(t),h=d>n||null!==r&&r>n;if(v(n-d),null===r||h){const r=function(e,t,n){const r=Intl.Segmenter;let o=0,i=0;if("function"==typeof r){const s=(new r).segment(e);for(const{segment:e}of s){const r=i+n(e);if(r>t)break;i=r,o+=e.length}}else{const r=Array.from(e),s=r.length;for(let e=0;e<s;e++){const s=r[e],l=i+n(s);if(l>t)break;i=l,o+=s.length}}return o}(t,n,s);e.update((()=>{!function(e){const t=a(),n=t.length;let r=0;for(let o=0;o<n;o+=1){const{node:n}=t[o];if(i(n)){const t=r;if(r+n.getTextContentSize()<=e){const e=n.getParent(),t=n.getPreviousSibling(),r=n.getNextSibling();f(n);const o=u();!m(o)||o.anchor.getNode().isAttached()&&o.focus.getNode().isAttached()||(p(t)?t.select():p(r)?r.select():null!==e&&e.select())}else if(t<e){const r=n.getFirstDescendant(),o=t+(null!==r?r.getTextContentSize():0);(p(r)&&r.isSimpleText()||o<=e)&&f(n)}}else if(x(n)){const t=r;if(r+=n.getTextContentSize(),r>e&&!i(n.getParent())){const r=u();let o;if(t<e&&p(n)&&n.isSimpleText()){const[,r]=n.splitText(e-t);o=T(r)}else o=T(n);null!==r&&C(r),b(o)}}}}(r)}),{tag:"history-merge"})}r=d})),e.registerCommand(g,(e=>{const t=u();if(!m(t))return!1;const n=t.anchor.getNode().getParent(),r=n?n.getParent():null,o=r?r.getNextSibling():null;return t.deleteCharacter(e),r&&r.isEmpty()?r.remove():d(o)&&o.isEmpty()&&o.remove(),!0}),h))}),[e,n,v,s])}function T(e){const t=s();return e.replace(t),t.append(e),t}function b(e){const t=e.getPreviousSibling();if(!i(t))return;const n=e.getFirstChild(),r=t.getChildren(),o=r.length;if(null===n)e.append(...r);else for(let e=0;e<o;e++)n.insertBefore(r[e]);const s=u();if(m(s)){const n=s.anchor,r=n.getNode(),i=s.focus,l=n.getNode();r.is(t)?n.set(e.getKey(),n.offset,"element"):r.is(e)&&n.set(e.getKey(),o+n.offset,"element"),l.is(t)?i.set(e.getKey(),i.offset,"element"):l.is(e)&&i.set(e.getKey(),o+i.offset,"element")}t.remove()}let N=null;function E(e){const t=void 0===window.TextEncoder?null:(null===N&&(N=new window.TextEncoder),N);if(null===t){const t=encodeURIComponent(e).match(/%[89ABab]/g);return e.length+(t?t.length:0)}return t.encode(e).length}function L({remainingCharacters:e}){return v("span",{className:"characters-limit "+(e<0?"characters-limit-exceeded":""),children:e})}function P({charset:t="UTF-16",maxLength:o=5,renderer:i=L}){const[s]=e(),[l,c]=n(o);return y(s,o,r((()=>({remainingCharacters:c,strlen:e=>{if("UTF-8"===t)return E(e);if("UTF-16"===t)return e.length;throw new Error("Unrecognized charset")}})),[t])),i({remainingCharacters:l})}export{P as CharacterLimitPlugin};
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useEffect as t,useState as n,useMemo as r}from"react";import{OverflowNode as o,$isOverflowNode as i,$createOverflowNode as s}from"@lexical/overflow";import{$rootTextContent as l}from"@lexical/text";import{mergeRegister as c,$dfs as a,$unwrapNode as f}from"@lexical/utils";import{DELETE_CHARACTER_COMMAND as g,$getSelection as m,$isRangeSelection as u,$isElementNode as d,COMMAND_PRIORITY_LOW as h,$isTextNode as p,$isLeafNode as x,$setSelection as C}from"lexical";import{jsx as S}from"react/jsx-runtime";function v(e,n,r=Object.freeze({})){const{strlen:s=(e=>e.length),remainingCharacters:S=(()=>{})}=r;t((()=>{e.hasNodes([o])||function(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.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.`)}(57)}),[e]),t((()=>{let t=e.getEditorState().read(l),r=0;return c(e.registerTextContentListener((e=>{t=e})),e.registerUpdateListener((({dirtyLeaves:o,dirtyElements:l})=>{const c=e.isComposing(),g=o.size>0||l.size>0;if(c||!g)return;const d=s(t),h=d>n||null!==r&&r>n;if(S(n-d),null===r||h){const r=function(e,t,n){const r=Intl.Segmenter;let o=0,i=0;if("function"==typeof r){const s=(new r).segment(e);for(const{segment:e}of s){const r=i+n(e);if(r>t)break;i=r,o+=e.length}}else{const r=Array.from(e),s=r.length;for(let e=0;e<s;e++){const s=r[e],l=i+n(s);if(l>t)break;i=l,o+=s.length}}return o}(t,n,s);e.update((()=>{!function(e){const t=a(),n=t.length;let r=0;for(let o=0;o<n;o+=1){const{node:n}=t[o];if(i(n)){const t=r;if(r+n.getTextContentSize()<=e){const e=n.getParent(),t=n.getPreviousSibling(),r=n.getNextSibling();f(n);const o=m();!u(o)||o.anchor.getNode().isAttached()&&o.focus.getNode().isAttached()||(p(t)?t.select():p(r)?r.select():null!==e&&e.select())}else if(t<e){const r=n.getFirstDescendant(),o=t+(null!==r?r.getTextContentSize():0);(p(r)&&r.isSimpleText()||o<=e)&&f(n)}}else if(x(n)){const t=r;if(r+=n.getTextContentSize(),r>e&&!i(n.getParent())){const r=m();let o;if(t<e&&p(n)&&n.isSimpleText()){const[,r]=n.splitText(e-t);o=w(r)}else o=w(n);null!==r&&C(r),T(o)}}}}(r)}),{tag:"history-merge"})}r=d})),e.registerCommand(g,(e=>{const t=m();if(!u(t))return!1;const n=t.anchor.getNode().getParent(),r=n?n.getParent():null,o=r?r.getNextSibling():null;return t.deleteCharacter(e),r&&r.isEmpty()?r.remove():d(o)&&o.isEmpty()&&o.remove(),!0}),h))}),[e,n,S,s])}function w(e){const t=s();return e.replace(t),t.append(e),t}function T(e){const t=e.getPreviousSibling();if(!i(t))return;const n=e.getFirstChild(),r=t.getChildren(),o=r.length;if(null===n)e.append(...r);else for(let e=0;e<o;e++)n.insertBefore(r[e]);const s=m();if(u(s)){const n=s.anchor,r=n.getNode(),i=s.focus,l=n.getNode();r.is(t)?n.set(e.getKey(),n.offset,"element"):r.is(e)&&n.set(e.getKey(),o+n.offset,"element"),l.is(t)?i.set(e.getKey(),i.offset,"element"):l.is(e)&&i.set(e.getKey(),o+i.offset,"element")}t.remove()}let y=null;function N(e){const t=void 0===window.TextEncoder?null:(null===y&&(y=new window.TextEncoder),y);if(null===t){const t=encodeURIComponent(e).match(/%[89ABab]/g);return e.length+(t?t.length:0)}return t.encode(e).length}function b({remainingCharacters:e}){return S("span",{className:"characters-limit "+(e<0?"characters-limit-exceeded":""),children:e})}function E({charset:t="UTF-16",maxLength:o=5,renderer:i=b}){const[s]=e(),[l,c]=n(o);return v(s,o,r((()=>({remainingCharacters:c,strlen:e=>{if("UTF-8"===t)return N(e);if("UTF-16"===t)return e.length;throw new Error("Unrecognized charset")}})),[t])),i({remainingCharacters:l})}export{E as CharacterLimitPlugin};
@@ -18,6 +18,12 @@ var react = require('react');
18
18
  *
19
19
  */
20
20
 
21
+ // Do not require this module directly! Use normal `invariant` calls.
22
+
23
+ function formatDevErrorMessage(message) {
24
+ throw new Error(message);
25
+ }
26
+
21
27
  const LexicalComposerContext = /*#__PURE__*/react.createContext(null);
22
28
  function createLexicalComposerContext(parent, theme) {
23
29
  let parentContext = null;
@@ -38,7 +44,7 @@ function useLexicalComposerContext() {
38
44
  const composerContext = react.useContext(LexicalComposerContext);
39
45
  if (composerContext == null) {
40
46
  {
41
- throw Error(`LexicalComposerContext.useLexicalComposerContext: cannot find a LexicalComposerContext`);
47
+ formatDevErrorMessage(`LexicalComposerContext.useLexicalComposerContext: cannot find a LexicalComposerContext`);
42
48
  }
43
49
  }
44
50
  return composerContext;
@@ -16,6 +16,12 @@ import { createContext, useContext } from 'react';
16
16
  *
17
17
  */
18
18
 
19
+ // Do not require this module directly! Use normal `invariant` calls.
20
+
21
+ function formatDevErrorMessage(message) {
22
+ throw new Error(message);
23
+ }
24
+
19
25
  const LexicalComposerContext = /*#__PURE__*/createContext(null);
20
26
  function createLexicalComposerContext(parent, theme) {
21
27
  let parentContext = null;
@@ -36,7 +42,7 @@ function useLexicalComposerContext() {
36
42
  const composerContext = useContext(LexicalComposerContext);
37
43
  if (composerContext == null) {
38
44
  {
39
- throw Error(`LexicalComposerContext.useLexicalComposerContext: cannot find a LexicalComposerContext`);
45
+ formatDevErrorMessage(`LexicalComposerContext.useLexicalComposerContext: cannot find a LexicalComposerContext`);
40
46
  }
41
47
  }
42
48
  return composerContext;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("react");function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r=t((function(e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(let e=1;e<arguments.length;e++)r.append("v",arguments[e]);throw t.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const n=e.createContext(null);exports.LexicalComposerContext=n,exports.createLexicalComposerContext=function(e,t){let r=null;return null!=e&&(r=e[1]),{getTheme:function(){return null!=t?t:null!=r?r.getTheme():null}}},exports.useLexicalComposerContext=function(){const t=e.useContext(n);return null==t&&r(8),t};
9
+ "use strict";var e=require("react");const n=e.createContext(null);exports.LexicalComposerContext=n,exports.createLexicalComposerContext=function(e,n){let t=null;return null!=e&&(t=e[1]),{getTheme:function(){return null!=n?n:null!=t?t.getTheme():null}}},exports.useLexicalComposerContext=function(){const t=e.useContext(n);return null==t&&function(e,...n){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of n)r.append("v",e);throw t.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),t};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{createContext as e,useContext as n}from"react";function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t=r((function(e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(let e=1;e<arguments.length;e++)r.append("v",arguments[e]);throw n.search=r.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.`)}));const l=e(null);function o(e,n){let r=null;return null!=e&&(r=e[1]),{getTheme:function(){return null!=n?n:null!=r?r.getTheme():null}}}function u(){const e=n(l);return null==e&&t(8),e}export{l as LexicalComposerContext,o as createLexicalComposerContext,u as useLexicalComposerContext};
9
+ import{createContext as n,useContext as e}from"react";const r=n(null);function t(n,e){let r=null;return null!=n&&(r=n[1]),{getTheme:function(){return null!=e?e:null!=r?r.getTheme():null}}}function o(){const n=e(r);return null==n&&function(n,...e){const r=new URL("https://lexical.dev/docs/error"),t=new URLSearchParams;t.append("code",n);for(const n of e)t.append("v",n);throw r.search=t.toString(),Error(`Minified Lexical error #${n}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),n}export{r as LexicalComposerContext,t as createLexicalComposerContext,o as useLexicalComposerContext};
@@ -56,7 +56,7 @@ function HorizontalRuleComponent({
56
56
  }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected]);
57
57
  react.useEffect(() => {
58
58
  const hrElem = editor.getElementByKey(nodeKey);
59
- const isSelectedClassName = 'selected';
59
+ const isSelectedClassName = editor._config.theme.hrSelected ?? 'selected';
60
60
  if (hrElem !== null) {
61
61
  if (isSelected) {
62
62
  utils.addClassNamesToElement(hrElem, isSelectedClassName);
@@ -54,7 +54,7 @@ function HorizontalRuleComponent({
54
54
  }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected]);
55
55
  useEffect(() => {
56
56
  const hrElem = editor.getElementByKey(nodeKey);
57
- const isSelectedClassName = 'selected';
57
+ const isSelectedClassName = editor._config.theme.hrSelected ?? 'selected';
58
58
  if (hrElem !== null) {
59
59
  if (isSelected) {
60
60
  addClassNamesToElement(hrElem, isSelectedClassName);
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("@lexical/react/useLexicalNodeSelection"),r=require("@lexical/utils"),n=require("lexical"),o=require("react"),s=require("react/jsx-runtime");const a=n.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");function c({nodeKey:s}){const[a]=e.useLexicalComposerContext(),[c,i,l]=t.useLexicalNodeSelection(s),u=o.useCallback((e=>{const t=n.$getSelection();return c&&n.$isNodeSelection(t)&&(e.preventDefault(),t.getNodes().forEach((e=>{m(e)&&e.remove()}))),!1}),[c]);return o.useEffect((()=>r.mergeRegister(a.registerCommand(n.CLICK_COMMAND,(e=>{const t=a.getElementByKey(s);return e.target===t&&(e.shiftKey||l(),i(!c),!0)}),n.COMMAND_PRIORITY_LOW),a.registerCommand(n.KEY_DELETE_COMMAND,u,n.COMMAND_PRIORITY_LOW),a.registerCommand(n.KEY_BACKSPACE_COMMAND,u,n.COMMAND_PRIORITY_LOW))),[l,a,c,s,u,i]),o.useEffect((()=>{const e=a.getElementByKey(s),t="selected";null!==e&&(c?r.addClassNamesToElement(e,t):r.removeClassNamesFromElement(e,t))}),[a,c,s]),null}class i extends n.DecoratorNode{static getType(){return"horizontalrule"}static clone(e){return new i(e.__key)}static importJSON(e){return u().updateFromJSON(e)}static importDOM(){return{hr:()=>({conversion:l,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(e){const t=document.createElement("hr");return r.addClassNamesToElement(t,e.theme.hr),t}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}decorate(){return s.jsx(c,{nodeKey:this.__key})}}function l(){return{node:u()}}function u(){return n.$applyNodeReplacement(new i)}function m(e){return e instanceof i}exports.$createHorizontalRuleNode=u,exports.$isHorizontalRuleNode=m,exports.HorizontalRuleNode=i,exports.INSERT_HORIZONTAL_RULE_COMMAND=a;
9
+ "use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("@lexical/react/useLexicalNodeSelection"),r=require("@lexical/utils"),n=require("lexical"),o=require("react"),c=require("react/jsx-runtime");const s=n.createCommand("INSERT_HORIZONTAL_RULE_COMMAND");function a({nodeKey:c}){const[s]=e.useLexicalComposerContext(),[a,i,l]=t.useLexicalNodeSelection(c),u=o.useCallback((e=>{const t=n.$getSelection();return a&&n.$isNodeSelection(t)&&(e.preventDefault(),t.getNodes().forEach((e=>{m(e)&&e.remove()}))),!1}),[a]);return o.useEffect((()=>r.mergeRegister(s.registerCommand(n.CLICK_COMMAND,(e=>{const t=s.getElementByKey(c);return e.target===t&&(e.shiftKey||l(),i(!a),!0)}),n.COMMAND_PRIORITY_LOW),s.registerCommand(n.KEY_DELETE_COMMAND,u,n.COMMAND_PRIORITY_LOW),s.registerCommand(n.KEY_BACKSPACE_COMMAND,u,n.COMMAND_PRIORITY_LOW))),[l,s,a,c,u,i]),o.useEffect((()=>{const e=s.getElementByKey(c),t=s._config.theme.hrSelected??"selected";null!==e&&(a?r.addClassNamesToElement(e,t):r.removeClassNamesFromElement(e,t))}),[s,a,c]),null}class i extends n.DecoratorNode{static getType(){return"horizontalrule"}static clone(e){return new i(e.__key)}static importJSON(e){return u().updateFromJSON(e)}static importDOM(){return{hr:()=>({conversion:l,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(e){const t=document.createElement("hr");return r.addClassNamesToElement(t,e.theme.hr),t}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}decorate(){return c.jsx(a,{nodeKey:this.__key})}}function l(){return{node:u()}}function u(){return n.$applyNodeReplacement(new i)}function m(e){return e instanceof i}exports.$createHorizontalRuleNode=u,exports.$isHorizontalRuleNode=m,exports.HorizontalRuleNode=i,exports.INSERT_HORIZONTAL_RULE_COMMAND=s;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLexicalNodeSelection as t}from"@lexical/react/useLexicalNodeSelection";import{addClassNamesToElement as r,mergeRegister as n,removeClassNamesFromElement as o}from"@lexical/utils";import{createCommand as c,DecoratorNode as i,$applyNodeReplacement as m,$getSelection as u,$isNodeSelection as a,CLICK_COMMAND as l,COMMAND_PRIORITY_LOW as s,KEY_DELETE_COMMAND as p,KEY_BACKSPACE_COMMAND as d}from"lexical";import{useCallback as f,useEffect as x}from"react";import{jsx as y}from"react/jsx-runtime";const g=c("INSERT_HORIZONTAL_RULE_COMMAND");function h({nodeKey:c}){const[i]=e(),[m,y,g]=t(c),h=f((e=>{const t=u();return m&&a(t)&&(e.preventDefault(),t.getNodes().forEach((e=>{N(e)&&e.remove()}))),!1}),[m]);return x((()=>n(i.registerCommand(l,(e=>{const t=i.getElementByKey(c);return e.target===t&&(e.shiftKey||g(),y(!m),!0)}),s),i.registerCommand(p,h,s),i.registerCommand(d,h,s))),[g,i,m,c,h,y]),x((()=>{const e=i.getElementByKey(c),t="selected";null!==e&&(m?r(e,t):o(e,t))}),[i,m,c]),null}class O extends i{static getType(){return"horizontalrule"}static clone(e){return new O(e.__key)}static importJSON(e){return E().updateFromJSON(e)}static importDOM(){return{hr:()=>({conversion:C,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(e){const t=document.createElement("hr");return r(t,e.theme.hr),t}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}decorate(){return y(h,{nodeKey:this.__key})}}function C(){return{node:E()}}function E(){return m(new O)}function N(e){return e instanceof O}export{E as $createHorizontalRuleNode,N as $isHorizontalRuleNode,O as HorizontalRuleNode,g as INSERT_HORIZONTAL_RULE_COMMAND};
9
+ import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useLexicalNodeSelection as t}from"@lexical/react/useLexicalNodeSelection";import{addClassNamesToElement as r,mergeRegister as n,removeClassNamesFromElement as o}from"@lexical/utils";import{createCommand as c,DecoratorNode as i,$applyNodeReplacement as m,$getSelection as u,$isNodeSelection as a,CLICK_COMMAND as l,COMMAND_PRIORITY_LOW as s,KEY_DELETE_COMMAND as d,KEY_BACKSPACE_COMMAND as p}from"lexical";import{useCallback as f,useEffect as x}from"react";import{jsx as h}from"react/jsx-runtime";const y=c("INSERT_HORIZONTAL_RULE_COMMAND");function g({nodeKey:c}){const[i]=e(),[m,h,y]=t(c),g=f((e=>{const t=u();return m&&a(t)&&(e.preventDefault(),t.getNodes().forEach((e=>{E(e)&&e.remove()}))),!1}),[m]);return x((()=>n(i.registerCommand(l,(e=>{const t=i.getElementByKey(c);return e.target===t&&(e.shiftKey||y(),h(!m),!0)}),s),i.registerCommand(d,g,s),i.registerCommand(p,g,s))),[y,i,m,c,g,h]),x((()=>{const e=i.getElementByKey(c),t=i._config.theme.hrSelected??"selected";null!==e&&(m?r(e,t):o(e,t))}),[i,m,c]),null}class O extends i{static getType(){return"horizontalrule"}static clone(e){return new O(e.__key)}static importJSON(e){return C().updateFromJSON(e)}static importDOM(){return{hr:()=>({conversion:_,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(e){const t=document.createElement("hr");return r(t,e.theme.hr),t}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}decorate(){return h(g,{nodeKey:this.__key})}}function _(){return{node:C()}}function C(){return m(new O)}function E(e){return e instanceof O}export{C as $createHorizontalRuleNode,E as $isHorizontalRuleNode,O as HorizontalRuleNode,y as INSERT_HORIZONTAL_RULE_COMMAND};
@@ -21,6 +21,12 @@ var jsxRuntime = require('react/jsx-runtime');
21
21
  *
22
22
  */
23
23
 
24
+ // Do not require this module directly! Use normal `invariant` calls.
25
+
26
+ function formatDevErrorMessage(message) {
27
+ throw new Error(message);
28
+ }
29
+
24
30
  function getTransformSetFromKlass(klass) {
25
31
  const transform = klass.transform();
26
32
  return transform !== null ? new Set([transform]) : new Set();
@@ -36,7 +42,7 @@ function LexicalNestedComposer({
36
42
  const parentContext = react.useContext(LexicalComposerContext.LexicalComposerContext);
37
43
  if (parentContext == null) {
38
44
  {
39
- throw Error(`Unexpected parent context null on a nested composer`);
45
+ formatDevErrorMessage(`Unexpected parent context null on a nested composer`);
40
46
  }
41
47
  }
42
48
  const [parentEditor, {
@@ -19,6 +19,12 @@ import { jsx } from 'react/jsx-runtime';
19
19
  *
20
20
  */
21
21
 
22
+ // Do not require this module directly! Use normal `invariant` calls.
23
+
24
+ function formatDevErrorMessage(message) {
25
+ throw new Error(message);
26
+ }
27
+
22
28
  function getTransformSetFromKlass(klass) {
23
29
  const transform = klass.transform();
24
30
  return transform !== null ? new Set([transform]) : new Set();
@@ -34,7 +40,7 @@ function LexicalNestedComposer({
34
40
  const parentContext = useContext(LexicalComposerContext);
35
41
  if (parentContext == null) {
36
42
  {
37
- throw Error(`Unexpected parent context null on a nested composer`);
43
+ formatDevErrorMessage(`Unexpected parent context null on a nested composer`);
38
44
  }
39
45
  }
40
46
  const [parentEditor, {
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/react/LexicalCollaborationContext"),t=require("@lexical/react/LexicalComposerContext"),r=require("react"),o=require("react/jsx-runtime");function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s=n((function(e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(let e=1;e<arguments.length;e++)r.append("v",arguments[e]);throw t.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function l(e){const t=e.transform();return null!==t?new Set([t]):new Set}exports.LexicalNestedComposer=function({initialEditor:n,children:i,initialNodes:a,initialTheme:c,skipCollabChecks:u}){const p=r.useRef(!1),d=r.useContext(t.LexicalComposerContext);null==d&&s(9);const[f,{getTheme:x}]=d,h=r.useMemo((()=>{const e=c||x()||void 0,r=t.createLexicalComposerContext(d,e);if(void 0!==e&&(n._config.theme=e),n._parentEditor=f,a)for(let e of a){let t=null,r=null;if("function"!=typeof e){const o=e;e=o.replace,t=o.with,r=o.withKlass||null}const o=n._nodes.get(e.getType());n._nodes.set(e.getType(),{exportDOM:o?o.exportDOM:void 0,klass:e,replace:t,replaceWithKlass:r,transforms:l(e)})}else{const e=n._nodes=new Map(f._nodes);for(const[t,r]of e)n._nodes.set(t,{exportDOM:r.exportDOM,klass:r.klass,replace:r.replace,replaceWithKlass:r.replaceWithKlass,transforms:l(r.klass)})}return n._config.namespace=f._config.namespace,n._editable=f._editable,[n,r]}),[]),{isCollabActive:m,yjsDocMap:C}=e.useCollaborationContext(),g=u||p.current||C.has(n.getKey());return r.useEffect((()=>{g&&(p.current=!0)}),[g]),r.useEffect((()=>f.registerEditableListener((e=>{n.setEditable(e)}))),[n,f]),o.jsx(t.LexicalComposerContext.Provider,{value:h,children:!m||g?i:null})};
9
+ "use strict";var e=require("@lexical/react/LexicalCollaborationContext"),t=require("@lexical/react/LexicalComposerContext"),r=require("react"),o=require("react/jsx-runtime");function n(e){const t=e.transform();return null!==t?new Set([t]):new Set}exports.LexicalNestedComposer=function({initialEditor:s,children:i,initialNodes:l,initialTheme:a,skipCollabChecks:c}){const p=r.useRef(!1),u=r.useContext(t.LexicalComposerContext);null==u&&function(e,...t){const r=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw r.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(9);const[f,{getTheme:d}]=u,x=r.useMemo((()=>{const e=a||d()||void 0,r=t.createLexicalComposerContext(u,e);if(void 0!==e&&(s._config.theme=e),s._parentEditor=f,l)for(let e of l){let t=null,r=null;if("function"!=typeof e){const o=e;e=o.replace,t=o.with,r=o.withKlass||null}const o=s._nodes.get(e.getType());s._nodes.set(e.getType(),{exportDOM:o?o.exportDOM:void 0,klass:e,replace:t,replaceWithKlass:r,transforms:n(e)})}else{const e=s._nodes=new Map(f._nodes);for(const[t,r]of e)s._nodes.set(t,{exportDOM:r.exportDOM,klass:r.klass,replace:r.replace,replaceWithKlass:r.replaceWithKlass,transforms:n(r.klass)})}return s._config.namespace=f._config.namespace,s._editable=f._editable,[s,r]}),[]),{isCollabActive:h,yjsDocMap:m}=e.useCollaborationContext(),C=c||p.current||m.has(s.getKey());return r.useEffect((()=>{C&&(p.current=!0)}),[C]),r.useEffect((()=>f.registerEditableListener((e=>{s.setEditable(e)}))),[s,f]),o.jsx(t.LexicalComposerContext.Provider,{value:x,children:!h||C?i:null})};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useCollaborationContext as e}from"@lexical/react/LexicalCollaborationContext";import{LexicalComposerContext as t,createLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import{useRef as o,useContext as n,useMemo as l,useEffect as i}from"react";import{jsx as a}from"react/jsx-runtime";function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c=s((function(e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(let e=1;e<arguments.length;e++)r.append("v",arguments[e]);throw t.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));function p(e){const t=e.transform();return null!==t?new Set([t]):new Set}function d({initialEditor:s,children:d,initialNodes:f,initialTheme:u,skipCollabChecks:m}){const h=o(!1),g=n(t);null==g&&c(9);const[x,{getTheme:_}]=g,v=l((()=>{const e=u||_()||void 0,t=r(g,e);if(void 0!==e&&(s._config.theme=e),s._parentEditor=x,f)for(let e of f){let t=null,r=null;if("function"!=typeof e){const o=e;e=o.replace,t=o.with,r=o.withKlass||null}const o=s._nodes.get(e.getType());s._nodes.set(e.getType(),{exportDOM:o?o.exportDOM:void 0,klass:e,replace:t,replaceWithKlass:r,transforms:p(e)})}else{const e=s._nodes=new Map(x._nodes);for(const[t,r]of e)s._nodes.set(t,{exportDOM:r.exportDOM,klass:r.klass,replace:r.replace,replaceWithKlass:r.replaceWithKlass,transforms:p(r.klass)})}return s._config.namespace=x._config.namespace,s._editable=x._editable,[s,t]}),[]),{isCollabActive:w,yjsDocMap:b}=e(),M=m||h.current||b.has(s.getKey());return i((()=>{M&&(h.current=!0)}),[M]),i((()=>x.registerEditableListener((e=>{s.setEditable(e)}))),[s,x]),a(t.Provider,{value:v,children:!w||M?d:null})}export{d as LexicalNestedComposer};
9
+ import{useCollaborationContext as e}from"@lexical/react/LexicalCollaborationContext";import{LexicalComposerContext as t,createLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import{useRef as o,useContext as n,useMemo as i,useEffect as l}from"react";import{jsx as s}from"react/jsx-runtime";function a(e){const t=e.transform();return null!==t?new Set([t]):new Set}function c({initialEditor:c,children:p,initialNodes:f,initialTheme:d,skipCollabChecks:m}){const u=o(!1),h=n(t);null==h&&function(e,...t){const r=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw r.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(9);const[x,{getTheme:g}]=h,v=i((()=>{const e=d||g()||void 0,t=r(h,e);if(void 0!==e&&(c._config.theme=e),c._parentEditor=x,f)for(let e of f){let t=null,r=null;if("function"!=typeof e){const o=e;e=o.replace,t=o.with,r=o.withKlass||null}const o=c._nodes.get(e.getType());c._nodes.set(e.getType(),{exportDOM:o?o.exportDOM:void 0,klass:e,replace:t,replaceWithKlass:r,transforms:a(e)})}else{const e=c._nodes=new Map(x._nodes);for(const[t,r]of e)c._nodes.set(t,{exportDOM:r.exportDOM,klass:r.klass,replace:r.replace,replaceWithKlass:r.replaceWithKlass,transforms:a(r.klass)})}return c._config.namespace=x._config.namespace,c._editable=x._editable,[c,t]}),[]),{isCollabActive:_,yjsDocMap:w}=e(),b=m||u.current||w.has(c.getKey());return l((()=>{b&&(u.current=!0)}),[b]),l((()=>x.registerEditableListener((e=>{c.setEditable(e)}))),[c,x]),s(t.Provider,{value:v,children:!_||b?p:null})}export{c as LexicalNestedComposer};
package/package.json CHANGED
@@ -8,27 +8,27 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.26.0",
11
+ "version": "0.27.0",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.26.0",
14
- "@lexical/code": "0.26.0",
15
- "@lexical/devtools-core": "0.26.0",
16
- "@lexical/dragon": "0.26.0",
17
- "@lexical/hashtag": "0.26.0",
18
- "@lexical/history": "0.26.0",
19
- "@lexical/link": "0.26.0",
20
- "@lexical/list": "0.26.0",
21
- "@lexical/mark": "0.26.0",
22
- "@lexical/markdown": "0.26.0",
23
- "@lexical/overflow": "0.26.0",
24
- "@lexical/plain-text": "0.26.0",
25
- "@lexical/rich-text": "0.26.0",
26
- "@lexical/selection": "0.26.0",
27
- "@lexical/table": "0.26.0",
28
- "@lexical/text": "0.26.0",
29
- "@lexical/utils": "0.26.0",
30
- "@lexical/yjs": "0.26.0",
31
- "lexical": "0.26.0",
13
+ "@lexical/clipboard": "0.27.0",
14
+ "@lexical/code": "0.27.0",
15
+ "@lexical/devtools-core": "0.27.0",
16
+ "@lexical/dragon": "0.27.0",
17
+ "@lexical/hashtag": "0.27.0",
18
+ "@lexical/history": "0.27.0",
19
+ "@lexical/link": "0.27.0",
20
+ "@lexical/list": "0.27.0",
21
+ "@lexical/mark": "0.27.0",
22
+ "@lexical/markdown": "0.27.0",
23
+ "@lexical/overflow": "0.27.0",
24
+ "@lexical/plain-text": "0.27.0",
25
+ "@lexical/rich-text": "0.27.0",
26
+ "@lexical/selection": "0.27.0",
27
+ "@lexical/table": "0.27.0",
28
+ "@lexical/text": "0.27.0",
29
+ "@lexical/utils": "0.27.0",
30
+ "@lexical/yjs": "0.27.0",
31
+ "lexical": "0.27.0",
32
32
  "react-error-boundary": "^3.1.4"
33
33
  },
34
34
  "peerDependencies": {