@lexical/react 0.1.9 → 0.1.12

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 (95) hide show
  1. package/DEPRECATED_useLexical.dev.js +5 -44
  2. package/DEPRECATED_useLexical.prod.js +1 -2
  3. package/DEPRECATED_useLexicalAutoFormatter.dev.js +87 -41
  4. package/DEPRECATED_useLexicalAutoFormatter.prod.js +20 -18
  5. package/DEPRECATED_useLexicalCharacterLimit.dev.js +22 -19
  6. package/DEPRECATED_useLexicalCharacterLimit.prod.js +8 -8
  7. package/DEPRECATED_useLexicalEditor.dev.js +1 -25
  8. package/DEPRECATED_useLexicalEditor.prod.js +1 -1
  9. package/DEPRECATED_useLexicalHistory.dev.js +1 -1
  10. package/DEPRECATED_useLexicalHistory.prod.js +2 -2
  11. package/DEPRECATED_useLexicalList.dev.js +6 -0
  12. package/DEPRECATED_useLexicalList.prod.js +1 -1
  13. package/DEPRECATED_useLexicalPlainText.dev.js +81 -89
  14. package/DEPRECATED_useLexicalPlainText.prod.js +15 -16
  15. package/DEPRECATED_useLexicalRichText.dev.js +98 -592
  16. package/DEPRECATED_useLexicalRichText.prod.js +17 -29
  17. package/LexicalAutoFormatterPlugin.d.ts +9 -0
  18. package/LexicalAutoFormatterPlugin.dev.js +87 -41
  19. package/LexicalAutoFormatterPlugin.js.flow +10 -0
  20. package/LexicalAutoFormatterPlugin.prod.js +21 -19
  21. package/LexicalAutoLinkPlugin.d.ts +20 -0
  22. package/LexicalAutoLinkPlugin.js.flow +23 -0
  23. package/LexicalCharacterLimitPlugin.d.ts +11 -0
  24. package/LexicalCharacterLimitPlugin.dev.js +22 -19
  25. package/LexicalCharacterLimitPlugin.js.flow +12 -0
  26. package/LexicalCharacterLimitPlugin.prod.js +9 -8
  27. package/LexicalClearEditorPlugin.d.ts +14 -0
  28. package/LexicalClearEditorPlugin.dev.js +73 -0
  29. package/LexicalClearEditorPlugin.js +9 -0
  30. package/LexicalClearEditorPlugin.js.flow +14 -0
  31. package/LexicalClearEditorPlugin.prod.js +8 -0
  32. package/LexicalCollaborationPlugin.d.ts +49 -0
  33. package/LexicalCollaborationPlugin.dev.js +21 -11
  34. package/LexicalCollaborationPlugin.js.flow +55 -0
  35. package/LexicalCollaborationPlugin.prod.js +7 -7
  36. package/LexicalComposer.d.ts +22 -0
  37. package/LexicalComposer.dev.js +29 -5
  38. package/LexicalComposer.js.flow +24 -0
  39. package/LexicalComposer.prod.js +3 -3
  40. package/LexicalComposerContext.d.ts +24 -0
  41. package/LexicalComposerContext.js.flow +27 -0
  42. package/LexicalContentEditable.d.ts +32 -0
  43. package/LexicalContentEditable.dev.js +35 -8
  44. package/LexicalContentEditable.js.flow +35 -0
  45. package/LexicalContentEditable.prod.js +3 -3
  46. package/LexicalHashtagPlugin.d.ts +9 -0
  47. package/LexicalHashtagPlugin.js.flow +10 -0
  48. package/LexicalHistoryPlugin.d.ts +29 -0
  49. package/LexicalHistoryPlugin.dev.js +1 -1
  50. package/LexicalHistoryPlugin.js.flow +34 -0
  51. package/LexicalHistoryPlugin.prod.js +2 -2
  52. package/LexicalHorizontalRuleNode.d.ts +23 -0
  53. package/LexicalHorizontalRuleNode.js.flow +25 -0
  54. package/LexicalLinkPlugin.d.ts +9 -0
  55. package/LexicalLinkPlugin.js.flow +10 -0
  56. package/LexicalListPlugin.d.ts +9 -0
  57. package/LexicalListPlugin.dev.js +6 -0
  58. package/LexicalListPlugin.js.flow +10 -0
  59. package/LexicalListPlugin.prod.js +2 -2
  60. package/LexicalNestedComposer.d.ts +20 -0
  61. package/LexicalNestedComposer.js.flow +21 -0
  62. package/LexicalOnChangePlugin.d.ts +12 -0
  63. package/LexicalOnChangePlugin.js.flow +14 -0
  64. package/LexicalPlainTextPlugin.d.ts +15 -0
  65. package/LexicalPlainTextPlugin.dev.js +77 -84
  66. package/LexicalPlainTextPlugin.js.flow +18 -0
  67. package/LexicalPlainTextPlugin.prod.js +12 -12
  68. package/LexicalRichTextPlugin.d.ts +15 -0
  69. package/LexicalRichTextPlugin.dev.js +93 -586
  70. package/LexicalRichTextPlugin.js.flow +18 -0
  71. package/LexicalRichTextPlugin.prod.js +13 -25
  72. package/LexicalTablePlugin.d.ts +9 -0
  73. package/LexicalTablePlugin.dev.js +23 -1
  74. package/LexicalTablePlugin.js.flow +10 -0
  75. package/LexicalTablePlugin.prod.js +4 -3
  76. package/LexicalTreeView.d.ts +17 -0
  77. package/LexicalTreeView.dev.js +10 -2
  78. package/LexicalTreeView.js.flow +19 -0
  79. package/LexicalTreeView.prod.js +9 -8
  80. package/README.md +0 -1
  81. package/package.json +6 -5
  82. package/useLexicalDecoratorMap.d.ts +14 -0
  83. package/useLexicalDecoratorMap.js.flow +16 -0
  84. package/useLexicalIsTextContentEmpty.d.ts +13 -0
  85. package/useLexicalIsTextContentEmpty.js.flow +15 -0
  86. package/useLexicalNodeSelection.d.ts +12 -0
  87. package/useLexicalNodeSelection.dev.js +70 -0
  88. package/useLexicalNodeSelection.js +9 -0
  89. package/useLexicalNodeSelection.js.flow +14 -0
  90. package/useLexicalNodeSelection.prod.js +8 -0
  91. package/withSubscriptions.d.ts +12 -0
  92. package/withSubscriptions.js.flow +13 -0
  93. package/LexicalBootstrapPlugin.dev.js +0 -122
  94. package/LexicalBootstrapPlugin.js +0 -9
  95. package/LexicalBootstrapPlugin.prod.js +0 -8
