@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
package/README.md CHANGED
@@ -19,7 +19,7 @@ import {useEffect} from 'react';
19
19
  import LexicalComposer from '@lexical/react/LexicalComposer';
20
20
  import LexicalPlainTextPlugin from '@lexical/react/LexicalPlainTextPlugin';
21
21
  import LexicalContentEditable from '@lexical/react/LexicalContentEditable';
22
- import LexicalHistoryPlugin from '@lexical/react/LexicalHistoryPlugin';
22
+ import {HistoryPlugin} from '@lexical/react/LexicalHistoryPlugin';
23
23
  import LexicalOnChangePlugin from '@lexical/react/LexicalOnChangePlugin';
24
24
  import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
25
25
 
@@ -63,17 +63,22 @@ function onError(error) {
63
63
  }
64
64
 
65
65
  function Editor() {
66
+ const initialConfig = {
67
+ theme,
68
+ onError,
69
+ };
70
+
66
71
  return (
67
- <LexicalComposer theme={theme}>
72
+ <LexicalComposer initialConfig={initialConfig}>
73
+ <LexicalBootstrapPlugin />
68
74
  <LexicalPlainTextPlugin
69
- contentEditable={<LexicalContentEditable className="editor-input" />}
75
+ contentEditable={<LexicalContentEditable />}
70
76
  placeholder={<div>Enter some text...</div>}
71
- onError={onError}
72
77
  />
73
78
  <LexicalOnChangePlugin onChange={onChange} />
74
- <LexicalHistoryPlugin />
79
+ <HistoryPlugin />
75
80
  <MyCustomAutoFocusPlugin />
76
81
  </LexicalComposer>
77
82
  );
78
83
  }
79
- ```
84
+ ```
package/package.json CHANGED
@@ -12,11 +12,11 @@
12
12
  "rich-text"
13
13
  ],
14
14
  "license": "MIT",
15
- "version": "0.1.4",
15
+ "version": "0.1.8",
16
16
  "peerDependencies": {
17
- "lexical": "0.1.4",
18
- "@lexical/helpers": "0.1.4",
19
- "@lexical/yjs": "0.1.4",
17
+ "lexical": "0.1.8",
18
+ "@lexical/helpers": "0.1.8",
19
+ "@lexical/yjs": "0.1.8",
20
20
  "react": ">=17.x",
21
21
  "react-dom": ">=17.x"
22
22
  },
