@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.
- package/DEPRECATED_useLexical.dev.js +84 -0
- package/DEPRECATED_useLexical.js +9 -2
- package/DEPRECATED_useLexical.prod.js +8 -0
- package/DEPRECATED_useLexicalAutoFormatter.dev.js +642 -0
- package/DEPRECATED_useLexicalAutoFormatter.js +9 -12
- package/DEPRECATED_useLexicalAutoFormatter.prod.js +22 -0
- package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +136 -0
- package/DEPRECATED_useLexicalCanShowPlaceholder.js +9 -3
- package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +8 -0
- package/DEPRECATED_useLexicalCharacterLimit.dev.js +294 -0
- package/DEPRECATED_useLexicalCharacterLimit.js +9 -9
- package/DEPRECATED_useLexicalCharacterLimit.prod.js +14 -0
- package/DEPRECATED_useLexicalDecorators.dev.js +82 -0
- package/DEPRECATED_useLexicalDecorators.js +9 -2
- package/DEPRECATED_useLexicalDecorators.prod.js +8 -0
- package/DEPRECATED_useLexicalEditor.dev.js +52 -0
- package/DEPRECATED_useLexicalEditor.js +9 -1
- package/DEPRECATED_useLexicalEditor.prod.js +7 -0
- package/DEPRECATED_useLexicalEditorEvents.dev.js +96 -0
- package/DEPRECATED_useLexicalEditorEvents.js +9 -2
- package/DEPRECATED_useLexicalEditorEvents.prod.js +8 -0
- package/DEPRECATED_useLexicalHistory.dev.js +339 -0
- package/DEPRECATED_useLexicalHistory.js +9 -7
- package/DEPRECATED_useLexicalHistory.prod.js +13 -0
- package/DEPRECATED_useLexicalList.dev.js +64 -0
- package/DEPRECATED_useLexicalList.js +9 -12
- package/DEPRECATED_useLexicalList.prod.js +7 -0
- package/DEPRECATED_useLexicalPlainText.dev.js +755 -0
- package/DEPRECATED_useLexicalPlainText.js +9 -17
- package/DEPRECATED_useLexicalPlainText.prod.js +22 -0
- package/DEPRECATED_useLexicalRichText.dev.js +1326 -0
- package/DEPRECATED_useLexicalRichText.js +9 -30
- package/DEPRECATED_useLexicalRichText.prod.js +35 -0
- package/LexicalAutoFormatterPlugin.dev.js +645 -0
- package/LexicalAutoFormatterPlugin.js +9 -13
- package/LexicalAutoFormatterPlugin.prod.js +23 -0
- package/LexicalAutoLinkPlugin.dev.js +227 -0
- package/LexicalAutoLinkPlugin.js +9 -5
- package/LexicalAutoLinkPlugin.prod.js +12 -0
- package/LexicalBootstrapPlugin.dev.js +124 -0
- package/LexicalBootstrapPlugin.js +9 -0
- package/LexicalBootstrapPlugin.prod.js +8 -0
- package/LexicalCharacterLimitPlugin.dev.js +352 -0
- package/LexicalCharacterLimitPlugin.js +9 -10
- package/LexicalCharacterLimitPlugin.prod.js +14 -0
- package/LexicalCollaborationPlugin.dev.js +235 -0
- package/LexicalCollaborationPlugin.js +9 -8
- package/LexicalCollaborationPlugin.prod.js +14 -0
- package/LexicalComposer.dev.js +76 -0
- package/LexicalComposer.js +9 -2
- package/LexicalComposer.prod.js +9 -0
- package/LexicalComposerContext.dev.js +53 -0
- package/LexicalComposerContext.js +9 -1
- package/LexicalComposerContext.prod.js +7 -0
- package/LexicalContentEditable.dev.js +71 -0
- package/LexicalContentEditable.js +9 -3
- package/LexicalContentEditable.prod.js +9 -0
- package/LexicalHashtagPlugin.dev.js +152 -0
- package/LexicalHashtagPlugin.js +9 -4
- package/LexicalHashtagPlugin.prod.js +10 -0
- package/LexicalHistoryPlugin.dev.js +344 -0
- package/LexicalHistoryPlugin.js +9 -7
- package/LexicalHistoryPlugin.prod.js +13 -0
- package/LexicalHorizontalRulePlugin.dev.js +51 -0
- package/LexicalHorizontalRulePlugin.js +9 -1
- package/LexicalHorizontalRulePlugin.prod.js +7 -0
- package/LexicalLinkPlugin.dev.js +137 -0
- package/LexicalLinkPlugin.js +9 -3
- package/LexicalLinkPlugin.prod.js +9 -0
- package/LexicalListPlugin.dev.js +67 -0
- package/LexicalListPlugin.js +9 -12
- package/LexicalListPlugin.prod.js +8 -0
- package/LexicalNestedComposer.dev.js +60 -0
- package/LexicalNestedComposer.js +9 -1
- package/LexicalNestedComposer.prod.js +8 -0
- package/LexicalOnChangePlugin.dev.js +57 -0
- package/LexicalOnChangePlugin.js +9 -1
- package/LexicalOnChangePlugin.prod.js +7 -0
- package/LexicalPlainTextPlugin.dev.js +565 -0
- package/LexicalPlainTextPlugin.js +9 -13
- package/LexicalPlainTextPlugin.prod.js +17 -0
- package/LexicalRichTextPlugin.dev.js +1136 -0
- package/LexicalRichTextPlugin.js +9 -26
- package/LexicalRichTextPlugin.prod.js +31 -0
- package/LexicalTablePlugin.dev.js +95 -0
- package/LexicalTablePlugin.js +9 -4
- package/LexicalTablePlugin.prod.js +9 -0
- package/LexicalTreeView.dev.js +340 -0
- package/LexicalTreeView.js +9 -12
- package/LexicalTreeView.prod.js +19 -0
- package/README.md +11 -6
- package/package.json +4 -4
- package/useLexicalDecoratorMap.dev.js +83 -0
- package/useLexicalDecoratorMap.js +9 -1
- package/useLexicalDecoratorMap.prod.js +8 -0
- package/useLexicalIsTextContentEmpty.dev.js +84 -0
- package/useLexicalIsTextContentEmpty.js +9 -2
- package/useLexicalIsTextContentEmpty.prod.js +8 -0
- package/withSubscriptions.dev.js +23 -0
- package/withSubscriptions.js +9 -1
- 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
|
|
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
|
|
72
|
+
<LexicalComposer initialConfig={initialConfig}>
|
|
73
|
+
<LexicalBootstrapPlugin />
|
|
68
74
|
<LexicalPlainTextPlugin
|
|
69
|
-
contentEditable={<LexicalContentEditable
|
|
75
|
+
contentEditable={<LexicalContentEditable />}
|
|
70
76
|
placeholder={<div>Enter some text...</div>}
|
|
71
|
-
onError={onError}
|
|
72
77
|
/>
|
|
73
78
|
<LexicalOnChangePlugin onChange={onChange} />
|
|
74
|
-
<
|
|
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.
|
|
15
|
+
"version": "0.1.8",
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"lexical": "0.1.
|
|
18
|
-
"@lexical/helpers": "0.1.
|
|
19
|
-
"@lexical/yjs": "0.1.
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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;
|
package/withSubscriptions.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
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())}};
|