@lexical/react 0.1.11 → 0.1.14

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 (55) hide show
  1. package/DEPRECATED_useLexical.dev.js +3 -7
  2. package/DEPRECATED_useLexical.prod.js +1 -1
  3. package/DEPRECATED_useLexicalAutoFormatter.dev.js +14 -9
  4. package/DEPRECATED_useLexicalAutoFormatter.prod.js +18 -18
  5. package/DEPRECATED_useLexicalPlainText.dev.js +33 -27
  6. package/DEPRECATED_useLexicalPlainText.prod.js +12 -12
  7. package/DEPRECATED_useLexicalRichText.dev.js +43 -388
  8. package/DEPRECATED_useLexicalRichText.prod.js +17 -25
  9. package/LexicalAutoFormatterPlugin.d.ts +9 -0
  10. package/LexicalAutoFormatterPlugin.dev.js +14 -9
  11. package/LexicalAutoFormatterPlugin.prod.js +18 -18
  12. package/LexicalAutoLinkPlugin.d.ts +20 -0
  13. package/LexicalCharacterLimitPlugin.d.ts +11 -0
  14. package/LexicalClearEditorPlugin.d.ts +14 -0
  15. package/LexicalClearEditorPlugin.dev.js +22 -1
  16. package/LexicalClearEditorPlugin.prod.js +2 -1
  17. package/LexicalCollaborationPlugin.d.ts +51 -0
  18. package/LexicalCollaborationPlugin.dev.js +39 -12
  19. package/LexicalCollaborationPlugin.js.flow +4 -2
  20. package/LexicalCollaborationPlugin.prod.js +8 -7
  21. package/LexicalComposer.d.ts +22 -0
  22. package/LexicalComposer.dev.js +28 -6
  23. package/LexicalComposer.js.flow +5 -4
  24. package/LexicalComposer.prod.js +3 -3
  25. package/LexicalComposerContext.d.ts +24 -0
  26. package/LexicalComposerContext.js.flow +1 -1
  27. package/LexicalContentEditable.d.ts +32 -0
  28. package/LexicalContentEditable.dev.js +22 -1
  29. package/LexicalContentEditable.prod.js +3 -3
  30. package/LexicalHashtagPlugin.d.ts +9 -0
  31. package/LexicalHashtagPlugin.dev.js +56 -1
  32. package/LexicalHashtagPlugin.js.flow +0 -10
  33. package/LexicalHashtagPlugin.prod.js +7 -4
  34. package/LexicalHistoryPlugin.d.ts +29 -0
  35. package/LexicalHorizontalRuleNode.d.ts +23 -0
  36. package/LexicalLinkPlugin.d.ts +9 -0
  37. package/LexicalListPlugin.d.ts +9 -0
  38. package/LexicalNestedComposer.d.ts +17 -0
  39. package/LexicalNestedComposer.dev.js +21 -11
  40. package/LexicalNestedComposer.js.flow +3 -6
  41. package/LexicalNestedComposer.prod.js +3 -2
  42. package/LexicalOnChangePlugin.d.ts +12 -0
  43. package/LexicalPlainTextPlugin.d.ts +15 -0
  44. package/LexicalPlainTextPlugin.dev.js +11 -26
  45. package/LexicalPlainTextPlugin.prod.js +8 -8
  46. package/LexicalRichTextPlugin.d.ts +15 -0
  47. package/LexicalRichTextPlugin.dev.js +24 -390
  48. package/LexicalRichTextPlugin.prod.js +13 -21
  49. package/LexicalTablePlugin.d.ts +9 -0
  50. package/LexicalTreeView.d.ts +17 -0
  51. package/package.json +9 -5
  52. package/useLexicalDecoratorMap.d.ts +14 -0
  53. package/useLexicalIsTextContentEmpty.d.ts +13 -0
  54. package/useLexicalNodeSelection.d.ts +12 -0
  55. package/withSubscriptions.d.ts +12 -0
