@lexical/react
Advanced tools
Comparing version 0.17.1-nightly.20240813.0 to 0.17.1-nightly.20240814.0
@@ -12,3 +12,2 @@ /** | ||
export type InitialConfigType = Readonly<{ | ||
editor__DEPRECATED?: LexicalEditor | null; | ||
namespace: string; | ||
@@ -15,0 +14,0 @@ nodes?: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>; |
@@ -59,3 +59,2 @@ /** | ||
namespace, | ||
editor__DEPRECATED: initialEditor, | ||
nodes, | ||
@@ -67,15 +66,11 @@ onError, | ||
const context = LexicalComposerContext.createLexicalComposerContext(null, theme); | ||
let editor = initialEditor || null; | ||
if (editor === null) { | ||
const newEditor = lexical.createEditor({ | ||
editable: initialConfig.editable, | ||
html, | ||
namespace, | ||
nodes, | ||
onError: error => onError(error, newEditor), | ||
theme | ||
}); | ||
initializeEditor(newEditor, initialEditorState); | ||
editor = newEditor; | ||
} | ||
const editor = lexical.createEditor({ | ||
editable: initialConfig.editable, | ||
html, | ||
namespace, | ||
nodes, | ||
onError: error => onError(error, editor), | ||
theme | ||
}); | ||
initializeEditor(editor, initialEditorState); | ||
return [editor, context]; | ||
@@ -82,0 +77,0 @@ }, |
@@ -9,4 +9,4 @@ /** | ||
'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("lexical"),g=require("react"),m=require("react/jsx-runtime");let n="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,p=n?g.useLayoutEffect:g.useEffect,q={tag:"history-merge"}; | ||
function r(a,c){if(null!==c)if(void 0===c)a.update(()=>{var b=f.$getRoot();if(b.isEmpty()){let d=f.$createParagraphNode();b.append(d);b=n?document.activeElement:null;(null!==f.$getSelection()||null!==b&&b===a.getRootElement())&&d.select()}},q);else if(null!==c)switch(typeof c){case "string":let b=a.parseEditorState(c);a.setEditorState(b,q);break;case "object":a.setEditorState(c,q);break;case "function":a.update(()=>{f.$getRoot().isEmpty()&&c(a)},q)}} | ||
exports.LexicalComposer=function({initialConfig:a,children:c}){let b=g.useMemo(()=>{const {theme:d,namespace:h,editor__DEPRECATED:t,nodes:u,onError:v,editorState:w,html:x}=a,y=e.createLexicalComposerContext(null,d);let k=t||null;if(null===k){const l=f.createEditor({editable:a.editable,html:x,namespace:h,nodes:u,onError:z=>v(z,l),theme:d});r(l,w);k=l}return[k,y]},[]);p(()=>{let d=a.editable,[h]=b;h.setEditable(void 0!==d?d:!0)},[]);return m.jsx(e.LexicalComposerContext.Provider,{value:b,children:c})} | ||
'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("lexical"),g=require("react"),l=require("react/jsx-runtime");let m="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,n=m?g.useLayoutEffect:g.useEffect,p={tag:"history-merge"}; | ||
function q(a,c){if(null!==c)if(void 0===c)a.update(()=>{var b=f.$getRoot();if(b.isEmpty()){let d=f.$createParagraphNode();b.append(d);b=m?document.activeElement:null;(null!==f.$getSelection()||null!==b&&b===a.getRootElement())&&d.select()}},p);else if(null!==c)switch(typeof c){case "string":let b=a.parseEditorState(c);a.setEditorState(b,p);break;case "object":a.setEditorState(c,p);break;case "function":a.update(()=>{f.$getRoot().isEmpty()&&c(a)},p)}} | ||
exports.LexicalComposer=function({initialConfig:a,children:c}){let b=g.useMemo(()=>{const {theme:d,namespace:h,nodes:r,onError:t,editorState:u,html:v}=a,w=e.createLexicalComposerContext(null,d),k=f.createEditor({editable:a.editable,html:v,namespace:h,nodes:r,onError:x=>t(x,k),theme:d});q(k,u);return[k,w]},[]);n(()=>{let d=a.editable,[h]=b;h.setEditable(void 0!==d?d:!0)},[]);return l.jsx(e.LexicalComposerContext.Provider,{value:b,children:c})} |
@@ -10,6 +10,3 @@ /** | ||
import type { Props as ElementProps } from './shared/LexicalContentEditableElement'; | ||
import type { LexicalEditor } from 'lexical'; | ||
export type Props = Omit<ElementProps, 'editor'> & { | ||
editor__DEPRECATED?: LexicalEditor; | ||
} & ({ | ||
export type Props = Omit<ElementProps, 'editor'> & ({ | ||
'aria-placeholder'?: void; | ||
@@ -16,0 +13,0 @@ placeholder?: null; |
@@ -177,8 +177,5 @@ /** | ||
placeholder, | ||
editor__DEPRECATED, | ||
...rest | ||
} = props; | ||
// editor__DEPRECATED will always be defined for non MLC surfaces | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
const editor = editor__DEPRECATED || LexicalComposerContext.useLexicalComposerContext()[0]; | ||
const [editor] = LexicalComposerContext.useLexicalComposerContext(); | ||
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, { | ||
@@ -185,0 +182,0 @@ children: [/*#__PURE__*/jsxRuntime.jsx(ContentEditableElement, { |
@@ -9,7 +9,6 @@ /** | ||
'use strict';var d=require("@lexical/react/LexicalComposerContext"),h=require("react"),m=require("react/jsx-runtime"),t=require("@lexical/text"),u=require("@lexical/utils");let v="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;function w(...a){return c=>{a.forEach(b=>{"function"===typeof b?b(c):null!=b&&(b.current=c)})}} | ||
let x=h.forwardRef(function({editor:a,ariaActiveDescendant:c,ariaAutoComplete:b,ariaControls:e,ariaDescribedBy:f,ariaExpanded:l,ariaLabel:y,ariaLabelledBy:z,ariaMultiline:A,ariaOwns:B,ariaRequired:C,autoCapitalize:D,className:E,id:F,role:n="textbox",spellCheck:G=!0,style:H,tabIndex:I,"data-testid":J,...K},p){let [g,q]=h.useState(a.isEditable()),r=h.useCallback(k=>{k&&k.ownerDocument&&k.ownerDocument.defaultView?a.setRootElement(k):a.setRootElement(null)},[a]),L=h.useMemo(()=>w(p,r),[r,p]);v(()=>{q(a.isEditable()); | ||
return a.registerEditableListener(k=>{q(k)})},[a]);return m.jsx("div",{...K,"aria-activedescendant":g?c:void 0,"aria-autocomplete":g?b:"none","aria-controls":g?e:void 0,"aria-describedby":f,"aria-expanded":g&&"combobox"===n?!!l:void 0,"aria-label":y,"aria-labelledby":z,"aria-multiline":A,"aria-owns":g?B:void 0,"aria-readonly":g?void 0:!0,"aria-required":C,autoCapitalize:D,className:E,contentEditable:g,"data-testid":J,id:F,ref:L,role:g?n:void 0,spellCheck:G,style:H,tabIndex:I})}); | ||
function M(a){return a.getEditorState().read(t.$canShowPlaceholderCurry(a.isComposing()))}function N(a){let [c,b]=h.useState(()=>M(a));v(()=>{function e(){let f=M(a);b(f)}e();return u.mergeRegister(a.registerUpdateListener(()=>{e()}),a.registerEditableListener(()=>{e()}))},[a]);return c}let P=h.forwardRef(O); | ||
function O(a,c){let {placeholder:b,editor__DEPRECATED:e,...f}=a;a=e||d.useLexicalComposerContext()[0];return m.jsxs(m.Fragment,{children:[m.jsx(x,{editor:a,...f,ref:c}),null!=b&&m.jsx(Q,{editor:a,content:b})]})} | ||
function Q({content:a,editor:c}){var b=N(c);let [e,f]=h.useState(c.isEditable());h.useLayoutEffect(()=>{f(c.isEditable());return c.registerEditableListener(l=>{f(l)})},[c]);if(!b)return null;b=null;"function"===typeof a?b=a(e):null!==a&&(b=a);return null===b?null:m.jsx("div",{"aria-hidden":!0,children:b})}exports.ContentEditable=P | ||
'use strict';var d=require("@lexical/react/LexicalComposerContext"),g=require("react"),m=require("react/jsx-runtime"),t=require("@lexical/text"),u=require("@lexical/utils");let v="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect;function w(...a){return c=>{a.forEach(b=>{"function"===typeof b?b(c):null!=b&&(b.current=c)})}} | ||
let x=g.forwardRef(function({editor:a,ariaActiveDescendant:c,ariaAutoComplete:b,ariaControls:e,ariaDescribedBy:h,ariaExpanded:l,ariaLabel:y,ariaLabelledBy:z,ariaMultiline:A,ariaOwns:B,ariaRequired:C,autoCapitalize:D,className:E,id:F,role:n="textbox",spellCheck:G=!0,style:H,tabIndex:I,"data-testid":J,...K},p){let [f,q]=g.useState(a.isEditable()),r=g.useCallback(k=>{k&&k.ownerDocument&&k.ownerDocument.defaultView?a.setRootElement(k):a.setRootElement(null)},[a]),L=g.useMemo(()=>w(p,r),[r,p]);v(()=>{q(a.isEditable()); | ||
return a.registerEditableListener(k=>{q(k)})},[a]);return m.jsx("div",{...K,"aria-activedescendant":f?c:void 0,"aria-autocomplete":f?b:"none","aria-controls":f?e:void 0,"aria-describedby":h,"aria-expanded":f&&"combobox"===n?!!l:void 0,"aria-label":y,"aria-labelledby":z,"aria-multiline":A,"aria-owns":f?B:void 0,"aria-readonly":f?void 0:!0,"aria-required":C,autoCapitalize:D,className:E,contentEditable:f,"data-testid":J,id:F,ref:L,role:f?n:void 0,spellCheck:G,style:H,tabIndex:I})}); | ||
function M(a){return a.getEditorState().read(t.$canShowPlaceholderCurry(a.isComposing()))}function N(a){let [c,b]=g.useState(()=>M(a));v(()=>{function e(){let h=M(a);b(h)}e();return u.mergeRegister(a.registerUpdateListener(()=>{e()}),a.registerEditableListener(()=>{e()}))},[a]);return c}let P=g.forwardRef(O);function O(a,c){let {placeholder:b,...e}=a;[a]=d.useLexicalComposerContext();return m.jsxs(m.Fragment,{children:[m.jsx(x,{editor:a,...e,ref:c}),null!=b&&m.jsx(Q,{editor:a,content:b})]})} | ||
function Q({content:a,editor:c}){var b=N(c);let [e,h]=g.useState(c.isEditable());g.useLayoutEffect(()=>{h(c.isEditable());return c.registerEditableListener(l=>{h(l)})},[c]);if(!b)return null;b=null;"function"===typeof a?b=a(e):null!==a&&(b=a);return null===b?null:m.jsx("div",{"aria-hidden":!0,children:b})}exports.ContentEditable=P |
@@ -11,23 +11,23 @@ { | ||
"license": "MIT", | ||
"version": "0.17.1-nightly.20240813.0", | ||
"version": "0.17.1-nightly.20240814.0", | ||
"dependencies": { | ||
"@lexical/clipboard": "0.17.1-nightly.20240813.0", | ||
"@lexical/code": "0.17.1-nightly.20240813.0", | ||
"@lexical/devtools-core": "0.17.1-nightly.20240813.0", | ||
"@lexical/dragon": "0.17.1-nightly.20240813.0", | ||
"@lexical/hashtag": "0.17.1-nightly.20240813.0", | ||
"@lexical/history": "0.17.1-nightly.20240813.0", | ||
"@lexical/link": "0.17.1-nightly.20240813.0", | ||
"@lexical/list": "0.17.1-nightly.20240813.0", | ||
"@lexical/mark": "0.17.1-nightly.20240813.0", | ||
"@lexical/markdown": "0.17.1-nightly.20240813.0", | ||
"@lexical/overflow": "0.17.1-nightly.20240813.0", | ||
"@lexical/plain-text": "0.17.1-nightly.20240813.0", | ||
"@lexical/rich-text": "0.17.1-nightly.20240813.0", | ||
"@lexical/selection": "0.17.1-nightly.20240813.0", | ||
"@lexical/table": "0.17.1-nightly.20240813.0", | ||
"@lexical/text": "0.17.1-nightly.20240813.0", | ||
"@lexical/utils": "0.17.1-nightly.20240813.0", | ||
"@lexical/yjs": "0.17.1-nightly.20240813.0", | ||
"lexical": "0.17.1-nightly.20240813.0", | ||
"@lexical/clipboard": "0.17.1-nightly.20240814.0", | ||
"@lexical/code": "0.17.1-nightly.20240814.0", | ||
"@lexical/devtools-core": "0.17.1-nightly.20240814.0", | ||
"@lexical/dragon": "0.17.1-nightly.20240814.0", | ||
"@lexical/hashtag": "0.17.1-nightly.20240814.0", | ||
"@lexical/history": "0.17.1-nightly.20240814.0", | ||
"@lexical/link": "0.17.1-nightly.20240814.0", | ||
"@lexical/list": "0.17.1-nightly.20240814.0", | ||
"@lexical/mark": "0.17.1-nightly.20240814.0", | ||
"@lexical/markdown": "0.17.1-nightly.20240814.0", | ||
"@lexical/overflow": "0.17.1-nightly.20240814.0", | ||
"@lexical/plain-text": "0.17.1-nightly.20240814.0", | ||
"@lexical/rich-text": "0.17.1-nightly.20240814.0", | ||
"@lexical/selection": "0.17.1-nightly.20240814.0", | ||
"@lexical/table": "0.17.1-nightly.20240814.0", | ||
"@lexical/text": "0.17.1-nightly.20240814.0", | ||
"@lexical/utils": "0.17.1-nightly.20240814.0", | ||
"@lexical/yjs": "0.17.1-nightly.20240814.0", | ||
"lexical": "0.17.1-nightly.20240814.0", | ||
"react-error-boundary": "^3.1.4" | ||
@@ -34,0 +34,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
826697
16245
+ Added@lexical/clipboard@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/code@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/devtools-core@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/dragon@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/hashtag@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/history@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/html@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/link@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/list@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/mark@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/markdown@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/offset@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/overflow@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/plain-text@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/rich-text@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/selection@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/table@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/text@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/utils@0.17.1-nightly.20240814.0(transitive)
+ Added@lexical/yjs@0.17.1-nightly.20240814.0(transitive)
+ Addedlexical@0.17.1-nightly.20240814.0(transitive)
- Removed@lexical/clipboard@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/code@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/devtools-core@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/dragon@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/hashtag@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/history@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/html@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/link@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/list@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/mark@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/markdown@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/offset@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/overflow@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/plain-text@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/rich-text@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/selection@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/table@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/text@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/utils@0.17.1-nightly.20240813.0(transitive)
- Removed@lexical/yjs@0.17.1-nightly.20240813.0(transitive)
- Removedlexical@0.17.1-nightly.20240813.0(transitive)