@lexical/react 0.1.19 → 0.2.0
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/LexicalAutoLinkPlugin.d.ts +1 -1
- package/LexicalCharacterLimitPlugin.d.ts +1 -1
- package/LexicalClearEditorPlugin.d.ts +3 -1
- package/LexicalCollaborationPlugin.d.ts +1 -1
- package/LexicalComposer.d.ts +2 -2
- package/LexicalContentEditable.d.ts +3 -1
- package/LexicalHashtagPlugin.d.ts +1 -1
- package/LexicalHistoryPlugin.d.ts +1 -1
- package/LexicalHorizontalRuleNode.d.ts +2 -2
- package/LexicalHorizontalRuleNode.dev.js +23 -1
- package/LexicalHorizontalRuleNode.prod.js +3 -2
- package/LexicalMarkdownShortcutPlugin.d.ts +1 -1
- package/LexicalNestedComposer.d.ts +5 -7
- package/LexicalNestedComposer.dev.js +13 -35
- package/LexicalNestedComposer.js.flow +3 -5
- package/LexicalNestedComposer.prod.js +3 -3
- package/LexicalPlainTextPlugin.d.ts +3 -3
- package/LexicalRichTextPlugin.d.ts +3 -3
- package/LexicalTreeView.d.ts +1 -1
- package/package.json +18 -17
- package/useLexicalDecoratorMap.d.ts +0 -14
- package/useLexicalDecoratorMap.dev.js +0 -83
- package/useLexicalDecoratorMap.js +0 -9
- package/useLexicalDecoratorMap.js.flow +0 -16
- package/useLexicalDecoratorMap.prod.js +0 -8
|
@@ -11,4 +11,6 @@ import {$ReadOnly} from 'utility-types';
|
|
|
11
11
|
type Props = $ReadOnly<{
|
|
12
12
|
onClear?: () => void;
|
|
13
13
|
}>;
|
|
14
|
-
export default function LexicalClearEditorPlugin(
|
|
14
|
+
export default function LexicalClearEditorPlugin(
|
|
15
|
+
arg0: Props,
|
|
16
|
+
): JSX.Element | null;
|
|
@@ -51,6 +51,6 @@ export function CollaborationPlugin(arg0: {
|
|
|
51
51
|
providerFactory: ProviderFactory;
|
|
52
52
|
shouldBootstrap: boolean;
|
|
53
53
|
username?: string;
|
|
54
|
-
}):
|
|
54
|
+
}): JSX.Element | null;
|
|
55
55
|
export declare var CollaborationContext: React.Context<CollaborationContextType>;
|
|
56
56
|
export function useCollaborationContext(): CollaborationContextType;
|
package/LexicalComposer.d.ts
CHANGED
|
@@ -17,6 +17,6 @@ type Props = {
|
|
|
17
17
|
theme?: EditorThemeClasses;
|
|
18
18
|
onError: (error: Error, editor: LexicalEditor) => void;
|
|
19
19
|
};
|
|
20
|
-
children:
|
|
20
|
+
children: JSX.Element | null;
|
|
21
21
|
};
|
|
22
|
-
export default function LexicalComposer(arg0: Props):
|
|
22
|
+
export default function LexicalComposer(arg0: Props): JSX.Element | null;
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
|
|
9
9
|
import type {LexicalNode, LexicalCommand} from 'lexical';
|
|
10
10
|
import {DecoratorNode} from 'lexical';
|
|
11
|
-
export declare class HorizontalRuleNode extends DecoratorNode<
|
|
11
|
+
export declare class HorizontalRuleNode extends DecoratorNode<JSX.Element | null> {
|
|
12
12
|
getType(): string;
|
|
13
13
|
clone(node: HorizontalRuleNode): HorizontalRuleNode;
|
|
14
14
|
createDOM(): HTMLElement;
|
|
15
15
|
getTextContent(): '\n';
|
|
16
16
|
isTopLevel(): true;
|
|
17
17
|
updateDOM(): false;
|
|
18
|
-
decorate():
|
|
18
|
+
decorate(): JSX.Element | null;
|
|
19
19
|
}
|
|
20
20
|
export function $createHorizontalRuleNode(): HorizontalRuleNode;
|
|
21
21
|
export function $isHorizontalRuleNode(
|
|
@@ -29,7 +29,22 @@ class HorizontalRuleNode extends lexical.DecoratorNode {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
static clone(node) {
|
|
32
|
-
return new HorizontalRuleNode(node.
|
|
32
|
+
return new HorizontalRuleNode(node.__key);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static importDOM() {
|
|
36
|
+
return {
|
|
37
|
+
hr: node => ({
|
|
38
|
+
conversion: convertHorizontalRuleElement,
|
|
39
|
+
priority: 0
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exportDOM() {
|
|
45
|
+
return {
|
|
46
|
+
element: document.createElement('hr')
|
|
47
|
+
};
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
createDOM() {
|
|
@@ -55,6 +70,13 @@ class HorizontalRuleNode extends lexical.DecoratorNode {
|
|
|
55
70
|
}
|
|
56
71
|
|
|
57
72
|
}
|
|
73
|
+
|
|
74
|
+
function convertHorizontalRuleElement() {
|
|
75
|
+
return {
|
|
76
|
+
node: $createHorizontalRuleNode()
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
58
80
|
function $createHorizontalRuleNode() {
|
|
59
81
|
return new HorizontalRuleNode();
|
|
60
82
|
}
|
|
@@ -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 b=require("lexical"),c=require("react");const d=b.createCommand();function e(){return c.createElement("hr",null)}
|
|
8
|
-
|
|
7
|
+
var b=require("lexical"),c=require("react");const d=b.createCommand();function e(){return c.createElement("hr",null)}
|
|
8
|
+
class f extends b.DecoratorNode{static getType(){return"horizontalrule"}static clone(a){return new f(a.__key)}static importDOM(){return{hr:()=>({conversion:g,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(){const a=document.createElement("div");a.style.display="contents";return a}getTextContent(){return"\n"}isTopLevel(){return!0}updateDOM(){return!1}decorate(){return c.createElement(e,null)}}function g(){return{node:h()}}function h(){return new f}
|
|
9
|
+
exports.$createHorizontalRuleNode=h;exports.$isHorizontalRuleNode=function(a){return a instanceof f};exports.HorizontalRuleNode=f;exports.INSERT_HORIZONTAL_RULE_COMMAND=d;
|
|
@@ -6,12 +6,10 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type {LexicalEditor, EditorThemeClasses} from 'lexical';
|
|
10
10
|
|
|
11
11
|
export default function LexicalNestedComposer(arg0: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
}): React.ReactNode;
|
|
12
|
+
initialEditor: LexicalEditor;
|
|
13
|
+
initialTheme?: EditorThemeClasses;
|
|
14
|
+
children: JSX.Element | null;
|
|
15
|
+
}): JSX.Element | null;
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
10
|
-
var LexicalOnChangePlugin = require('@lexical/react/LexicalOnChangePlugin');
|
|
11
|
-
var lexical = require('lexical');
|
|
12
10
|
var React = require('react');
|
|
13
11
|
|
|
14
12
|
/**
|
|
@@ -20,8 +18,9 @@ var React = require('react');
|
|
|
20
18
|
*
|
|
21
19
|
*/
|
|
22
20
|
function LexicalNestedComposer({
|
|
23
|
-
|
|
24
|
-
children
|
|
21
|
+
initialEditor,
|
|
22
|
+
children,
|
|
23
|
+
initialTheme
|
|
25
24
|
}) {
|
|
26
25
|
const parentContext = React.useContext(LexicalComposerContext.LexicalComposerContext);
|
|
27
26
|
|
|
@@ -31,45 +30,24 @@ function LexicalNestedComposer({
|
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
const [nestedEditor, setNestedEditor] = React.useState(null);
|
|
35
|
-
const {
|
|
36
|
-
decoratorEditor
|
|
37
|
-
} = initialConfig;
|
|
38
|
-
React.useEffect(() => {
|
|
39
|
-
if (!decoratorEditor.isEmpty() && nestedEditor !== null) {
|
|
40
|
-
decoratorEditor.init(nestedEditor);
|
|
41
|
-
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
|
-
|
|
43
|
-
}, [nestedEditor]);
|
|
44
33
|
const composerContext = React.useMemo(() => {
|
|
45
34
|
const [parentEditor, parentContextContext] = parentContext;
|
|
46
|
-
const composerTheme =
|
|
35
|
+
const composerTheme = initialTheme || parentContextContext.getTheme() || undefined;
|
|
47
36
|
const context = LexicalComposerContext.createLexicalComposerContext(parentContext, composerTheme);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return [editor, context];
|
|
37
|
+
|
|
38
|
+
if (composerTheme !== undefined) {
|
|
39
|
+
initialEditor._config.theme = composerTheme;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
initialEditor._parentEditor = parentEditor;
|
|
43
|
+
initialEditor._nodes = parentEditor._nodes;
|
|
44
|
+
return [initialEditor, context];
|
|
57
45
|
}, // We only do this for init
|
|
58
46
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
47
|
[]);
|
|
60
|
-
const onChange = React.useCallback((editorState, nextNestedEditor) => {
|
|
61
|
-
if (!editorState.isEmpty()) {
|
|
62
|
-
decoratorEditor.set(nextNestedEditor);
|
|
63
|
-
} else {
|
|
64
|
-
setNestedEditor(nextNestedEditor);
|
|
65
|
-
}
|
|
66
|
-
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
|
-
[]);
|
|
68
48
|
return /*#__PURE__*/React.createElement(LexicalComposerContext.LexicalComposerContext.Provider, {
|
|
69
49
|
value: composerContext
|
|
70
|
-
},
|
|
71
|
-
onChange: onChange
|
|
72
|
-
}), children);
|
|
50
|
+
}, children);
|
|
73
51
|
}
|
|
74
52
|
|
|
75
53
|
module.exports = LexicalNestedComposer;
|
|
@@ -7,12 +7,10 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type {LexicalEditor, EditorThemeClasses, LexicalNode} from 'lexical';
|
|
11
11
|
|
|
12
12
|
declare export default function LexicalNestedComposer({
|
|
13
|
-
initialConfig: $ReadOnly<{
|
|
14
|
-
decoratorEditor: DecoratorEditor,
|
|
15
|
-
theme?: EditorThemeClasses,
|
|
16
|
-
}>,
|
|
17
13
|
children: React$Node,
|
|
14
|
+
initialEditor: LexicalEditor,
|
|
15
|
+
initialTheme?: EditorThemeClasses,
|
|
18
16
|
}): React$Node;
|
|
@@ -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
|
|
8
|
-
module.exports=function({
|
|
9
|
-
|
|
7
|
+
var b=require("@lexical/react/LexicalComposerContext"),c=require("react");
|
|
8
|
+
module.exports=function({initialEditor:a,children:g,initialTheme:h}){const d=c.useContext(b.LexicalComposerContext);if(null==d)throw Error("Minified Lexical error #72; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");const m=c.useMemo(()=>{const [f,k]=d,e=h||k.getTheme()||void 0,l=b.createLexicalComposerContext(d,e);void 0!==e&&(a._config.theme=e);a._parentEditor=f;a._nodes=f._nodes;return[a,l]},[]);return c.createElement(b.LexicalComposerContext.Provider,
|
|
9
|
+
{value:m},g)};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type {EditorState} from 'lexical';
|
|
10
10
|
type InitialEditorStateType = null | string | EditorState | (() => void);
|
|
11
11
|
export default function PlainTextPlugin(arg0: {
|
|
12
|
-
contentEditable:
|
|
12
|
+
contentEditable: JSX.Element | null;
|
|
13
13
|
initialEditorState?: InitialEditorStateType;
|
|
14
|
-
placeholder:
|
|
15
|
-
}):
|
|
14
|
+
placeholder: JSX.Element | null;
|
|
15
|
+
}): JSX.Element | null;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type {EditorState} from 'lexical';
|
|
10
10
|
type InitialEditorStateType = null | string | EditorState | (() => void);
|
|
11
11
|
export default function RichTextPlugin(arg0: {
|
|
12
|
-
contentEditable:
|
|
12
|
+
contentEditable: JSX.Element | null;
|
|
13
13
|
initialEditorState?: InitialEditorStateType;
|
|
14
|
-
placeholder:
|
|
15
|
-
}):
|
|
14
|
+
placeholder: JSX.Element | null;
|
|
15
|
+
}): JSX.Element | null;
|
package/LexicalTreeView.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -8,26 +8,27 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.2.0",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.
|
|
14
|
-
"@lexical/list": "0.
|
|
15
|
-
"@lexical/table": "0.
|
|
16
|
-
"@lexical/yjs": "0.
|
|
17
|
-
"@lexical/hashtag": "0.
|
|
18
|
-
"@lexical/selection": "0.
|
|
19
|
-
"@lexical/utils": "0.
|
|
20
|
-
"@lexical/dragon": "0.
|
|
21
|
-
"@lexical/plain-text": "0.
|
|
22
|
-
"@lexical/rich-text": "0.
|
|
23
|
-
"@lexical/code": "0.
|
|
24
|
-
"@lexical/text": "0.
|
|
25
|
-
"@lexical/link": "0.
|
|
26
|
-
"@lexical/overflow": "0.
|
|
27
|
-
"@lexical/history": "0.
|
|
13
|
+
"@lexical/clipboard": "0.2.0",
|
|
14
|
+
"@lexical/list": "0.2.0",
|
|
15
|
+
"@lexical/table": "0.2.0",
|
|
16
|
+
"@lexical/yjs": "0.2.0",
|
|
17
|
+
"@lexical/hashtag": "0.2.0",
|
|
18
|
+
"@lexical/selection": "0.2.0",
|
|
19
|
+
"@lexical/utils": "0.2.0",
|
|
20
|
+
"@lexical/dragon": "0.2.0",
|
|
21
|
+
"@lexical/plain-text": "0.2.0",
|
|
22
|
+
"@lexical/rich-text": "0.2.0",
|
|
23
|
+
"@lexical/code": "0.2.0",
|
|
24
|
+
"@lexical/text": "0.2.0",
|
|
25
|
+
"@lexical/link": "0.2.0",
|
|
26
|
+
"@lexical/overflow": "0.2.0",
|
|
27
|
+
"@lexical/history": "0.2.0",
|
|
28
|
+
"@lexical/markdown": "0.2.0"
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {
|
|
30
|
-
"lexical": "0.
|
|
31
|
+
"lexical": "0.2.0",
|
|
31
32
|
"react": ">=17.x",
|
|
32
33
|
"react-dom": ">=17.x"
|
|
33
34
|
},
|
|
@@ -1,14 +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
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type {DecoratorMap, DecoratorStateValue} from 'lexical';
|
|
10
|
-
export default function useLexicalDecoratorMap<V extends DecoratorStateValue>(
|
|
11
|
-
decoratorMap: DecoratorMap,
|
|
12
|
-
key: string,
|
|
13
|
-
initialValue: (() => V) | V,
|
|
14
|
-
): [V, (arg0: DecoratorStateValue) => void];
|
|
@@ -1,83 +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 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,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 useLexicalDecoratorMap = process.env.NODE_ENV === 'development' ? require('./useLexicalDecoratorMap.dev.js') : require('./useLexicalDecoratorMap.prod.js')
|
|
9
|
-
module.exports = useLexicalDecoratorMap;
|
|
@@ -1,16 +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
|
-
* @flow strict
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type {DecoratorMap, DecoratorStateValue} from 'lexical';
|
|
11
|
-
|
|
12
|
-
declare export default function useLexicalDecoratorMap<V: DecoratorStateValue>(
|
|
13
|
-
decoratorMap: DecoratorMap,
|
|
14
|
-
key: string,
|
|
15
|
-
initialValue: (() => V) | V,
|
|
16
|
-
): [V, (DecoratorStateValue) => void];
|
|
@@ -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 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]};
|