@@ -1,122 +0,0 @@
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 LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
10
- var lexical = require('lexical');
11
- var react = require('react');
12
-
13
- /**
14
- * Copyright (c) Meta Platforms, Inc. and affiliates.
15
- *
16
- * This source code is licensed under the MIT license found in the
17
- * LICENSE file in the root directory of this source tree.
18
- *
19
- *
20
- */
21
- const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
22
-
23
- /**
24
- * Copyright (c) Meta Platforms, Inc. and affiliates.
25
- *
26
- * This source code is licensed under the MIT license found in the
27
- * LICENSE file in the root directory of this source tree.
28
- *
29
- *
30
- */
31
- const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
32
- var useLayoutEffect = useLayoutEffectImpl;
33
-
34
- /**
35
- * Copyright (c) Meta Platforms, Inc. and affiliates.
36
- *
37
- * This source code is licensed under the MIT license found in the
38
- * LICENSE file in the root directory of this source tree.
39
- *
40
- *
41
- */
42
- const BootstrapPriority = 0;
43
-
44
- function shouldSelectParagraph(editor) {
45
- const activeElement = document.activeElement;
46
- return lexical.$getSelection() !== null || activeElement !== null && activeElement === editor.getRootElement();
47
- }
48
-
49
- function initParagraph(root, editor) {
50
- const paragraph = lexical.$createParagraphNode();
51
- root.append(paragraph);
52
-
53
- if (shouldSelectParagraph(editor)) {
54
- paragraph.select();
55
- }
56
- }
57
-
58
- function defaultInitEditor(editor) {
59
- const root = lexical.$getRoot();
60
- const firstChild = root.getFirstChild();
61
-
62
- if (firstChild === null) {
63
- initParagraph(root, editor);
64
- }
65
- }
66
-
67
- function defaultClearEditor(editor) {
68
- const root = lexical.$getRoot();
69
- root.clear();
70
- initParagraph(root, editor);
71
- }
72
-
73
- function initEditor(editor, initialPayloadFn) {
74
- editor.update(() => {
75
- initialPayloadFn(editor);
76
- });
77
- }
78
-
79
- function clearEditor(editor, clearEditorFn, callbackFn) {
80
- editor.update(() => {
81
- clearEditorFn(editor);
82
- }, {
83
- onUpdate: callbackFn
84
- });
85
- }
86
-
87
- function useBootstrapEditor(editor, initialPayloadFn, clearEditorFn) {
88
- useLayoutEffect(() => {
89
- return editor.addListener('command', (type, payload) => {
90
- if (type === 'bootstrapEditor') {
91
- initEditor(editor, initialPayloadFn != null ? initialPayloadFn : defaultInitEditor);
92
- return true;
93
- }
94
-
95
- if (type === 'clearEditor') {
96
- clearEditor(editor, clearEditorFn != null ? clearEditorFn : defaultClearEditor);
97
- return true;
98
- }
99
-
100
- return false;
101
- }, BootstrapPriority);
102
- }, [clearEditorFn, editor, initialPayloadFn]);
103
- }
104
-
105
- /**
106
- * Copyright (c) Meta Platforms, Inc. and affiliates.
107
- *
108
- * This source code is licensed under the MIT license found in the
109
- * LICENSE file in the root directory of this source tree.
110
- *
111
- *
112
- */
113
- function LexicalBootstrapPlugin({
114
- initialPayloadFn,
115
- clearEditorFn
116
- }) {
117
- const [editor] = LexicalComposerContext.useLexicalComposerContext();
118
- useBootstrapEditor(editor, initialPayloadFn, clearEditorFn);
119
- return null;
120
- }
121
-
122
- module.exports = LexicalBootstrapPlugin;
@@ -1,9 +0,0 @@
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 LexicalBootstrapPlugin = process.env.NODE_ENV === 'development' ? require('./LexicalBootstrapPlugin.dev.js') : require('./LexicalBootstrapPlugin.prod.js')
9
- module.exports = LexicalBootstrapPlugin;
@@ -1,8 +0,0 @@
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
- var d=require("@lexical/react/LexicalComposerContext"),e=require("lexical"),f=require("react"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;function k(a,b){const c=e.$createParagraphNode();a.append(c);a=document.activeElement;(null!==e.$getSelection()||null!==a&&a===b.getRootElement())&&c.select()}function l(a){const b=e.$getRoot();null===b.getFirstChild()&&k(b,a)}
8
- function m(a){const b=e.$getRoot();b.clear();k(b,a)}function n(a,b){a.update(()=>{b(a)})}function p(a,b,c){a.update(()=>{b(a)},{onUpdate:c})}function q(a,b,c){h(()=>a.addListener("command",g=>"bootstrapEditor"===g?(n(a,null!=b?b:l),!0):"clearEditor"===g?(p(a,null!=c?c:m),!0):!1,0),[c,a,b])}module.exports=function({initialPayloadFn:a,clearEditorFn:b}){const [c]=d.useLexicalComposerContext();q(c,a,b);return null};