@lexical/react 0.3.4 → 0.3.7

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 (42) hide show
  1. package/DEPRECATED_useLexical.d.ts +1 -2
  2. package/DEPRECATED_useLexical.dev.js +18 -9
  3. package/DEPRECATED_useLexical.prod.js +2 -3
  4. package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +18 -9
  5. package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +2 -2
  6. package/DEPRECATED_useLexicalCharacterLimit.prod.js +3 -3
  7. package/DEPRECATED_useLexicalEditor.dev.js +18 -9
  8. package/DEPRECATED_useLexicalEditor.prod.js +2 -2
  9. package/LexicalAutoFocusPlugin.d.ts +5 -1
  10. package/LexicalAutoFocusPlugin.dev.js +7 -3
  11. package/LexicalAutoFocusPlugin.js.flow +5 -1
  12. package/LexicalAutoFocusPlugin.prod.js +1 -1
  13. package/LexicalAutoLinkPlugin.d.ts +1 -1
  14. package/LexicalAutoLinkPlugin.prod.js +3 -3
  15. package/LexicalAutoScrollPlugin.d.ts +1 -1
  16. package/LexicalBlockWithAlignableContents.d.ts +2 -1
  17. package/LexicalBlockWithAlignableContents.dev.js +3 -4
  18. package/LexicalBlockWithAlignableContents.prod.js +2 -2
  19. package/LexicalCharacterLimitPlugin.prod.js +3 -3
  20. package/LexicalCheckListPlugin.dev.js +11 -6
  21. package/LexicalCheckListPlugin.prod.js +7 -7
  22. package/LexicalClearEditorPlugin.d.ts +1 -1
  23. package/LexicalComposer.d.ts +2 -2
  24. package/LexicalComposer.js.flow +5 -0
  25. package/LexicalComposerContext.prod.js +2 -1
  26. package/LexicalContentEditable.dev.js +3 -3
  27. package/LexicalContentEditable.prod.js +1 -1
  28. package/LexicalDecoratorBlockNode.d.ts +2 -2
  29. package/LexicalDecoratorBlockNode.dev.js +1 -1
  30. package/LexicalDecoratorBlockNode.prod.js +1 -1
  31. package/LexicalHashtagPlugin.d.ts +1 -1
  32. package/LexicalNestedComposer.d.ts +2 -1
  33. package/LexicalNestedComposer.prod.js +2 -2
  34. package/LexicalPlainTextPlugin.dev.js +20 -12
  35. package/LexicalPlainTextPlugin.prod.js +4 -4
  36. package/LexicalRichTextPlugin.dev.js +20 -12
  37. package/LexicalRichTextPlugin.prod.js +4 -4
  38. package/LexicalTablePlugin.d.ts +1 -1
  39. package/LexicalTablePlugin.dev.js +1 -1
  40. package/LexicalTablePlugin.prod.js +3 -3
  41. package/package.json +19 -22
  42. package/useLexicalTextEntity.d.ts +2 -3