@@ -0,0 +1,83 @@
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
+ 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
+
42
+ function getInitialMapValue(decoratorMap, key, initialValue) {
43
+ // $FlowFixMe: Flow struggles with the generic
44
+ const value = decoratorMap.get(key);
45
+
46
+ if (value !== undefined) {
47
+ return value;
48
+ }
49
+
50
+ return typeof initialValue === 'function' ? initialValue() : initialValue;
51
+ }
52
+
53
+ function useLexicalDecoratorMap(decoratorMap, key, initialValue) {
54
+ const [latestValue, setReactValue] = react.useState(() => getInitialMapValue(decoratorMap, key, initialValue));
55
+ const [, triggerUpdate] = react.useState();
56
+ useLayoutEffect(() => {
57
+ const prevValue = decoratorMap.get(key);
58
+
59
+ if (prevValue !== latestValue) {
60
+ decoratorMap.set(key, latestValue);
61
+ }
62
+ }, [key, latestValue, decoratorMap]);
63
+ useLayoutEffect(() => {
64
+ if (lexical.isDecoratorArray(latestValue)) {
65
+ return latestValue.observe(() => {
66
+ triggerUpdate({});
67
+ });
68
+ }
69
+ }, [latestValue]);
70
+ useLayoutEffect(() => {
71
+ return decoratorMap.observe((changedKey, value) => {
72
+ if (changedKey === key) {
73
+ decoratorMap._map.set(changedKey, value);
74
+
75
+ setReactValue(value);
76
+ }
77
+ });
78
+ }, [decoratorMap, key]); // $FlowFixMe: needs refining
79
+
80
+ return [latestValue, setReactValue];
81
+ }
82
+
83
+ module.exports = useLexicalDecoratorMap;
@@ -1 +1,9 @@
1
- 'use strict';var e=require("react"),g="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?e.useLayoutEffect:e.useEffect;module.exports=function(a,c,f){const [d,h]=e.useState(()=>{var b=a.get(c);b=void 0!==b?b:"function"===typeof f?f():f;return b});g(()=>{a.get(c)!==d&&a.set(c,d)},[c,d,a]);g(()=>a.observe((b,k)=>{b===c&&(a._map.set(b,k),h(k))}),[a,c]);return[d,h]};
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 useLexicalDecoratorMap = process.env.NODE_ENV === 'development' ? require('./useLexicalDecoratorMap.dev.js') : require('./useLexicalDecoratorMap.prod.js')
9
+ module.exports = useLexicalDecoratorMap;
@@ -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"),l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;
8
+ module.exports=function(a,d,g){const [b,h]=f.useState(()=>{var c=a.get(d);c=void 0!==c?c:"function"===typeof g?g():g;return c}),[,m]=f.useState();l(()=>{a.get(d)!==b&&a.set(d,b)},[d,b,a]);l(()=>{if(e.isDecoratorArray(b))return b.observe(()=>{m({})})},[b]);l(()=>a.observe((c,k)=>{c===d&&(a._map.set(c,k),h(k))}),[a,d]);return[b,h]};
@@ -0,0 +1,84 @@
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 $isTextContentEmptyCurry(isEditorComposing, trim) {
38
+ return () => $isTextContentEmpty(isEditorComposing, trim);
39
+ }
40
+
41
+ /**
42
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
43
+ *
44
+ * This source code is licensed under the MIT license found in the
45
+ * LICENSE file in the root directory of this source tree.
46
+ *
47
+ *
48
+ */
49
+ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
50
+
51
+ /**
52
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
53
+ *
54
+ * This source code is licensed under the MIT license found in the
55
+ * LICENSE file in the root directory of this source tree.
56
+ *
57
+ *
58
+ */
59
+ const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
60
+ var useLayoutEffect = useLayoutEffectImpl;
61
+
62
+ /**
63
+ * Copyright (c) Facebook, Inc. and its affiliates.
64
+ *
65
+ * This source code is licensed under the MIT license found in the
66
+ * LICENSE file in the root directory of this source tree.
67
+ *
68
+ *
69
+ */
70
+ function useLexicalIsTextContentEmpty(editor, trim) {
71
+ const [isEmpty, setIsEmpty] = react.useState(editor.getEditorState().read($isTextContentEmptyCurry(editor.isComposing(), trim)));
72
+ useLayoutEffect(() => {
73
+ return editor.addListener('update', ({
74
+ editorState
75
+ }) => {
76
+ const isComposing = editor.isComposing();
77
+ const currentIsEmpty = editorState.read($isTextContentEmptyCurry(isComposing, trim));
78
+ setIsEmpty(currentIsEmpty);
79
+ });
80
+ }, [editor, trim]);
81
+ return isEmpty;
82
+ }
83
+
84
+ module.exports = useLexicalIsTextContentEmpty;
@@ -1,2 +1,9 @@
1
- 'use strict';var c=require("react"),e=require("lexical"),f="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?c.useLayoutEffect:c.useEffect;function g(a,b=!0){if(a)return!1;a=e.$getRoot().getTextContent();b&&(a=a.trim());return""===a}function h(a,b){return()=>g(a,b)}
2
- module.exports=function(a,b){const [k,l]=c.useState(a.getEditorState().read(h(a.isComposing(),b)));f(()=>a.addListener("update",({editorState:d})=>{const m=a.isComposing();d=d.read(h(m,b));l(d)}),[a,b]);return k};
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 useLexicalIsTextContentEmpty = process.env.NODE_ENV === 'development' ? require('./useLexicalIsTextContentEmpty.dev.js') : require('./useLexicalIsTextContentEmpty.prod.js')
9
+ module.exports = useLexicalIsTextContentEmpty;
@@ -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("lexical"),e=require("react");function f(a,b=!0){if(a)return!1;a=c.$getRoot().getTextContent();b&&(a=a.trim());return""===a}function g(a,b){return()=>f(a,b)}var h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?e.useLayoutEffect:e.useEffect;
8
+ module.exports=function(a,b){const [k,l]=e.useState(a.getEditorState().read(g(a.isComposing(),b)));h(()=>a.addListener("update",({editorState:d})=>{const m=a.isComposing();d=d.read(g(m,b));l(d)}),[a,b]);return k};
@@ -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
+ 'use strict';
8
+
9
+ /**
10
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
11
+ *
12
+ * This source code is licensed under the MIT license found in the
13
+ * LICENSE file in the root directory of this source tree.
14
+ *
15
+ *
16
+ */
17
+ function withSubscriptions(...func) {
18
+ return () => {
19
+ func.forEach(f => f());
20
+ };
21
+ }
22
+
23
+ module.exports = withSubscriptions;
@@ -1 +1,9 @@
1
- 'use strict';module.exports=function(...a){return()=>{a.forEach(b=>b())}};
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 withSubscriptions = process.env.NODE_ENV === 'development' ? require('./withSubscriptions.dev.js') : require('./withSubscriptions.prod.js')
9
+ module.exports = withSubscriptions;
@@ -0,0 +1,7 @@
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';module.exports=function(...a){return()=>{a.forEach(b=>b())}};