@lexical/react 0.1.10 → 0.1.13
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 +3 -7
- package/DEPRECATED_useLexical.prod.js +1 -1
- package/DEPRECATED_useLexicalAutoFormatter.dev.js +83 -37
- package/DEPRECATED_useLexicalAutoFormatter.prod.js +20 -19
- package/DEPRECATED_useLexicalCharacterLimit.dev.js +20 -17
- package/DEPRECATED_useLexicalCharacterLimit.prod.js +8 -8
- package/DEPRECATED_useLexicalList.dev.js +6 -0
- package/DEPRECATED_useLexicalList.prod.js +1 -1
- package/DEPRECATED_useLexicalPlainText.dev.js +84 -75
- package/DEPRECATED_useLexicalPlainText.prod.js +15 -15
- package/DEPRECATED_useLexicalRichText.dev.js +96 -438
- package/DEPRECATED_useLexicalRichText.prod.js +17 -26
- package/LexicalAutoFormatterPlugin.d.ts +9 -0
- package/LexicalAutoFormatterPlugin.dev.js +83 -37
- package/LexicalAutoFormatterPlugin.js.flow +10 -0
- package/LexicalAutoFormatterPlugin.prod.js +21 -20
- package/LexicalAutoLinkPlugin.d.ts +20 -0
- package/LexicalAutoLinkPlugin.js.flow +23 -0
- package/LexicalCharacterLimitPlugin.d.ts +11 -0
- package/LexicalCharacterLimitPlugin.dev.js +20 -17
- package/LexicalCharacterLimitPlugin.js.flow +12 -0
- package/LexicalCharacterLimitPlugin.prod.js +9 -8
- package/LexicalClearEditorPlugin.d.ts +14 -0
- package/LexicalClearEditorPlugin.dev.js +73 -0
- package/LexicalClearEditorPlugin.js +9 -0
- package/LexicalClearEditorPlugin.js.flow +14 -0
- package/LexicalClearEditorPlugin.prod.js +8 -0
- package/LexicalCollaborationPlugin.d.ts +49 -0
- package/LexicalCollaborationPlugin.dev.js +21 -13
- package/LexicalCollaborationPlugin.js.flow +55 -0
- package/LexicalCollaborationPlugin.prod.js +7 -7
- package/LexicalComposer.d.ts +22 -0
- package/LexicalComposer.dev.js +32 -3
- package/LexicalComposer.js.flow +24 -0
- package/LexicalComposer.prod.js +3 -2
- package/LexicalComposerContext.d.ts +24 -0
- package/LexicalComposerContext.js.flow +27 -0
- package/LexicalContentEditable.d.ts +32 -0
- package/LexicalContentEditable.dev.js +35 -8
- package/LexicalContentEditable.js.flow +35 -0
- package/LexicalContentEditable.prod.js +3 -3
- package/LexicalHashtagPlugin.d.ts +9 -0
- package/LexicalHashtagPlugin.js.flow +10 -0
- package/LexicalHistoryPlugin.d.ts +29 -0
- package/LexicalHistoryPlugin.js.flow +34 -0
- package/LexicalHorizontalRuleNode.d.ts +23 -0
- package/LexicalHorizontalRuleNode.js.flow +25 -0
- package/LexicalLinkPlugin.d.ts +9 -0
- package/LexicalLinkPlugin.js.flow +10 -0
- package/LexicalListPlugin.d.ts +9 -0
- package/LexicalListPlugin.dev.js +6 -0
- package/LexicalListPlugin.js.flow +10 -0
- package/LexicalListPlugin.prod.js +2 -2
- package/LexicalNestedComposer.d.ts +17 -0
- package/LexicalNestedComposer.dev.js +21 -11
- package/LexicalNestedComposer.js.flow +18 -0
- package/LexicalNestedComposer.prod.js +3 -2
- package/LexicalOnChangePlugin.d.ts +12 -0
- package/LexicalOnChangePlugin.js.flow +14 -0
- package/LexicalPlainTextPlugin.d.ts +15 -0
- package/LexicalPlainTextPlugin.dev.js +73 -84
- package/LexicalPlainTextPlugin.js.flow +18 -0
- package/LexicalPlainTextPlugin.prod.js +12 -12
- package/LexicalRichTextPlugin.d.ts +15 -0
- package/LexicalRichTextPlugin.dev.js +85 -447
- package/LexicalRichTextPlugin.js.flow +18 -0
- package/LexicalRichTextPlugin.prod.js +13 -22
- package/LexicalTablePlugin.d.ts +9 -0
- package/LexicalTablePlugin.dev.js +22 -0
- package/LexicalTablePlugin.js.flow +10 -0
- package/LexicalTablePlugin.prod.js +4 -3
- package/LexicalTreeView.d.ts +17 -0
- package/LexicalTreeView.js.flow +19 -0
- package/README.md +0 -1
- package/package.json +9 -5
- package/useLexicalDecoratorMap.d.ts +14 -0
- package/useLexicalDecoratorMap.js.flow +16 -0
- package/useLexicalIsTextContentEmpty.d.ts +13 -0
- package/useLexicalIsTextContentEmpty.js.flow +15 -0
- package/useLexicalNodeSelection.d.ts +12 -0
- package/useLexicalNodeSelection.js.flow +14 -0
- package/withSubscriptions.d.ts +12 -0
- package/withSubscriptions.js.flow +13 -0
- package/LexicalBootstrapPlugin.dev.js +0 -122
- package/LexicalBootstrapPlugin.js +0 -9
- package/LexicalBootstrapPlugin.prod.js +0 -8
|
@@ -9,6 +9,27 @@
|
|
|
9
9
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
10
10
|
var React = require('react');
|
|
11
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
|
+
|
|
12
33
|
/**
|
|
13
34
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
35
|
*
|
|
@@ -32,7 +53,6 @@ function LexicalContentEditable({
|
|
|
32
53
|
autoComplete,
|
|
33
54
|
autoCorrect,
|
|
34
55
|
className,
|
|
35
|
-
readOnly = false,
|
|
36
56
|
role = 'textbox',
|
|
37
57
|
spellCheck = true,
|
|
38
58
|
style,
|
|
@@ -40,28 +60,35 @@ function LexicalContentEditable({
|
|
|
40
60
|
testid
|
|
41
61
|
}) {
|
|
42
62
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
63
|
+
const [isReadOnly, setReadOnly] = React.useState(true);
|
|
43
64
|
const ref = React.useCallback(rootElement => {
|
|
44
65
|
editor.setRootElement(rootElement);
|
|
45
66
|
}, [editor]);
|
|
67
|
+
useLayoutEffect(() => {
|
|
68
|
+
setReadOnly(editor.isReadOnly());
|
|
69
|
+
return editor.addListener('readonly', currentIsReadOnly => {
|
|
70
|
+
setReadOnly(currentIsReadOnly);
|
|
71
|
+
});
|
|
72
|
+
}, [editor]);
|
|
46
73
|
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
-
"aria-activedescendant":
|
|
48
|
-
"aria-autocomplete":
|
|
49
|
-
"aria-controls":
|
|
74
|
+
"aria-activedescendant": isReadOnly ? null : ariaActiveDescendantID,
|
|
75
|
+
"aria-autocomplete": isReadOnly ? null : ariaAutoComplete,
|
|
76
|
+
"aria-controls": isReadOnly ? null : ariaControls,
|
|
50
77
|
"aria-describedby": ariaDescribedBy,
|
|
51
|
-
"aria-expanded":
|
|
78
|
+
"aria-expanded": isReadOnly ? null : role === 'combobox' ? !!ariaExpanded : null,
|
|
52
79
|
"aria-label": ariaLabel,
|
|
53
80
|
"aria-labelledby": ariaLabelledBy,
|
|
54
81
|
"aria-multiline": ariaMultiline,
|
|
55
|
-
"aria-owns":
|
|
82
|
+
"aria-owns": isReadOnly ? null : ariaOwneeID,
|
|
56
83
|
"aria-required": ariaRequired,
|
|
57
84
|
autoCapitalize: autoCapitalize,
|
|
58
85
|
autoComplete: autoComplete,
|
|
59
86
|
autoCorrect: autoCorrect,
|
|
60
87
|
className: className,
|
|
61
|
-
contentEditable: !
|
|
88
|
+
contentEditable: !isReadOnly,
|
|
62
89
|
"data-testid": testid,
|
|
63
90
|
ref: ref,
|
|
64
|
-
role:
|
|
91
|
+
role: isReadOnly ? null : role,
|
|
65
92
|
spellCheck: spellCheck,
|
|
66
93
|
style: style,
|
|
67
94
|
tabIndex: tabIndex
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
export type Props = $ReadOnly<{
|
|
11
|
+
ariaActiveDescendantID?: string,
|
|
12
|
+
ariaAutoComplete?: string,
|
|
13
|
+
ariaControls?: string,
|
|
14
|
+
ariaDescribedBy?: string,
|
|
15
|
+
ariaExpanded?: boolean,
|
|
16
|
+
ariaLabel?: string,
|
|
17
|
+
ariaLabelledBy?: string,
|
|
18
|
+
ariaMultiline?: boolean,
|
|
19
|
+
ariaOwneeID?: string,
|
|
20
|
+
ariaRequired?: string,
|
|
21
|
+
autoCapitalize?: boolean,
|
|
22
|
+
autoComplete?: boolean,
|
|
23
|
+
autoCorrect?: boolean,
|
|
24
|
+
className?: string,
|
|
25
|
+
readOnly?: boolean,
|
|
26
|
+
role?: string,
|
|
27
|
+
style?: StyleSheetList,
|
|
28
|
+
spellCheck?: boolean,
|
|
29
|
+
tabIndex?: number,
|
|
30
|
+
testid?: string,
|
|
31
|
+
}>;
|
|
32
|
+
|
|
33
|
+
declare export default function LexicalContentEditable(
|
|
34
|
+
props: Props,
|
|
35
|
+
): 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 b=require("@lexical/react/LexicalComposerContext"),
|
|
8
|
-
module.exports=function({ariaActiveDescendantID:
|
|
9
|
-
|
|
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;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
declare export default function LexicalHashtagPlugin(): React$Node;
|
|
@@ -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,34 @@
|
|
|
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 {
|
|
11
|
+
EditorState,
|
|
12
|
+
GridSelection,
|
|
13
|
+
LexicalEditor,
|
|
14
|
+
NodeSelection,
|
|
15
|
+
RangeSelection,
|
|
16
|
+
} from 'lexical';
|
|
17
|
+
|
|
18
|
+
export type HistoryStateEntry = {
|
|
19
|
+
editor: LexicalEditor,
|
|
20
|
+
editorState: EditorState,
|
|
21
|
+
undoSelection?: RangeSelection | NodeSelection | GridSelection | null,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type HistoryState = {
|
|
25
|
+
current: null | HistoryStateEntry,
|
|
26
|
+
redoStack: Array<HistoryStateEntry>,
|
|
27
|
+
undoStack: Array<HistoryStateEntry>,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
declare export function HistoryPlugin({
|
|
31
|
+
externalHistoryState?: HistoryState,
|
|
32
|
+
}): React$Node;
|
|
33
|
+
|
|
34
|
+
declare 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,25 @@
|
|
|
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 {LexicalNode} from 'lexical';
|
|
11
|
+
|
|
12
|
+
import {DecoratorNode} from 'lexical';
|
|
13
|
+
|
|
14
|
+
declare export class HorizontalRuleNode extends DecoratorNode<React$Node> {
|
|
15
|
+
static getType(): string;
|
|
16
|
+
static clone(node: HorizontalRuleNode): HorizontalRuleNode;
|
|
17
|
+
createDOM(): HTMLElement;
|
|
18
|
+
getTextContent(): '\n';
|
|
19
|
+
isTopLevel(): true;
|
|
20
|
+
updateDOM(): false;
|
|
21
|
+
decorate(): React$Node;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare export function $createHorizontalRuleNode(): HorizontalRuleNode;
|
|
25
|
+
declare export function $isHorizontalRuleNode(node: ?LexicalNode): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
declare export default function LexicalLinkPlugin(): null;
|
package/LexicalListPlugin.dev.js
CHANGED
|
@@ -43,6 +43,12 @@ function useList(editor) {
|
|
|
43
43
|
} else if (type === 'removeList') {
|
|
44
44
|
list.removeList(editor);
|
|
45
45
|
return true;
|
|
46
|
+
} else if (type === 'insertParagraph') {
|
|
47
|
+
const hasHandledInsertParagraph = list.$handleListInsertParagraph();
|
|
48
|
+
|
|
49
|
+
if (hasHandledInsertParagraph) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
return false;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
declare export default function ListPlugin(): null;
|
|
@@ -4,5 +4,5 @@
|
|
|
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/react/LexicalComposerContext"),d=require("@lexical/list"),e=require("react");
|
|
8
|
-
module.exports=function(){const [a]=b.useLexicalComposerContext();f(a);return null};
|
|
7
|
+
var b=require("@lexical/react/LexicalComposerContext"),d=require("@lexical/list"),e=require("react");
|
|
8
|
+
function f(a){e.useEffect(()=>a.addListener("command",c=>{if("indentContent"===c){if(d.indentList())return!0}else if("outdentContent"===c){if(d.outdentList())return!0}else{if("insertOrderedList"===c)return d.insertList(a,"ol"),!0;if("insertUnorderedList"===c)return d.insertList(a,"ul"),!0;if("removeList"===c)return d.removeList(a),!0;if("insertParagraph"===c&&d.$handleListInsertParagraph())return!0}return!1},1),[a])}module.exports=function(){const [a]=b.useLexicalComposerContext();f(a);return 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
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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);
|
|
@@ -0,0 +1,18 @@
|
|
|
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 {DecoratorEditor, EditorThemeClasses, LexicalNode} from 'lexical';
|
|
11
|
+
|
|
12
|
+
declare export default function LexicalNestedComposer({
|
|
13
|
+
initialConfig: $ReadOnly<{
|
|
14
|
+
decoratorEditor: DecoratorEditor,
|
|
15
|
+
theme?: EditorThemeClasses,
|
|
16
|
+
}>,
|
|
17
|
+
children: React$Node,
|
|
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"),
|
|
8
|
-
module.exports=function({initialConfig:
|
|
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,14 @@
|
|
|
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 {EditorState, LexicalEditor} from 'lexical';
|
|
11
|
+
|
|
12
|
+
declare export default function OnChangePlugin({
|
|
13
|
+
onChange: (editorState: EditorState, editor: LexicalEditor) => void,
|
|
14
|
+
}): 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;
|