@lexical/react 0.3.3 → 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 -15
- package/LexicalComposer.dev.js +39 -1
- package/LexicalComposer.prod.js +3 -2
- package/LexicalComposerContext.d.ts +10 -15
- package/LexicalContentEditable.d.ts +24 -23
- 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/LexicalOnChangePlugin.d.ts +5 -7
- package/LexicalPlainTextPlugin.d.ts +6 -9
- package/LexicalPlainTextPlugin.dev.js +25 -1
- package/LexicalPlainTextPlugin.prod.js +3 -3
- package/LexicalRichTextPlugin.d.ts +6 -9
- package/LexicalRichTextPlugin.dev.js +25 -1
- package/LexicalRichTextPlugin.prod.js +3 -3
- package/LexicalTablePlugin.d.ts +1 -2
- package/LexicalTreeView.d.ts +9 -11
- package/package.json +19 -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
|
@@ -0,0 +1,19 @@
|
|
|
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 { EditorState, EditorThemeClasses, LexicalEditor, LexicalNode } from 'lexical';
|
|
9
|
+
import type { Klass } from 'shared/types';
|
|
10
|
+
export declare function useLexical(editorConfig: {
|
|
11
|
+
disableEvents?: boolean;
|
|
12
|
+
editorState?: EditorState;
|
|
13
|
+
namespace: string;
|
|
14
|
+
nodes?: ReadonlyArray<Klass<LexicalNode>>;
|
|
15
|
+
onError: (error: Error) => void;
|
|
16
|
+
parentEditor?: LexicalEditor;
|
|
17
|
+
readOnly?: boolean;
|
|
18
|
+
theme?: EditorThemeClasses;
|
|
19
|
+
}): [LexicalEditor, (arg0: null | HTMLElement) => void, boolean];
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (c) Meta Platforms, Inc. and affiliates.
|
|
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.
|
|
3
6
|
*
|
|
4
7
|
* @flow strict
|
|
5
8
|
* @format
|
|
@@ -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 useLexicalAutoFormatter(editor: LexicalEditor): void;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (c) Meta Platforms, Inc. and affiliates.
|
|
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.
|
|
3
6
|
*
|
|
4
7
|
* @flow strict
|
|
5
8
|
* @format
|
|
@@ -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 useLexicalCanShowPlaceholder(editor: LexicalEditor): boolean;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (c) Meta Platforms, Inc. and affiliates.
|
|
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.
|
|
3
6
|
*
|
|
4
7
|
* @flow strict
|
|
5
8
|
* @format
|
|
@@ -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
|
+
*/
|
|
8
|
+
export { mergePrevious, useCharacterLimit } from './shared/useCharacterLimit';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (c) Meta Platforms, Inc. and affiliates.
|
|
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.
|
|
3
6
|
*
|
|
4
7
|
* @flow strict
|
|
5
8
|
* @format
|
|
@@ -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 useLexicalDecorators(editor: LexicalEditor): Array<JSX.Element>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (c) Meta Platforms, Inc. and affiliates.
|
|
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.
|
|
3
6
|
*
|
|
4
7
|
* @flow strict
|
|
5
8
|
* @format
|
|
@@ -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 useLexicalEditor(editor: LexicalEditor): [(rootElement: null | HTMLElement) => void, 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
|
+
*/
|
|
8
|
+
import type { InputEvents } from './shared/useEditorEvents';
|
|
9
|
+
import type { LexicalEditor } from 'lexical';
|
|
10
|
+
export declare function useLexicalEditorEvents(events: InputEvents, editor: LexicalEditor): void;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (c) Meta Platforms, Inc. and affiliates.
|
|
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.
|
|
3
6
|
*
|
|
4
7
|
* @flow strict
|
|
5
8
|
* @format
|
|
@@ -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
|
+
import type { HistoryState } from '@lexical/history';
|
|
9
|
+
import type { LexicalEditor } from 'lexical';
|
|
10
|
+
export { createEmptyHistoryState } from '@lexical/history';
|
|
11
|
+
export type { HistoryState };
|
|
12
|
+
export declare function useLexicalHistory(editor: LexicalEditor, externalHistoryState?: HistoryState, delay?: number): void;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (c) Meta Platforms, Inc. and affiliates.
|
|
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.
|
|
3
6
|
*
|
|
4
7
|
* @flow strict
|
|
5
8
|
* @format
|
|
@@ -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 useLexicalList(editor: LexicalEditor): void;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (c) Meta Platforms, Inc. and affiliates.
|
|
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.
|
|
3
6
|
*
|
|
4
7
|
* @flow strict
|
|
5
8
|
* @format
|
|
@@ -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 { HistoryState } from './DEPRECATED_useLexicalHistory';
|
|
9
|
+
import type { EditorState, LexicalEditor } from 'lexical';
|
|
10
|
+
export declare function useLexicalPlainText(editor: LexicalEditor, externalHistoryState?: HistoryState, initialEditorState?: null | string | EditorState | (() => void)): void;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (c) Meta Platforms, Inc. and affiliates.
|
|
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.
|
|
3
6
|
*
|
|
4
7
|
* @flow strict
|
|
5
8
|
* @format
|
|
@@ -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 { HistoryState } from './DEPRECATED_useLexicalHistory';
|
|
9
|
+
import type { EditorState, LexicalEditor } from 'lexical';
|
|
10
|
+
export declare function useLexicalRichText(editor: LexicalEditor, externalHistoryState?: HistoryState, initialEditorState?: null | string | EditorState | (() => void)): void;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (c) Meta Platforms, Inc. and affiliates.
|
|
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.
|
|
3
6
|
*
|
|
4
7
|
* @flow strict
|
|
5
8
|
* @format
|
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
index: number;
|
|
8
|
+
declare type ChangeHandler = (url: string | null, prevUrl: string | null) => void;
|
|
9
|
+
declare type LinkMatcherResult = {
|
|
10
|
+
index: number;
|
|
11
|
+
length: number;
|
|
12
|
+
text: string;
|
|
13
|
+
url: string;
|
|
15
14
|
};
|
|
16
|
-
export type LinkMatcher = (text: string) => LinkMatcherResult | null;
|
|
17
|
-
export function AutoLinkPlugin(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}): JSX.Element
|
|
15
|
+
export declare type LinkMatcher = (text: string) => LinkMatcherResult | null;
|
|
16
|
+
export declare function AutoLinkPlugin({ matchers, onChange, }: {
|
|
17
|
+
matchers: Array<LinkMatcher>;
|
|
18
|
+
onChange?: ChangeHandler;
|
|
19
|
+
}): JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
declare type Props = Readonly<{
|
|
9
|
+
scrollRef: {
|
|
10
|
+
current: HTMLElement | null;
|
|
11
|
+
};
|
|
11
12
|
}>;
|
|
12
|
-
export function AutoScrollPlugin(
|
|
13
|
+
export declare function AutoScrollPlugin({ scrollRef }: Props): JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
import type { ElementFormatType, NodeKey } from 'lexical';
|
|
9
|
+
declare type Props = Readonly<{
|
|
10
|
+
children: JSX.Element | string | (JSX.Element | string)[];
|
|
11
|
+
format: ElementFormatType | null | undefined;
|
|
12
|
+
nodeKey: NodeKey;
|
|
13
|
+
className: Readonly<{
|
|
14
|
+
base: string;
|
|
15
|
+
focus: string;
|
|
16
|
+
}>;
|
|
15
17
|
}>;
|
|
16
|
-
declare function BlockWithAlignableContents(
|
|
18
|
+
export declare function BlockWithAlignableContents({ children, format, nodeKey, className, }: Props): JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -23,7 +23,8 @@ var React = require('react');
|
|
|
23
23
|
function BlockWithAlignableContents({
|
|
24
24
|
children,
|
|
25
25
|
format,
|
|
26
|
-
nodeKey
|
|
26
|
+
nodeKey,
|
|
27
|
+
className
|
|
27
28
|
}) {
|
|
28
29
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
29
30
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
@@ -89,7 +90,7 @@ function BlockWithAlignableContents({
|
|
|
89
90
|
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_DELETE_COMMAND, onDelete, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, onDelete, lexical.COMMAND_PRIORITY_LOW));
|
|
90
91
|
}, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected]);
|
|
91
92
|
return /*#__PURE__*/React.createElement("div", {
|
|
92
|
-
className:
|
|
93
|
+
className: [className.base, isSelected ? className.focus : null].filter(Boolean).join(' '),
|
|
93
94
|
ref: ref,
|
|
94
95
|
style: {
|
|
95
96
|
textAlign: format ? format : null
|
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
'use strict';var a=require("@lexical/react/LexicalComposerContext"),h=require("@lexical/react/LexicalDecoratorBlockNode"),m=require("@lexical/react/useLexicalNodeSelection"),n=require("@lexical/utils"),
|
|
8
|
-
exports.BlockWithAlignableContents=function({children:
|
|
9
|
-
|
|
10
|
-
l,
|
|
7
|
+
'use strict';var a=require("@lexical/react/LexicalComposerContext"),h=require("@lexical/react/LexicalDecoratorBlockNode"),m=require("@lexical/react/useLexicalNodeSelection"),n=require("@lexical/utils"),u=require("lexical"),v=require("react");
|
|
8
|
+
exports.BlockWithAlignableContents=function({children:w,format:p,nodeKey:g,className:q}){let [d]=a.useLexicalComposerContext(),[e,k,r]=m.useLexicalNodeSelection(g),t=v.useRef(),l=v.useCallback(b=>{e&&u.$isNodeSelection(u.$getSelection())&&(b.preventDefault(),d.update(()=>{const c=u.$getNodeByKey(g);u.$isDecoratorNode(c)&&c.isTopLevel()&&c.remove();k(!1)}));return!1},[d,e,g,k]);v.useEffect(()=>n.mergeRegister(d.registerCommand(u.FORMAT_ELEMENT_COMMAND,b=>{if(e){var c=u.$getSelection();if(u.$isNodeSelection(c)){var f=
|
|
9
|
+
u.$getNodeByKey(g);h.$isDecoratorBlockNode(f)&&f.setFormat(b)}else if(u.$isRangeSelection(c)){c=c.getNodes();for(f of c)h.$isDecoratorBlockNode(f)?f.setFormat(b):n.$getNearestBlockElementAncestorOrThrow(f).setFormat(b)}return!0}return!1},u.COMMAND_PRIORITY_LOW),d.registerCommand(u.CLICK_COMMAND,b=>{b.preventDefault();return b.target===t.current?(b.shiftKey||r(),k(!e),!0):!1},u.COMMAND_PRIORITY_LOW),d.registerCommand(u.KEY_DELETE_COMMAND,l,u.COMMAND_PRIORITY_LOW),d.registerCommand(u.KEY_BACKSPACE_COMMAND,
|
|
10
|
+
l,u.COMMAND_PRIORITY_LOW)),[r,d,e,g,l,k]);return v.createElement("div",{className:[q.base,e?q.focus:null].filter(Boolean).join(" "),ref:t,style:{textAlign:p?p:null}},w)}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}): JSX.Element | null;
|
|
8
|
+
export declare function CharacterLimitPlugin({ charset, }: {
|
|
9
|
+
charset: 'UTF-8' | 'UTF-16';
|
|
10
|
+
}): JSX.Element;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
onClear?: () => void;
|
|
8
|
+
declare type Props = Readonly<{
|
|
9
|
+
onClear?: () => void;
|
|
11
10
|
}>;
|
|
12
|
-
export function ClearEditorPlugin(
|
|
11
|
+
export declare function ClearEditorPlugin({ onClear }: Props): JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -5,35 +5,21 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
import type {
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
color: string;
|
|
17
|
-
focusing: boolean;
|
|
8
|
+
/// <reference types="react" />
|
|
9
|
+
import type { Doc } from 'yjs';
|
|
10
|
+
import { WebsocketProvider } from 'y-websocket';
|
|
11
|
+
declare type CollaborationContextType = {
|
|
12
|
+
clientID: number;
|
|
13
|
+
color: string;
|
|
14
|
+
name: string;
|
|
15
|
+
yjsDocMap: Map<string, Doc>;
|
|
18
16
|
};
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
color: string;
|
|
29
|
-
name: string;
|
|
30
|
-
yjsDocMap: Map<string, Doc>;
|
|
31
|
-
};
|
|
32
|
-
export function CollaborationPlugin(arg0: {
|
|
33
|
-
id: string;
|
|
34
|
-
providerFactory(id: string, yjsDocMap: Map<string, Doc>): Provider;
|
|
35
|
-
shouldBootstrap: boolean;
|
|
36
|
-
username?: string;
|
|
37
|
-
}): JSX.Element | null;
|
|
38
|
-
export declare var CollaborationContext: React.Context<CollaborationContextType>;
|
|
39
|
-
export function useCollaborationContext(): CollaborationContextType;
|
|
17
|
+
export declare function CollaborationPlugin({ id, providerFactory, shouldBootstrap, username, }: {
|
|
18
|
+
id: string;
|
|
19
|
+
providerFactory: (id: string, yjsDocMap: Map<string, Doc>) => WebsocketProvider;
|
|
20
|
+
shouldBootstrap: boolean;
|
|
21
|
+
username?: string;
|
|
22
|
+
}): JSX.Element;
|
|
23
|
+
export declare const CollaborationContext: React.Context<CollaborationContextType>;
|
|
24
|
+
export declare function useCollaborationContext(username?: string): CollaborationContextType;
|
|
25
|
+
export {};
|
package/LexicalComposer.d.ts
CHANGED
|
@@ -5,19 +5,20 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
import {Class} from 'utility-types';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
import { EditorState, EditorThemeClasses, LexicalEditor, LexicalNode } from 'lexical';
|
|
9
|
+
import { Class } from 'utility-types';
|
|
10
|
+
export declare type InitialEditorStateType = null | string | EditorState | ((editor: LexicalEditor) => void);
|
|
11
|
+
declare type Props = {
|
|
12
|
+
children: JSX.Element | string | (JSX.Element | string)[];
|
|
13
|
+
initialConfig: Readonly<{
|
|
14
|
+
editor__DEPRECATED?: LexicalEditor | null;
|
|
15
|
+
namespace: string;
|
|
16
|
+
nodes?: ReadonlyArray<Class<LexicalNode>>;
|
|
17
|
+
onError: (error: Error, editor: LexicalEditor) => void;
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
theme?: EditorThemeClasses;
|
|
20
|
+
editorState?: InitialEditorStateType;
|
|
21
|
+
}>;
|
|
22
22
|
};
|
|
23
|
-
export function LexicalComposer(
|
|
23
|
+
export declare function LexicalComposer({ initialConfig, children }: Props): JSX.Element;
|
|
24
|
+
export {};
|
package/LexicalComposer.dev.js
CHANGED
|
@@ -36,6 +36,9 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
36
36
|
* LICENSE file in the root directory of this source tree.
|
|
37
37
|
*
|
|
38
38
|
*/
|
|
39
|
+
const HISTORY_MERGE_OPTIONS = {
|
|
40
|
+
tag: 'history-merge'
|
|
41
|
+
};
|
|
39
42
|
function LexicalComposer({
|
|
40
43
|
initialConfig,
|
|
41
44
|
children
|
|
@@ -46,7 +49,8 @@ function LexicalComposer({
|
|
|
46
49
|
namespace,
|
|
47
50
|
editor__DEPRECATED: initialEditor,
|
|
48
51
|
nodes,
|
|
49
|
-
onError
|
|
52
|
+
onError,
|
|
53
|
+
editorState: initialEditorState
|
|
50
54
|
} = initialConfig;
|
|
51
55
|
const context = LexicalComposerContext.createLexicalComposerContext(null, theme);
|
|
52
56
|
let editor = initialEditor || null;
|
|
@@ -59,6 +63,7 @@ function LexicalComposer({
|
|
|
59
63
|
readOnly: true,
|
|
60
64
|
theme
|
|
61
65
|
});
|
|
66
|
+
initializeEditor(newEditor, initialEditorState);
|
|
62
67
|
editor = newEditor;
|
|
63
68
|
}
|
|
64
69
|
|
|
@@ -77,4 +82,37 @@ function LexicalComposer({
|
|
|
77
82
|
}, children);
|
|
78
83
|
}
|
|
79
84
|
|
|
85
|
+
function initializeEditor(editor, initialEditorState) {
|
|
86
|
+
if (initialEditorState === null) {
|
|
87
|
+
return;
|
|
88
|
+
} else if (initialEditorState === undefined) ; else if (initialEditorState !== null) {
|
|
89
|
+
switch (typeof initialEditorState) {
|
|
90
|
+
case 'string':
|
|
91
|
+
{
|
|
92
|
+
const parsedEditorState = editor.parseEditorState(initialEditorState);
|
|
93
|
+
editor.setEditorState(parsedEditorState, HISTORY_MERGE_OPTIONS);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
case 'object':
|
|
98
|
+
{
|
|
99
|
+
editor.setEditorState(initialEditorState, HISTORY_MERGE_OPTIONS);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
case 'function':
|
|
104
|
+
{
|
|
105
|
+
editor.update(() => {
|
|
106
|
+
const root = lexical.$getRoot();
|
|
107
|
+
|
|
108
|
+
if (root.isEmpty()) {
|
|
109
|
+
initialEditorState(editor);
|
|
110
|
+
}
|
|
111
|
+
}, HISTORY_MERGE_OPTIONS);
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
80
118
|
exports.LexicalComposer = LexicalComposer;
|
package/LexicalComposer.prod.js
CHANGED
|
@@ -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
|
-
'use strict';var
|
|
8
|
-
|
|
7
|
+
'use strict';var c=require("@lexical/react/LexicalComposerContext"),f=require("lexical"),l=require("react"),m="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?l.useLayoutEffect:l.useEffect;let n={tag:"history-merge"};
|
|
8
|
+
function p(b,a){if(null!==a&&void 0!==a&&null!==a)switch(typeof a){case "string":let d=b.parseEditorState(a);b.setEditorState(d,n);break;case "object":b.setEditorState(a,n);break;case "function":b.update(()=>{f.$getRoot().isEmpty()&&a(b)},n)}}
|
|
9
|
+
exports.LexicalComposer=function({initialConfig:b,children:a}){let d=l.useMemo(()=>{const {theme:e,namespace:g,editor__DEPRECATED:q,nodes:r,onError:t,editorState:u}=b,v=c.createLexicalComposerContext(null,e);let h=q||null;if(null===h){const k=f.createEditor({namespace:g,nodes:r,onError:w=>t(w,k),readOnly:!0,theme:e});p(k,u);h=k}return[h,v]},[]);m(()=>{let e=b.readOnly,[g]=d;g.setReadOnly(e||!1)},[]);return l.createElement(c.LexicalComposerContext.Provider,{value:d},a)}
|
|
@@ -5,20 +5,15 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
import type {EditorThemeClasses, LexicalEditor} from 'lexical';
|
|
10
|
-
export type LexicalComposerContextType = {
|
|
11
|
-
|
|
8
|
+
/// <reference types="react" />
|
|
9
|
+
import type { EditorThemeClasses, LexicalEditor } from 'lexical';
|
|
10
|
+
export declare type LexicalComposerContextType = {
|
|
11
|
+
getTheme: () => EditorThemeClasses | null | undefined;
|
|
12
12
|
};
|
|
13
|
-
export type LexicalComposerContextWithEditor = [
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export declare type LexicalComposerContextWithEditor = [
|
|
14
|
+
LexicalEditor,
|
|
15
|
+
LexicalComposerContextType
|
|
16
16
|
];
|
|
17
|
-
export declare
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export function createLexicalComposerContext(
|
|
21
|
-
parent: LexicalComposerContextWithEditor | null | undefined,
|
|
22
|
-
theme: EditorThemeClasses | null | undefined,
|
|
23
|
-
): LexicalComposerContextType;
|
|
24
|
-
export function useLexicalComposerContext(): LexicalComposerContextWithEditor;
|
|
17
|
+
export declare const LexicalComposerContext: React.Context<LexicalComposerContextWithEditor | null | undefined>;
|
|
18
|
+
export declare function createLexicalComposerContext(parent: LexicalComposerContextWithEditor | null | undefined, theme: EditorThemeClasses | null | undefined): LexicalComposerContextType;
|
|
19
|
+
export declare function useLexicalComposerContext(): LexicalComposerContextWithEditor;
|