@@ -4,6 +4,6 @@
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
- var c=require("@lexical/react/LexicalComposerContext"),g=require("react");
8
- module.exports=function({ariaActiveDescendantID:h,ariaAutoComplete:k,ariaControls:l,ariaDescribedBy:m,ariaExpanded:n,ariaLabel:p,ariaLabelledBy:q,ariaMultiline:r,ariaOwneeID:t,ariaRequired:u,autoCapitalize:v,autoComplete:w,autoCorrect:x,className:y,role:e="textbox",spellCheck:z=!0,style:A,tabIndex:B,testid:C}){const [b]=c.useLexicalComposerContext(),[a,f]=g.useState(!0),D=g.useCallback(d=>{b.setRootElement(d)},[b]);g.useLayoutEffect(()=>{f(b.isReadOnly());return b.addListener("readonly",d=>{f(d)})},
9
- [b]);return g.createElement("div",{"aria-activedescendant":a?null:h,"aria-autocomplete":a?null:k,"aria-controls":a?null:l,"aria-describedby":m,"aria-expanded":a?null:"combobox"===e?!!n:null,"aria-label":p,"aria-labelledby":q,"aria-multiline":r,"aria-owns":a?null:t,"aria-required":u,autoCapitalize:v,autoComplete:w,autoCorrect:x,className:y,contentEditable:!a,"data-testid":C,ref:D,role:a?null:e,spellCheck:z,style:A,tabIndex:B})};
7
+ var b=require("@lexical/react/LexicalComposerContext"),g=require("react"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect;
8
+ module.exports=function({ariaActiveDescendantID:k,ariaAutoComplete:l,ariaControls:m,ariaDescribedBy:n,ariaExpanded:p,ariaLabel:q,ariaLabelledBy:r,ariaMultiline:t,ariaOwneeID:u,ariaRequired:v,autoCapitalize:w,autoComplete:x,autoCorrect:y,className:z,role:e="textbox",spellCheck:A=!0,style:B,tabIndex:C,testid:D}){const [c]=b.useLexicalComposerContext(),[a,f]=g.useState(!0),E=g.useCallback(d=>{c.setRootElement(d)},[c]);h(()=>{f(c.isReadOnly());return c.addListener("readonly",d=>{f(d)})},[c]);return g.createElement("div",
9
+ {"aria-activedescendant":a?null:k,"aria-autocomplete":a?null:l,"aria-controls":a?null:m,"aria-describedby":n,"aria-expanded":a?null:"combobox"===e?!!p:null,"aria-label":q,"aria-labelledby":r,"aria-multiline":t,"aria-owns":a?null:u,"aria-required":v,autoCapitalize:w,autoComplete:x,autoCorrect:y,className:z,contentEditable:!a,"data-testid":D,ref:E,role:a?null:e,spellCheck:A,style:B,tabIndex:C})};
@@ -0,0 +1,9 @@
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
+ */
8
+
9
+ export default function LexicalHashtagPlugin(): React.ReactNode;
@@ -105,6 +105,18 @@ function getHashtagRegexString() {
105
105
 
106
106
  const REGEX = new RegExp(getHashtagRegexString(), 'ig');
107
107
 
108
+ function isValidCharacter(character) {
109
+ return character === '' || character.search(/[\s.,\\\/#!$%\^&\*;:{}=\-`~()@]/) > -1;
110
+ }
111
+
112
+ function startsWithValidChar(string) {
113
+ return isValidCharacter(string[0]);
114
+ }
115
+
116
+ function endsWithValidChar(string) {
117
+ return isValidCharacter(string[string.length - 1]);
118
+ }
119
+
108
120
  function textNodeTransform(node) {
109
121
  if (!node.isSimpleText()) {
110
122
  return;
@@ -118,12 +130,27 @@ function textNodeTransform(node) {
118
130
  const matchArr = REGEX.exec(text);
119
131
 
120
132
  if (matchArr === null) {
133
+ if (currentNode != null) {
134
+ const nextSibling = currentNode.getNextSibling();
135
+
136
+ if (HashtagNode.$isHashtagNode(nextSibling) && !endsWithValidChar(text) && !isNextNodeValid(currentNode)) {
137
+ HashtagNode.$toggleHashtag(nextSibling);
138
+ }
139
+ }
140
+
121
141
  return;
122
142
  }
123
143
 
124
144
  const hashtagLength = matchArr[3].length + 1;
125
145
  const startOffset = matchArr.index + matchArr[1].length - adjustedOffset;
126
146
  const endOffset = startOffset + hashtagLength;
147
+ const prevChar = text[startOffset - 1] || '';
148
+ const nextChar = text[endOffset] || '';
149
+
150
+ if (startOffset === 0 && HashtagNode.$isHashtagNode(currentNode.getPreviousSibling()) || !isValidCharacter(prevChar) || !isValidCharacter(nextChar)) {
151
+ continue;
152
+ }
153
+
127
154
  let targetNode;
128
155
 
129
156
  if (startOffset === 0) {
@@ -137,9 +164,37 @@ function textNodeTransform(node) {
137
164
  }
138
165
  }
139
166
 
167
+ function isPreviousNodeValid(node) {
168
+ const previousNode = node.getPreviousSibling();
169
+ return previousNode === null || lexical.$isLineBreakNode(previousNode) || lexical.$isTextNode(previousNode) && !HashtagNode.$isHashtagNode(previousNode) && endsWithValidChar(previousNode.getTextContent());
170
+ }
171
+
172
+ function isNextNodeValid(node) {
173
+ const nextNode = node.getNextSibling();
174
+ return nextNode === null || lexical.$isLineBreakNode(nextNode) || lexical.$isTextNode(nextNode) && !HashtagNode.$isHashtagNode(nextNode) && startsWithValidChar(nextNode.getTextContent());
175
+ }
176
+
177
+ function $hashtagToPlainTextTransform(hashtagNode) {
178
+ // Check neighbors
179
+ if (!isPreviousNodeValid(hashtagNode) || !isNextNodeValid(hashtagNode)) {
180
+ $convertHashtagNodeToPlainTextNode(hashtagNode);
181
+ return;
182
+ }
183
+ }
184
+
185
+ function $convertHashtagNodeToPlainTextNode(node) {
186
+ const textNode = lexical.$createTextNode(node.getTextContent());
187
+ node.replace(textNode);
188
+ }
189
+
140
190
  function useHashtags(editor) {
141
191
  react.useEffect(() => {
142
- return editor.addTransform(lexical.TextNode, textNodeTransform);
192
+ const removePlainTextTransform = editor.addTransform(lexical.TextNode, textNodeTransform);
193
+ const removeHashtagToPlainTextTransform = editor.addTransform(HashtagNode.HashtagNode, $hashtagToPlainTextTransform);
194
+ return () => {
195
+ removePlainTextTransform();
196
+ removeHashtagToPlainTextTransform();
197
+ };
143
198
  }, [editor]);
144
199
  }
145
200
 
@@ -6,15 +6,5 @@
6
6
  *
7
7
  * @flow strict
8
8
  */
9
- import type {LexicalEditor, TextNode} from 'lexical';
10
9
 
11
- declare function getHashtagRegexStringChars(): $ReadOnly<{
12
- alpha: string,
13
- alphanumeric: string,
14
- hashChars: string,
15
- }>;
16
-
17
- declare function getHashtagRegexString(): string;
18
- declare function textNodeTransform(node: TextNode): void;
19
- declare function useHashtags(editor: LexicalEditor): void;
20
10
  declare export default function LexicalHashtagPlugin(): React$Node;
@@ -4,7 +4,10 @@
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
- var c=require("@lexical/react/LexicalComposerContext"),f=require("lexical"),g=require("lexical/HashtagNode"),h=require("react"),l=RegExp;
8
- const m=String.fromCharCode,n="A-Za-z\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u0241\u0250-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ee\u037a\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03f5\u03f7-\u0481\u048a-\u04ce\u04d0-\u04f9\u0500-\u050f\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0640-\u064a\u066e-\u066f\u0671-\u06d3\u06d5\u06e5-\u06e6\u06ee-\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u076d\u0780-\u07a5\u07b1\u0904-\u0939\u093d\u0950\u0958-\u0961\u097d\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0-\u0ae1\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b35-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32-\u0e33\u0e40-\u0e46\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edd\u0f00\u0f40-\u0f47\u0f49-\u0f6a\u0f88-\u0f8b\u1000-\u1021\u1023-\u1027\u1029-\u102a\u1050-\u1055\u10a0-\u10c5\u10d0-\u10fa\u10fc\u1100-\u1159\u115f-\u11a2\u11a8-\u11f9\u1200-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19a9\u19c1-\u19c7\u1a00-\u1a16\u1d00-\u1dbf\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u2094\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2131\u2133-\u2139\u213c-\u213f\u2145-\u2149\u2c00-\u2c2e\u2c30-\u2c5e\u2c80-\u2ce4\u2d00-\u2d25\u2d30-\u2d65\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3006\u3031-\u3035\u303b-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312c\u3131-\u318e\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fbb\ua000-\ua48c\ua800-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\uac00-\ud7a3\uf900-\ufa2d\ufa30-\ufa6a\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc\u0300-\u036f\u0483-\u0486\u0591-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u0610-\u0615\u064b-\u065e\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u0901-\u0903\u093c\u093e-\u094d\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09bc\u09be-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09e2-\u09e3\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a70-\u0a71\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0b01-\u0b03\u0b3c\u0b3e-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c82-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0d02-\u0d03\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d82-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2-\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f3e-\u0f3f\u0f71-\u0f84\u0f86-\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102c-\u1032\u1036-\u1039\u1056-\u1059\u135f\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17b6-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u192b\u1930-\u193b\u19b0-\u19c0\u19c8-\u19c9\u1a17-\u1a1b\u1dc0-\u1dc3\u20d0-\u20dc\u20e1\u20e5-\u20eb\u302a-\u302f\u3099-\u309a\ua802\ua806\ua80b\ua823-\ua827\ufb1e\ufe00-\ufe0f\ufe20-\ufe23\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253-\u0254\u0256-\u0257\u0259\u025b\u0263\u0268\u026f\u0272\u0289\u028b\u02bb\u0300-\u036f\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de0-\u2dff\ua640-\ua69f\u0591-\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f4\ufb12-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4f\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06de-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u06ff\u0750-\u077f\u08a0\u08a2-\u08ac\u08e4-\u08fe\ufb50-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\u200c-\u200c\u0e01-\u0e3a\u0e40-\u0e4e\u1100-\u11ff\u3130-\u3185\ua960-\ua97f\uac00-\ud7af\ud7b0-\ud7ff\uffa1-\uffdc\u30a1-\u30fa\u30fc-\u30fe\uff66-\uff9f\uff10-\uff19\uff21-\uff3a\uff41-\uff5a\u3041-\u3096\u3099-\u309e\u3400-\u4dbf\u4e00-\u9fff"+(m(173824)+
9
- "-"+m(177983)+m(177984)+"-"+m(178207)+m(194560)+"-"+m(195103)+"\u3003\u3005\u303b"),{alpha:p,alphanumeric:q,hashChars:r}={alpha:n,alphanumeric:n+"0-9\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19d9\uff10-\uff19_",hashChars:"#\\uFF03"},t="["+q+"]",u=new l("(^|$|[^&/"+(q+"])([")+(r+"])(")+t+"*["+(p+"]")+
10
- t+"*)","ig");function v(a){if(a.isSimpleText())for(var w=a.getTextContent(),k=0;;){var b=u.exec(w);if(null===b)break;const d=b.index+b[1].length-k;b=d+(b[3].length+1);let e;0===d?[e,a]=a.splitText(b):[,e,a]=a.splitText(d,b);k+=b;g.$toggleHashtag(e)}}function x(a){h.useEffect(()=>a.addTransform(f.TextNode,v),[a])}module.exports=function(){const [a]=c.useLexicalComposerContext();x(a);return null};
7
+ var e=require("@lexical/react/LexicalComposerContext"),f=require("lexical"),g=require("lexical/HashtagNode"),h=require("react"),m=RegExp;
8
+ const n=String.fromCharCode,p="A-Za-z\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u0241\u0250-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ee\u037a\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03f5\u03f7-\u0481\u048a-\u04ce\u04d0-\u04f9\u0500-\u050f\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0640-\u064a\u066e-\u066f\u0671-\u06d3\u06d5\u06e5-\u06e6\u06ee-\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u076d\u0780-\u07a5\u07b1\u0904-\u0939\u093d\u0950\u0958-\u0961\u097d\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0-\u0ae1\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b35-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32-\u0e33\u0e40-\u0e46\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edd\u0f00\u0f40-\u0f47\u0f49-\u0f6a\u0f88-\u0f8b\u1000-\u1021\u1023-\u1027\u1029-\u102a\u1050-\u1055\u10a0-\u10c5\u10d0-\u10fa\u10fc\u1100-\u1159\u115f-\u11a2\u11a8-\u11f9\u1200-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19a9\u19c1-\u19c7\u1a00-\u1a16\u1d00-\u1dbf\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u2094\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2131\u2133-\u2139\u213c-\u213f\u2145-\u2149\u2c00-\u2c2e\u2c30-\u2c5e\u2c80-\u2ce4\u2d00-\u2d25\u2d30-\u2d65\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3006\u3031-\u3035\u303b-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312c\u3131-\u318e\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fbb\ua000-\ua48c\ua800-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\uac00-\ud7a3\uf900-\ufa2d\ufa30-\ufa6a\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc\u0300-\u036f\u0483-\u0486\u0591-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u0610-\u0615\u064b-\u065e\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u0901-\u0903\u093c\u093e-\u094d\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09bc\u09be-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09e2-\u09e3\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a70-\u0a71\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0b01-\u0b03\u0b3c\u0b3e-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c82-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0d02-\u0d03\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d82-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2-\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f3e-\u0f3f\u0f71-\u0f84\u0f86-\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102c-\u1032\u1036-\u1039\u1056-\u1059\u135f\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17b6-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u192b\u1930-\u193b\u19b0-\u19c0\u19c8-\u19c9\u1a17-\u1a1b\u1dc0-\u1dc3\u20d0-\u20dc\u20e1\u20e5-\u20eb\u302a-\u302f\u3099-\u309a\ua802\ua806\ua80b\ua823-\ua827\ufb1e\ufe00-\ufe0f\ufe20-\ufe23\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253-\u0254\u0256-\u0257\u0259\u025b\u0263\u0268\u026f\u0272\u0289\u028b\u02bb\u0300-\u036f\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de0-\u2dff\ua640-\ua69f\u0591-\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f4\ufb12-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4f\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06de-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u06ff\u0750-\u077f\u08a0\u08a2-\u08ac\u08e4-\u08fe\ufb50-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\u200c-\u200c\u0e01-\u0e3a\u0e40-\u0e4e\u1100-\u11ff\u3130-\u3185\ua960-\ua97f\uac00-\ud7af\ud7b0-\ud7ff\uffa1-\uffdc\u30a1-\u30fa\u30fc-\u30fe\uff66-\uff9f\uff10-\uff19\uff21-\uff3a\uff41-\uff5a\u3041-\u3096\u3099-\u309e\u3400-\u4dbf\u4e00-\u9fff"+(n(173824)+
9
+ "-"+n(177983)+n(177984)+"-"+n(178207)+n(194560)+"-"+n(195103)+"\u3003\u3005\u303b"),{alpha:q,alphanumeric:r,hashChars:t}={alpha:p,alphanumeric:p+"0-9\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19d9\uff10-\uff19_",hashChars:"#\\uFF03"},u="["+r+"]",v=new m("(^|$|[^&/"+(r+"])([")+(t+"])(")+u+"*["+(q+"]")+
10
+ u+"*)","ig");function w(a){return""===a||-1<a.search(/[\s.,\\\/#!$%\^&\*;:{}=\-`~()@]/)}
11
+ function x(a){if(a.isSimpleText())for(var b=a.getTextContent(),c=0;;){var d=v.exec(b);if(null===d){if(null!=a){var k=a.getNextSibling();!g.$isHashtagNode(k)||w(b[b.length-1])||y(a)||g.$toggleHashtag(k)}break}const l=d.index+d[1].length-c;d=l+(d[3].length+1);const z=b[l-1]||"",A=b[d]||"";0===l&&g.$isHashtagNode(a.getPreviousSibling())||!w(z)||!w(A)||(0===l?[k,a]=a.splitText(d):[,k,a]=a.splitText(l,d),c+=d,g.$toggleHashtag(k))}}
12
+ function y(a){a=a.getNextSibling();return null===a||f.$isLineBreakNode(a)||f.$isTextNode(a)&&!g.$isHashtagNode(a)&&w(a.getTextContent()[0])}function B(a){var b=a.getPreviousSibling(),c;!(c=null===b||f.$isLineBreakNode(b))&&(c=f.$isTextNode(b)&&!g.$isHashtagNode(b))&&(b=b.getTextContent(),c=w(b[b.length-1]));c&&y(a)||(b=f.$createTextNode(a.getTextContent()),a.replace(b))}
13
+ function C(a){h.useEffect(()=>{const b=a.addTransform(f.TextNode,x),c=a.addTransform(g.HashtagNode,B);return()=>{b();c()}},[a])}module.exports=function(){const [a]=e.useLexicalComposerContext();C(a);return null};
@@ -0,0 +1,29 @@
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
+ */
8
+
9
+ import type {
10
+ EditorState,
11
+ GridSelection,
12
+ LexicalEditor,
13
+ NodeSelection,
14
+ RangeSelection,
15
+ } from 'lexical';
16
+ export type HistoryStateEntry = {
17
+ editor: LexicalEditor;
18
+ editorState: EditorState;
19
+ undoSelection?: RangeSelection | NodeSelection | GridSelection | null;
20
+ };
21
+ export type HistoryState = {
22
+ current: null | HistoryStateEntry;
23
+ redoStack: Array<HistoryStateEntry>;
24
+ undoStack: Array<HistoryStateEntry>;
25
+ };
26
+ export function HistoryPlugin(arg0: {
27
+ externalHistoryState?: HistoryState;
28
+ }): React.ReactNode;
29
+ export function createEmptyHistoryState(): HistoryState;
@@ -0,0 +1,23 @@
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
+ */
8
+
9
+ import type {LexicalNode} from 'lexical';
10
+ import {DecoratorNode} from 'lexical';
11
+ export declare class HorizontalRuleNode extends DecoratorNode<React.ReactNode> {
12
+ getType(): string;
13
+ clone(node: HorizontalRuleNode): HorizontalRuleNode;
14
+ createDOM(): HTMLElement;
15
+ getTextContent(): '\n';
16
+ isTopLevel(): true;
17
+ updateDOM(): false;
18
+ decorate(): React.ReactNode;
19
+ }
20
+ export function $createHorizontalRuleNode(): HorizontalRuleNode;
21
+ export function $isHorizontalRuleNode(
22
+ node: LexicalNode | null | undefined,
23
+ ): boolean;
@@ -0,0 +1,9 @@
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
+ */
8
+
9
+ export default function LexicalLinkPlugin(): null;
@@ -0,0 +1,9 @@
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
+ */
8
+
9
+ export default function ListPlugin(): null;
@@ -0,0 +1,17 @@
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
+ */
8
+
9
+ import type {DecoratorEditor, EditorThemeClasses} from 'lexical';
10
+
11
+ export default function LexicalNestedComposer(arg0: {
12
+ initialConfig: {
13
+ decoratorEditor: DecoratorEditor;
14
+ theme?: EditorThemeClasses;
15
+ };
16
+ children: React.ReactNode;
17
+ }): React.ReactNode;
@@ -7,6 +7,7 @@
7
7
  'use strict';
8
8
 
9
9
  var LexicalComposer = require('@lexical/react/LexicalComposer');
10
+ var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
10
11
  var LexicalOnChangePlugin = require('@lexical/react/LexicalOnChangePlugin');
11
12
  var React = require('react');
12
13
 
@@ -22,13 +23,18 @@ function LexicalNestedComposer({
22
23
  initialConfig = {},
23
24
  children
24
25
  }) {
26
+ const parentContext = React.useContext(LexicalComposerContext.LexicalComposerContext);
27
+
28
+ if (parentContext == null) {
29
+ {
30
+ throw Error(`Unexpected parent context null on a nested composer`);
31
+ }
32
+ }
33
+
25
34
  const [nestedEditor, setNestedEditor] = React.useState(null);
26
35
  const {
27
36
  decoratorEditor,
28
- namespace,
29
- theme,
30
- nodes,
31
- onError
37
+ theme
32
38
  } = initialConfig;
33
39
  React.useEffect(() => {
34
40
  if (!decoratorEditor.isEmpty() && nestedEditor !== null) {
@@ -45,13 +51,17 @@ function LexicalNestedComposer({
45
51
  }, // eslint-disable-next-line react-hooks/exhaustive-deps
46
52
  []);
47
53
  return /*#__PURE__*/React.createElement(LexicalComposer, {
48
- initialConfig: {
49
- editor: decoratorEditor.editor,
50
- namespace,
51
- nodes,
52
- onError,
53
- theme
54
- }
54
+ initialConfig: React.useMemo(() => {
55
+ const [parentEditor] = parentContext;
56
+ return {
57
+ editor: decoratorEditor.editor,
58
+ namespace: parentEditor._config.namespace,
59
+ nodes: Array.from(parentEditor._nodes.values()).map(registeredNode => registeredNode.klass),
60
+ onError: parentEditor._onError,
61
+ theme
62
+ }; // We only do this for init
63
+ // eslint-disable-next-line react-hooks/exhaustive-deps
64
+ }, [])
55
65
  }, /*#__PURE__*/React.createElement(LexicalOnChangePlugin, {
56
66
  onChange: onChange
57
67
  }), children);
@@ -10,12 +10,9 @@
10
10
  import type {DecoratorEditor, EditorThemeClasses, LexicalNode} from 'lexical';
11
11
 
12
12
  declare export default function LexicalNestedComposer({
13
- initialConfig?: {
14
- namespace?: string,
13
+ initialConfig: $ReadOnly<{
15
14
  decoratorEditor: DecoratorEditor,
16
- nodes?: Array<Class<LexicalNode>>,
17
15
  theme?: EditorThemeClasses,
18
- onError?: (Error) => void,
19
- },
20
- children?: React$Node,
16
+ }>,
17
+ children: React$Node,
21
18
  }): React$Node;
@@ -4,5 +4,6 @@
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
- var a=require("@lexical/react/LexicalComposer"),f=require("@lexical/react/LexicalOnChangePlugin"),g=require("react");
8
- module.exports=function({initialConfig:c={},children:h}){const [d,k]=g.useState(null),{decoratorEditor:b,namespace:l,theme:m,nodes:n,onError:p}=c;g.useEffect(()=>{b.isEmpty()||null===d||b.init(d)},[d]);c=g.useCallback((q,e)=>{q.isEmpty()?k(e):b.set(e)},[]);return g.createElement(a,{initialConfig:{editor:b.editor,namespace:l,nodes:n,onError:p,theme:m}},g.createElement(f,{onChange:c}),h)};
7
+ var a=require("@lexical/react/LexicalComposer"),h=require("@lexical/react/LexicalComposerContext"),k=require("@lexical/react/LexicalOnChangePlugin"),l=require("react");
8
+ module.exports=function({initialConfig:e={},children:m}){const g=l.useContext(h.LexicalComposerContext);if(null==g)throw Error("Unexpected parent context null on a nested composer");const [f,n]=l.useState(null),{decoratorEditor:c,theme:p}=e;l.useEffect(()=>{c.isEmpty()||null===f||c.init(f)},[f]);e=l.useCallback((b,d)=>{b.isEmpty()?n(d):c.set(d)},[]);return l.createElement(a,{initialConfig:l.useMemo(()=>{const [b]=g;return{editor:c.editor,namespace:b._config.namespace,nodes:Array.from(b._nodes.values()).map(d=>
9
+ d.klass),onError:b._onError,theme:p}},[])},l.createElement(k,{onChange:e}),m)};
@@ -0,0 +1,12 @@
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
+ */
8
+
9
+ import type {EditorState, LexicalEditor} from 'lexical';
10
+ export default function OnChangePlugin(arg0: {
11
+ onChange: (editorState: EditorState, editor: LexicalEditor) => void;
12
+ }): null;
@@ -0,0 +1,15 @@
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
+ */
8
+
9
+ import type {EditorState} from 'lexical';
10
+ type InitialEditorStateType = null | string | EditorState | (() => void);
11
+ export default function PlainTextPlugin(arg0: {
12
+ contentEditable: React.ReactNode;
13
+ initialEditorState?: InitialEditorStateType;
14
+ placeholder: React.ReactNode;
15
+ }): React.ReactNode;
@@ -10,6 +10,7 @@ var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
10
10
  var React = require('react');
11
11
  var lexical = require('lexical');
12
12
  var reactDom = require('react-dom');
13
+ var clipboard = require('@lexical/clipboard');
13
14
 
14
15
  /**
15
16
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -181,6 +182,10 @@ function $moveCharacter(selection, isHoldingShift, isBackward) {
181
182
  const isRTL = $isParentElementRTL(selection);
182
183
  $moveCaretSelection(selection, isHoldingShift, isBackward ? !isRTL : isRTL, 'character');
183
184
  }
185
+ function $shouldOverrideDefaultCharacterSelection(selection, isBackward) {
186
+ const possibleNode = lexical.$getDecoratorNode(selection.focus, isBackward);
187
+ return lexical.$isDecoratorNode(possibleNode) && !possibleNode.isIsolated();
188
+ }
184
189
 
185
190
  /**
186
191
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -190,17 +195,6 @@ function $moveCharacter(selection, isHoldingShift, isBackward) {
190
195
  *
191
196
  *
192
197
  */
193
- function $insertDataTransferForPlainText(dataTransfer, selection) {
194
- const text = dataTransfer.getData('text/plain');
195
-
196
- if (text != null) {
197
- selection.insertRawText(text);
198
- }
199
- }
200
- function $shouldOverrideDefaultCharacterSelection(selection, isBackward) {
201
- const possibleNode = lexical.$getDecoratorNode(selection.focus, isBackward);
202
- return lexical.$isDecoratorNode(possibleNode) && !possibleNode.isIsolated();
203
- }
204
198
  function onPasteForPlainText(event, editor) {
205
199
  event.preventDefault();
206
200
  editor.update(() => {
@@ -208,7 +202,7 @@ function onPasteForPlainText(event, editor) {
208
202
  const clipboardData = event.clipboardData;
209
203
 
210
204
  if (clipboardData != null && lexical.$isRangeSelection(selection)) {
211
- $insertDataTransferForPlainText(clipboardData, selection);
205
+ clipboard.$insertDataTransferForPlainText(clipboardData, selection);
212
206
  }
213
207
  });
214
208
  }
@@ -230,19 +224,10 @@ function onCopyForPlainText(event, editor) {
230
224
 
231
225
  if (selection !== null) {
232
226
  if (clipboardData != null) {
233
- const domSelection = window.getSelection(); // If we haven't selected a range, then don't copy anything
234
-
235
- if (domSelection.isCollapsed) {
236
- return;
237
- }
238
-
239
- const range = domSelection.getRangeAt(0);
227
+ const htmlString = clipboard.getHtmlContent(editor);
240
228
 
241
- if (range) {
242
- const container = document.createElement('div');
243
- const frag = range.cloneContents();
244
- container.appendChild(frag);
245
- clipboardData.setData('text/html', container.innerHTML);
229
+ if (htmlString !== null) {
230
+ clipboardData.setData('text/html', htmlString);
246
231
  }
247
232
 
248
233
  clipboardData.setData('text/plain', selection.getTextContent());
@@ -404,7 +389,7 @@ function useLexicalDragonSupport(editor) {
404
389
  *
405
390
  */
406
391
  function usePlainTextSetup(editor, initialEditorState) {
407
- React.useEffect(() => {
392
+ useLayoutEffect(() => {
408
393
  const removeListener = editor.addListener('command', (type, payload) => {
409
394
  const selection = lexical.$getSelection();
410
395
 
@@ -444,7 +429,7 @@ function usePlainTextSetup(editor, initialEditorState) {
444
429
  const dataTransfer = eventOrText.dataTransfer;
445
430
 
446
431
  if (dataTransfer != null) {
447
- $insertDataTransferForPlainText(dataTransfer, selection);
432
+ clipboard.$insertDataTransferForPlainText(dataTransfer, selection);
448
433
  } else {
449
434
  const data = eventOrText.data;
450
435
 
@@ -4,15 +4,15 @@
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
- var g=require("@lexical/react/LexicalComposerContext"),h=require("react"),t=require("lexical"),u=require("react-dom");function v(a,d=!0){if(a)return!1;a=t.$getRoot().getTextContent();d&&(a=a.trim());return""===a}
8
- function w(a){if(!v(a,!1))return!1;a=t.$getRoot().getChildren();const d=a.length;if(1<d)return!1;for(let c=0;c<d;c++){var e=a[c];if(t.$isElementNode(e)){if("paragraph"!==e.__type||0!==e.__indent)return!1;e=e.getChildren();const b=e.length;for(let f=0;f<b;f++)if(!t.$isTextNode(e[c]))return!1}}return!0}function x(a){return()=>w(a)}var y="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
9
- function z(a){const [d,e]=h.useState(a.getEditorState().read(x(a.isComposing())));y(()=>a.addListener("update",({editorState:c})=>{const b=a.isComposing();c=c.read(x(b));e(c)}),[a]);return d}function A(a){const [d,e]=h.useState(()=>a.getDecorators());y(()=>a.addListener("decorator",c=>{u.flushSync(()=>{e(c)})}),[a]);return h.useMemo(()=>{const c=[],b=Object.keys(d);for(let p=0;p<b.length;p++){var f=b[p];const r=d[f];f=a.getElementByKey(f);null!==f&&c.push(u.createPortal(r,f))}return c},[d,a])}
10
- function C(a){a=a.anchor.getNode();return"rtl"===(t.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}function D(a,d){a=a.getData("text/plain");null!=a&&d.insertRawText(a)}function E(a,d){a=t.$getDecoratorNode(a.focus,d);return t.$isDecoratorNode(a)&&!a.isIsolated()}function F(a,d){a.preventDefault();d.update(()=>{const e=t.$getSelection(),c=a.clipboardData;null!=c&&t.$isRangeSelection(e)&&D(c,e)})}
11
- function G(a,d){H(a,d);d.update(()=>{const e=t.$getSelection();t.$isRangeSelection(e)&&e.removeText()})}function H(a,d){a.preventDefault();d.update(()=>{const e=a.clipboardData,c=t.$getSelection();if(null!==c&&null!=e){var b=window.getSelection();if(!b.isCollapsed){var f=b.getRangeAt(0);f&&(b=document.createElement("div"),f=f.cloneContents(),b.appendChild(f),e.setData("text/html",b.innerHTML));e.setData("text/plain",c.getTextContent())}}})}const I={tag:"history-merge"};
7
+ var g=require("@lexical/react/LexicalComposerContext"),h=require("react"),t=require("lexical"),u=require("react-dom"),v=require("@lexical/clipboard");function w(a,d=!0){if(a)return!1;a=t.$getRoot().getTextContent();d&&(a=a.trim());return""===a}
8
+ function x(a){if(!w(a,!1))return!1;a=t.$getRoot().getChildren();const d=a.length;if(1<d)return!1;for(let c=0;c<d;c++){var e=a[c];if(t.$isElementNode(e)){if("paragraph"!==e.__type||0!==e.__indent)return!1;e=e.getChildren();const b=e.length;for(let f=0;f<b;f++)if(!t.$isTextNode(e[c]))return!1}}return!0}function y(a){return()=>x(a)}var z="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
9
+ function A(a){const [d,e]=h.useState(a.getEditorState().read(y(a.isComposing())));z(()=>a.addListener("update",({editorState:c})=>{const b=a.isComposing();c=c.read(y(b));e(c)}),[a]);return d}function C(a){const [d,e]=h.useState(()=>a.getDecorators());z(()=>a.addListener("decorator",c=>{u.flushSync(()=>{e(c)})}),[a]);return h.useMemo(()=>{const c=[],b=Object.keys(d);for(let p=0;p<b.length;p++){var f=b[p];const r=d[f];f=a.getElementByKey(f);null!==f&&c.push(u.createPortal(r,f))}return c},[d,a])}
10
+ function D(a){a=a.anchor.getNode();return"rtl"===(t.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}function E(a,d){a=t.$getDecoratorNode(a.focus,d);return t.$isDecoratorNode(a)&&!a.isIsolated()}function F(a,d){a.preventDefault();d.update(()=>{const e=t.$getSelection(),c=a.clipboardData;null!=c&&t.$isRangeSelection(e)&&v.$insertDataTransferForPlainText(c,e)})}function G(a,d){H(a,d);d.update(()=>{const e=t.$getSelection();t.$isRangeSelection(e)&&e.removeText()})}
11
+ function H(a,d){a.preventDefault();d.update(()=>{const e=a.clipboardData,c=t.$getSelection();if(null!==c&&null!=e){const b=v.getHtmlContent(d);null!==b&&e.setData("text/html",b);e.setData("text/plain",c.getTextContent())}})}const I={tag:"history-merge"};
12
12
  function J(a,d){if(null!==d)if(void 0===d)a.update(()=>{var e=t.$getRoot();if(null===e.getFirstChild()){const c=t.$createParagraphNode();e.append(c);e=document.activeElement;(null!==t.$getSelection()||null!==e&&e===a.getRootElement())&&c.select()}},I);else if(null!==d)switch(typeof d){case "string":d=a.parseEditorState(d);a.setEditorState(d,I);break;case "object":a.setEditorState(d,I);break;case "function":a.update(d,I)}}
13
13
  function K(a){h.useEffect(()=>{const d=e=>{var c=a.getRootElement();if(document.activeElement===c&&(c=e.data,"string"===typeof c)){try{var b=JSON.parse(c)}catch(f){return}if(b&&"nuanria_messaging"===b.protocol&&"request"===b.type&&(b=b.payload)&&"makeChanges"===b.functionId&&(b=b.args)){const [f,p,r,B,L]=b;a.update(()=>{const q=t.$getSelection();if(t.$isRangeSelection(q)){var n=q.anchor;let k=n.getNode(),l=0,m=0;t.$isTextNode(k)&&0<=f&&0<=p&&(l=f,m=f+p,q.setTextNodeRange(k,l,k,m));if(l!==m||""!==
14
14
  r)q.insertRawText(r),k=n.getNode();t.$isTextNode(k)&&(l=B,m=B+L,n=k.getTextContentSize(),l=l>n?n:l,m=m>n?n:m,q.setTextNodeRange(k,l,k,m));e.stopImmediatePropagation()}})}}};window.addEventListener("message",d,!0);return()=>{window.removeEventListener("message",d,!0)}},[a])}
15
- function M(a,d){h.useEffect(()=>{const e=a.addListener("command",(c,b)=>{const f=t.$getSelection();if(!t.$isRangeSelection(f))return!1;switch(c){case "deleteCharacter":return f.deleteCharacter(b),!0;case "deleteWord":return f.deleteWord(b),!0;case "deleteLine":return f.deleteLine(b),!0;case "insertText":return"string"===typeof b?f.insertText(b):(c=b.dataTransfer,null!=c?D(c,f):(b=b.data)&&f.insertText(b)),!0;case "removeText":return f.removeText(),!0;case "insertLineBreak":return f.insertLineBreak(b),
16
- !0;case "insertParagraph":return f.insertLineBreak(),!0;case "indentContent":case "outdentContent":case "insertHorizontalRule":case "insertImage":case "insertTable":case "formatElement":case "formatText":return!0;case "keyArrowLeft":c=b.shiftKey;if(E(f,!0))return b.preventDefault(),b=c,c=C(f),f.modify(b?"extend":"move",!c,"character"),!0;break;case "keyArrowRight":c=b.shiftKey;if(E(f,!1))return b.preventDefault(),b=c,c=C(f),f.modify(b?"extend":"move",c,"character"),!0;break;case "keyBackspace":return b.preventDefault(),
15
+ function M(a,d){z(()=>{const e=a.addListener("command",(c,b)=>{const f=t.$getSelection();if(!t.$isRangeSelection(f))return!1;switch(c){case "deleteCharacter":return f.deleteCharacter(b),!0;case "deleteWord":return f.deleteWord(b),!0;case "deleteLine":return f.deleteLine(b),!0;case "insertText":return"string"===typeof b?f.insertText(b):(c=b.dataTransfer,null!=c?v.$insertDataTransferForPlainText(c,f):(b=b.data)&&f.insertText(b)),!0;case "removeText":return f.removeText(),!0;case "insertLineBreak":return f.insertLineBreak(b),
16
+ !0;case "insertParagraph":return f.insertLineBreak(),!0;case "indentContent":case "outdentContent":case "insertHorizontalRule":case "insertImage":case "insertTable":case "formatElement":case "formatText":return!0;case "keyArrowLeft":c=b.shiftKey;if(E(f,!0))return b.preventDefault(),b=c,c=D(f),f.modify(b?"extend":"move",!c,"character"),!0;break;case "keyArrowRight":c=b.shiftKey;if(E(f,!1))return b.preventDefault(),b=c,c=D(f),f.modify(b?"extend":"move",c,"character"),!0;break;case "keyBackspace":return b.preventDefault(),
17
17
  a.execCommand("deleteCharacter",!0);case "keyDelete":return b.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return b.preventDefault(),a.execCommand("insertLineBreak");case "copy":return H(b,a),!0;case "cut":return G(b,a),!0;case "paste":return F(b,a),!0;case "drop":case "dragstart":return b.preventDefault(),!0}return!1},0);J(a,d);return e},[a]);K(a)}
18
- module.exports=function({contentEditable:a,placeholder:d,initialEditorState:e}){const [c]=g.useLexicalComposerContext(),b=z(c);M(c,e);e=A(c);return h.createElement(h.Fragment,null,a,b&&d,e)};
18
+ module.exports=function({contentEditable:a,placeholder:d,initialEditorState:e}){const [c]=g.useLexicalComposerContext(),b=A(c);M(c,e);e=C(c);return h.createElement(h.Fragment,null,a,b&&d,e)};
@@ -0,0 +1,15 @@
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
+ */
8
+
9
+ import type {EditorState} from 'lexical';
10
+ type InitialEditorStateType = null | string | EditorState | (() => void);
11
+ export default function RichTextPlugin(arg0: {
12
+ contentEditable: React.ReactNode;
13
+ initialEditorState?: InitialEditorStateType;
14
+ placeholder: React.ReactNode;
15
+ }): React.ReactNode;