@@ -5,8 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { EditorState, EditorThemeClasses, LexicalEditor, LexicalNode } from 'lexical';
9
- import type { Klass } from 'shared/types';
8
+ import type { EditorState, EditorThemeClasses, Klass, LexicalEditor, LexicalNode } from 'lexical';
10
9
  export declare function useLexical(editorConfig: {
11
10
  disableEvents?: boolean;
12
11
  editorState?: EditorState;
@@ -9,6 +9,7 @@
9
9
  var lexical = require('lexical');
10
10
  var react = require('react');
11
11
  var text = require('@lexical/text');
12
+ var utils = require('@lexical/utils');
12
13
 
13
14
  /**
14
15
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -36,18 +37,26 @@ var useLayoutEffect = useLayoutEffectImpl;
36
37
  * LICENSE file in the root directory of this source tree.
37
38
  *
38
39
  */
40
+
41
+ function canShowPlaceholderFromCurrentEditorState(editor) {
42
+ const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
43
+ return currentCanShowPlaceholder;
44
+ }
45
+
39
46
  function useCanShowPlaceholder(editor) {
40
- const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
47
+ const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
41
48
  useLayoutEffect(() => {
42
- let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
43
- setCanShowPlaceholder(currentCanShowPlaceholder);
44
- return editor.registerUpdateListener(({
45
- editorState
46
- }) => {
47
- const isComposing = editor.isComposing();
48
- currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
49
+ function resetCanShowPlaceholder() {
50
+ const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
49
51
  setCanShowPlaceholder(currentCanShowPlaceholder);
50
- });
52
+ }
53
+
54
+ resetCanShowPlaceholder();
55
+ return utils.mergeRegister(editor.registerUpdateListener(() => {
56
+ resetCanShowPlaceholder();
57
+ }), editor.registerReadOnlyListener(() => {
58
+ resetCanShowPlaceholder();
59
+ }));
51
60
  }, [editor]);
52
61
  return canShowPlaceholder;
53
62
  }
@@ -4,6 +4,5 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var d=require("lexical"),f=require("react"),g=require("@lexical/text"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;
8
- function k(a){let [b,c]=f.useState(a.getEditorState().read(g.$canShowPlaceholderCurry(a.isComposing())));h(()=>{let e=a.getEditorState().read(g.$canShowPlaceholderCurry(a.isComposing()));c(e);return a.registerUpdateListener(({editorState:l})=>{let m=a.isComposing();e=l.read(g.$canShowPlaceholderCurry(m));c(e)})},[a]);return b}function n(a){let b=k(a);return[f.useCallback(c=>{a.setRootElement(c)},[a]),b]}
9
- exports.useLexical=function(a){let b=f.useMemo(()=>d.createEditor(a),[]),[c,e]=n(b);return[b,c,e]}
7
+ 'use strict';var c=require("lexical"),f=require("react"),g=require("@lexical/text"),h=require("@lexical/utils"),k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;function l(a){return a.getEditorState().read(g.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
8
+ function m(a){let [b,d]=f.useState(()=>l(a));k(()=>{function e(){let n=l(a);d(n)}e();return h.mergeRegister(a.registerUpdateListener(()=>{e()}),a.registerReadOnlyListener(()=>{e()}))},[a]);return b}function p(a){let b=m(a);return[f.useCallback(d=>{a.setRootElement(d)},[a]),b]}exports.useLexical=function(a){let b=f.useMemo(()=>c.createEditor(a),[]),[d,e]=p(b);return[b,d,e]}
@@ -7,6 +7,7 @@
7
7
  'use strict';
8
8
 
9
9
  var text = require('@lexical/text');
10
+ var utils = require('@lexical/utils');
10
11
  var react = require('react');
11
12
 
12
13
  /**
@@ -35,18 +36,26 @@ var useLayoutEffect = useLayoutEffectImpl;
35
36
  * LICENSE file in the root directory of this source tree.
36
37
  *
37
38
  */
39
+
40
+ function canShowPlaceholderFromCurrentEditorState(editor) {
41
+ const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
42
+ return currentCanShowPlaceholder;
43
+ }
44
+
38
45
  function useCanShowPlaceholder(editor) {
39
- const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
46
+ const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
40
47
  useLayoutEffect(() => {
41
- let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
42
- setCanShowPlaceholder(currentCanShowPlaceholder);
43
- return editor.registerUpdateListener(({
44
- editorState
45
- }) => {
46
- const isComposing = editor.isComposing();
47
- currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
48
+ function resetCanShowPlaceholder() {
49
+ const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
48
50
  setCanShowPlaceholder(currentCanShowPlaceholder);
49
- });
51
+ }
52
+
53
+ resetCanShowPlaceholder();
54
+ return utils.mergeRegister(editor.registerUpdateListener(() => {
55
+ resetCanShowPlaceholder();
56
+ }), editor.registerReadOnlyListener(() => {
57
+ resetCanShowPlaceholder();
58
+ }));
50
59
  }, [editor]);
51
60
  return canShowPlaceholder;
52
61
  }
@@ -4,5 +4,5 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var b=require("@lexical/text"),c=require("react"),f="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?c.useLayoutEffect:c.useEffect;
8
- function g(a){let [h,e]=c.useState(a.getEditorState().read(b.$canShowPlaceholderCurry(a.isComposing())));f(()=>{let d=a.getEditorState().read(b.$canShowPlaceholderCurry(a.isComposing()));e(d);return a.registerUpdateListener(({editorState:k})=>{let l=a.isComposing();d=k.read(b.$canShowPlaceholderCurry(l));e(d)})},[a]);return h}exports.useLexicalCanShowPlaceholder=function(a){return g(a)}
7
+ 'use strict';var b=require("@lexical/text"),d=require("@lexical/utils"),e=require("react"),f="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?e.useLayoutEffect:e.useEffect;function g(a){return a.getEditorState().read(b.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
8
+ function h(a){let [k,l]=e.useState(()=>g(a));f(()=>{function c(){let m=g(a);l(m)}c();return d.mergeRegister(a.registerUpdateListener(()=>{c()}),a.registerReadOnlyListener(()=>{c()}))},[a]);return k}exports.useLexicalCanShowPlaceholder=function(a){return h(a)}
@@ -8,6 +8,6 @@
8
8
  function C(a){let d=a.getChildren(),f=d.length;for(let e=0;e<f;e++)a.insertBefore(d[e]);a.remove();return 0<f?d[f-1]:null}
9
9
  function D(a){let d=a.getPreviousSibling();if(k.$isOverflowNode(d)){var f=a.getFirstChild(),e=d.getChildren(),m=e.length;if(null===f)a.append(...e);else for(var c=0;c<m;c++)f.insertBefore(e[c]);c=x.$getSelection();if(x.$isRangeSelection(c)){f=c.anchor;e=f.getNode();c=c.focus;let g=f.getNode();e.is(d)?f.set(a.getKey(),f.offset,"element"):e.is(a)&&f.set(a.getKey(),m+f.offset,"element");g.is(d)?c.set(a.getKey(),c.offset,"element"):g.is(a)&&c.set(a.getKey(),m+c.offset,"element")}d.remove()}}
10
10
  exports.mergePrevious=D;
11
- exports.useCharacterLimit=function(a,d,f=Object.freeze({})){let {strlen:e=c=>c.length,remainingCharacters:m=()=>{}}=f;y.useEffect(()=>{if(!a.hasNodes([k.OverflowNode]))throw Error("Minified Lexical error #57; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");},[a]);y.useEffect(()=>{let c=a.getEditorState().read(q.$rootTextContent),g=0;return w.mergeRegister(a.registerTextContentListener(n=>{c=n}),a.registerUpdateListener(({dirtyLeaves:n})=>
12
- {var r=a.isComposing();n=0<n.size;if(!r&&n){r=e(c);n=r>d||null!==g&&g>d;m(d-r);if(null===g||n){let p=z(c,d,e);a.update(()=>{let B=w.$dfs(),E=B.length,t=0;for(let v=0;v<E;v+=1){var {node:b}=B[v];if(k.$isOverflowNode(b)){var l=t;if(t+b.getTextContentSize()<=p){var h=b.getParent();l=b.getPreviousSibling();var u=b.getNextSibling();C(b);b=x.$getSelection();!x.$isRangeSelection(b)||b.anchor.getNode().isAttached()&&b.focus.getNode().isAttached()||(x.$isTextNode(l)?l.select():x.$isTextNode(u)?u.select():
13
- null!==h&&h.select())}else l<p&&(h=b.getFirstDescendant(),u=null!==h?h.getTextContentSize():0,l+=u,h=x.$isTextNode(h)&&h.isSimpleText(),l=l<=p,(h||l)&&C(b))}else x.$isLeafNode(b)&&(l=t,t+=b.getTextContentSize(),t>p&&!k.$isOverflowNode(b.getParent())&&(h=x.$getSelection(),l<p&&x.$isTextNode(b)&&b.isSimpleText()?([,b]=b.splitText(p-l),b=A(b)):b=A(b),null!==h&&x.$setSelection(h),D(b)))}},{tag:"history-merge"})}g=r}}))},[a,d,m,e])}
11
+ exports.useCharacterLimit=function(a,d,f=Object.freeze({})){let {strlen:e=c=>c.length,remainingCharacters:m=()=>{}}=f;y.useEffect(()=>{if(!a.hasNodes([k.OverflowNode]))throw Error("Minified Lexical error #57; visit https://lexical.dev/docs/error?code=57 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");},[a]);y.useEffect(()=>{let c=a.getEditorState().read(q.$rootTextContent),g=0;return w.mergeRegister(a.registerTextContentListener(n=>{c=
12
+ n}),a.registerUpdateListener(({dirtyLeaves:n})=>{var r=a.isComposing();n=0<n.size;if(!r&&n){r=e(c);n=r>d||null!==g&&g>d;m(d-r);if(null===g||n){let p=z(c,d,e);a.update(()=>{let B=w.$dfs(),E=B.length,t=0;for(let v=0;v<E;v+=1){var {node:b}=B[v];if(k.$isOverflowNode(b)){var l=t;if(t+b.getTextContentSize()<=p){var h=b.getParent();l=b.getPreviousSibling();var u=b.getNextSibling();C(b);b=x.$getSelection();!x.$isRangeSelection(b)||b.anchor.getNode().isAttached()&&b.focus.getNode().isAttached()||(x.$isTextNode(l)?
13
+ l.select():x.$isTextNode(u)?u.select():null!==h&&h.select())}else l<p&&(h=b.getFirstDescendant(),u=null!==h?h.getTextContentSize():0,l+=u,h=x.$isTextNode(h)&&h.isSimpleText(),l=l<=p,(h||l)&&C(b))}else x.$isLeafNode(b)&&(l=t,t+=b.getTextContentSize(),t>p&&!k.$isOverflowNode(b.getParent())&&(h=x.$getSelection(),l<p&&x.$isTextNode(b)&&b.isSimpleText()?([,b]=b.splitText(p-l),b=A(b)):b=A(b),null!==h&&x.$setSelection(h),D(b)))}},{tag:"history-merge"})}g=r}}))},[a,d,m,e])}
@@ -8,6 +8,7 @@
8
8
 
9
9
  var react = require('react');
10
10
  var text = require('@lexical/text');
11
+ var utils = require('@lexical/utils');
11
12
 
12
13
  /**
13
14
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -35,18 +36,26 @@ var useLayoutEffect = useLayoutEffectImpl;
35
36
  * LICENSE file in the root directory of this source tree.
36
37
  *
37
38
  */
39
+
40
+ function canShowPlaceholderFromCurrentEditorState(editor) {
41
+ const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
42
+ return currentCanShowPlaceholder;
43
+ }
44
+
38
45
  function useCanShowPlaceholder(editor) {
39
- const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
46
+ const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
40
47
  useLayoutEffect(() => {
41
- let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
42
- setCanShowPlaceholder(currentCanShowPlaceholder);
43
- return editor.registerUpdateListener(({
44
- editorState
45
- }) => {
46
- const isComposing = editor.isComposing();
47
- currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
48
+ function resetCanShowPlaceholder() {
49
+ const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
48
50
  setCanShowPlaceholder(currentCanShowPlaceholder);
49
- });
51
+ }
52
+
53
+ resetCanShowPlaceholder();
54
+ return utils.mergeRegister(editor.registerUpdateListener(() => {
55
+ resetCanShowPlaceholder();
56
+ }), editor.registerReadOnlyListener(() => {
57
+ resetCanShowPlaceholder();
58
+ }));
50
59
  }, [editor]);
51
60
  return canShowPlaceholder;
52
61
  }
@@ -4,5 +4,5 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var b=require("react"),d=require("@lexical/text"),g="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?b.useLayoutEffect:b.useEffect;
8
- function h(a){let [e,c]=b.useState(a.getEditorState().read(d.$canShowPlaceholderCurry(a.isComposing())));g(()=>{let f=a.getEditorState().read(d.$canShowPlaceholderCurry(a.isComposing()));c(f);return a.registerUpdateListener(({editorState:k})=>{let l=a.isComposing();f=k.read(d.$canShowPlaceholderCurry(l));c(f)})},[a]);return e}exports.useLexicalEditor=function(a){let e=h(a);return[b.useCallback(c=>{a.setRootElement(c)},[a]),e]}
7
+ 'use strict';var b=require("react"),f=require("@lexical/text"),g=require("@lexical/utils"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?b.useLayoutEffect:b.useEffect;function k(a){return a.getEditorState().read(f.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
8
+ function l(a){let [c,d]=b.useState(()=>k(a));h(()=>{function e(){let m=k(a);d(m)}e();return g.mergeRegister(a.registerUpdateListener(()=>{e()}),a.registerReadOnlyListener(()=>{e()}))},[a]);return c}exports.useLexicalEditor=function(a){let c=l(a);return[b.useCallback(d=>{a.setRootElement(d)},[a]),c]}
@@ -5,4 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export declare function AutoFocusPlugin(): null;
8
+ declare type Props = {
9
+ defaultSelection?: 'rootStart' | 'rootEnd';
10
+ };
11
+ export declare function AutoFocusPlugin({ defaultSelection }: Props): null;
12
+ export {};
@@ -16,7 +16,9 @@ var react = require('react');
16
16
  * LICENSE file in the root directory of this source tree.
17
17
  *
18
18
  */
19
- function AutoFocusPlugin() {
19
+ function AutoFocusPlugin({
20
+ defaultSelection
21
+ }) {
20
22
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
21
23
  react.useEffect(() => {
22
24
  editor.focus(() => {
@@ -27,14 +29,16 @@ function AutoFocusPlugin() {
27
29
  const activeElement = document.activeElement;
28
30
  const rootElement = editor.getRootElement();
29
31
 
30
- if (rootElement !== null || activeElement === null || !rootElement.contains(activeElement)) {
32
+ if (!rootElement.contains(activeElement) || rootElement !== null || activeElement === null) {
31
33
  // Note: preventScroll won't work in Webkit.
32
34
  rootElement.focus({
33
35
  preventScroll: true
34
36
  });
35
37
  }
38
+ }, {
39
+ defaultSelection
36
40
  });
37
- }, [editor]);
41
+ }, [defaultSelection, editor]);
38
42
  return null;
39
43
  }
40
44
 
@@ -7,4 +7,8 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- declare export function AutoFocusPlugin(): null;
10
+ type Props = $ReadOnly<{
11
+ defaultSelection?: 'rootStart' | 'rootEnd',
12
+ }>;
13
+
14
+ declare export function AutoFocusPlugin(props: Props): null;
@@ -4,4 +4,4 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var d=require("@lexical/react/LexicalComposerContext"),e=require("react");exports.AutoFocusPlugin=function(){let [a]=d.useLexicalComposerContext();e.useEffect(()=>{a.focus(()=>{let c=document.activeElement,b=a.getRootElement();null===b&&null!==c&&b.contains(c)||b.focus({preventScroll:!0})})},[a]);return null}
7
+ 'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("react");exports.AutoFocusPlugin=function({defaultSelection:c}){let [a]=e.useLexicalComposerContext();f.useEffect(()=>{a.focus(()=>{let d=document.activeElement,b=a.getRootElement();b.contains(d)&&null===b&&null!==d||b.focus({preventScroll:!0})},{defaultSelection:c})},[c,a]);return null}
@@ -16,5 +16,5 @@ export declare type LinkMatcher = (text: string) => LinkMatcherResult | null;
16
16
  export declare function AutoLinkPlugin({ matchers, onChange, }: {
17
17
  matchers: Array<LinkMatcher>;
18
18
  onChange?: ChangeHandler;
19
- }): JSX.Element;
19
+ }): JSX.Element | null;
20
20
  export {};
@@ -7,6 +7,6 @@
7
7
  'use strict';var h=require("@lexical/link"),l=require("@lexical/react/LexicalComposerContext"),p=require("@lexical/utils"),v=require("lexical"),w=require("react");function x(a,c){for(let b=0;b<c.length;b++){let e=c[b](a);if(e)return e}return null}function y(a){a=a.getPreviousSibling();v.$isElementNode(a)&&(a=a.getLastDescendant());return null===a||v.$isLineBreakNode(a)||v.$isTextNode(a)&&a.getTextContent().endsWith(" ")}
8
8
  function A(a){a=a.getNextSibling();v.$isElementNode(a)&&(a=a.getFirstDescendant());return null===a||v.$isLineBreakNode(a)||v.$isTextNode(a)&&a.getTextContent().startsWith(" ")}
9
9
  function B(a,c,b){var e=a.getChildren();let d=e.length;for(let f=0;f<d;f++){let g=e[f];if(!v.$isTextNode(g)||!g.isSimpleText()){C(a);b(null,a.getURL());return}}e=a.getTextContent();c=x(e,c);null===c||c.text!==e?(C(a),b(null,a.getURL())):y(a)&&A(a)?(e=a.getURL(),null!==c&&e!==c.url&&(a.setURL(c.url),b(c.url,e))):(C(a),b(null,a.getURL()))}function C(a){let c=a.getChildren();var b=c.length;for(--b;0<=b;b--)a.insertAfter(c[b]);a.remove();return c.map(e=>e.getLatest())}
10
- function D(a,c,b){w.useEffect(()=>{if(!a.hasNodes([h.AutoLinkNode]))throw Error("Minified Lexical error #7; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let e=(d,f)=>{b&&b(d,f)};return p.mergeRegister(a.registerNodeTransform(v.TextNode,d=>{var f=d.getParentOrThrow();if(h.$isAutoLinkNode(f))B(f,c,e);else if(!h.$isLinkNode(f)){if(d.isSimpleText()){f=d.getTextContent();let E=f.length,u=f,z=0,t=d;for(var g;(g=x(u,c))&&null!==
11
- g;){var m=g.index,n=z+m;let q=g.length;var r=void 0;r=0<n?" "===f[n-1]:y(d);n=n+q<E?" "===f[n+q]:A(d);if(r&&n){var k=void 0;0===m?[k,t]=t.splitText(q):[,k,t]=t.splitText(m,m+q);r=h.$createAutoLinkNode(g.url);r.append(v.$createTextNode(g.text));k.replace(r);b&&b(g.url,null)}m+=q;u=u.substring(m);z+=m}}k=d.getPreviousSibling();g=d.getNextSibling();d=d.getTextContent();h.$isAutoLinkNode(k)&&!d.startsWith(" ")&&(C(k),k=k.getURL(),b&&b(null,k));h.$isAutoLinkNode(g)&&!d.endsWith(" ")&&(C(g),d=g.getURL(),
12
- b&&b(null,d))}}),a.registerNodeTransform(h.AutoLinkNode,d=>{B(d,c,e)}))},[a,c,b])}exports.AutoLinkPlugin=function({matchers:a,onChange:c}){let [b]=l.useLexicalComposerContext();D(b,a,c);return null}
10
+ function D(a,c,b){w.useEffect(()=>{if(!a.hasNodes([h.AutoLinkNode]))throw Error("Minified Lexical error #7; visit https://lexical.dev/docs/error?code=7 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let e=(d,f)=>{b&&b(d,f)};return p.mergeRegister(a.registerNodeTransform(v.TextNode,d=>{var f=d.getParentOrThrow();if(h.$isAutoLinkNode(f))B(f,c,e);else if(!h.$isLinkNode(f)){if(d.isSimpleText()){f=d.getTextContent();let E=f.length,u=f,z=
11
+ 0,t=d;for(var g;(g=x(u,c))&&null!==g;){var m=g.index,n=z+m;let q=g.length;var r=void 0;r=0<n?" "===f[n-1]:y(d);n=n+q<E?" "===f[n+q]:A(d);if(r&&n){var k=void 0;0===m?[k,t]=t.splitText(q):[,k,t]=t.splitText(m,m+q);r=h.$createAutoLinkNode(g.url);r.append(v.$createTextNode(g.text));k.replace(r);b&&b(g.url,null)}m+=q;u=u.substring(m);z+=m}}k=d.getPreviousSibling();g=d.getNextSibling();d=d.getTextContent();h.$isAutoLinkNode(k)&&!d.startsWith(" ")&&(C(k),k=k.getURL(),b&&b(null,k));h.$isAutoLinkNode(g)&&
12
+ !d.endsWith(" ")&&(C(g),d=g.getURL(),b&&b(null,d))}}),a.registerNodeTransform(h.AutoLinkNode,d=>{B(d,c,e)}))},[a,c,b])}exports.AutoLinkPlugin=function({matchers:a,onChange:c}){let [b]=l.useLexicalComposerContext();D(b,a,c);return null}
@@ -10,5 +10,5 @@ declare type Props = Readonly<{
10
10
  current: HTMLElement | null;
11
11
  };
