@lexical/react 0.3.3 → 0.3.6
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 +18 -0
- package/DEPRECATED_useLexical.dev.js +18 -9
- package/DEPRECATED_useLexical.js.flow +4 -1
- package/DEPRECATED_useLexical.prod.js +2 -3
- package/DEPRECATED_useLexicalAutoFormatter.d.ts +9 -0
- package/DEPRECATED_useLexicalAutoFormatter.js.flow +4 -1
- package/DEPRECATED_useLexicalCanShowPlaceholder.d.ts +9 -0
- package/DEPRECATED_useLexicalCanShowPlaceholder.dev.js +18 -9
- package/DEPRECATED_useLexicalCanShowPlaceholder.js.flow +4 -1
- package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +2 -2
- 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_useLexicalEditor.dev.js +18 -9
- package/DEPRECATED_useLexicalEditor.prod.js +2 -2
- 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/LexicalAutoFocusPlugin.dev.js +1 -1
- package/LexicalAutoFocusPlugin.prod.js +1 -1
- package/LexicalAutoLinkPlugin.d.ts +11 -11
- package/LexicalAutoScrollPlugin.d.ts +6 -4
- package/LexicalBlockWithAlignableContents.d.ts +12 -8
- package/LexicalBlockWithAlignableContents.dev.js +6 -6
- 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/LexicalCheckListPlugin.dev.js +11 -6
- package/LexicalCheckListPlugin.prod.js +7 -7
- 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.js.flow +5 -0
- package/LexicalComposer.prod.js +3 -2
- package/LexicalComposerContext.d.ts +10 -15
- package/LexicalContentEditable.d.ts +24 -23
- package/LexicalContentEditable.dev.js +3 -3
- package/LexicalContentEditable.prod.js +1 -1
- package/LexicalDecoratorBlockNode.d.ts +13 -24
- package/LexicalDecoratorBlockNode.dev.js +1 -1
- package/LexicalDecoratorBlockNode.prod.js +1 -1
- 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 +7 -8
- package/LexicalOnChangePlugin.d.ts +5 -7
- package/LexicalPlainTextPlugin.d.ts +6 -9
- package/LexicalPlainTextPlugin.dev.js +43 -11
- package/LexicalPlainTextPlugin.prod.js +4 -4
- package/LexicalRichTextPlugin.d.ts +6 -9
- package/LexicalRichTextPlugin.dev.js +43 -11
- package/LexicalRichTextPlugin.prod.js +4 -4
- package/LexicalTablePlugin.d.ts +1 -2
- package/LexicalTablePlugin.dev.js +1 -1
- package/LexicalTablePlugin.prod.js +3 -3
- package/LexicalTreeView.d.ts +9 -11
- package/package.json +19 -22
- 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 +3 -13
|
@@ -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
|
+
*/
|
|
8
|
+
import type { EditorState, EditorThemeClasses, Klass, LexicalEditor, LexicalNode } from 'lexical';
|
|
9
|
+
export declare function useLexical(editorConfig: {
|
|
10
|
+
disableEvents?: boolean;
|
|
11
|
+
editorState?: EditorState;
|
|
12
|
+
namespace: string;
|
|
13
|
+
nodes?: ReadonlyArray<Klass<LexicalNode>>;
|
|
14
|
+
onError: (error: Error) => void;
|
|
15
|
+
parentEditor?: LexicalEditor;
|
|
16
|
+
readOnly?: boolean;
|
|
17
|
+
theme?: EditorThemeClasses;
|
|
18
|
+
}): [LexicalEditor, (arg0: null | HTMLElement) => void, boolean];
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
var lexical = require('lexical');
|
|
10
10
|
var react = require('react');
|
|
11
11
|
var text = require('@lexical/text');
|
|
12
|
+
var utils = require('@lexical/utils');
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -36,18 +37,26 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
36
37
|
* LICENSE file in the root directory of this source tree.
|
|
37
38
|
*
|
|
38
39
|
*/
|
|
40
|
+
|
|
41
|
+
function canShowPlaceholderFromCurrentEditorState(editor) {
|
|
42
|
+
const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
|
|
43
|
+
return currentCanShowPlaceholder;
|
|
44
|
+
}
|
|
45
|
+
|
|
39
46
|
function useCanShowPlaceholder(editor) {
|
|
40
|
-
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(
|
|
47
|
+
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
|
|
41
48
|
useLayoutEffect(() => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return editor.registerUpdateListener(({
|
|
45
|
-
editorState
|
|
46
|
-
}) => {
|
|
47
|
-
const isComposing = editor.isComposing();
|
|
48
|
-
currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
|
|
49
|
+
function resetCanShowPlaceholder() {
|
|
50
|
+
const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
|
|
49
51
|
setCanShowPlaceholder(currentCanShowPlaceholder);
|
|
50
|
-
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
resetCanShowPlaceholder();
|
|
55
|
+
return utils.mergeRegister(editor.registerUpdateListener(() => {
|
|
56
|
+
resetCanShowPlaceholder();
|
|
57
|
+
}), editor.registerReadOnlyListener(() => {
|
|
58
|
+
resetCanShowPlaceholder();
|
|
59
|
+
}));
|
|
51
60
|
}, [editor]);
|
|
52
61
|
return canShowPlaceholder;
|
|
53
62
|
}
|
|
@@ -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
|
|
@@ -4,6 +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
|
-
'use strict';var
|
|
8
|
-
function
|
|
9
|
-
exports.useLexical=function(a){let b=f.useMemo(()=>d.createEditor(a),[]),[c,e]=n(b);return[b,c,e]}
|
|
7
|
+
'use strict';var c=require("lexical"),f=require("react"),g=require("@lexical/text"),h=require("@lexical/utils"),k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;function l(a){return a.getEditorState().read(g.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
|
|
8
|
+
function m(a){let [b,d]=f.useState(()=>l(a));k(()=>{function e(){let n=l(a);d(n)}e();return h.mergeRegister(a.registerUpdateListener(()=>{e()}),a.registerReadOnlyListener(()=>{e()}))},[a]);return b}function p(a){let b=m(a);return[f.useCallback(d=>{a.setRootElement(d)},[a]),b]}exports.useLexical=function(a){let b=f.useMemo(()=>c.createEditor(a),[]),[d,e]=p(b);return[b,d,e]}
|
|
@@ -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;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
var text = require('@lexical/text');
|
|
10
|
+
var utils = require('@lexical/utils');
|
|
10
11
|
var react = require('react');
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -35,18 +36,26 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
35
36
|
* LICENSE file in the root directory of this source tree.
|
|
36
37
|
*
|
|
37
38
|
*/
|
|
39
|
+
|
|
40
|
+
function canShowPlaceholderFromCurrentEditorState(editor) {
|
|
41
|
+
const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
|
|
42
|
+
return currentCanShowPlaceholder;
|
|
43
|
+
}
|
|
44
|
+
|
|
38
45
|
function useCanShowPlaceholder(editor) {
|
|
39
|
-
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(
|
|
46
|
+
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
|
|
40
47
|
useLayoutEffect(() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return editor.registerUpdateListener(({
|
|
44
|
-
editorState
|
|
45
|
-
}) => {
|
|
46
|
-
const isComposing = editor.isComposing();
|
|
47
|
-
currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
|
|
48
|
+
function resetCanShowPlaceholder() {
|
|
49
|
+
const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
|
|
48
50
|
setCanShowPlaceholder(currentCanShowPlaceholder);
|
|
49
|
-
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
resetCanShowPlaceholder();
|
|
54
|
+
return utils.mergeRegister(editor.registerUpdateListener(() => {
|
|
55
|
+
resetCanShowPlaceholder();
|
|
56
|
+
}), editor.registerReadOnlyListener(() => {
|
|
57
|
+
resetCanShowPlaceholder();
|
|
58
|
+
}));
|
|
50
59
|
}, [editor]);
|
|
51
60
|
return canShowPlaceholder;
|
|
52
61
|
}
|
|
@@ -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
|
|
@@ -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
|
-
'use strict';var b=require("@lexical/text"),
|
|
8
|
-
function
|
|
7
|
+
'use strict';var b=require("@lexical/text"),d=require("@lexical/utils"),e=require("react"),f="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?e.useLayoutEffect:e.useEffect;function g(a){return a.getEditorState().read(b.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
|
|
8
|
+
function h(a){let [k,l]=e.useState(()=>g(a));f(()=>{function c(){let m=g(a);l(m)}c();return d.mergeRegister(a.registerUpdateListener(()=>{c()}),a.registerReadOnlyListener(()=>{c()}))},[a]);return k}exports.useLexicalCanShowPlaceholder=function(a){return h(a)}
|
|
@@ -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];
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
var react = require('react');
|
|
10
10
|
var text = require('@lexical/text');
|
|
11
|
+
var utils = require('@lexical/utils');
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -35,18 +36,26 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
35
36
|
* LICENSE file in the root directory of this source tree.
|
|
36
37
|
*
|
|
37
38
|
*/
|
|
39
|
+
|
|
40
|
+
function canShowPlaceholderFromCurrentEditorState(editor) {
|
|
41
|
+
const currentCanShowPlaceholder = editor.getEditorState().read(text.$canShowPlaceholderCurry(editor.isComposing(), editor.isReadOnly()));
|
|
42
|
+
return currentCanShowPlaceholder;
|
|
43
|
+
}
|
|
44
|
+
|
|
38
45
|
function useCanShowPlaceholder(editor) {
|
|
39
|
-
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(
|
|
46
|
+
const [canShowPlaceholder, setCanShowPlaceholder] = react.useState(() => canShowPlaceholderFromCurrentEditorState(editor));
|
|
40
47
|
useLayoutEffect(() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return editor.registerUpdateListener(({
|
|
44
|
-
editorState
|
|
45
|
-
}) => {
|
|
46
|
-
const isComposing = editor.isComposing();
|
|
47
|
-
currentCanShowPlaceholder = editorState.read(text.$canShowPlaceholderCurry(isComposing));
|
|
48
|
+
function resetCanShowPlaceholder() {
|
|
49
|
+
const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
|
|
48
50
|
setCanShowPlaceholder(currentCanShowPlaceholder);
|
|
49
|
-
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
resetCanShowPlaceholder();
|
|
54
|
+
return utils.mergeRegister(editor.registerUpdateListener(() => {
|
|
55
|
+
resetCanShowPlaceholder();
|
|
56
|
+
}), editor.registerReadOnlyListener(() => {
|
|
57
|
+
resetCanShowPlaceholder();
|
|
58
|
+
}));
|
|
50
59
|
}, [editor]);
|
|
51
60
|
return canShowPlaceholder;
|
|
52
61
|
}
|
|
@@ -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
|
-
'use strict';var b=require("react"),
|
|
8
|
-
function
|
|
7
|
+
'use strict';var b=require("react"),f=require("@lexical/text"),g=require("@lexical/utils"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?b.useLayoutEffect:b.useEffect;function k(a){return a.getEditorState().read(f.$canShowPlaceholderCurry(a.isComposing(),a.isReadOnly()))}
|
|
8
|
+
function l(a){let [c,d]=b.useState(()=>k(a));h(()=>{function e(){let m=k(a);d(m)}e();return g.mergeRegister(a.registerUpdateListener(()=>{e()}),a.registerReadOnlyListener(()=>{e()}))},[a]);return c}exports.useLexicalEditor=function(a){let c=l(a);return[b.useCallback(d=>{a.setRootElement(d)},[a]),c]}
|
|
@@ -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
|
|
@@ -27,7 +27,7 @@ function AutoFocusPlugin() {
|
|
|
27
27
|
const activeElement = document.activeElement;
|
|
28
28
|
const rootElement = editor.getRootElement();
|
|
29
29
|
|
|
30
|
-
if (rootElement !== null || activeElement === null
|
|
30
|
+
if (!rootElement.contains(activeElement) || rootElement !== null || activeElement === null) {
|
|
31
31
|
// Note: preventScroll won't work in Webkit.
|
|
32
32
|
rootElement.focus({
|
|
33
33
|
preventScroll: true
|
|
@@ -4,4 +4,4 @@
|
|
|
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 d=require("@lexical/react/LexicalComposerContext"),e=require("react");exports.AutoFocusPlugin=function(){let [a]=d.useLexicalComposerContext();e.useEffect(()=>{a.focus(()=>{let c=document.activeElement,b=a.getRootElement();null===b&&null!==c
|
|
7
|
+
'use strict';var d=require("@lexical/react/LexicalComposerContext"),e=require("react");exports.AutoFocusPlugin=function(){let [a]=d.useLexicalComposerContext();e.useEffect(()=>{a.focus(()=>{let c=document.activeElement,b=a.getRootElement();b.contains(c)&&null===b&&null!==c||b.focus({preventScroll:!0})})},[a]);return null}
|
|
@@ -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
|
-
|
|
15
|
+
export declare type LinkMatcher = (text: string) => LinkMatcherResult | null;
|
|
16
|
+
export declare function AutoLinkPlugin({ matchers, onChange, }: {
|
|
17
|
+
matchers: Array<LinkMatcher>;
|
|
18
|
+
onChange?: ChangeHandler;
|
|
20
19
|
}): JSX.Element | null;
|
|
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 | null;
|
|
14
|
+
export {};
|
|
@@ -5,12 +5,16 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
import type { ElementFormatType, NodeKey } from 'lexical';
|
|
9
|
+
import { ReactNode } from 'react';
|
|
10
|
+
declare type Props = Readonly<{
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
format: ElementFormatType | null | undefined;
|
|
13
|
+
nodeKey: NodeKey;
|
|
14
|
+
className: Readonly<{
|
|
15
|
+
base: string;
|
|
16
|
+
focus: string;
|
|
17
|
+
}>;
|
|
15
18
|
}>;
|
|
16
|
-
declare function BlockWithAlignableContents(
|
|
19
|
+
export declare function BlockWithAlignableContents({ children, format, nodeKey, className, }: Props): JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -23,14 +23,14 @@ 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);
|
|
30
|
-
const ref = React.useRef();
|
|
31
|
-
const onDelete = React.useCallback(
|
|
31
|
+
const ref = React.useRef(null);
|
|
32
|
+
const onDelete = React.useCallback(event => {
|
|
32
33
|
if (isSelected && lexical.$isNodeSelection(lexical.$getSelection())) {
|
|
33
|
-
const event = payload;
|
|
34
34
|
event.preventDefault();
|
|
35
35
|
editor.update(() => {
|
|
36
36
|
const node = lexical.$getNodeByKey(nodeKey);
|
|
@@ -89,10 +89,10 @@ function BlockWithAlignableContents({
|
|
|
89
89
|
}, 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
90
|
}, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected]);
|
|
91
91
|
return /*#__PURE__*/React.createElement("div", {
|
|
92
|
-
className:
|
|
92
|
+
className: [className.base, isSelected ? className.focus : null].filter(Boolean).join(' '),
|
|
93
93
|
ref: ref,
|
|
94
94
|
style: {
|
|
95
|
-
textAlign: format ? format :
|
|
95
|
+
textAlign: format ? format : undefined
|
|
96
96
|
}
|
|
97
97
|
}, children);
|
|
98
98
|
}
|
|
@@ -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(null),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:void 0}},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;
|
|
@@ -117,7 +117,7 @@ function handleCheckItemEvent(event, callback) {
|
|
|
117
117
|
|
|
118
118
|
const firstChild = target.firstChild;
|
|
119
119
|
|
|
120
|
-
if (firstChild != null && (firstChild.tagName === 'UL' || firstChild.tagName === 'OL')) {
|
|
120
|
+
if (firstChild != null && firstChild instanceof HTMLElement && (firstChild.tagName === 'UL' || firstChild.tagName === 'OL')) {
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -137,15 +137,18 @@ function handleCheckItemEvent(event, callback) {
|
|
|
137
137
|
|
|
138
138
|
function handleClick(event) {
|
|
139
139
|
handleCheckItemEvent(event, () => {
|
|
140
|
-
const
|
|
140
|
+
const domNode = event.target;
|
|
141
|
+
const editor = findEditor(domNode);
|
|
141
142
|
|
|
142
143
|
if (editor != null && !editor.isReadOnly()) {
|
|
143
144
|
editor.update(() => {
|
|
144
|
-
|
|
145
|
+
if (event.target) {
|
|
146
|
+
const node = lexical.$getNearestNodeFromDOMNode(domNode);
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
if (list.$isListItemNode(node)) {
|
|
149
|
+
domNode.focus();
|
|
150
|
+
node.toggleChecked();
|
|
151
|
+
}
|
|
149
152
|
}
|
|
150
153
|
});
|
|
151
154
|
}
|
|
@@ -163,7 +166,9 @@ function findEditor(target) {
|
|
|
163
166
|
let node = target;
|
|
164
167
|
|
|
165
168
|
while (node) {
|
|
169
|
+
// @ts-ignore internal field
|
|
166
170
|
if (node.__lexicalEditor) {
|
|
171
|
+
// @ts-ignore internal field
|
|
167
172
|
return node.__lexicalEditor;
|
|
168
173
|
}
|
|
169
174
|
|