@lexical/react 0.3.1 → 0.3.4
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.d.ts +19 -0
- package/DEPRECATED_useLexical.js.flow +4 -1
- package/DEPRECATED_useLexicalAutoFormatter.d.ts +9 -0
- package/DEPRECATED_useLexicalAutoFormatter.js.flow +4 -1
- package/DEPRECATED_useLexicalCanShowPlaceholder.d.ts +9 -0
- package/DEPRECATED_useLexicalCanShowPlaceholder.js.flow +4 -1
- package/DEPRECATED_useLexicalCharacterLimit.d.ts +8 -0
- package/DEPRECATED_useLexicalCharacterLimit.js.flow +4 -1
- package/DEPRECATED_useLexicalDecorators.d.ts +9 -0
- package/DEPRECATED_useLexicalDecorators.js.flow +4 -1
- package/DEPRECATED_useLexicalEditor.d.ts +9 -0
- package/DEPRECATED_useLexicalEditorEvents.d.ts +10 -0
- package/DEPRECATED_useLexicalEditorEvents.js.flow +4 -1
- package/DEPRECATED_useLexicalHistory.d.ts +12 -0
- package/DEPRECATED_useLexicalHistory.js.flow +4 -1
- package/DEPRECATED_useLexicalList.d.ts +9 -0
- package/DEPRECATED_useLexicalList.js.flow +4 -1
- package/DEPRECATED_useLexicalPlainText.d.ts +10 -0
- package/DEPRECATED_useLexicalPlainText.js.flow +4 -1
- package/DEPRECATED_useLexicalRichText.d.ts +10 -0
- package/DEPRECATED_useLexicalRichText.js.flow +4 -1
- package/LexicalAutoFocusPlugin.d.ts +1 -2
- package/LexicalAutoLinkPlugin.d.ts +12 -12
- package/LexicalAutoScrollPlugin.d.ts +6 -4
- package/LexicalBlockWithAlignableContents.d.ts +11 -8
- package/LexicalBlockWithAlignableContents.dev.js +3 -2
- package/LexicalBlockWithAlignableContents.js.flow +4 -0
- package/LexicalBlockWithAlignableContents.prod.js +4 -4
- package/LexicalCharacterLimitPlugin.d.ts +3 -4
- package/LexicalCheckListPlugin.d.ts +1 -2
- package/LexicalClearEditorPlugin.d.ts +4 -4
- package/LexicalCollaborationPlugin.d.ts +17 -31
- package/LexicalComposer.d.ts +16 -14
- package/LexicalComposer.dev.js +41 -1
- package/LexicalComposer.js.flow +1 -1
- package/LexicalComposer.prod.js +3 -2
- package/LexicalComposerContext.d.ts +10 -15
- package/LexicalContentEditable.d.ts +24 -23
- package/LexicalContentEditable.js.flow +1 -1
- package/LexicalDecoratorBlockNode.d.ts +13 -24
- package/LexicalHashtagPlugin.d.ts +1 -2
- package/LexicalHistoryPlugin.d.ts +6 -23
- package/LexicalHorizontalRuleNode.d.ts +19 -17
- package/LexicalLinkPlugin.d.ts +1 -2
- package/LexicalLinkPlugin.dev.js +1 -0
- package/LexicalListPlugin.d.ts +1 -2
- package/LexicalMarkdownShortcutPlugin.d.ts +4 -6
- package/LexicalNestedComposer.d.ts +6 -8
- package/LexicalNestedComposer.dev.js +1 -0
- package/LexicalNestedComposer.prod.js +2 -2
- package/LexicalOnChangePlugin.d.ts +5 -7
- package/LexicalPlainTextPlugin.d.ts +6 -9
- package/LexicalPlainTextPlugin.dev.js +25 -1
- package/LexicalPlainTextPlugin.js.flow +6 -2
- package/LexicalPlainTextPlugin.prod.js +3 -3
- package/LexicalRichTextPlugin.d.ts +6 -9
- package/LexicalRichTextPlugin.dev.js +25 -1
- package/LexicalRichTextPlugin.js.flow +6 -2
- package/LexicalRichTextPlugin.prod.js +3 -3
- package/LexicalTablePlugin.d.ts +1 -2
- package/LexicalTreeView.d.ts +9 -11
- package/README.md +1 -2
- package/package.json +22 -19
- package/shared/useCanShowPlaceholder.d.ts +9 -0
- package/shared/useCharacterLimit.d.ts +16 -0
- package/shared/useDecorators.d.ts +9 -0
- package/shared/useEditorEvents.d.ts +10 -0
- package/shared/useHistory.d.ts +10 -0
- package/shared/useList.d.ts +9 -0
- package/shared/usePlainTextSetup.d.ts +10 -0
- package/shared/useRichTextSetup.d.ts +10 -0
- package/shared/useYjsCollaboration.d.ts +14 -0
- package/useLexicalIsTextContentEmpty.d.ts +2 -7
- package/useLexicalNodeSelection.d.ts +2 -6
- package/useLexicalTextEntity.d.ts +4 -13
|
@@ -5,27 +5,28 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
export type Props = Readonly<{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
import { CSSProperties } from 'react';
|
|
9
|
+
export declare type Props = Readonly<{
|
|
10
|
+
ariaActiveDescendantID?: string;
|
|
11
|
+
ariaAutoComplete?: string;
|
|
12
|
+
ariaControls?: string;
|
|
13
|
+
ariaDescribedBy?: string;
|
|
14
|
+
ariaExpanded?: boolean;
|
|
15
|
+
ariaLabel?: string;
|
|
16
|
+
ariaLabelledBy?: string;
|
|
17
|
+
ariaMultiline?: boolean;
|
|
18
|
+
ariaOwneeID?: string;
|
|
19
|
+
ariaRequired?: string;
|
|
20
|
+
autoCapitalize?: boolean;
|
|
21
|
+
autoComplete?: boolean;
|
|
22
|
+
autoCorrect?: boolean;
|
|
23
|
+
className?: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
role?: string;
|
|
27
|
+
spellCheck?: boolean;
|
|
28
|
+
style?: CSSProperties;
|
|
29
|
+
tabIndex?: number;
|
|
30
|
+
testid?: string;
|
|
30
31
|
}>;
|
|
31
|
-
export function ContentEditable(
|
|
32
|
+
export declare function ContentEditable({ ariaActiveDescendantID, ariaAutoComplete, ariaControls, ariaDescribedBy, ariaExpanded, ariaLabel, ariaLabelledBy, ariaMultiline, ariaOwneeID, ariaRequired, autoCapitalize, autoComplete, autoCorrect, className, id, role, spellCheck, style, tabIndex, testid, }: Props): JSX.Element;
|
|
@@ -5,28 +5,17 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
declare class DecoratorBlockNode<T> extends DecoratorNode<T> {
|
|
23
|
-
__format: ElementFormatType;
|
|
24
|
-
constructor(format?: ElementFormatType | null, key?: NodeKey);
|
|
25
|
-
createDOM(): HTMLElement;
|
|
26
|
-
setFormat(format: ElementFormatType): void;
|
|
27
|
-
exportJSON(): SerializedDecoratorBlockNode;
|
|
8
|
+
import type { ElementFormatType, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
9
|
+
import { DecoratorNode } from 'lexical';
|
|
10
|
+
export declare type SerializedDecoratorBlockNode = Spread<{
|
|
11
|
+
format: ElementFormatType | '';
|
|
12
|
+
}, SerializedLexicalNode>;
|
|
13
|
+
export declare class DecoratorBlockNode extends DecoratorNode<JSX.Element> {
|
|
14
|
+
__format: ElementFormatType | null | undefined;
|
|
15
|
+
constructor(format?: ElementFormatType, key?: NodeKey);
|
|
16
|
+
exportJSON(): SerializedDecoratorBlockNode;
|
|
17
|
+
createDOM(): HTMLElement;
|
|
18
|
+
updateDOM(): false;
|
|
19
|
+
setFormat(format: ElementFormatType): void;
|
|
28
20
|
}
|
|
29
|
-
|
|
30
|
-
declare function $isDecoratorBlockNode<T>(
|
|
31
|
-
node: LexicalNode,
|
|
32
|
-
): node is DecoratorBlockNode<T>;
|
|
21
|
+
export declare function $isDecoratorBlockNode(node: LexicalNode | null | undefined): node is DecoratorBlockNode;
|
|
@@ -5,26 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
RangeSelection,
|
|
15
|
-
} from 'lexical';
|
|
16
|
-
|
|
17
|
-
export type HistoryStateEntry = {
|
|
18
|
-
editor: LexicalEditor;
|
|
19
|
-
editorState: EditorState;
|
|
20
|
-
undoSelection?: RangeSelection | NodeSelection | GridSelection | null;
|
|
21
|
-
};
|
|
22
|
-
export type HistoryState = {
|
|
23
|
-
current: null | HistoryStateEntry;
|
|
24
|
-
redoStack: Array<HistoryStateEntry>;
|
|
25
|
-
undoStack: Array<HistoryStateEntry>;
|
|
26
|
-
};
|
|
27
|
-
export function HistoryPlugin(arg0: {
|
|
28
|
-
externalHistoryState?: HistoryState;
|
|
29
|
-
}): JSX.Element | null;
|
|
30
|
-
export function createEmptyHistoryState(): HistoryState;
|
|
8
|
+
import type { HistoryState } from '@lexical/history';
|
|
9
|
+
export { createEmptyHistoryState } from '@lexical/history';
|
|
10
|
+
export type { HistoryState };
|
|
11
|
+
export declare function HistoryPlugin({ externalHistoryState, }: {
|
|
12
|
+
externalHistoryState?: HistoryState;
|
|
13
|
+
}): null;
|
|
@@ -5,21 +5,23 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
import type { LexicalCommand, LexicalNode, SerializedLexicalNode } from 'lexical';
|
|
9
|
+
import { DecoratorNode } from 'lexical';
|
|
10
|
+
export declare type SerializedHorizontalRuleNode = SerializedLexicalNode & {
|
|
11
|
+
type: 'horizontalrule';
|
|
12
|
+
version: 1;
|
|
13
|
+
};
|
|
14
|
+
export declare const INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>;
|
|
15
|
+
export declare class HorizontalRuleNode extends DecoratorNode<JSX.Element> {
|
|
16
|
+
static getType(): string;
|
|
17
|
+
static clone(node: HorizontalRuleNode): HorizontalRuleNode;
|
|
18
|
+
static importJSON(serializedNode: SerializedHorizontalRuleNode): HorizontalRuleNode;
|
|
19
|
+
exportJSON(): SerializedLexicalNode;
|
|
20
|
+
createDOM(): HTMLElement;
|
|
21
|
+
getTextContent(): '\n';
|
|
22
|
+
isTopLevel(): true;
|
|
23
|
+
updateDOM(): false;
|
|
24
|
+
decorate(): JSX.Element;
|
|
20
25
|
}
|
|
21
|
-
export function $createHorizontalRuleNode(): HorizontalRuleNode;
|
|
22
|
-
export function $isHorizontalRuleNode(
|
|
23
|
-
node: LexicalNode | null | undefined,
|
|
24
|
-
): node is HorizontalRuleNode;
|
|
25
|
-
export var INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>;
|
|
26
|
+
export declare function $createHorizontalRuleNode(): HorizontalRuleNode;
|
|
27
|
+
export declare function $isHorizontalRuleNode(node: LexicalNode | null | undefined): node is HorizontalRuleNode;
|
package/LexicalLinkPlugin.d.ts
CHANGED
package/LexicalLinkPlugin.dev.js
CHANGED
|
@@ -16,6 +16,7 @@ var react = require('react');
|
|
|
16
16
|
*
|
|
17
17
|
* This source code is licensed under the MIT license found in the
|
|
18
18
|
* LICENSE file in the root directory of this source tree.
|
|
19
|
+
*
|
|
19
20
|
*/
|
|
20
21
|
function LinkPlugin() {
|
|
21
22
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
package/LexicalListPlugin.d.ts
CHANGED
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
transformers?: Array<Transformer>;
|
|
13
|
-
}): JSX.Element | null;
|
|
8
|
+
import type { Transformer } from '@lexical/markdown';
|
|
9
|
+
export declare function MarkdownShortcutPlugin({ transformers, }: Readonly<{
|
|
10
|
+
transformers?: Array<Transformer>;
|
|
11
|
+
}>): null;
|
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
children: JSX.Element | (JSX.Element | string | null)[] | null;
|
|
15
|
-
}): JSX.Element | null;
|
|
8
|
+
import type { EditorThemeClasses, LexicalEditor } from 'lexical';
|
|
9
|
+
export declare function LexicalNestedComposer({ initialEditor, children, initialTheme, }: {
|
|
10
|
+
children: JSX.Element | string | (JSX.Element | string)[];
|
|
11
|
+
initialEditor: LexicalEditor;
|
|
12
|
+
initialTheme?: EditorThemeClasses;
|
|
13
|
+
}): JSX.Element;
|
|
@@ -41,6 +41,7 @@ function LexicalNestedComposer({
|
|
|
41
41
|
|
|
42
42
|
initialEditor._parentEditor = parentEditor;
|
|
43
43
|
initialEditor._nodes = parentEditor._nodes;
|
|
44
|
+
initialEditor._config.namespace = parentEditor._config.namespace;
|
|
44
45
|
return [initialEditor, context];
|
|
45
46
|
}, // We only do this for init
|
|
46
47
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
'use strict';var c=require("@lexical/react/LexicalCollaborationPlugin"),d=require("@lexical/react/LexicalComposerContext"),h=require("react");
|
|
8
|
-
exports.LexicalNestedComposer=function({initialEditor:a,children:k,initialTheme:l}){let e=h.useContext(d.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #9; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let p=h.useMemo(()=>{const [
|
|
9
|
-
c.useCollaborationContext();let q=void 0!==b.get("main");b=b.has(a.getKey());return h.createElement(d.LexicalComposerContext.Provider,{value:p},!q||b?k:null)}
|
|
8
|
+
exports.LexicalNestedComposer=function({initialEditor:a,children:k,initialTheme:l}){let e=h.useContext(d.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #9; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let p=h.useMemo(()=>{const [f,m]=e,g=l||m.getTheme()||void 0,n=d.createLexicalComposerContext(e,g);void 0!==g&&(a._config.theme=g);a._parentEditor=f;a._nodes=f._nodes;a._config.namespace=f._config.namespace;
|
|
9
|
+
return[a,n]},[]);var {yjsDocMap:b}=c.useCollaborationContext();let q=void 0!==b.get("main");b=b.has(a.getKey());return h.createElement(d.LexicalComposerContext.Provider,{value:p},!q||b?k:null)}
|
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
ignoreSelectionChange?: boolean;
|
|
14
|
-
onChange: (editorState: EditorState, editor: LexicalEditor) => void;
|
|
8
|
+
import type { EditorState, LexicalEditor } from 'lexical';
|
|
9
|
+
export declare function OnChangePlugin({ ignoreInitialChange, ignoreSelectionChange, onChange, }: {
|
|
10
|
+
ignoreInitialChange?: boolean;
|
|
11
|
+
ignoreSelectionChange?: boolean;
|
|
12
|
+
onChange: (editorState: EditorState, editor: LexicalEditor) => void;
|
|
15
13
|
}): null;
|
|
@@ -5,12 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
initialEditorState?: InitialEditorStateType;
|
|
15
|
-
placeholder: JSX.Element | string | null;
|
|
16
|
-
}): JSX.Element | null;
|
|
8
|
+
import { InitialEditorStateType } from '@lexical/plain-text';
|
|
9
|
+
export declare function PlainTextPlugin({ contentEditable, placeholder, initialEditorState, }: {
|
|
10
|
+
contentEditable: JSX.Element;
|
|
11
|
+
initialEditorState?: InitialEditorStateType;
|
|
12
|
+
placeholder: JSX.Element | string;
|
|
13
|
+
}): JSX.Element;
|
|
@@ -14,6 +14,25 @@ var dragon = require('@lexical/dragon');
|
|
|
14
14
|
var plainText = require('@lexical/plain-text');
|
|
15
15
|
var utils = require('@lexical/utils');
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the MIT license found in the
|
|
21
|
+
* LICENSE file in the root directory of this source tree.
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
function warnOnlyOnce(message) {
|
|
25
|
+
|
|
26
|
+
let run = false;
|
|
27
|
+
return () => {
|
|
28
|
+
if (!run) {
|
|
29
|
+
console.warn(message);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
run = true;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
17
36
|
/**
|
|
18
37
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
19
38
|
*
|
|
@@ -119,15 +138,20 @@ function usePlainTextSetup(editor, initialEditorState) {
|
|
|
119
138
|
* LICENSE file in the root directory of this source tree.
|
|
120
139
|
*
|
|
121
140
|
*/
|
|
141
|
+
const deprecatedInitialEditorStateWarning = warnOnlyOnce('initialEditorState on PlainTextPlugin is deprecated and will be removed soon. Use LexicalComposer initialEditorState instead.');
|
|
122
142
|
function PlainTextPlugin({
|
|
123
143
|
contentEditable,
|
|
124
144
|
placeholder,
|
|
125
145
|
initialEditorState
|
|
126
146
|
}) {
|
|
147
|
+
if (initialEditorState !== undefined) {
|
|
148
|
+
deprecatedInitialEditorStateWarning();
|
|
149
|
+
}
|
|
150
|
+
|
|
127
151
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
128
152
|
const showPlaceholder = useCanShowPlaceholder(editor);
|
|
129
|
-
usePlainTextSetup(editor, initialEditorState);
|
|
130
153
|
const decorators = useDecorators(editor);
|
|
154
|
+
usePlainTextSetup(editor, initialEditorState);
|
|
131
155
|
return /*#__PURE__*/React.createElement(React.Fragment, null, contentEditable, showPlaceholder && placeholder, decorators);
|
|
132
156
|
}
|
|
133
157
|
|
|
@@ -7,9 +7,13 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type {EditorState} from 'lexical';
|
|
10
|
+
import type {EditorState, LexicalEditor} from 'lexical';
|
|
11
11
|
|
|
12
|
-
type InitialEditorStateType =
|
|
12
|
+
type InitialEditorStateType =
|
|
13
|
+
| null
|
|
14
|
+
| string
|
|
15
|
+
| EditorState
|
|
16
|
+
| ((editor: LexicalEditor) => void);
|
|
13
17
|
|
|
14
18
|
declare export function PlainTextPlugin({
|
|
15
19
|
contentEditable: React$Node,
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
'use strict';var e=require("@lexical/react/LexicalComposerContext"),h=require("react"),k=require("@lexical/text"),m=require("react-dom"),n=require("@lexical/dragon"),p=require("@lexical/plain-text"),q=require("@lexical/utils"),r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
|
|
8
|
-
function t(a){let [c,
|
|
9
|
-
function u(a){let [c,
|
|
10
|
-
exports.PlainTextPlugin=function({contentEditable:a,placeholder:c,initialEditorState:
|
|
8
|
+
function t(a){let [c,f]=h.useState(a.getEditorState().read(k.$canShowPlaceholderCurry(a.isComposing())));r(()=>{let b=a.getEditorState().read(k.$canShowPlaceholderCurry(a.isComposing()));f(b);return a.registerUpdateListener(({editorState:g})=>{let d=a.isComposing();b=g.read(k.$canShowPlaceholderCurry(d));f(b)})},[a]);return c}
|
|
9
|
+
function u(a){let [c,f]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{m.flushSync(()=>{f(b)})}),[a]);h.useEffect(()=>{f(a.getDecorators())},[a]);return h.useMemo(()=>{let b=[],g=Object.keys(c);for(let l=0;l<g.length;l++){var d=g[l];let v=c[d];d=a.getElementByKey(d);null!==d&&b.push(m.createPortal(v,d))}return b},[c,a])}function w(a,c){r(()=>q.mergeRegister(p.registerPlainText(a,c),n.registerDragonSupport(a)),[a])}
|
|
10
|
+
exports.PlainTextPlugin=function({contentEditable:a,placeholder:c,initialEditorState:f}){void 0!==f&&(void 0)();let [b]=e.useLexicalComposerContext(),g=t(b),d=u(b);w(b,f);return h.createElement(h.Fragment,null,a,g&&c,d)}
|
|
@@ -5,12 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
initialEditorState?: InitialEditorStateType;
|
|
15
|
-
placeholder: JSX.Element | string | null;
|
|
16
|
-
}): JSX.Element | null;
|
|
8
|
+
import { InitialEditorStateType } from '@lexical/rich-text';
|
|
9
|
+
export declare function RichTextPlugin({ contentEditable, placeholder, initialEditorState, }: Readonly<{
|
|
10
|
+
contentEditable: JSX.Element;
|
|
11
|
+
initialEditorState?: InitialEditorStateType;
|
|
12
|
+
placeholder: JSX.Element | string;
|
|
13
|
+
}>): JSX.Element;
|
|
@@ -14,6 +14,25 @@ var dragon = require('@lexical/dragon');
|
|
|
14
14
|
var richText = require('@lexical/rich-text');
|
|
15
15
|
var utils = require('@lexical/utils');
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the MIT license found in the
|
|
21
|
+
* LICENSE file in the root directory of this source tree.
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
function warnOnlyOnce(message) {
|
|
25
|
+
|
|
26
|
+
let run = false;
|
|
27
|
+
return () => {
|
|
28
|
+
if (!run) {
|
|
29
|
+
console.warn(message);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
run = true;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
17
36
|
/**
|
|
18
37
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
19
38
|
*
|
|
@@ -119,15 +138,20 @@ function useRichTextSetup(editor, initialEditorState) {
|
|
|
119
138
|
* LICENSE file in the root directory of this source tree.
|
|
120
139
|
*
|
|
121
140
|
*/
|
|
141
|
+
const deprecatedInitialEditorStateWarning = warnOnlyOnce('initialEditorState on RichTextPlugin is deprecated and will be removed soon. Use LexicalComposer initialEditorState instead.');
|
|
122
142
|
function RichTextPlugin({
|
|
123
143
|
contentEditable,
|
|
124
144
|
placeholder,
|
|
125
145
|
initialEditorState
|
|
126
146
|
}) {
|
|
147
|
+
if (initialEditorState !== undefined) {
|
|
148
|
+
deprecatedInitialEditorStateWarning();
|
|
149
|
+
}
|
|
150
|
+
|
|
127
151
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
128
152
|
const showPlaceholder = useCanShowPlaceholder(editor);
|
|
129
|
-
useRichTextSetup(editor, initialEditorState);
|
|
130
153
|
const decorators = useDecorators(editor);
|
|
154
|
+
useRichTextSetup(editor, initialEditorState);
|
|
131
155
|
return /*#__PURE__*/React.createElement(React.Fragment, null, contentEditable, showPlaceholder && placeholder, decorators);
|
|
132
156
|
}
|
|
133
157
|
|
|
@@ -7,9 +7,13 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type {EditorState} from 'lexical';
|
|
10
|
+
import type {EditorState, LexicalEditor} from 'lexical';
|
|
11
11
|
|
|
12
|
-
type InitialEditorStateType =
|
|
12
|
+
type InitialEditorStateType =
|
|
13
|
+
| null
|
|
14
|
+
| string
|
|
15
|
+
| EditorState
|
|
16
|
+
| ((editor: LexicalEditor) => void);
|
|
13
17
|
|
|
14
18
|
declare export function RichTextPlugin({
|
|
15
19
|
contentEditable: React$Node,
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
'use strict';var e=require("@lexical/react/LexicalComposerContext"),h=require("react"),k=require("@lexical/text"),m=require("react-dom"),n=require("@lexical/dragon"),p=require("@lexical/rich-text"),q=require("@lexical/utils"),r="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;
|
|
8
|
-
function t(a){let [c,
|
|
9
|
-
function u(a){let [c,
|
|
10
|
-
exports.RichTextPlugin=function({contentEditable:a,placeholder:c,initialEditorState:
|
|
8
|
+
function t(a){let [c,f]=h.useState(a.getEditorState().read(k.$canShowPlaceholderCurry(a.isComposing())));r(()=>{let b=a.getEditorState().read(k.$canShowPlaceholderCurry(a.isComposing()));f(b);return a.registerUpdateListener(({editorState:g})=>{let d=a.isComposing();b=g.read(k.$canShowPlaceholderCurry(d));f(b)})},[a]);return c}
|
|
9
|
+
function u(a){let [c,f]=h.useState(()=>a.getDecorators());r(()=>a.registerDecoratorListener(b=>{m.flushSync(()=>{f(b)})}),[a]);h.useEffect(()=>{f(a.getDecorators())},[a]);return h.useMemo(()=>{let b=[],g=Object.keys(c);for(let l=0;l<g.length;l++){var d=g[l];let v=c[d];d=a.getElementByKey(d);null!==d&&b.push(m.createPortal(v,d))}return b},[c,a])}function w(a,c){r(()=>q.mergeRegister(p.registerRichText(a,c),n.registerDragonSupport(a)),[a])}
|
|
10
|
+
exports.RichTextPlugin=function({contentEditable:a,placeholder:c,initialEditorState:f}){void 0!==f&&(void 0)();let [b]=e.useLexicalComposerContext(),g=t(b),d=u(b);w(b,f);return h.createElement(h.Fragment,null,a,g&&c,d)}
|
package/LexicalTablePlugin.d.ts
CHANGED
package/LexicalTreeView.d.ts
CHANGED
|
@@ -5,14 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
editor: LexicalEditor;
|
|
18
|
-
}): JSX.Element | null;
|
|
8
|
+
import type { LexicalEditor } from 'lexical';
|
|
9
|
+
export declare function TreeView({ timeTravelButtonClassName, timeTravelPanelSliderClassName, timeTravelPanelButtonClassName, viewClassName, timeTravelPanelClassName, editor, }: {
|
|
10
|
+
editor: LexicalEditor;
|
|
11
|
+
timeTravelButtonClassName: string;
|
|
12
|
+
timeTravelPanelButtonClassName: string;
|
|
13
|
+
timeTravelPanelClassName: string;
|
|
14
|
+
timeTravelPanelSliderClassName: string;
|
|
15
|
+
viewClassName: string;
|
|
16
|
+
}): JSX.Element;
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -8,28 +8,28 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.3.
|
|
11
|
+
"version": "0.3.4",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.3.
|
|
14
|
-
"@lexical/
|
|
15
|
-
"@lexical/
|
|
16
|
-
"@lexical/
|
|
17
|
-
"@lexical/
|
|
18
|
-
"@lexical/
|
|
19
|
-
"@lexical/
|
|
20
|
-
"@lexical/
|
|
21
|
-
"@lexical/
|
|
22
|
-
"@lexical/
|
|
23
|
-
"@lexical/
|
|
24
|
-
"@lexical/text": "0.3.
|
|
25
|
-
"@lexical/
|
|
26
|
-
"@lexical/
|
|
27
|
-
"@lexical/
|
|
28
|
-
"@lexical/
|
|
29
|
-
"@lexical/
|
|
13
|
+
"@lexical/clipboard": "0.3.4",
|
|
14
|
+
"@lexical/code": "0.3.4",
|
|
15
|
+
"@lexical/dragon": "0.3.4",
|
|
16
|
+
"@lexical/hashtag": "0.3.4",
|
|
17
|
+
"@lexical/history": "0.3.4",
|
|
18
|
+
"@lexical/link": "0.3.4",
|
|
19
|
+
"@lexical/list": "0.3.4",
|
|
20
|
+
"@lexical/mark": "0.3.4",
|
|
21
|
+
"@lexical/markdown": "0.3.4",
|
|
22
|
+
"@lexical/overflow": "0.3.4",
|
|
23
|
+
"@lexical/plain-text": "0.3.4",
|
|
24
|
+
"@lexical/rich-text": "0.3.4",
|
|
25
|
+
"@lexical/selection": "0.3.4",
|
|
26
|
+
"@lexical/table": "0.3.4",
|
|
27
|
+
"@lexical/text": "0.3.4",
|
|
28
|
+
"@lexical/utils": "0.3.4",
|
|
29
|
+
"@lexical/yjs": "0.3.4"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"lexical": "0.3.
|
|
32
|
+
"lexical": "0.3.4",
|
|
33
33
|
"react": ">=17.x",
|
|
34
34
|
"react-dom": ">=17.x"
|
|
35
35
|
},
|
|
@@ -37,5 +37,8 @@
|
|
|
37
37
|
"type": "git",
|
|
38
38
|
"url": "https://github.com/facebook/lexical",
|
|
39
39
|
"directory": "packages/lexical-react"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"utility-types": "^3.10.0"
|
|
40
43
|
}
|
|
41
44
|
}
|
|
@@ -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
|
+
import type { LexicalEditor } from 'lexical';
|
|
9
|
+
export declare function useCanShowPlaceholder(editor: LexicalEditor): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
import type { LexicalEditor } from 'lexical';
|
|
9
|
+
import { OverflowNode } from '@lexical/overflow';
|
|
10
|
+
declare type OptionalProps = {
|
|
11
|
+
remainingCharacters?: (characters: number) => void;
|
|
12
|
+
strlen?: (input: string) => number;
|
|
13
|
+
};
|
|
14
|
+
export declare function useCharacterLimit(editor: LexicalEditor, maxCharacters: number, optional?: OptionalProps): void;
|
|
15
|
+
export declare function mergePrevious(overflowNode: OverflowNode): void;
|
|
16
|
+
export {};
|
|
@@ -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
|
+
import type { LexicalEditor } from 'lexical';
|
|
9
|
+
export declare function useDecorators(editor: LexicalEditor): Array<JSX.Element>;
|
|
@@ -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
|
+
*/
|
|
8
|
+
import type { EventHandler, LexicalEditor } from 'lexical';
|
|
9
|
+
export declare type InputEvents = Array<[string, EventHandler]>;
|
|
10
|
+
export declare function useEditorEvents(events: InputEvents, editor: LexicalEditor): void;
|