12
12
  }>;
13
- export declare function AutoScrollPlugin({ scrollRef }: Props): JSX.Element;
13
+ export declare function AutoScrollPlugin({ scrollRef }: Props): JSX.Element | null;
14
14
  export {};
@@ -6,8 +6,9 @@
6
6
  *
7
7
  */
8
8
  import type { ElementFormatType, NodeKey } from 'lexical';
9
+ import { ReactNode } from 'react';
9
10
  declare type Props = Readonly<{
10
- children: JSX.Element | string | (JSX.Element | string)[];
11
+ children: ReactNode;
11
12
  format: ElementFormatType | null | undefined;
12
13
  nodeKey: NodeKey;
13
14
  className: Readonly<{
@@ -28,10 +28,9 @@ function BlockWithAlignableContents({
28
28
  }) {
29
29
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
30
30
  const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
31
- const ref = React.useRef();
32
- const onDelete = React.useCallback(payload => {
31
+ const ref = React.useRef(null);
32
+ const onDelete = React.useCallback(event => {
33
33
  if (isSelected && lexical.$isNodeSelection(lexical.$getSelection())) {
34
- const event = payload;
35
34
  event.preventDefault();
36
35
  editor.update(() => {
37
36
  const node = lexical.$getNodeByKey(nodeKey);
@@ -93,7 +92,7 @@ function BlockWithAlignableContents({
93
92
  className: [className.base, isSelected ? className.focus : null].filter(Boolean).join(' '),
94
93
  ref: ref,
95
94
  style: {
96
- textAlign: format ? format : null
95
+ textAlign: format ? format : undefined
97
96
  }
98
97
  }, children);
99
98
  }
@@ -5,6 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict';var a=require("@lexical/react/LexicalComposerContext"),h=require("@lexical/react/LexicalDecoratorBlockNode"),m=require("@lexical/react/useLexicalNodeSelection"),n=require("@lexical/utils"),u=require("lexical"),v=require("react");
8
- exports.BlockWithAlignableContents=function({children:w,format:p,nodeKey:g,className:q}){let [d]=a.useLexicalComposerContext(),[e,k,r]=m.useLexicalNodeSelection(g),t=v.useRef(),l=v.useCallback(b=>{e&&u.$isNodeSelection(u.$getSelection())&&(b.preventDefault(),d.update(()=>{const c=u.$getNodeByKey(g);u.$isDecoratorNode(c)&&c.isTopLevel()&&c.remove();k(!1)}));return!1},[d,e,g,k]);v.useEffect(()=>n.mergeRegister(d.registerCommand(u.FORMAT_ELEMENT_COMMAND,b=>{if(e){var c=u.$getSelection();if(u.$isNodeSelection(c)){var f=
8
+ exports.BlockWithAlignableContents=function({children:w,format:p,nodeKey:g,className:q}){let [d]=a.useLexicalComposerContext(),[e,k,r]=m.useLexicalNodeSelection(g),t=v.useRef(null),l=v.useCallback(b=>{e&&u.$isNodeSelection(u.$getSelection())&&(b.preventDefault(),d.update(()=>{const c=u.$getNodeByKey(g);u.$isDecoratorNode(c)&&c.isTopLevel()&&c.remove();k(!1)}));return!1},[d,e,g,k]);v.useEffect(()=>n.mergeRegister(d.registerCommand(u.FORMAT_ELEMENT_COMMAND,b=>{if(e){var c=u.$getSelection();if(u.$isNodeSelection(c)){var f=
9
9
  u.$getNodeByKey(g);h.$isDecoratorBlockNode(f)&&f.setFormat(b)}else if(u.$isRangeSelection(c)){c=c.getNodes();for(f of c)h.$isDecoratorBlockNode(f)?f.setFormat(b):n.$getNearestBlockElementAncestorOrThrow(f).setFormat(b)}return!0}return!1},u.COMMAND_PRIORITY_LOW),d.registerCommand(u.CLICK_COMMAND,b=>{b.preventDefault();return b.target===t.current?(b.shiftKey||r(),k(!e),!0):!1},u.COMMAND_PRIORITY_LOW),d.registerCommand(u.KEY_DELETE_COMMAND,l,u.COMMAND_PRIORITY_LOW),d.registerCommand(u.KEY_BACKSPACE_COMMAND,
10
- l,u.COMMAND_PRIORITY_LOW)),[r,d,e,g,l,k]);return v.createElement("div",{className:[q.base,e?q.focus:null].filter(Boolean).join(" "),ref:t,style:{textAlign:p?p:null}},w)}
10
+ l,u.COMMAND_PRIORITY_LOW)),[r,d,e,g,l,k]);return v.createElement("div",{className:[q.base,e?q.focus:null].filter(Boolean).join(" "),ref:t,style:{textAlign:p?p:void 0}},w)}
@@ -5,9 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict';var m=require("@lexical/react/LexicalComposerContext"),u=require("react"),v=require("@lexical/overflow"),z=require("@lexical/text"),A=require("@lexical/utils"),C=require("lexical");
8
- function D(b,c,n=Object.freeze({})){let {strlen:g=d=>d.length,remainingCharacters:q=()=>{}}=n;u.useEffect(()=>{if(!b.hasNodes([v.OverflowNode]))throw Error("Minified Lexical error #57; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");},[b]);u.useEffect(()=>{let d=b.getEditorState().read(z.$rootTextContent),e=0;return A.mergeRegister(b.registerTextContentListener(p=>{d=p}),b.registerUpdateListener(({dirtyLeaves:p})=>{var w=
9
- b.isComposing();p=0<p.size;if(!w&&p){w=g(d);p=w>c||null!==e&&e>c;q(c-w);if(null===e||p){let r=F(d,c,g);b.update(()=>{let B=A.$dfs(),J=B.length,x=0;for(let y=0;y<J;y+=1){var {node:a}=B[y];if(v.$isOverflowNode(a)){var f=x;if(x+a.getTextContentSize()<=r){var h=a.getParent();f=a.getPreviousSibling();var k=a.getNextSibling();G(a);a=C.$getSelection();!C.$isRangeSelection(a)||a.anchor.getNode().isAttached()&&a.focus.getNode().isAttached()||(C.$isTextNode(f)?f.select():C.$isTextNode(k)?k.select():null!==
10
- h&&h.select())}else f<r&&(h=a.getFirstDescendant(),k=null!==h?h.getTextContentSize():0,f+=k,h=C.$isTextNode(h)&&h.isSimpleText(),f=f<=r,(h||f)&&G(a))}else if(C.$isLeafNode(a)&&(f=x,x+=a.getTextContentSize(),x>r&&!v.$isOverflowNode(a.getParent())&&(h=C.$getSelection(),f<r&&C.$isTextNode(a)&&a.isSimpleText()?([,a]=a.splitText(r-f),a=H(a)):a=H(a),null!==h&&C.$setSelection(h),f=a.getPreviousSibling(),v.$isOverflowNode(f)))){k=a.getFirstChild();var t=f.getChildren();h=t.length;if(null===k)a.append(...t);
8
+ function D(b,c,n=Object.freeze({})){let {strlen:g=d=>d.length,remainingCharacters:q=()=>{}}=n;u.useEffect(()=>{if(!b.hasNodes([v.OverflowNode]))throw Error("Minified Lexical error #57; visit https://lexical.dev/docs/error?code=57 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");},[b]);u.useEffect(()=>{let d=b.getEditorState().read(z.$rootTextContent),e=0;return A.mergeRegister(b.registerTextContentListener(p=>{d=p}),b.registerUpdateListener(({dirtyLeaves:p})=>
9
+ {var w=b.isComposing();p=0<p.size;if(!w&&p){w=g(d);p=w>c||null!==e&&e>c;q(c-w);if(null===e||p){let r=F(d,c,g);b.update(()=>{let B=A.$dfs(),J=B.length,x=0;for(let y=0;y<J;y+=1){var {node:a}=B[y];if(v.$isOverflowNode(a)){var f=x;if(x+a.getTextContentSize()<=r){var h=a.getParent();f=a.getPreviousSibling();var k=a.getNextSibling();G(a);a=C.$getSelection();!C.$isRangeSelection(a)||a.anchor.getNode().isAttached()&&a.focus.getNode().isAttached()||(C.$isTextNode(f)?f.select():C.$isTextNode(k)?k.select():
10
+ null!==h&&h.select())}else f<r&&(h=a.getFirstDescendant(),k=null!==h?h.getTextContentSize():0,f+=k,h=C.$isTextNode(h)&&h.isSimpleText(),f=f<=r,(h||f)&&G(a))}else if(C.$isLeafNode(a)&&(f=x,x+=a.getTextContentSize(),x>r&&!v.$isOverflowNode(a.getParent())&&(h=C.$getSelection(),f<r&&C.$isTextNode(a)&&a.isSimpleText()?([,a]=a.splitText(r-f),a=H(a)):a=H(a),null!==h&&C.$setSelection(h),f=a.getPreviousSibling(),v.$isOverflowNode(f)))){k=a.getFirstChild();var t=f.getChildren();h=t.length;if(null===k)a.append(...t);
11
11
  else for(var l=0;l<h;l++)k.insertBefore(t[l]);l=C.$getSelection();if(C.$isRangeSelection(l)){k=l.anchor;t=k.getNode();l=l.focus;let E=k.getNode();t.is(f)?k.set(a.getKey(),k.offset,"element"):t.is(a)&&k.set(a.getKey(),h+k.offset,"element");E.is(f)?l.set(a.getKey(),l.offset,"element"):E.is(a)&&l.set(a.getKey(),h+l.offset,"element")}f.remove()}}},{tag:"history-merge"})}e=w}}))},[b,c,q,g])}
12
12
  function F(b,c,n){var g=Intl.Segmenter;let q=0;var d=0;if("function"===typeof g){b=(new g).segment(b);for(var {segment:e}of b){d+=n(e);if(d>c)break;q+=e.length}}else for(e=Array.from(b),b=e.length,g=0;g<b;g++){let p=e[g];d+=n(p);if(d>c)break;q+=p.length}return q}function H(b){let c=v.$createOverflowNode();b.insertBefore(c);c.append(b);return c}function G(b){let c=b.getChildren(),n=c.length;for(let g=0;g<n;g++)b.insertBefore(c[g]);b.remove();return 0<n?c[n-1]:null}let I=null;
13
13
  exports.CharacterLimitPlugin=function({charset:b="UTF-16"}){let [c]=m.useLexicalComposerContext(),[n,g]=u.useState(0),q=u.useMemo(()=>({remainingCharacters:g,strlen:d=>{if("UTF-8"===b){if(void 0===window.TextEncoder)var e=null;else null===I&&(I=new window.TextEncoder),e=I;null===e?(e=encodeURIComponent(d).match(/%[89ABab]/g),d=d.length+(e?e.length:0)):d=e.encode(d).length;return d}if("UTF-16"===b)return d.length;throw Error("Unrecognized charset");}}),[b]);D(c,5,q);return u.createElement("span",{className:`characters-limit ${0>
@@ -117,7 +117,7 @@ function handleCheckItemEvent(event, callback) {
117
117
 
118
118
  const firstChild = target.firstChild;
119
119
 
120
- if (firstChild != null && (firstChild.tagName === 'UL' || firstChild.tagName === 'OL')) {
120
+ if (firstChild != null && firstChild instanceof HTMLElement && (firstChild.tagName === 'UL' || firstChild.tagName === 'OL')) {
121
121
  return;
122
122
  }
123
123
 
@@ -137,15 +137,18 @@ function handleCheckItemEvent(event, callback) {
137
137
 
138
138
  function handleClick(event) {
139
139
  handleCheckItemEvent(event, () => {
140
- const editor = findEditor(event.target);
140
+ const domNode = event.target;
141
+ const editor = findEditor(domNode);
141
142
 
142
143
  if (editor != null && !editor.isReadOnly()) {
143
144
  editor.update(() => {
144
- const node = lexical.$getNearestNodeFromDOMNode(event.target);
145
+ if (event.target) {
146
+ const node = lexical.$getNearestNodeFromDOMNode(domNode);
145
147
 
146
- if (list.$isListItemNode(node)) {
147
- event.target.focus();
148
- node.toggleChecked();
148
+ if (list.$isListItemNode(node)) {
149
+ domNode.focus();
150
+ node.toggleChecked();
151
+ }
149
152
  }
150
153
  });
151
154
  }
@@ -163,7 +166,9 @@ function findEditor(target) {
163
166
  let node = target;
164
167
 
165
168
  while (node) {
169
+ // @ts-ignore internal field
166
170
  if (node.__lexicalEditor) {
171
+ // @ts-ignore internal field
167
172
  return node.__lexicalEditor;
168
173
  }
169
174
 
@@ -5,10 +5,10 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict';var e=require("@lexical/list"),g=require("@lexical/react/LexicalComposerContext"),k=require("@lexical/utils"),l=require("lexical"),m=require("react");let n=0;function p(){0===n++&&(document.addEventListener("click",q),document.addEventListener("pointerdown",r));return()=>{0===--n&&(document.removeEventListener("click",q),document.removeEventListener("pointerdown",r))}}
8
- function t(a,c){let b=a.target;if(b instanceof HTMLElement){var d=b.firstChild;(null==d||"UL"!==d.tagName&&"OL"!==d.tagName)&&(d=b.parentNode)&&"check"===d.__lexicalListType&&(a=a.pageX,d=b.getBoundingClientRect(),("rtl"===b.dir?a<d.right&&a>d.right-20:a>d.left&&a<d.left+20)&&c())}}function q(a){t(a,()=>{let c=u(a.target);null==c||c.isReadOnly()||c.update(()=>{let b=l.$getNearestNodeFromDOMNode(a.target);e.$isListItemNode(b)&&(a.target.focus(),b.toggleChecked())})})}
9
- function r(a){t(a,()=>{a.preventDefault()})}function u(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}function v(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}
10
- function w(a,c){let b=c?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=c?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=c?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=c?a.getLastChild():a.getFirstChild()}return null}
11
- function x(a,c,b){let d=v();null!=d&&c.update(()=>{var f=l.$getNearestNodeFromDOMNode(d);if(e.$isListItemNode(f)&&(f=w(f,b),null!=f)){f.selectStart();let h=c.getElementByKey(f.__key);null!=h&&(a.preventDefault(),setTimeout(()=>{h.focus()},0))}});return!1}
12
- exports.CheckListPlugin=function(){let [a]=g.useLexicalComposerContext();m.useEffect(()=>k.mergeRegister(a.registerCommand(e.INSERT_CHECK_LIST_COMMAND,()=>{e.insertList(a,"check");return!0},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_DOWN_COMMAND,c=>x(c,a,!1),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_UP_COMMAND,c=>x(c,a,!0),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{if(null!=v()){let c=a.getRootElement();null!=c&&c.focus();return!0}return!1},l.COMMAND_PRIORITY_LOW),
13
- a.registerCommand(l.KEY_SPACE_COMMAND,c=>{let b=v();return null==b||a.isReadOnly()?!1:(a.update(()=>{let d=l.$getNearestNodeFromDOMNode(b);e.$isListItemNode(d)&&(c.preventDefault(),d.toggleChecked())}),!0)},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_LEFT_COMMAND,c=>a.getEditorState().read(()=>{var b=l.$getSelection();if(l.$isRangeSelection(b)&&b.isCollapsed()){var {anchor:d}=b;if((b="element"===d.type)||0===d.offset){d=d.getNode();let f=k.$findMatchingParent(d,h=>l.$isElementNode(h)&&!h.isInline());
14
- if(e.$isListItemNode(f)&&(b||f.getFirstDescendant()===d)&&(b=a.getElementByKey(f.__key),null!=b&&document.activeElement!==b))return b.focus(),c.preventDefault(),!0}}return!1}),l.COMMAND_PRIORITY_LOW),p()));return null}
8
+ function t(a,d){let b=a.target;if(b instanceof HTMLElement){var c=b.firstChild;null!=c&&c instanceof HTMLElement&&("UL"===c.tagName||"OL"===c.tagName)||(c=b.parentNode)&&"check"===c.__lexicalListType&&(a=a.pageX,c=b.getBoundingClientRect(),("rtl"===b.dir?a<c.right&&a>c.right-20:a>c.left&&a<c.left+20)&&d())}}
9
+ function q(a){t(a,()=>{let d=a.target,b=u(d);null==b||b.isReadOnly()||b.update(()=>{if(a.target){let c=l.$getNearestNodeFromDOMNode(d);e.$isListItemNode(c)&&(d.focus(),c.toggleChecked())}})})}function r(a){t(a,()=>{a.preventDefault()})}function u(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}function v(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null}
10
+ function w(a,d){let b=d?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=d?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=d?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=d?a.getLastChild():a.getFirstChild()}return null}
11
+ function x(a,d,b){let c=v();null!=c&&d.update(()=>{var f=l.$getNearestNodeFromDOMNode(c);if(e.$isListItemNode(f)&&(f=w(f,b),null!=f)){f.selectStart();let h=d.getElementByKey(f.__key);null!=h&&(a.preventDefault(),setTimeout(()=>{h.focus()},0))}});return!1}
12
+ exports.CheckListPlugin=function(){let [a]=g.useLexicalComposerContext();m.useEffect(()=>k.mergeRegister(a.registerCommand(e.INSERT_CHECK_LIST_COMMAND,()=>{e.insertList(a,"check");return!0},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_DOWN_COMMAND,d=>x(d,a,!1),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_UP_COMMAND,d=>x(d,a,!0),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{if(null!=v()){let d=a.getRootElement();null!=d&&d.focus();return!0}return!1},l.COMMAND_PRIORITY_LOW),
13
+ a.registerCommand(l.KEY_SPACE_COMMAND,d=>{let b=v();return null==b||a.isReadOnly()?!1:(a.update(()=>{let c=l.$getNearestNodeFromDOMNode(b);e.$isListItemNode(c)&&(d.preventDefault(),c.toggleChecked())}),!0)},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_LEFT_COMMAND,d=>a.getEditorState().read(()=>{var b=l.$getSelection();if(l.$isRangeSelection(b)&&b.isCollapsed()){var {anchor:c}=b;if((b="element"===c.type)||0===c.offset){c=c.getNode();let f=k.$findMatchingParent(c,h=>l.$isElementNode(h)&&!h.isInline());
14
+ if(e.$isListItemNode(f)&&(b||f.getFirstDescendant()===c)&&(b=a.getElementByKey(f.__key),null!=b&&document.activeElement!==b))return b.focus(),d.preventDefault(),!0}}return!1}),l.COMMAND_PRIORITY_LOW),p()));return null}
@@ -8,5 +8,5 @@
8
8
  declare type Props = Readonly<{
9
9
  onClear?: () => void;
10
10
  }>;
11
- export declare function ClearEditorPlugin({ onClear }: Props): JSX.Element;
11
+ export declare function ClearEditorPlugin({ onClear }: Props): JSX.Element | null;
12
12
  export {};
@@ -5,15 +5,15 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
+ import type { Klass } from 'lexical';
8
9
  import { EditorState, EditorThemeClasses, LexicalEditor, LexicalNode } from 'lexical';
9
- import { Class } from 'utility-types';
10
10
  export declare type InitialEditorStateType = null | string | EditorState | ((editor: LexicalEditor) => void);
11
11
  declare type Props = {
12
12
  children: JSX.Element | string | (JSX.Element | string)[];
13
13
  initialConfig: Readonly<{
14
14
  editor__DEPRECATED?: LexicalEditor | null;
15
15
  namespace: string;
16
- nodes?: ReadonlyArray<Class<LexicalNode>>;
16
+ nodes?: ReadonlyArray<Klass<LexicalNode>>;
17
17
  onError: (error: Error, editor: LexicalEditor) => void;
18
18
  readOnly?: boolean;
19
19
  theme?: EditorThemeClasses;
@@ -8,6 +8,8 @@
8
8
  */
9
9
 
10
10
  import type {EditorThemeClasses, LexicalEditor, LexicalNode} from 'lexical';
11
+ import type {InitialEditorStateType as InitialEditorStatePlainTextType} from '@lexical/plain-text';
12
+ import type {InitialEditorStateType as InitialEditorStateRichTextType} from '@lexical/rich-text';
11
13
 
12
14
  type Props = {
13
15
  initialConfig: $ReadOnly<{
@@ -16,6 +18,9 @@ type Props = {
16
18
  namespace: string,
17
19
  nodes?: $ReadOnlyArray<Class<LexicalNode>>,
18
20
  theme?: EditorThemeClasses,
21
+ editorState?:
22
+ | InitialEditorStateRichTextType
23
+ | InitialEditorStatePlainTextType,
19
24
  onError: (error: Error, editor: LexicalEditor) => void,
20
25
  }>,
21
26
  children: React$Node,
@@ -4,4 +4,5 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var c=require("react");let d=c.createContext(null);exports.LexicalComposerContext=d;exports.createLexicalComposerContext=function(a,e){let b=null;null!=a&&(b=a[1]);return{getTheme:function(){return null!=e?e:null!=b?b.getTheme():null}}};exports.useLexicalComposerContext=function(){let a=c.useContext(d);if(null==a)throw Error("Minified Lexical error #8; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return a}
7
+ 'use strict';var c=require("react");let d=c.createContext(null);exports.LexicalComposerContext=d;exports.createLexicalComposerContext=function(a,e){let b=null;null!=a&&(b=a[1]);return{getTheme:function(){return null!=e?e:null!=b?b.getTheme():null}}};
8
+ exports.useLexicalComposerContext=function(){let a=c.useContext(d);if(null==a)throw Error("Minified Lexical error #8; visit https://lexical.dev/docs/error?code=8 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return a}
@@ -79,16 +79,16 @@ function ContentEditable({
79
79
  "aria-multiline": ariaMultiline,
80
80
  "aria-owns": isReadOnly ? null : ariaOwneeID,
81
81
  "aria-required": ariaRequired,
82
- autoCapitalize: autoCapitalize !== undefined ? String(autoCapitalize) : null // @ts-ignore This is a valid attribute
82
+ autoCapitalize: autoCapitalize !== undefined ? String(autoCapitalize) : undefined // @ts-ignore This is a valid attribute
83
83
  ,
84
84
  autoComplete: autoComplete,
85
- autoCorrect: autoCorrect !== undefined ? String(autoCorrect) : null,
85
+ autoCorrect: autoCorrect !== undefined ? String(autoCorrect) : undefined,
86
86
  className: className,
87
87
  contentEditable: !isReadOnly,
88
88
  "data-testid": testid,
89
89
  id: id,
90
90
  ref: ref,
91
- role: isReadOnly ? null : role,
91
+ role: isReadOnly ? undefined : role,
92
92
  spellCheck: spellCheck,
93
93
  style: style,
94
94
  tabIndex: tabIndex
@@ -6,4 +6,4 @@
6
6
  */
7
7
  'use strict';var b=require("@lexical/react/LexicalComposerContext"),k=require("react"),l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
8
8
  exports.ContentEditable=function({ariaActiveDescendantID:m,ariaAutoComplete:n,ariaControls:p,ariaDescribedBy:q,ariaExpanded:r,ariaLabel:t,ariaLabelledBy:u,ariaMultiline:v,ariaOwneeID:w,ariaRequired:x,autoCapitalize:e,autoComplete:y,autoCorrect:f,className:z,id:A,role:g="textbox",spellCheck:B=!0,style:C,tabIndex:D,testid:E}){let [c]=b.useLexicalComposerContext(),[a,h]=k.useState(!0),F=k.useCallback(d=>{c.setRootElement(d)},[c]);l(()=>{h(c.isReadOnly());return c.registerReadOnlyListener(d=>{h(d)})},
9
- [c]);return k.createElement("div",{"aria-activedescendant":a?null:m,"aria-autocomplete":a?null:n,"aria-controls":a?null:p,"aria-describedby":q,"aria-expanded":a?null:"combobox"===g?!!r:null,"aria-label":t,"aria-labelledby":u,"aria-multiline":v,"aria-owns":a?null:w,"aria-required":x,autoCapitalize:void 0!==e?String(e):null,autoComplete:y,autoCorrect:void 0!==f?String(f):null,className:z,contentEditable:!a,"data-testid":E,id:A,ref:F,role:a?null:g,spellCheck:B,style:C,tabIndex:D})}
9
+ [c]);return k.createElement("div",{"aria-activedescendant":a?null:m,"aria-autocomplete":a?null:n,"aria-controls":a?null:p,"aria-describedby":q,"aria-expanded":a?null:"combobox"===g?!!r:null,"aria-label":t,"aria-labelledby":u,"aria-multiline":v,"aria-owns":a?null:w,"aria-required":x,autoCapitalize:void 0!==e?String(e):void 0,autoComplete:y,autoCorrect:void 0!==f?String(f):void 0,className:z,contentEditable:!a,"data-testid":E,id:A,ref:F,role:a?void 0:g,spellCheck:B,style:C,tabIndex:D})}
@@ -8,10 +8,10 @@
8
8
  import type { ElementFormatType, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
9
9
  import { DecoratorNode } from 'lexical';
10
10
  export declare type SerializedDecoratorBlockNode = Spread<{
11
- format: ElementFormatType | '';
11
+ format: ElementFormatType;
12
12
  }, SerializedLexicalNode>;
13
13
  export declare class DecoratorBlockNode extends DecoratorNode<JSX.Element> {
14
- __format: ElementFormatType | null | undefined;
14
+ __format: ElementFormatType;
15
15
  constructor(format?: ElementFormatType, key?: NodeKey);
16
16
  exportJSON(): SerializedDecoratorBlockNode;
17
17
  createDOM(): HTMLElement;
@@ -18,7 +18,7 @@ var lexical = require('lexical');
18
18
  class DecoratorBlockNode extends lexical.DecoratorNode {
19
19
  constructor(format, key) {
20
20
  super(key);
21
- this.__format = format;
21
+ this.__format = format || '';
22
22
  }
23
23
 
24
24
  exportJSON() {
@@ -4,4 +4,4 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var b=require("lexical");class c extends b.DecoratorNode{constructor(a,d){super(d);this.__format=a}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(a){this.getWritable().__format=a}}exports.$isDecoratorBlockNode=function(a){return a instanceof c};exports.DecoratorBlockNode=c
7
+ 'use strict';var b=require("lexical");class c extends b.DecoratorNode{constructor(a,d){super(d);this.__format=a||""}exportJSON(){return{format:this.__format||"",type:"decorator-block",version:1}}createDOM(){return document.createElement("div")}updateDOM(){return!1}setFormat(a){this.getWritable().__format=a}}exports.$isDecoratorBlockNode=function(a){return a instanceof c};exports.DecoratorBlockNode=c
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export declare function HashtagPlugin(): JSX.Element;
8
+ export declare function HashtagPlugin(): JSX.Element | null;
@@ -6,8 +6,9 @@
6
6
  *
7
7
  */
8
8
  import type { EditorThemeClasses, LexicalEditor } from 'lexical';
9
+ import { ReactNode } from 'react';
9
10
  export declare function LexicalNestedComposer({ initialEditor, children, initialTheme, }: {
10
- children: JSX.Element | string | (JSX.Element | string)[];
11
+ children: ReactNode;
11
12
  initialEditor: LexicalEditor;
12
13
  initialTheme?: EditorThemeClasses;
13
14
  }): JSX.Element;
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict';var c=require("@lexical/react/LexicalCollaborationPlugin"),d=require("@lexical/react/LexicalComposerContext"),h=require("react");
8
- exports.LexicalNestedComposer=function({initialEditor:a,children:k,initialTheme:l}){let e=h.useContext(d.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #9; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let p=h.useMemo(()=>{const [f,m]=e,g=l||m.getTheme()||void 0,n=d.createLexicalComposerContext(e,g);void 0!==g&&(a._config.theme=g);a._parentEditor=f;a._nodes=f._nodes;a._config.namespace=f._config.namespace;
9
- return[a,n]},[]);var {yjsDocMap:b}=c.useCollaborationContext();let q=void 0!==b.get("main");b=b.has(a.getKey());return h.createElement(d.LexicalComposerContext.Provider,{value:p},!q||b?k:null)}
8
+ exports.LexicalNestedComposer=function({initialEditor:a,children:k,initialTheme:l}){let e=h.useContext(d.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #9; visit https://lexical.dev/docs/error?code=9 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let p=h.useMemo(()=>{const [f,m]=e,g=l||m.getTheme()||void 0,n=d.createLexicalComposerContext(e,g);void 0!==g&&(a._config.theme=g);a._parentEditor=f;a._nodes=f._nodes;
9
+ a._config.namespace=f._config.namespace;return[a,n]},[]);var {yjsDocMap:b}=c.useCollaborationContext();let q=void 0!==b.get("main");b=b.has(a.getKey());return h.createElement(d.LexicalComposerContext.Provider,{value:p},!q||b?k:null)}
@@ -9,10 +9,10 @@
9
9
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
10
10
  var React = require('react');
11
11
  var text = require('@lexical/text');
12
+ var utils = require('@lexical/utils');
12
13
  var reactDom = require('react-dom');
13
14
  var dragon = require('@lexical/dragon');
14
15
  var plainText = require('@lexical/plain-text');
15
- var utils = require('@lexical/utils');
16
16
 
17
17
  /**
18
18
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -59,18 +59,26 @@ var useLayoutEffect = useLayoutEffectImpl;
59
59
  * LICENSE file in the root directory of this source tree.
60
60
  *
61
61
  */
62
+
63
+ function canShowPlaceholderFromCurrentEditorState(editor) {
64
+ const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
65
+ return currentCanShowPlaceholder;
66
+ }
67
+
62
68
  function useCanShowPlaceholder(editor) {
63
- const [canShowPlaceholder, setCanShowPlaceholder] = React.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
69
+ const [canShowPlaceholder, setCanShowPlaceholder] = React.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
64
70
  useLayoutEffect(() => {
65
- let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
66
- setCanShowPlaceholder(currentCanShowPlaceholder);
67
- return editor.registerUpdateListener(({
68
- editorState
69
- }) => {
70
- const isComposing = editor.isComposing();
71
- currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
71
+ function resetCanShowPlaceholder() {
72
+ const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
72
73
  setCanShowPlaceholder(currentCanShowPlaceholder);
73
- });
74
+ }
75
+
76
+ resetCanShowPlaceholder();
77
+ return utils.mergeRegister(editor.registerUpdateListener(() => {
78
+ resetCanShowPlaceholder();
79
+ }), editor.registerReadOnlyListener(() => {
80
+ resetCanShowPlaceholder();
81
+ }));
74
82
  }, [editor]);
75
83
  return canShowPlaceholder;
76
84
  }
@@ -138,13 +146,13 @@ function usePlainTextSetup(editor, initialEditorState) {
138
146
  * LICENSE file in the root directory of this source tree.
139
147
  *
140
148
  */
141
- const deprecatedInitialEditorStateWarning = warnOnlyOnce('initialEditorState on PlainTextPlugin is deprecated and will be removed soon. Use LexicalComposer initialEditorState instead.');
149
+ const deprecatedInitialEditorStateWarning = warnOnlyOnce('`initialEditorState` on `PlainTextPlugin` is deprecated and will be removed soon. Use the `initialConfig.editorState` prop on the `LexicalComposer` instead.');
142
150
  function PlainTextPlugin({
143
151
  contentEditable,
144
152
  placeholder,
145
153
  initialEditorState
146
154
  }) {
147
- if (initialEditorState !== undefined) {
155
+ if (deprecatedInitialEditorStateWarning && initialEditorState !== undefined) {
148
156
  deprecatedInitialEditorStateWarning();
149
157
  }
150
158
 
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var e=require("@lexical/react/LexicalComposerContext"),h=require("react"),k=require("@lexical/text"),m=require("react-dom"),n=require("@lexical/dragon"),p=require("@lexical/plain-text"),q=require("@lexical/utils"),r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
8
- function t(a){let [c,f]=h.useState(a.getEditorState().read(k.$canShowPlaceholderCurry(a.isComposing())));r(()=>{let b=a.getEditorState().read(k.$canShowPlaceholderCurry(a.isComposing()));f(b);return a.registerUpdateListener(({editorState:g})=>{let d=a.isComposing();b=g.read(k.$canShowPlaceholderCurry(d));f(b)})},[a]);return c}
9
- function u(a){let [c,f]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{m.flushSync(()=>{f(b)})}),[a]);h.useEffect(()=>{f(a.getDecorators())},[a]);return h.useMemo(()=>{let b=[],g=Object.keys(c);for(let l=0;l<g.length;l++){var d=g[l];let v=c[d];d=a.getElementByKey(d);null!==d&&b.push(m.createPortal(v,d))}return b},[c,a])}function w(a,c){r(()=>q.mergeRegister(p.registerPlainText(a,c),n.registerDragonSupport(a)),[a])}
10
- exports.PlainTextPlugin=function({contentEditable:a,placeholder:c,initialEditorState:f}){void 0!==f&&(void 0)();let [b]=e.useLexicalComposerContext(),g=t(b),d=u(b);w(b,f);return h.createElement(h.Fragment,null,a,g&&c,d)}
7
+ 'use strict';var d=require("@lexical/react/LexicalComposerContext"),h=require("react"),l=require("@lexical/text"),m=require("@lexical/utils"),n=require("react-dom"),p=require("@lexical/dragon"),q=require("@lexical/plain-text"),r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;function t(a){return a.getEditorState().read(l.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
8
+ function u(a){let [c,f]=h.useState(()=>t(a));r(()=>{function b(){let g=t(a);f(g)}b();return m.mergeRegister(a.registerUpdateListener(()=>{b()}),a.registerReadOnlyListener(()=>{b()}))},[a]);return c}
9
+ function v(a){let [c,f]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{n.flushSync(()=>{f(b)})}),[a]);h.useEffect(()=>{f(a.getDecorators())},[a]);return h.useMemo(()=>{let b=[],g=Object.keys(c);for(let k=0;k<g.length;k++){var e=g[k];let w=c[e];e=a.getElementByKey(e);null!==e&&b.push(n.createPortal(w,e))}return b},[c,a])}function x(a,c){r(()=>m.mergeRegister(q.registerPlainText(a,c),p.registerDragonSupport(a)),[a])}
10
+ exports.PlainTextPlugin=function({contentEditable:a,placeholder:c,initialEditorState:f}){let [b]=d.useLexicalComposerContext(),g=u(b),e=v(b);x(b,f);return h.createElement(h.Fragment,null,a,g&&c,e)}
@@ -9,10 +9,10 @@
9
9
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
10
10
  var React = require('react');
11
11
  var text = require('@lexical/text');
12
+ var utils = require('@lexical/utils');
12
13
  var reactDom = require('react-dom');
13
14
  var dragon = require('@lexical/dragon');
14
15
  var richText = require('@lexical/rich-text');
15
- var utils = require('@lexical/utils');
16
16
 
17
17
  /**
18
18
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -59,18 +59,26 @@ var useLayoutEffect = useLayoutEffectImpl;
59
59
  * LICENSE file in the root directory of this source tree.
60
60
  *
61
61
  */
62
+
63
+ function canShowPlaceholderFromCurrentEditorState(editor) {
64
+ const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
65
+ return currentCanShowPlaceholder;
66
+ }
67
+
62
68
  function useCanShowPlaceholder(editor) {
63
- const [canShowPlaceholder, setCanShowPlaceholder] = React.useState(editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing())));
69
+ const [canShowPlaceholder, setCanShowPlaceholder] = React.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
64
70
  useLayoutEffect(() => {
65
- let currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing()));
66
- setCanShowPlaceholder(currentCanShowPlaceholder);
67
- return editor.registerUpdateListener(({
68
- editorState
69
- }) => {
70
- const isComposing = editor.isComposing();
71
- currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
71
+ function resetCanShowPlaceholder() {
72
+ const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
72
73
  setCanShowPlaceholder(currentCanShowPlaceholder);
73
- });
74
+ }
75
+
76
+ resetCanShowPlaceholder();
77
+ return utils.mergeRegister(editor.registerUpdateListener(() => {
78
+ resetCanShowPlaceholder();
79
+ }), editor.registerReadOnlyListener(() => {
80
+ resetCanShowPlaceholder();
81
+ }));
74
82
  }, [editor]);
75
83
  return canShowPlaceholder;
76
84
  }
@@ -138,13 +146,13 @@ function useRichTextSetup(editor, initialEditorState) {
138
146
  * LICENSE file in the root directory of this source tree.
139
147
  *
140
148
  */
141
- const deprecatedInitialEditorStateWarning = warnOnlyOnce('initialEditorState on RichTextPlugin is deprecated and will be removed soon. Use LexicalComposer initialEditorState instead.');
149
+ const deprecatedInitialEditorStateWarning = warnOnlyOnce('`initialEditorState` on `RichTextPlugin` is deprecated and will be removed soon. Use the `initialConfig.editorState` prop on the `LexicalComposer` instead.');
142
150
  function RichTextPlugin({
143
151
  contentEditable,
144
152
  placeholder,
145
153
  initialEditorState
146
154
  }) {
147
- if (initialEditorState !== undefined) {
155
+ if (deprecatedInitialEditorStateWarning && initialEditorState !== undefined) {
148
156
  deprecatedInitialEditorStateWarning();
149
157
  }
150
158
 
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var e=require("@lexical/react/LexicalComposerContext"),h=require("react"),k=require("@lexical/text"),m=require("react-dom"),n=require("@lexical/dragon"),p=require("@lexical/rich-text"),q=require("@lexical/utils"),r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
8
- function t(a){let [c,f]=h.useState(a.getEditorState().read(k.$canShowPlaceholderCurry(a.isComposing())));r(()=>{let b=a.getEditorState().read(k.$canShowPlaceholderCurry(a.isComposing()));f(b);return a.registerUpdateListener(({editorState:g})=>{let d=a.isComposing();b=g.read(k.$canShowPlaceholderCurry(d));f(b)})},[a]);return c}
9
- function u(a){let [c,f]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{m.flushSync(()=>{f(b)})}),[a]);h.useEffect(()=>{f(a.getDecorators())},[a]);return h.useMemo(()=>{let b=[],g=Object.keys(c);for(let l=0;l<g.length;l++){var d=g[l];let v=c[d];d=a.getElementByKey(d);null!==d&&b.push(m.createPortal(v,d))}return b},[c,a])}function w(a,c){r(()=>q.mergeRegister(p.registerRichText(a,c),n.registerDragonSupport(a)),[a])}
10
- exports.RichTextPlugin=function({contentEditable:a,placeholder:c,initialEditorState:f}){void 0!==f&&(void 0)();let [b]=e.useLexicalComposerContext(),g=t(b),d=u(b);w(b,f);return h.createElement(h.Fragment,null,a,g&&c,d)}
7
+ 'use strict';var d=require("@lexical/react/LexicalComposerContext"),h=require("react"),l=require("@lexical/text"),m=require("@lexical/utils"),n=require("react-dom"),p=require("@lexical/dragon"),q=require("@lexical/rich-text"),r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;function t(a){return a.getEditorState().read(l.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
8
+ function u(a){let [c,f]=h.useState(()=>t(a));r(()=>{function b(){let g=t(a);f(g)}b();return m.mergeRegister(a.registerUpdateListener(()=>{b()}),a.registerReadOnlyListener(()=>{b()}))},[a]);return c}
9
+ function v(a){let [c,f]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{n.flushSync(()=>{f(b)})}),[a]);h.useEffect(()=>{f(a.getDecorators())},[a]);return h.useMemo(()=>{let b=[],g=Object.keys(c);for(let k=0;k<g.length;k++){var e=g[k];let w=c[e];e=a.getElementByKey(e);null!==e&&b.push(n.createPortal(w,e))}return b},[c,a])}function x(a,c){r(()=>m.mergeRegister(q.registerRichText(a,c),p.registerDragonSupport(a)),[a])}
10
+ exports.RichTextPlugin=function({contentEditable:a,placeholder:c,initialEditorState:f}){let [b]=d.useLexicalComposerContext(),g=u(b),e=v(b);x(b,f);return h.createElement(h.Fragment,null,a,g&&c,e)}
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export declare function TablePlugin(): JSX.Element;
8
+ export declare function TablePlugin(): JSX.Element | null;
@@ -84,7 +84,7 @@ function TablePlugin() {
84
84
  } else if (mutation === 'destroyed') {
85
85
  const tableSelection = tableSelections.get(nodeKey);
86
86
 
87
- if (tableSelection) {
87
+ if (tableSelection !== undefined) {
88
88
  tableSelection.removeListeners();
89
89
  tableSelections.delete(nodeKey);
90
90
  }
@@ -5,6 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("@lexical/table"),k=require("lexical"),m=require("react");
8
- exports.TablePlugin=function(){let [c]=e.useLexicalComposerContext();m.useEffect(()=>{if(!c.hasNodes([f.TableNode,f.TableCellNode,f.TableRowNode]))throw Error("Minified Lexical error #10; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return c.registerCommand(f.INSERT_TABLE_COMMAND,({columns:a,rows:d,includeHeaders:g})=>{var b=k.$getSelection();if(!k.$isRangeSelection(b))return!0;let h=b.focus;b=h.getNode();null!==b&&
9
- (a=f.$createTableNodeWithDimensions(Number(d),Number(a),g),k.$isRootNode(b)?(d=b.getChildAtIndex(h.offset),null!==d?d.insertBefore(a):b.append(a),a.insertBefore(k.$createParagraphNode())):b.getTopLevelElementOrThrow().insertAfter(a),a.insertAfter(k.$createParagraphNode()),a.getFirstChildOrThrow().getFirstChildOrThrow().select());return!0},k.COMMAND_PRIORITY_EDITOR)},[c]);m.useEffect(()=>{let a=new Map;return c.registerMutationListener(f.TableNode,d=>{for(let [g,b]of d)"created"===b?c.update(()=>{var h=
10
- c.getElementByKey(g);let l=k.$getNodeByKey(g);h&&l&&(h=f.applyTableHandlers(l,h,c),a.set(g,h))}):"destroyed"===b&&(d=a.get(g))&&(d.removeListeners(),a.delete(g))})},[c]);return null}
8
+ exports.TablePlugin=function(){let [d]=e.useLexicalComposerContext();m.useEffect(()=>{if(!d.hasNodes([f.TableNode,f.TableCellNode,f.TableRowNode]))throw Error("Minified Lexical error #10; visit https://lexical.dev/docs/error?code=10 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return d.registerCommand(f.INSERT_TABLE_COMMAND,({columns:a,rows:c,includeHeaders:g})=>{var b=k.$getSelection();if(!k.$isRangeSelection(b))return!0;let h=b.focus;
9
+ b=h.getNode();null!==b&&(a=f.$createTableNodeWithDimensions(Number(c),Number(a),g),k.$isRootNode(b)?(c=b.getChildAtIndex(h.offset),null!==c?c.insertBefore(a):b.append(a),a.insertBefore(k.$createParagraphNode())):b.getTopLevelElementOrThrow().insertAfter(a),a.insertAfter(k.$createParagraphNode()),a.getFirstChildOrThrow().getFirstChildOrThrow().select());return!0},k.COMMAND_PRIORITY_EDITOR)},[d]);m.useEffect(()=>{let a=new Map;return d.registerMutationListener(f.TableNode,c=>{for(let [g,b]of c)"created"===
10
+ b?d.update(()=>{var h=d.getElementByKey(g);let l=k.$getNodeByKey(g);h&&l&&(h=f.applyTableHandlers(l,h,d),a.set(g,h))}):"destroyed"===b&&(c=a.get(g),void 0!==c&&(c.removeListeners(),a.delete(g)))})},[d]);return null}
package/package.json CHANGED
@@ -8,28 +8,28 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.3.4",
11
+ "version": "0.3.7",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.3.4",
14
- "@lexical/code": "0.3.4",
15
- "@lexical/dragon": "0.3.4",
16
- "@lexical/hashtag": "0.3.4",
17
- "@lexical/history": "0.3.4",
18
- "@lexical/link": "0.3.4",
19
- "@lexical/list": "0.3.4",
20
- "@lexical/mark": "0.3.4",
21
- "@lexical/markdown": "0.3.4",
22
- "@lexical/overflow": "0.3.4",
23
- "@lexical/plain-text": "0.3.4",
24
- "@lexical/rich-text": "0.3.4",
25
- "@lexical/selection": "0.3.4",
26
- "@lexical/table": "0.3.4",
27
- "@lexical/text": "0.3.4",
28
- "@lexical/utils": "0.3.4",
29
- "@lexical/yjs": "0.3.4"
13
+ "@lexical/clipboard": "0.3.7",
14
+ "@lexical/code": "0.3.7",
15
+ "@lexical/dragon": "0.3.7",
16
+ "@lexical/hashtag": "0.3.7",
17
+ "@lexical/history": "0.3.7",
18
+ "@lexical/link": "0.3.7",
19
+ "@lexical/list": "0.3.7",
20
+ "@lexical/mark": "0.3.7",
21
+ "@lexical/markdown": "0.3.7",
22
+ "@lexical/overflow": "0.3.7",
23
+ "@lexical/plain-text": "0.3.7",
24
+ "@lexical/rich-text": "0.3.7",
25
+ "@lexical/selection": "0.3.7",
26
+ "@lexical/table": "0.3.7",
27
+ "@lexical/text": "0.3.7",
28
+ "@lexical/utils": "0.3.7",
29
+ "@lexical/yjs": "0.3.7"
30
30
  },
31
31
  "peerDependencies": {
32
- "lexical": "0.3.4",
32
+ "lexical": "0.3.7",
33
33
  "react": ">=17.x",
34
34
  "react-dom": ">=17.x"
35
35
  },
@@ -37,8 +37,5 @@
37
37
  "type": "git",
38
38
  "url": "https://github.com/facebook/lexical",
39
39
  "directory": "packages/lexical-react"
40
- },
41
- "devDependencies": {
42
- "utility-types": "^3.10.0"
43
40
  }
44
41
  }
@@ -6,6 +6,5 @@
6
6
  *
7
7
  */
8
8
  import type { EntityMatch } from '@lexical/text';
9
- import type { TextNode } from 'lexical';
10
- import type { Klass } from 'shared/types';
11
- export declare function useLexicalTextEntity<N extends TextNode>(getMatch: (text: string) => null | EntityMatch, targetNode: Klass<N>, createNode: (textNode: TextNode) => N): void;
9
+ import type { Klass, TextNode } from 'lexical';
10
+ export declare function useLexicalTextEntity<T extends TextNode>(getMatch: (text: string) => null | EntityMatch, targetNode: Klass<T>, createNode: (textNode: TextNode) => T): void;