@lexical/react 0.1.4 → 0.1.8

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 (101) hide show
  1. package/DEPRECATED_useLexical.dev.js +84 -0
  2. package/DEPRECATED_useLexical.js +9 -2
  3. package/DEPRECATED_useLexical.prod.js +8 -0
  4. package/DEPRECATED_useLexicalAutoFormatter.dev.js +642 -0
  5. package/DEPRECATED_useLexicalAutoFormatter.js +9 -12
  6. package/DEPRECATED_useLexicalAutoFormatter.prod.js +22 -0
  7. package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +136 -0
  8. package/DEPRECATED_useLexicalCanShowPlaceholder.js +9 -3
  9. package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +8 -0
  10. package/DEPRECATED_useLexicalCharacterLimit.dev.js +294 -0
  11. package/DEPRECATED_useLexicalCharacterLimit.js +9 -9
  12. package/DEPRECATED_useLexicalCharacterLimit.prod.js +14 -0
  13. package/DEPRECATED_useLexicalDecorators.dev.js +82 -0
  14. package/DEPRECATED_useLexicalDecorators.js +9 -2
  15. package/DEPRECATED_useLexicalDecorators.prod.js +8 -0
  16. package/DEPRECATED_useLexicalEditor.dev.js +52 -0
  17. package/DEPRECATED_useLexicalEditor.js +9 -1
  18. package/DEPRECATED_useLexicalEditor.prod.js +7 -0
  19. package/DEPRECATED_useLexicalEditorEvents.dev.js +96 -0
  20. package/DEPRECATED_useLexicalEditorEvents.js +9 -2
  21. package/DEPRECATED_useLexicalEditorEvents.prod.js +8 -0
  22. package/DEPRECATED_useLexicalHistory.dev.js +339 -0
  23. package/DEPRECATED_useLexicalHistory.js +9 -7
  24. package/DEPRECATED_useLexicalHistory.prod.js +13 -0
  25. package/DEPRECATED_useLexicalList.dev.js +64 -0
  26. package/DEPRECATED_useLexicalList.js +9 -12
  27. package/DEPRECATED_useLexicalList.prod.js +7 -0
  28. package/DEPRECATED_useLexicalPlainText.dev.js +755 -0
  29. package/DEPRECATED_useLexicalPlainText.js +9 -17
  30. package/DEPRECATED_useLexicalPlainText.prod.js +22 -0
  31. package/DEPRECATED_useLexicalRichText.dev.js +1326 -0
  32. package/DEPRECATED_useLexicalRichText.js +9 -30
  33. package/DEPRECATED_useLexicalRichText.prod.js +35 -0
  34. package/LexicalAutoFormatterPlugin.dev.js +645 -0
  35. package/LexicalAutoFormatterPlugin.js +9 -13
  36. package/LexicalAutoFormatterPlugin.prod.js +23 -0
  37. package/LexicalAutoLinkPlugin.dev.js +227 -0
  38. package/LexicalAutoLinkPlugin.js +9 -5
  39. package/LexicalAutoLinkPlugin.prod.js +12 -0
  40. package/LexicalBootstrapPlugin.dev.js +124 -0
  41. package/LexicalBootstrapPlugin.js +9 -0
  42. package/LexicalBootstrapPlugin.prod.js +8 -0
  43. package/LexicalCharacterLimitPlugin.dev.js +352 -0
  44. package/LexicalCharacterLimitPlugin.js +9 -10
  45. package/LexicalCharacterLimitPlugin.prod.js +14 -0
  46. package/LexicalCollaborationPlugin.dev.js +235 -0
  47. package/LexicalCollaborationPlugin.js +9 -8
  48. package/LexicalCollaborationPlugin.prod.js +14 -0
  49. package/LexicalComposer.dev.js +76 -0
  50. package/LexicalComposer.js +9 -2
  51. package/LexicalComposer.prod.js +9 -0
  52. package/LexicalComposerContext.dev.js +53 -0
  53. package/LexicalComposerContext.js +9 -1
  54. package/LexicalComposerContext.prod.js +7 -0
  55. package/LexicalContentEditable.dev.js +71 -0
  56. package/LexicalContentEditable.js +9 -3
  57. package/LexicalContentEditable.prod.js +9 -0
  58. package/LexicalHashtagPlugin.dev.js +152 -0
  59. package/LexicalHashtagPlugin.js +9 -4
  60. package/LexicalHashtagPlugin.prod.js +10 -0
  61. package/LexicalHistoryPlugin.dev.js +344 -0
  62. package/LexicalHistoryPlugin.js +9 -7
  63. package/LexicalHistoryPlugin.prod.js +13 -0
  64. package/LexicalHorizontalRulePlugin.dev.js +51 -0
  65. package/LexicalHorizontalRulePlugin.js +9 -1
  66. package/LexicalHorizontalRulePlugin.prod.js +7 -0
  67. package/LexicalLinkPlugin.dev.js +137 -0
  68. package/LexicalLinkPlugin.js +9 -3
  69. package/LexicalLinkPlugin.prod.js +9 -0
  70. package/LexicalListPlugin.dev.js +67 -0
  71. package/LexicalListPlugin.js +9 -12
  72. package/LexicalListPlugin.prod.js +8 -0
  73. package/LexicalNestedComposer.dev.js +60 -0
  74. package/LexicalNestedComposer.js +9 -1
  75. package/LexicalNestedComposer.prod.js +8 -0
  76. package/LexicalOnChangePlugin.dev.js +57 -0
  77. package/LexicalOnChangePlugin.js +9 -1
  78. package/LexicalOnChangePlugin.prod.js +7 -0
  79. package/LexicalPlainTextPlugin.dev.js +565 -0
  80. package/LexicalPlainTextPlugin.js +9 -13
  81. package/LexicalPlainTextPlugin.prod.js +17 -0
  82. package/LexicalRichTextPlugin.dev.js +1136 -0
  83. package/LexicalRichTextPlugin.js +9 -26
  84. package/LexicalRichTextPlugin.prod.js +31 -0
  85. package/LexicalTablePlugin.dev.js +95 -0
  86. package/LexicalTablePlugin.js +9 -4
  87. package/LexicalTablePlugin.prod.js +9 -0
  88. package/LexicalTreeView.dev.js +340 -0
  89. package/LexicalTreeView.js +9 -12
  90. package/LexicalTreeView.prod.js +19 -0
  91. package/README.md +11 -6
  92. package/package.json +4 -4
  93. package/useLexicalDecoratorMap.dev.js +83 -0
  94. package/useLexicalDecoratorMap.js +9 -1
  95. package/useLexicalDecoratorMap.prod.js +8 -0
  96. package/useLexicalIsTextContentEmpty.dev.js +84 -0
  97. package/useLexicalIsTextContentEmpty.js +9 -2
  98. package/useLexicalIsTextContentEmpty.prod.js +8 -0
  99. package/withSubscriptions.dev.js +23 -0
  100. package/withSubscriptions.js +9 -1
  101. package/withSubscriptions.prod.js +7 -0
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';var n=require("@lexical/list"),p=require("lexical"),r=require("lexical/CodeNode"),v=require("react"),x=require("lexical/HeadingNode"),y=require("lexical/QuoteNode");function z(g){throw Error(`Minified Lexical error #${g}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
8
+ function A(g,k,b,a){g=g.getChildren();const d=g.length;let e=0;for(let h=0;h<d&&!(e>=k);++h){const f=g[h];var c=p.$isTextNode(f)?f.getTextContent().length:a;c=e+c;if(e<=b&&b<c&&p.$isTextNode(f))return{node:f,offset:b-e};e=c}return null}
9
+ const B={nodeTransformationKind:null,regEx:/(?:)/,regExCaptureGroupsToDelete:null,regExExpectedCaptureGroupCount:1,requiresParagraphStart:!1},C={...B,requiresParagraphStart:!0},D=[{...B,nodeTransformationKind:"textBold",regEx:/(\*)(\s*\b)([^\*]*)(\b\s*)(\*\s)$/,regExCaptureGroupsToDelete:[1,5],regExExpectedCaptureGroupCount:6}],F=[{...C,nodeTransformationKind:"paragraphH1",regEx:/(?:# )/},{...C,nodeTransformationKind:"paragraphH2",regEx:/(?:## )/},{...C,nodeTransformationKind:"paragraphH2",regEx:/(?:### )/},
10
+ {...C,nodeTransformationKind:"paragraphBlockQuote",regEx:/(?:> )/},{...C,nodeTransformationKind:"paragraphUnorderedList",regEx:/(?:- )/},{...C,nodeTransformationKind:"paragraphUnorderedList",regEx:/(?:\* )/},{...C,nodeTransformationKind:"paragraphOrderedList",regEx:/^(\d+)\.\s/,regExExpectedCaptureGroupCount:2},{...C,nodeTransformationKind:"paragraphCodeBlock",regEx:/(?:``` )/},...D];
11
+ function G(g,k,b,a,d){const e={regExCaptureGroups:[],triggerState:null};a=g.match(a);if(null!==a&&0<a.length&&a.length===d&&(!1===k||0===a.index)&&(!1===b||a.index+a[0].length===g.length)){g=a.length;k=a.index;for(b=0;b<g;b++)d=a[b],e.regExCaptureGroups.push({anchorTextNodeWithOffset:null,focusTextNodeWithOffset:null,offsetInParent:k,text:d,textLength:d.length-(b+1===g?1:0)}),0<b&&(k+=d.length);return e}return null}
12
+ function H(g,k,b,a,d){d=d.regExCaptureGroups;const e=d.length;for(a+=1;a<e;a++){const c=d[a];null!=c.anchorTextNodeWithOffset&&c.anchorTextNodeWithOffset.offset>=k&&c.anchorTextNodeWithOffset.node.is(b)&&(c.anchorTextNodeWithOffset.offset+=g);null!=c.focusTextNodeWithOffset&&c.focusTextNodeWithOffset.offset>=k&&c.focusTextNodeWithOffset.node.is(b)&&(c.focusTextNodeWithOffset.offset+=g)}}
13
+ function I(g,k){g.update(()=>{var b=p.$getSelection();if(null==b)b=null;else{var a=b.anchor.getNode();b=p.$isTextNode(a)?{node:a,offset:b.anchor.offset}:null}if(null!==b){b={joinedText:null,textNodeWithOffset:b};a:{a=!1===k.isParentAListItemNode?F:D;var d=a.length;for(var e=0;e<d;e++){var c=a[e];if(!1===k.isCodeBlock||"paragraphCodeBlock"===c.nodeTransformationKind){var h=c,f=b;if(null!==h.requiresParagraphStart&&!0===h.requiresParagraphStart)null===f.textNodeWithOffset.node.getPreviousSibling()?
14
+ (f=f.textNodeWithOffset.node.getTextContent(),h=G(f,!0,!1,h.regEx,h.regExExpectedCaptureGroupCount)):h=null;else b:{if(null==f.joinedText){var q=f.textNodeWithOffset.node.getParentOrThrow();if(p.$isElementNode(q)){if(null==f.joinedText){var l=f,m=f.textNodeWithOffset;let u="";q=q.getChildren();const J=q.length;for(let w=0;w<J;++w){const t=q[w];if(p.$isTextNode(t)){const E=t.getTextContent();if(t.is(m.node)){m.offset>E.length&&z(50,t.__key);u+=t.getTextContent().substr(0,m.offset);break}else u+=E}else u+=
15
+ "\u0004"}l.joinedText=u}h=G(f.joinedText,!1,!0,h.regEx,h.regExExpectedCaptureGroupCount);break b}z(52,q.__key)}h=null}if(null!=h){h.triggerState=k;a={autoFormatCriteria:c,matchResultContext:h};break a}}}a={autoFormatCriteria:null,matchResultContext:null}}if(null!==a.autoFormatCriteria&&null!==a.matchResultContext)if(d=a.autoFormatCriteria,a=a.matchResultContext,d.requiresParagraphStart){e=b.textNodeWithOffset;b=e.node.getParentOrThrow();e=e.node.spliceText(0,a.regExCaptureGroups[0].text.length,"",
16
+ !0);""===e.getTextContent()&&(e.selectPrevious(),e.remove());e=b.getChildren();c=null;if(null!=d.nodeTransformationKind)switch(d.nodeTransformationKind){case "paragraphH1":c=x.$createHeadingNode("h1");c.append(...e);break;case "paragraphH2":c=x.$createHeadingNode("h2");c.append(...e);break;case "paragraphH3":c=x.$createHeadingNode("h3");c.append(...e);break;case "paragraphBlockQuote":c=y.$createQuoteNode();c.append(...e);break;case "paragraphUnorderedList":c=n.$createListNode("ul");a=n.$createListItemNode();
17
+ a.append(...e);c.append(a);break;case "paragraphOrderedList":a=parseInt(1<a.regExCaptureGroups.length?a.regExCaptureGroups[a.regExCaptureGroups.length-1].text:"1",10);c=n.$createListNode("ol",a);a=n.$createListItemNode();a.append(...e);c.append(a);break;case "paragraphCodeBlock":c=null!=a.triggerState&&a.triggerState.isCodeBlock?p.$createParagraphNode():r.$createCodeNode(),c.append(...e)}a=c;null!==a&&b.replace(a)}else if(null!=d.nodeTransformationKind)switch(d.nodeTransformationKind){case "textBold":e=
18
+ a.regExCaptureGroups;c=e.length;h=b.textNodeWithOffset.node.getParentOrThrow();if(null==b.joinedText)throw Error("joinedText was not calculated");b=b.joinedText.length;for(f=1;f<c;f++)if(l=e[f],l.anchorTextNodeWithOffset=A(h,b,l.offsetInParent,1),l.focusTextNodeWithOffset=A(h,b,l.offsetInParent+l.textLength,1),0>l.textLength)throw Error(`Bad regEx pattern found for ${d.nodeTransformationKind}`);a.regExCaptureGroups=e;if(null!=d.regExCaptureGroupsToDelete){b=d.regExCaptureGroupsToDelete;d=a.regExCaptureGroups;
19
+ e=d.length;for(c=b.length-1;0<=c;c--)if(c<e&&(h=b[c],m=d[h],l=m.anchorTextNodeWithOffset,f=m.focusTextNodeWithOffset,null!=l&&null!=f&&0<m.textLength&&(m=p.$createRangeSelection(),m.anchor.set(l.node.getKey(),l.offset,"text"),m.focus.set(f.node.getKey(),f.offset,"text"),p.$setSelection(m),m=p.$getSelection(),null!=m)))if(m.removeText(),l.node.getKey()===f.node.getKey()){m=f.offset-l.offset;if(!(0<m))throw Error("Expected anchor and focus offsets to have ascending character order.");H(-m,f.offset,
20
+ l.node,h,a)}else l=f.offset,0<l&&H(-l,l,f.node,h,a);b=a.regExCaptureGroups;if(!(3<b.length))throw Error("The capture group count in the RegEx does match the actual capture group count.");d=b[3];b=d.anchorTextNodeWithOffset;a=d.focusTextNodeWithOffset;null!=b&&null!=a&&0<d.textLength&&(d=p.$createRangeSelection(),d.anchor.set(b.node.getKey(),b.offset,"text"),d.focus.set(a.node.getKey(),a.offset,"text"),p.$setSelection(d),b=p.$getSelection(),null!=b&&b.formatText("bold"))}}}})}
21
+ function K(g){let k=null;g.read(()=>{const b=p.$getSelection();if(null!=b&&b.isCollapsed()){var a=b.anchor.getNode(),d=a.getParent(),e=null!==d&&n.$isListItemNode(d);k={anchorOffset:b.anchor.offset,hasParentNode:null!==d,isCodeBlock:r.$isCodeNode(a),isParentAListItemNode:e,isSelectionCollapsed:b.isCollapsed(),isSimpleText:p.$isTextNode(a)&&a.isSimpleText(),nodeKey:a.getKey(),textContent:a.getTextContent()}}});return k}
22
+ function L(g){v.useEffect(()=>{let k=null;g.addListener("update",({tags:b})=>{if(!1===b.has("historic")){b=K(g.getEditorState());var a=b;var d=k;if(null==a||null==d)a=!1;else{var e=a.textContent.length,c=a.anchorOffset-1;a=!0===a.hasParentNode&&a.isSimpleText&&a.isSelectionCollapsed&&a.nodeKey===d.nodeKey&&a.anchorOffset!==d.anchorOffset&&0<=c&&c+1<=e&&" "===a.textContent.substr(c,1)&&a.textContent!==d.textContent}a&&null!=b&&I(g,b);k=b}else k=null})},[g])}module.exports=function(g){L(g)};
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';
8
+
9
+ var lexical = require('lexical');
10
+ var react = require('react');
11
+
12
+ /**
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ *
19
+ */
20
+ function $textContent() {
21
+ const root = lexical.$getRoot();
22
+ return root.getTextContent();
23
+ }
24
+ function $isTextContentEmpty(isEditorComposing, trim = true) {
25
+ if (isEditorComposing) {
26
+ return false;
27
+ }
28
+
29
+ let text = $textContent();
30
+
31
+ if (trim) {
32
+ text = text.trim();
33
+ }
34
+
35
+ return text === '';
36
+ }
37
+ function $canShowPlaceholder(isComposing) {
38
+ if (!$isTextContentEmpty(isComposing, false)) {
39
+ return false;
40
+ }
41
+
42
+ const root = lexical.$getRoot();
43
+ const children = root.getChildren();
44
+ const childrenLength = children.length;
45
+
46
+ if (childrenLength > 1) {
47
+ return false;
48
+ }
49
+
50
+ for (let i = 0; i < childrenLength; i++) {
51
+ const topBlock = children[i];
52
+
53
+ if (lexical.$isElementNode(topBlock)) {
54
+ if (topBlock.__type !== 'paragraph') {
55
+ return false;
56
+ }
57
+
58
+ if (topBlock.__indent !== 0) {
59
+ return false;
60
+ }
61
+
62
+ const topBlockChildren = topBlock.getChildren();
63
+ const topBlockChildrenLength = topBlockChildren.length;
64
+
65
+ for (let s = 0; s < topBlockChildrenLength; s++) {
66
+ const child = topBlockChildren[i];
67
+
68
+ if (!lexical.$isTextNode(child)) {
69
+ return false;
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ return true;
76
+ }
77
+ function $canShowPlaceholderCurry(isEditorComposing) {
78
+ return () => $canShowPlaceholder(isEditorComposing);
79
+ }
80
+
81
+ /**
82
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
83
+ *
84
+ * This source code is licensed under the MIT license found in the
85
+ * LICENSE file in the root directory of this source tree.
86
+ *
87
+ *
88
+ */
89
+ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
90
+
91
+ /**
92
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
93
+ *
94
+ * This source code is licensed under the MIT license found in the
95
+ * LICENSE file in the root directory of this source tree.
96
+ *
97
+ *
98
+ */
99
+ const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
100
+ var useLayoutEffect = useLayoutEffectImpl;
101
+
102
+ /**
103
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
104
+ *
105
+ * This source code is licensed under the MIT license found in the
106
+ * LICENSE file in the root directory of this source tree.
107
+ *
108
+ *
109
+ */
110
+ function useLexicalCanShowPlaceholder$1(editor) {
111
+ const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(editor.getEditorState().read($canShowPlaceholderCurry(editor.isComposing())));
112
+ useLayoutEffect(() => {
113
+ return editor.addListener('update', ({
114
+ editorState
115
+ }) => {
116
+ const isComposing = editor.isComposing();
117
+ const currentCanShowPlaceholder = editorState.read($canShowPlaceholderCurry(isComposing));
118
+ setCanShowPlaceholder(currentCanShowPlaceholder);
119
+ });
120
+ }, [editor]);
121
+ return canShowPlaceholder;
122
+ }
123
+
124
+ /**
125
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
126
+ *
127
+ * This source code is licensed under the MIT license found in the
128
+ * LICENSE file in the root directory of this source tree.
129
+ *
130
+ *
131
+ */
132
+ function useLexicalCanShowPlaceholder(editor) {
133
+ return useLexicalCanShowPlaceholder$1(editor);
134
+ }
135
+
136
+ module.exports = useLexicalCanShowPlaceholder;
@@ -1,3 +1,9 @@
1
- 'use strict';var e=require("react"),f=require("lexical"),k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?e.useLayoutEffect:e.useEffect;function l(a,d=!0){if(a)return!1;a=f.$getRoot().getTextContent();d&&(a=a.trim());return""===a}
2
- function m(a){if(!l(a,!1))return!1;a=f.$getRoot().getChildren();const d=a.length;if(1<d)return!1;for(let c=0;c<d;c++){var b=a[c];if(f.$isElementNode(b)){if("paragraph"!==b.__type||0!==b.__indent)return!1;b=b.getChildren();const g=b.length;for(let h=0;h<g;h++)if(!f.$isTextNode(b[c]))return!1}}return!0}function n(a){return()=>m(a)}
3
- function p(a){const [d,b]=e.useState(a.getEditorState().read(n(a.isComposing())));k(()=>a.addListener("update",({editorState:c})=>{const g=a.isComposing();c=c.read(n(g));b(c)}),[a]);return d}module.exports=function(a){return p(a)};
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict'
8
+ const DEPRECATED_useLexicalCanShowPlaceholder = process.env.NODE_ENV === 'development' ? require('./DEPRECATED_useLexicalCanShowPlaceholder.dev.js') : require('./DEPRECATED_useLexicalCanShowPlaceholder.prod.js')
9
+ module.exports = DEPRECATED_useLexicalCanShowPlaceholder;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';var e=require("lexical"),f=require("react");function k(a,d=!0){if(a)return!1;a=e.$getRoot().getTextContent();d&&(a=a.trim());return""===a}function l(a){if(!k(a,!1))return!1;a=e.$getRoot().getChildren();const d=a.length;if(1<d)return!1;for(let c=0;c<d;c++){var b=a[c];if(e.$isElementNode(b)){if("paragraph"!==b.__type||0!==b.__indent)return!1;b=b.getChildren();const g=b.length;for(let h=0;h<g;h++)if(!e.$isTextNode(b[c]))return!1}}return!0}function m(a){return()=>l(a)}
8
+ var n="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;function p(a){const [d,b]=f.useState(a.getEditorState().read(m(a.isComposing())));n(()=>a.addListener("update",({editorState:c})=>{const g=a.isComposing();c=c.read(m(g));b(c)}),[a]);return d}module.exports=function(a){return p(a)};
@@ -0,0 +1,294 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';
8
+
9
+ var lexical = require('lexical');
10
+ var withSubscriptions = require('@lexical/react/withSubscriptions');
11
+ var OverflowNode = require('lexical/OverflowNode');
12
+ var react = require('react');
13
+
14
+ /**
15
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ *
20
+ *
21
+ */
22
+ function $dfs__DEPRECATED(startingNode, nextNode) {
23
+ let node = startingNode;
24
+ nextNode(node);
25
+
26
+ while (node !== null) {
27
+ if (lexical.$isElementNode(node) && node.getChildrenSize() > 0) {
28
+ node = node.getFirstChild();
29
+ } else {
30
+ // Find immediate sibling or nearest parent sibling
31
+ let sibling = null;
32
+
33
+ while (sibling === null && node !== null) {
34
+ sibling = node.getNextSibling();
35
+
36
+ if (sibling === null) {
37
+ node = node.getParent();
38
+ } else {
39
+ node = sibling;
40
+ }
41
+ }
42
+ }
43
+
44
+ if (node !== null) {
45
+ node = nextNode(node);
46
+ }
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
52
+ *
53
+ * This source code is licensed under the MIT license found in the
54
+ * LICENSE file in the root directory of this source tree.
55
+ *
56
+ *
57
+ */
58
+ function $textContent() {
59
+ const root = lexical.$getRoot();
60
+ return root.getTextContent();
61
+ }
62
+ const $textContentCurry = $textContent;
63
+
64
+ /**
65
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
66
+ *
67
+ * This source code is licensed under the MIT license found in the
68
+ * LICENSE file in the root directory of this source tree.
69
+ *
70
+ *
71
+ */
72
+ function useCharacterLimit(editor, maxCharacters, optional = Object.freeze({})) {
73
+ const {
74
+ strlen = input => input.length,
75
+ // UTF-16
76
+ remainingCharacters = characters => {}
77
+ } = optional;
78
+ react.useEffect(() => {
79
+ if (!editor.hasNodes([OverflowNode.OverflowNode])) {
80
+ {
81
+ throw Error(`useCharacterLimit: OverflowNode not registered on editor`);
82
+ }
83
+ }
84
+ }, [editor]);
85
+ react.useEffect(() => {
86
+ let text = editor.getEditorState().read($textContentCurry);
87
+ let lastComputedTextLength = 0;
88
+ return withSubscriptions(editor.addListener('textcontent', currentText => {
89
+ text = currentText;
90
+ }), editor.addListener('update', ({
91
+ dirtyLeaves
92
+ }) => {
93
+ const isComposing = editor.isComposing();
94
+ const hasDirtyLeaves = dirtyLeaves.size > 0;
95
+
96
+ if (isComposing || !hasDirtyLeaves) {
97
+ return;
98
+ }
99
+
100
+ const textLength = strlen(text);
101
+ const textLengthAboveThreshold = textLength > maxCharacters || lastComputedTextLength !== null && lastComputedTextLength > maxCharacters;
102
+ const diff = maxCharacters - textLength;
103
+ remainingCharacters(diff);
104
+
105
+ if (lastComputedTextLength === null || textLengthAboveThreshold) {
106
+ const offset = findOffset(text, maxCharacters, strlen);
107
+ editor.update(() => {
108
+ lexical.$log('CharacterLimit');
109
+ $wrapOverflowedNodes(offset);
110
+ }, {
111
+ tag: 'without-history'
112
+ });
113
+ }
114
+
115
+ lastComputedTextLength = textLength;
116
+ }));
117
+ }, [editor, maxCharacters, remainingCharacters, strlen]);
118
+ }
119
+
120
+ function findOffset(text, maxCharacters, strlen) {
121
+ const Segmenter = Intl.Segmenter;
122
+ let offsetUtf16 = 0;
123
+ let offset = 0;
124
+
125
+ if (typeof Segmenter === 'function') {
126
+ const segmenter = new Segmenter();
127
+ const graphemes = segmenter.segment(text); // eslint-disable-next-line no-for-of-loops/no-for-of-loops
128
+
129
+ for (const {
130
+ segment: grapheme
131
+ } of graphemes) {
132
+ const nextOffset = offset + strlen(grapheme);
133
+
134
+ if (nextOffset > maxCharacters) {
135
+ break;
136
+ }
137
+
138
+ offset = nextOffset;
139
+ offsetUtf16 += grapheme.length;
140
+ }
141
+ } else {
142
+ const codepoints = Array.from(text);
143
+ const codepointsLength = codepoints.length;
144
+
145
+ for (let i = 0; i < codepointsLength; i++) {
146
+ const codepoint = codepoints[i];
147
+ const nextOffset = offset + strlen(codepoint);
148
+
149
+ if (nextOffset > maxCharacters) {
150
+ break;
151
+ }
152
+
153
+ offset = nextOffset;
154
+ offsetUtf16 += codepoint.length;
155
+ }
156
+ }
157
+
158
+ return offsetUtf16;
159
+ }
160
+
161
+ function $wrapOverflowedNodes(offset) {
162
+ const root = lexical.$getRoot();
163
+ let accumulatedLength = 0;
164
+ let previousNode = root;
165
+ $dfs__DEPRECATED(root, node => {
166
+ if (OverflowNode.$isOverflowNode(node)) {
167
+ const previousLength = accumulatedLength;
168
+ const nextLength = accumulatedLength + node.getTextContentSize();
169
+
170
+ if (nextLength <= offset) {
171
+ const parent = node.getParent();
172
+ const previousSibling = node.getPreviousSibling();
173
+ const nextSibling = node.getNextSibling();
174
+ $unwrapNode(node);
175
+ const selection = lexical.$getSelection(); // Restore selection when the overflow children are removed
176
+
177
+ if (selection !== null && (!selection.anchor.getNode().isAttached() || !selection.focus.getNode().isAttached())) {
178
+ if (lexical.$isTextNode(previousSibling)) {
179
+ previousSibling.select();
180
+ } else if (lexical.$isTextNode(nextSibling)) {
181
+ nextSibling.select();
182
+ } else if (parent !== null) {
183
+ parent.select();
184
+ }
185
+ }
186
+
187
+ return previousNode;
188
+ } else if (previousLength < offset) {
189
+ const descendant = node.getFirstDescendant();
190
+ const descendantLength = descendant !== null ? descendant.getTextContentSize() : 0;
191
+ const previousPlusDescendantLength = previousLength + descendantLength; // For simple text we can redimension the overflow into a smaller and more accurate
192
+ // container
193
+
194
+ const firstDescendantIsSimpleText = lexical.$isTextNode(descendant) && descendant.isSimpleText();
195
+ const firstDescendantDoesNotOverflow = previousPlusDescendantLength <= offset;
196
+
197
+ if (firstDescendantIsSimpleText || firstDescendantDoesNotOverflow) {
198
+ $unwrapNode(node);
199
+ return previousNode;
200
+ }
201
+ }
202
+ } else if (lexical.$isLeafNode(node)) {
203
+ const previousAccumulatedLength = accumulatedLength;
204
+ accumulatedLength += node.getTextContentSize();
205
+
206
+ if (accumulatedLength > offset && !OverflowNode.$isOverflowNode(node.getParent())) {
207
+ const previousSelection = lexical.$getSelection();
208
+ let overflowNode; // For simple text we can improve the limit accuracy by splitting the TextNode
209
+ // on the split point
210
+
211
+ if (previousAccumulatedLength < offset && lexical.$isTextNode(node) && node.isSimpleText()) {
212
+ const [, overflowedText] = node.splitText(offset - previousAccumulatedLength);
213
+ overflowNode = $wrapNode(overflowedText);
214
+ } else {
215
+ overflowNode = $wrapNode(node);
216
+ }
217
+
218
+ if (previousSelection !== null) {
219
+ lexical.$setSelection(previousSelection);
220
+ }
221
+
222
+ mergePrevious(overflowNode);
223
+ }
224
+ }
225
+
226
+ previousNode = node;
227
+ return node;
228
+ });
229
+ }
230
+
231
+ function $wrapNode(node) {
232
+ const overflowNode = OverflowNode.$createOverflowNode();
233
+ node.insertBefore(overflowNode);
234
+ overflowNode.append(node);
235
+ return overflowNode;
236
+ }
237
+
238
+ function $unwrapNode(node) {
239
+ const children = node.getChildren();
240
+ const childrenLength = children.length;
241
+
242
+ for (let i = 0; i < childrenLength; i++) {
243
+ node.insertBefore(children[i]);
244
+ }
245
+
246
+ node.remove();
247
+ return childrenLength > 0 ? children[childrenLength - 1] : null;
248
+ }
249
+
250
+ function mergePrevious(overflowNode) {
251
+ const previousNode = overflowNode.getPreviousSibling();
252
+
253
+ if (!OverflowNode.$isOverflowNode(previousNode)) {
254
+ return;
255
+ }
256
+
257
+ const firstChild = overflowNode.getFirstChild();
258
+ const previousNodeChildren = previousNode.getChildren();
259
+ const previousNodeChildrenLength = previousNodeChildren.length;
260
+
261
+ if (firstChild === null) {
262
+ overflowNode.append(...previousNodeChildren);
263
+ } else {
264
+ for (let i = 0; i < previousNodeChildrenLength; i++) {
265
+ firstChild.insertBefore(previousNodeChildren[i]);
266
+ }
267
+ }
268
+
269
+ const selection = lexical.$getSelection();
270
+
271
+ if (selection !== null) {
272
+ const anchor = selection.anchor;
273
+ const anchorNode = anchor.getNode();
274
+ const focus = selection.focus;
275
+ const focusNode = anchor.getNode();
276
+
277
+ if (anchorNode.is(previousNode)) {
278
+ anchor.set(overflowNode.getKey(), anchor.offset, 'element');
279
+ } else if (anchorNode.is(overflowNode)) {
280
+ anchor.set(overflowNode.getKey(), previousNodeChildrenLength + anchor.offset, 'element');
281
+ }
282
+
283
+ if (focusNode.is(previousNode)) {
284
+ focus.set(overflowNode.getKey(), focus.offset, 'element');
285
+ } else if (focusNode.is(overflowNode)) {
286
+ focus.set(overflowNode.getKey(), previousNodeChildrenLength + focus.offset, 'element');
287
+ }
288
+ }
289
+
290
+ previousNode.remove();
291
+ }
292
+
293
+ exports.mergePrevious = mergePrevious;
294
+ exports.useCharacterLimit = useCharacterLimit;
@@ -1,9 +1,9 @@
1
- 'use strict';var k=require("lexical"),l=require("react"),n=require("@lexical/react/withSubscriptions");function p(a,c){for(c(a);null!==a;){if(k.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild();else{let e=null;for(;null===e&&null!==a;)e=a.getNextSibling(),a=null===e?a.getParent():e}null!==a&&(a=c(a))}}function q(){return k.$getRoot().getTextContent()}
2
- function r(a,c,e){var g=Intl.Segmenter;let d=0;var b=0;if("function"===typeof g){a=(new g).segment(a);for(var {segment:f}of a){b+=e(f);if(b>c)break;d+=f.length}}else for(f=Array.from(a),a=f.length,g=0;g<a;g++){const h=f[g];b+=e(h);if(b>c)break;d+=h.length}return d}
3
- function t(a){const c=k.$getRoot();let e=0,g=c;p(c,d=>{if(u(d)){var b=e;if(e+d.getTextContentSize()<=a){var f=d.getParent();b=d.getPreviousSibling();var h=d.getNextSibling();v(d);d=k.$getSelection();null===d||d.anchor.getNode().isAttached()&&d.focus.getNode().isAttached()||(k.$isTextNode(b)?b.select():k.$isTextNode(h)?h.select():null!==f&&f.select());return g}if(b<a&&(f=d.getFirstDescendant(),h=null!==f?f.getTextContentSize():0,b+=h,f=k.$isTextNode(f)&&f.isSimpleText(),b=b<=a,f||b))return v(d),g}else k.$isLeafNode(d)&&
4
- (b=e,e+=d.getTextContentSize(),e>a&&!u(d.getParent())&&(f=k.$getSelection(),b<a&&k.$isTextNode(d)&&d.isSimpleText()?([,b]=d.splitText(a-b),b=w(b)):b=w(d),null!==f&&k.$setSelection(f),x(b)));return g=d})}
5
- class y extends k.ElementNode{static getType(){return"overflow"}static clone(a){return new y(a.__key)}constructor(a){super(a);this.__type="overflow"}createDOM(a){const c=document.createElement("div");a=a.theme.characterLimit;"string"===typeof a&&(c.className=a);return c}updateDOM(){return!1}insertNewAfter(a){return this.getParentOrThrow().insertNewAfter(a)}excludeFromCopy(){return!0}}function z(){return new y}function u(a){return a instanceof y}
6
- function w(a){const c=z();a.insertBefore(c);c.append(a);return c}function v(a){const c=a.getChildren(),e=c.length;for(let g=0;g<e;g++)a.insertBefore(c[g]);a.remove();return 0<e?c[e-1]:null}
7
- function x(a){const c=a.getPreviousSibling();if(u(c)){var e=a.getFirstChild(),g=c.getChildren(),d=g.length;if(null===e)a.append(...g);else for(var b=0;b<d;b++)e.insertBefore(g[b]);b=k.$getSelection();if(null!==b){e=b.anchor;g=e.getNode();b=b.focus;const f=e.getNode();g.is(c)?e.set(a.getKey(),e.offset,"element"):g.is(a)&&e.set(a.getKey(),d+e.offset,"element");f.is(c)?b.set(a.getKey(),b.offset,"element"):f.is(a)&&b.set(a.getKey(),d+b.offset,"element")}c.remove()}}exports.$createOverflowNode=z;
8
- exports.OverflowNode=y;exports.isOverflowNode=u;exports.mergePrevious=x;
9
- exports.useCharacterLimit=function(a,c,e={}){const {strlen:g=b=>b.length,remainingCharacters:d=()=>{}}=e;l.useEffect(()=>a.registerNodes([y]),[a]);l.useEffect(()=>{let b=a.getEditorState().read(q),f=0;return n(a.addListener("textcontent",h=>{b=h}),a.addListener("update",({dirtyLeaves:h})=>{var m=a.isComposing();h=0<h.size;if(!m&&h){m=g(b);h=m>c||null!==f&&f>c;d(c-m);if(null===f||h){const A=r(b,c,g);a.update(()=>{k.$log("CharacterLimit");t(A)},{tag:"without-history"})}f=m}}))},[a,c,d,g])};
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict'
8
+ const DEPRECATED_useLexicalCharacterLimit = process.env.NODE_ENV === 'development' ? require('./DEPRECATED_useLexicalCharacterLimit.dev.js') : require('./DEPRECATED_useLexicalCharacterLimit.prod.js')
9
+ module.exports = DEPRECATED_useLexicalCharacterLimit;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';var k=require("lexical"),l=require("@lexical/react/withSubscriptions"),n=require("lexical/OverflowNode"),p=require("react");function q(a,e){for(e(a);null!==a;){if(k.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild();else{let d=null;for(;null===d&&null!==a;)d=a.getNextSibling(),a=null===d?a.getParent():d}null!==a&&(a=e(a))}}function r(){return k.$getRoot().getTextContent()}
8
+ function t(a,e,d){var g=Intl.Segmenter;let c=0;var b=0;if("function"===typeof g){a=(new g).segment(a);for(var {segment:f}of a){b+=d(f);if(b>e)break;c+=f.length}}else for(f=Array.from(a),a=f.length,g=0;g<a;g++){const h=f[g];b+=d(h);if(b>e)break;c+=h.length}return c}
9
+ function u(a){const e=k.$getRoot();let d=0,g=e;q(e,c=>{if(n.$isOverflowNode(c)){var b=d;if(d+c.getTextContentSize()<=a){var f=c.getParent();b=c.getPreviousSibling();var h=c.getNextSibling();v(c);c=k.$getSelection();null===c||c.anchor.getNode().isAttached()&&c.focus.getNode().isAttached()||(k.$isTextNode(b)?b.select():k.$isTextNode(h)?h.select():null!==f&&f.select());return g}if(b<a&&(f=c.getFirstDescendant(),h=null!==f?f.getTextContentSize():0,b+=h,f=k.$isTextNode(f)&&f.isSimpleText(),b=b<=a,f||b))return v(c),
10
+ g}else k.$isLeafNode(c)&&(b=d,d+=c.getTextContentSize(),d>a&&!n.$isOverflowNode(c.getParent())&&(f=k.$getSelection(),b<a&&k.$isTextNode(c)&&c.isSimpleText()?([,b]=c.splitText(a-b),b=w(b)):b=w(c),null!==f&&k.$setSelection(f),x(b)));return g=c})}function w(a){const e=n.$createOverflowNode();a.insertBefore(e);e.append(a);return e}function v(a){const e=a.getChildren(),d=e.length;for(let g=0;g<d;g++)a.insertBefore(e[g]);a.remove();return 0<d?e[d-1]:null}
11
+ function x(a){const e=a.getPreviousSibling();if(n.$isOverflowNode(e)){var d=a.getFirstChild(),g=e.getChildren(),c=g.length;if(null===d)a.append(...g);else for(var b=0;b<c;b++)d.insertBefore(g[b]);b=k.$getSelection();if(null!==b){d=b.anchor;g=d.getNode();b=b.focus;const f=d.getNode();g.is(e)?d.set(a.getKey(),d.offset,"element"):g.is(a)&&d.set(a.getKey(),c+d.offset,"element");f.is(e)?b.set(a.getKey(),b.offset,"element"):f.is(a)&&b.set(a.getKey(),c+b.offset,"element")}e.remove()}}
12
+ exports.mergePrevious=x;
13
+ exports.useCharacterLimit=function(a,e,d=Object.freeze({})){const {strlen:g=b=>b.length,remainingCharacters:c=()=>{}}=d;p.useEffect(()=>{if(!a.hasNodes([n.OverflowNode]))throw Error("useCharacterLimit: OverflowNode not registered on editor");},[a]);p.useEffect(()=>{let b=a.getEditorState().read(r),f=0;return l(a.addListener("textcontent",h=>{b=h}),a.addListener("update",({dirtyLeaves:h})=>{var m=a.isComposing();h=0<h.size;if(!m&&h){m=g(b);h=m>e||null!==f&&f>e;c(e-m);if(null===f||h){const y=t(b,e,
14
+ g);a.update(()=>{k.$log("CharacterLimit");u(y)},{tag:"without-history"})}f=m}}))},[a,e,c,g])};
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';
8
+
9
+ var react = require('react');
10
+ var reactDom = require('react-dom');
11
+
12
+ /**
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ *
19
+ */
20
+ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
21
+
22
+ /**
23
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
24
+ *
25
+ * This source code is licensed under the MIT license found in the
26
+ * LICENSE file in the root directory of this source tree.
27
+ *
28
+ *
29
+ */
30
+ const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
31
+ var useLayoutEffect = useLayoutEffectImpl;
32
+
33
+ /**
34
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
35
+ *
36
+ * This source code is licensed under the MIT license found in the
37
+ * LICENSE file in the root directory of this source tree.
38
+ *
39
+ *
40
+ */
41
+ function useDecorators(editor) {
42
+ const [decorators, setDecorators] = react.useState(() => editor.getDecorators()); // Subscribe to changes
43
+
44
+ useLayoutEffect(() => {
45
+ return editor.addListener('decorator', nextDecorators => {
46
+ reactDom.flushSync(() => {
47
+ setDecorators(nextDecorators);
48
+ });
49
+ });
50
+ }, [editor]); // Return decorators defined as React Portals
51
+
52
+ return react.useMemo(() => {
53
+ const decoratedPortals = [];
54
+ const decoratorKeys = Object.keys(decorators);
55
+
56
+ for (let i = 0; i < decoratorKeys.length; i++) {
57
+ const nodeKey = decoratorKeys[i];
58
+ const reactDecorator = decorators[nodeKey];
59
+ const element = editor.getElementByKey(nodeKey);
60
+
61
+ if (element !== null) {
62
+ decoratedPortals.push( /*#__PURE__*/reactDom.createPortal(reactDecorator, element));
63
+ }
64
+ }
65
+
66
+ return decoratedPortals;
67
+ }, [decorators, editor]);
68
+ }
69
+
70
+ /**
71
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
72
+ *
73
+ * This source code is licensed under the MIT license found in the
74
+ * LICENSE file in the root directory of this source tree.
75
+ *
76
+ *
77
+ */
78
+ function useLexicalDecorators(editor) {
79
+ return useDecorators(editor);
80
+ }
81
+
82
+ module.exports = useLexicalDecorators;
@@ -1,2 +1,9 @@
1
- 'use strict';var c=require("react-dom"),g=require("react"),k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect;
2
- function l(a){const [e,m]=g.useState(()=>a.getDecorators());k(()=>a.addListener("decorator",d=>{c.flushSync(()=>{m(d)})}),[a]);return g.useMemo(()=>{const d=[],h=Object.keys(e);for(let f=0;f<h.length;f++){var b=h[f];const n=e[b];b=a.getElementByKey(b);null!==b&&d.push(c.createPortal(n,b))}return d},[e,a])}module.exports=function(a){return l(a)};
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict'
8
+ const DEPRECATED_useLexicalDecorators = process.env.NODE_ENV === 'development' ? require('./DEPRECATED_useLexicalDecorators.dev.js') : require('./DEPRECATED_useLexicalDecorators.prod.js')
9
+ module.exports = DEPRECATED_useLexicalDecorators;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ 'use strict';var c=require("react"),g=require("react-dom"),k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?c.useLayoutEffect:c.useEffect;
8
+ function l(a){const [e,m]=c.useState(()=>a.getDecorators());k(()=>a.addListener("decorator",d=>{g.flushSync(()=>{m(d)})}),[a]);return c.useMemo(()=>{const d=[],h=Object.keys(e);for(let f=0;f<h.length;f++){var b=h[f];const n=e[b];b=a.getElementByKey(b);null!==b&&d.push(g.createPortal(n,b))}return d},[e,a])}module.exports=function(a){return l(a)};