@lexical/react 0.1.8 → 0.1.11
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 -38
- package/DEPRECATED_useLexical.prod.js +1 -2
- package/DEPRECATED_useLexicalAutoFormatter.dev.js +202 -74
- package/DEPRECATED_useLexicalAutoFormatter.prod.js +21 -16
- package/DEPRECATED_useLexicalCanShowPlaceholder.prod.js +1 -1
- package/DEPRECATED_useLexicalCharacterLimit.dev.js +23 -21
- package/DEPRECATED_useLexicalCharacterLimit.prod.js +8 -8
- package/DEPRECATED_useLexicalDecorators.prod.js +1 -1
- package/DEPRECATED_useLexicalEditor.dev.js +1 -25
- package/DEPRECATED_useLexicalEditor.prod.js +1 -1
- package/DEPRECATED_useLexicalEditorEvents.prod.js +1 -1
- package/DEPRECATED_useLexicalHistory.dev.js +18 -15
- package/DEPRECATED_useLexicalHistory.prod.js +7 -7
- package/DEPRECATED_useLexicalList.dev.js +6 -0
- package/DEPRECATED_useLexicalList.prod.js +1 -1
- package/DEPRECATED_useLexicalPlainText.dev.js +79 -70
- package/DEPRECATED_useLexicalPlainText.prod.js +15 -16
- package/DEPRECATED_useLexicalRichText.dev.js +124 -250
- package/DEPRECATED_useLexicalRichText.prod.js +25 -29
- package/LexicalAutoFormatterPlugin.dev.js +202 -74
- package/LexicalAutoFormatterPlugin.js.flow +10 -0
- package/LexicalAutoFormatterPlugin.prod.js +21 -17
- package/LexicalAutoLinkPlugin.js.flow +23 -0
- package/LexicalAutoLinkPlugin.prod.js +4 -4
- package/LexicalCharacterLimitPlugin.dev.js +23 -21
- package/LexicalCharacterLimitPlugin.js.flow +12 -0
- package/LexicalCharacterLimitPlugin.prod.js +9 -8
- package/LexicalClearEditorPlugin.dev.js +52 -0
- package/LexicalClearEditorPlugin.js +9 -0
- package/LexicalClearEditorPlugin.js.flow +14 -0
- package/LexicalClearEditorPlugin.prod.js +7 -0
- package/LexicalCollaborationPlugin.dev.js +31 -36
- package/LexicalCollaborationPlugin.js.flow +55 -0
- package/LexicalCollaborationPlugin.prod.js +7 -8
- package/LexicalComposer.dev.js +8 -6
- package/LexicalComposer.js.flow +23 -0
- package/LexicalComposer.prod.js +3 -3
- package/LexicalComposerContext.js.flow +27 -0
- package/LexicalComposerContext.prod.js +1 -1
- package/LexicalContentEditable.dev.js +14 -8
- package/LexicalContentEditable.js.flow +35 -0
- package/LexicalContentEditable.prod.js +3 -3
- package/LexicalHashtagPlugin.js.flow +20 -0
- package/LexicalHashtagPlugin.prod.js +1 -1
- package/LexicalHistoryPlugin.dev.js +18 -15
- package/LexicalHistoryPlugin.js.flow +34 -0
- package/LexicalHistoryPlugin.prod.js +7 -7
- package/LexicalHorizontalRuleNode.dev.js +66 -0
- package/LexicalHorizontalRuleNode.js +9 -0
- package/LexicalHorizontalRuleNode.js.flow +25 -0
- package/LexicalHorizontalRuleNode.prod.js +8 -0
- package/LexicalLinkPlugin.dev.js +0 -1
- package/LexicalLinkPlugin.js.flow +10 -0
- package/LexicalLinkPlugin.prod.js +3 -3
- package/LexicalListPlugin.dev.js +6 -0
- package/LexicalListPlugin.js.flow +10 -0
- package/LexicalListPlugin.prod.js +2 -2
- package/LexicalNestedComposer.js.flow +21 -0
- package/LexicalNestedComposer.prod.js +1 -1
- package/LexicalOnChangePlugin.js.flow +14 -0
- package/LexicalOnChangePlugin.prod.js +1 -1
- package/LexicalPlainTextPlugin.dev.js +72 -44
- package/LexicalPlainTextPlugin.js.flow +18 -0
- package/LexicalPlainTextPlugin.prod.js +12 -11
- package/LexicalRichTextPlugin.dev.js +115 -222
- package/LexicalRichTextPlugin.js.flow +18 -0
- package/LexicalRichTextPlugin.prod.js +21 -25
- package/LexicalTablePlugin.dev.js +43 -39
- package/LexicalTablePlugin.js.flow +10 -0
- package/LexicalTablePlugin.prod.js +4 -3
- package/LexicalTreeView.dev.js +10 -2
- package/LexicalTreeView.js.flow +19 -0
- package/LexicalTreeView.prod.js +9 -8
- package/README.md +0 -1
- package/package.json +5 -4
- package/useLexicalDecoratorMap.js.flow +16 -0
- package/useLexicalDecoratorMap.prod.js +1 -1
- package/useLexicalIsTextContentEmpty.js.flow +15 -0
- package/useLexicalIsTextContentEmpty.prod.js +1 -1
- package/useLexicalNodeSelection.dev.js +70 -0
- package/useLexicalNodeSelection.js +9 -0
- package/useLexicalNodeSelection.js.flow +14 -0
- package/useLexicalNodeSelection.prod.js +8 -0
- package/withSubscriptions.js.flow +13 -0
- package/withSubscriptions.prod.js +1 -1
- package/LexicalBootstrapPlugin.dev.js +0 -124
- package/LexicalBootstrapPlugin.js +0 -9
- package/LexicalBootstrapPlugin.prod.js +0 -8
- package/LexicalHorizontalRulePlugin.dev.js +0 -51
- package/LexicalHorizontalRulePlugin.js +0 -9
- package/LexicalHorizontalRulePlugin.prod.js +0 -7
package/LexicalComposer.dev.js
CHANGED
|
@@ -18,11 +18,6 @@ var React = require('react');
|
|
|
18
18
|
*
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
function defaultOnError(e) {
|
|
23
|
-
throw e;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
21
|
function LexicalComposer({
|
|
27
22
|
initialConfig = {},
|
|
28
23
|
children
|
|
@@ -58,16 +53,23 @@ function LexicalComposer({
|
|
|
58
53
|
context,
|
|
59
54
|
namespace,
|
|
60
55
|
nodes,
|
|
56
|
+
onError,
|
|
61
57
|
parentEditor,
|
|
62
58
|
theme: composerTheme
|
|
63
59
|
});
|
|
64
|
-
editor.
|
|
60
|
+
editor.setReadOnly(true);
|
|
65
61
|
}
|
|
66
62
|
|
|
67
63
|
return [editor, context];
|
|
68
64
|
}, // We only do this for init
|
|
69
65
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
66
|
[]);
|
|
67
|
+
React.useLayoutEffect(() => {
|
|
68
|
+
const isReadOnly = initialConfig.isReadOnly;
|
|
69
|
+
const [editor] = composerContext;
|
|
70
|
+
editor.setReadOnly(isReadOnly || false); // We only do this for init
|
|
71
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
+
}, []);
|
|
71
73
|
return /*#__PURE__*/React.createElement(LexicalComposerContext.LexicalComposerContext.Provider, {
|
|
72
74
|
value: composerContext
|
|
73
75
|
}, children);
|
|
@@ -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
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {EditorThemeClasses, LexicalEditor, LexicalNode} from 'lexical';
|
|
11
|
+
|
|
12
|
+
type Props = {
|
|
13
|
+
initialConfig?: {
|
|
14
|
+
editor?: LexicalEditor | null,
|
|
15
|
+
namespace?: string,
|
|
16
|
+
nodes?: Array<Class<LexicalNode>>,
|
|
17
|
+
theme?: EditorThemeClasses,
|
|
18
|
+
onError?: (Error) => void,
|
|
19
|
+
},
|
|
20
|
+
children: React$Node,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
declare export default function LexicalComposer(Props): React$MixedElement;
|
package/LexicalComposer.prod.js
CHANGED
|
@@ -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
|
-
|
|
8
|
-
module.exports=function({initialConfig:
|
|
9
|
-
{value:
|
|
7
|
+
var c=require("@lexical/react/LexicalComposerContext"),g=require("lexical"),m=require("react");
|
|
8
|
+
module.exports=function({initialConfig:h={},children:n}){const d=m.useContext(c.LexicalComposerContext),l=m.useMemo(()=>{let a,e;const {theme:k,namespace:p,editor:q,nodes:r,onError:t}=h;if(null!=k)a=k;else if(null!=d){e=d[0];var b=d[1].getTheme();null!=b&&(a=b)}b=c.createLexicalComposerContext(d,a);let f=q||null;null===f&&(f=g.createEditor({context:b,namespace:p,nodes:r,onError:t,parentEditor:e,theme:a}),f.setReadOnly(!0));return[f,b]},[]);m.useLayoutEffect(()=>{const a=h.isReadOnly,[e]=l;e.setReadOnly(a||
|
|
9
|
+
!1)},[]);return m.createElement(c.LexicalComposerContext.Provider,{value:l},n)};
|
|
@@ -0,0 +1,27 @@
|
|
|
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 {EditorThemeClasses, LexicalEditor} from 'lexical';
|
|
11
|
+
|
|
12
|
+
export type LexicalComposerContextType = {
|
|
13
|
+
getTheme: () => ?EditorThemeClasses,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type LexicalComposerContextWithEditor = [
|
|
17
|
+
LexicalEditor,
|
|
18
|
+
LexicalComposerContextType,
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
export let LexicalComposerContext: React$Context<?LexicalComposerContextWithEditor>;
|
|
22
|
+
|
|
23
|
+
declare export function createLexicalComposerContext(
|
|
24
|
+
parent: ?LexicalComposerContextWithEditor,
|
|
25
|
+
theme: ?EditorThemeClasses,
|
|
26
|
+
): LexicalComposerContextType;
|
|
27
|
+
declare export function useLexicalComposerContext(): LexicalComposerContextWithEditor;
|
|
@@ -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
|
-
|
|
7
|
+
var c=require("react");const d=c.createContext(null);exports.LexicalComposerContext=d;exports.createLexicalComposerContext=function(a,e){let b=null;null!=a&&(b=a[1]);return{getTheme:function(){return null!=e?e:null!=b?b.getTheme():null}}};exports.useLexicalComposerContext=function(){const a=c.useContext(d);if(null==a)throw Error("Minified Lexical error #0; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return a};
|
|
@@ -32,7 +32,6 @@ function LexicalContentEditable({
|
|
|
32
32
|
autoComplete,
|
|
33
33
|
autoCorrect,
|
|
34
34
|
className,
|
|
35
|
-
readOnly = false,
|
|
36
35
|
role = 'textbox',
|
|
37
36
|
spellCheck = true,
|
|
38
37
|
style,
|
|
@@ -40,28 +39,35 @@ function LexicalContentEditable({
|
|
|
40
39
|
testid
|
|
41
40
|
}) {
|
|
42
41
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
42
|
+
const [isReadOnly, setReadOnly] = React.useState(true);
|
|
43
43
|
const ref = React.useCallback(rootElement => {
|
|
44
44
|
editor.setRootElement(rootElement);
|
|
45
45
|
}, [editor]);
|
|
46
|
+
React.useLayoutEffect(() => {
|
|
47
|
+
setReadOnly(editor.isReadOnly());
|
|
48
|
+
return editor.addListener('readonly', currentIsReadOnly => {
|
|
49
|
+
setReadOnly(currentIsReadOnly);
|
|
50
|
+
});
|
|
51
|
+
}, [editor]);
|
|
46
52
|
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
-
"aria-activedescendant":
|
|
48
|
-
"aria-autocomplete":
|
|
49
|
-
"aria-controls":
|
|
53
|
+
"aria-activedescendant": isReadOnly ? null : ariaActiveDescendantID,
|
|
54
|
+
"aria-autocomplete": isReadOnly ? null : ariaAutoComplete,
|
|
55
|
+
"aria-controls": isReadOnly ? null : ariaControls,
|
|
50
56
|
"aria-describedby": ariaDescribedBy,
|
|
51
|
-
"aria-expanded":
|
|
57
|
+
"aria-expanded": isReadOnly ? null : role === 'combobox' ? !!ariaExpanded : null,
|
|
52
58
|
"aria-label": ariaLabel,
|
|
53
59
|
"aria-labelledby": ariaLabelledBy,
|
|
54
60
|
"aria-multiline": ariaMultiline,
|
|
55
|
-
"aria-owns":
|
|
61
|
+
"aria-owns": isReadOnly ? null : ariaOwneeID,
|
|
56
62
|
"aria-required": ariaRequired,
|
|
57
63
|
autoCapitalize: autoCapitalize,
|
|
58
64
|
autoComplete: autoComplete,
|
|
59
65
|
autoCorrect: autoCorrect,
|
|
60
66
|
className: className,
|
|
61
|
-
contentEditable: !
|
|
67
|
+
contentEditable: !isReadOnly,
|
|
62
68
|
"data-testid": testid,
|
|
63
69
|
ref: ref,
|
|
64
|
-
role:
|
|
70
|
+
role: isReadOnly ? null : role,
|
|
65
71
|
spellCheck: spellCheck,
|
|
66
72
|
style: style,
|
|
67
73
|
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
|
-
|
|
8
|
-
module.exports=function({ariaActiveDescendantID:
|
|
9
|
-
g,"aria-
|
|
7
|
+
var c=require("@lexical/react/LexicalComposerContext"),g=require("react");
|
|
8
|
+
module.exports=function({ariaActiveDescendantID:h,ariaAutoComplete:k,ariaControls:l,ariaDescribedBy:m,ariaExpanded:n,ariaLabel:p,ariaLabelledBy:q,ariaMultiline:r,ariaOwneeID:t,ariaRequired:u,autoCapitalize:v,autoComplete:w,autoCorrect:x,className:y,role:e="textbox",spellCheck:z=!0,style:A,tabIndex:B,testid:C}){const [b]=c.useLexicalComposerContext(),[a,f]=g.useState(!0),D=g.useCallback(d=>{b.setRootElement(d)},[b]);g.useLayoutEffect(()=>{f(b.isReadOnly());return b.addListener("readonly",d=>{f(d)})},
|
|
9
|
+
[b]);return g.createElement("div",{"aria-activedescendant":a?null:h,"aria-autocomplete":a?null:k,"aria-controls":a?null:l,"aria-describedby":m,"aria-expanded":a?null:"combobox"===e?!!n:null,"aria-label":p,"aria-labelledby":q,"aria-multiline":r,"aria-owns":a?null:t,"aria-required":u,autoCapitalize:v,autoComplete:w,autoCorrect:x,className:y,contentEditable:!a,"data-testid":C,ref:D,role:a?null:e,spellCheck:z,style:A,tabIndex:B})};
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
import type {LexicalEditor, TextNode} from 'lexical';
|
|
10
|
+
|
|
11
|
+
declare function getHashtagRegexStringChars(): $ReadOnly<{
|
|
12
|
+
alpha: string,
|
|
13
|
+
alphanumeric: string,
|
|
14
|
+
hashChars: string,
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
declare function getHashtagRegexString(): string;
|
|
18
|
+
declare function textNodeTransform(node: TextNode): void;
|
|
19
|
+
declare function useHashtags(editor: LexicalEditor): void;
|
|
20
|
+
declare export default function LexicalHashtagPlugin(): React$Node;
|
|
@@ -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
|
-
|
|
7
|
+
var c=require("@lexical/react/LexicalComposerContext"),f=require("lexical"),g=require("lexical/HashtagNode"),h=require("react"),l=RegExp;
|
|
8
8
|
const m=String.fromCharCode,n="A-Za-z\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u0241\u0250-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ee\u037a\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03f5\u03f7-\u0481\u048a-\u04ce\u04d0-\u04f9\u0500-\u050f\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0640-\u064a\u066e-\u066f\u0671-\u06d3\u06d5\u06e5-\u06e6\u06ee-\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u076d\u0780-\u07a5\u07b1\u0904-\u0939\u093d\u0950\u0958-\u0961\u097d\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0-\u0ae1\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b35-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32-\u0e33\u0e40-\u0e46\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edd\u0f00\u0f40-\u0f47\u0f49-\u0f6a\u0f88-\u0f8b\u1000-\u1021\u1023-\u1027\u1029-\u102a\u1050-\u1055\u10a0-\u10c5\u10d0-\u10fa\u10fc\u1100-\u1159\u115f-\u11a2\u11a8-\u11f9\u1200-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19a9\u19c1-\u19c7\u1a00-\u1a16\u1d00-\u1dbf\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u2094\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2131\u2133-\u2139\u213c-\u213f\u2145-\u2149\u2c00-\u2c2e\u2c30-\u2c5e\u2c80-\u2ce4\u2d00-\u2d25\u2d30-\u2d65\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3006\u3031-\u3035\u303b-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312c\u3131-\u318e\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fbb\ua000-\ua48c\ua800-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\uac00-\ud7a3\uf900-\ufa2d\ufa30-\ufa6a\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc\u0300-\u036f\u0483-\u0486\u0591-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u0610-\u0615\u064b-\u065e\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u0901-\u0903\u093c\u093e-\u094d\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09bc\u09be-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09e2-\u09e3\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a70-\u0a71\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0b01-\u0b03\u0b3c\u0b3e-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c82-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0d02-\u0d03\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d82-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2-\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f3e-\u0f3f\u0f71-\u0f84\u0f86-\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102c-\u1032\u1036-\u1039\u1056-\u1059\u135f\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17b6-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u192b\u1930-\u193b\u19b0-\u19c0\u19c8-\u19c9\u1a17-\u1a1b\u1dc0-\u1dc3\u20d0-\u20dc\u20e1\u20e5-\u20eb\u302a-\u302f\u3099-\u309a\ua802\ua806\ua80b\ua823-\ua827\ufb1e\ufe00-\ufe0f\ufe20-\ufe23\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253-\u0254\u0256-\u0257\u0259\u025b\u0263\u0268\u026f\u0272\u0289\u028b\u02bb\u0300-\u036f\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de0-\u2dff\ua640-\ua69f\u0591-\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f4\ufb12-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4f\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06de-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u06ff\u0750-\u077f\u08a0\u08a2-\u08ac\u08e4-\u08fe\ufb50-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\u200c-\u200c\u0e01-\u0e3a\u0e40-\u0e4e\u1100-\u11ff\u3130-\u3185\ua960-\ua97f\uac00-\ud7af\ud7b0-\ud7ff\uffa1-\uffdc\u30a1-\u30fa\u30fc-\u30fe\uff66-\uff9f\uff10-\uff19\uff21-\uff3a\uff41-\uff5a\u3041-\u3096\u3099-\u309e\u3400-\u4dbf\u4e00-\u9fff"+(m(173824)+
|
|
9
9
|
"-"+m(177983)+m(177984)+"-"+m(178207)+m(194560)+"-"+m(195103)+"\u3003\u3005\u303b"),{alpha:p,alphanumeric:q,hashChars:r}={alpha:n,alphanumeric:n+"0-9\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19d9\uff10-\uff19_",hashChars:"#\\uFF03"},t="["+q+"]",u=new l("(^|$|[^&/"+(q+"])([")+(r+"])(")+t+"*["+(p+"]")+
|
|
10
10
|
t+"*)","ig");function v(a){if(a.isSimpleText())for(var w=a.getTextContent(),k=0;;){var b=u.exec(w);if(null===b)break;const d=b.index+b[1].length-k;b=d+(b[3].length+1);let e;0===d?[e,a]=a.splitText(b):[,e,a]=a.splitText(d,b);k+=b;g.$toggleHashtag(e)}}function x(a){h.useEffect(()=>a.addTransform(f.TextNode,v),[a])}module.exports=function(){const [a]=c.useLexicalComposerContext();x(a);return null};
|
|
@@ -19,9 +19,9 @@ var react = require('react');
|
|
|
19
19
|
*
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
22
|
+
const HISTORY_MERGE = 0;
|
|
23
|
+
const HISTORY_PUSH = 1;
|
|
24
|
+
const DISCARD_HISTORY_CANDIDATE = 2;
|
|
25
25
|
const OTHER = 0;
|
|
26
26
|
const COMPOSING_CHARACTER = 1;
|
|
27
27
|
const INSERT_CHARACTER_AFTER_SELECTION = 2;
|
|
@@ -74,7 +74,7 @@ function getChangeType(prevEditorState, nextEditorState, dirtyLeavesSet, dirtyEl
|
|
|
74
74
|
return COMPOSING_CHARACTER;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
if (nextSelection
|
|
77
|
+
if (!lexical.$isRangeSelection(nextSelection) || !lexical.$isRangeSelection(prevSelection) || !prevSelection.isCollapsed() || !nextSelection.isCollapsed()) {
|
|
78
78
|
return OTHER;
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -149,18 +149,21 @@ function createMergeActionGetter(editor, delay) {
|
|
|
149
149
|
if (tags.has('historic')) {
|
|
150
150
|
prevChangeType = OTHER;
|
|
151
151
|
prevChangeTime = changeTime;
|
|
152
|
-
return
|
|
152
|
+
return DISCARD_HISTORY_CANDIDATE;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
const changeType = getChangeType(prevEditorState, nextEditorState, dirtyLeaves, dirtyElements, editor.isComposing());
|
|
156
156
|
|
|
157
157
|
const mergeAction = (() => {
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
const shouldPushHistory = tags.has('history-push');
|
|
159
|
+
const shouldMergeHistory = !shouldPushHistory && tags.has('history-merge');
|
|
160
|
+
|
|
161
|
+
if (shouldMergeHistory) {
|
|
162
|
+
return HISTORY_MERGE;
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
if (prevEditorState === null) {
|
|
163
|
-
return
|
|
166
|
+
return HISTORY_PUSH;
|
|
164
167
|
}
|
|
165
168
|
|
|
166
169
|
const selection = nextEditorState._selection;
|
|
@@ -169,19 +172,19 @@ function createMergeActionGetter(editor, delay) {
|
|
|
169
172
|
|
|
170
173
|
if (!hasDirtyNodes) {
|
|
171
174
|
if (prevSelection === null && selection !== null) {
|
|
172
|
-
return
|
|
175
|
+
return HISTORY_MERGE;
|
|
173
176
|
}
|
|
174
177
|
|
|
175
|
-
return
|
|
178
|
+
return DISCARD_HISTORY_CANDIDATE;
|
|
176
179
|
}
|
|
177
180
|
|
|
178
181
|
const isSameEditor = currentHistoryEntry === null || currentHistoryEntry.editor === editor;
|
|
179
182
|
|
|
180
|
-
if (changeType !== OTHER && changeType === prevChangeType && changeTime < prevChangeTime + delay && isSameEditor) {
|
|
181
|
-
return
|
|
183
|
+
if (shouldPushHistory === false && changeType !== OTHER && changeType === prevChangeType && changeTime < prevChangeTime + delay && isSameEditor) {
|
|
184
|
+
return HISTORY_MERGE;
|
|
182
185
|
}
|
|
183
186
|
|
|
184
|
-
return
|
|
187
|
+
return HISTORY_PUSH;
|
|
185
188
|
})();
|
|
186
189
|
|
|
187
190
|
prevChangeTime = changeTime;
|
|
@@ -218,7 +221,7 @@ function useHistory(editor, externalHistoryState, delay = 1000) {
|
|
|
218
221
|
|
|
219
222
|
const mergeAction = getMergeAction(prevEditorState, editorState, current, dirtyLeaves, dirtyElements, tags);
|
|
220
223
|
|
|
221
|
-
if (mergeAction ===
|
|
224
|
+
if (mergeAction === HISTORY_PUSH) {
|
|
222
225
|
if (redoStack.length !== 0) {
|
|
223
226
|
historyState.redoStack = [];
|
|
224
227
|
}
|
|
@@ -229,7 +232,7 @@ function useHistory(editor, externalHistoryState, delay = 1000) {
|
|
|
229
232
|
});
|
|
230
233
|
editor.execCommand('canUndo', true);
|
|
231
234
|
}
|
|
232
|
-
} else if (mergeAction ===
|
|
235
|
+
} else if (mergeAction === DISCARD_HISTORY_CANDIDATE) {
|
|
233
236
|
return;
|
|
234
237
|
} // Else we merge
|
|
235
238
|
|
|
@@ -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;
|
|
@@ -4,10 +4,10 @@
|
|
|
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
|
-
|
|
8
|
-
function x(b,d,
|
|
9
|
-
c&&!b._nodeMap.has(d.__key)&&v.$isTextNode(d)&&1===d.__text.length&&1===g.anchor.offset?2:0;d=h[0];b=b._nodeMap.get(d.__key);if(!v.$isTextNode(b)||!v.$isTextNode(d)||b.__mode!==d.__mode)return 0;b=b.__text;d=d.__text;if(b===d)return 0;g=g.anchor;c=c.anchor;if(g.key!==c.key||"text"!==g.type)return 0;g=g.offset;c=c.offset;b=d.length-b.length;return 1===b&&c===g-1?2:-1===b&&c===g+1?3:-1===b&&c===g?4:0}
|
|
10
|
-
function y(b,d){let
|
|
11
|
-
function z(b,d,
|
|
12
|
-
a.redoStack,e=a.undoStack,0!==c.length&&(f=a.current,null!==f&&(e.push(f),b.execCommand("canUndo",!0)),e=c.pop(),0===c.length&&b.execCommand("canRedo",!1),a.current=e,e.editor.setEditorState(e.editorState,{tag:"historic"})),!0;case "clearEditor":return h(),!1;case "clearHistory":return h(),!0;default:return!1}},0),b.addListener("update",({editorState:c,prevEditorState:e,dirtyLeaves:f,dirtyElements:
|
|
13
|
-
c!==
|
|
7
|
+
var n=require("@lexical/react/LexicalComposerContext"),t=require("@lexical/react/withSubscriptions"),v=require("lexical"),w=require("react");
|
|
8
|
+
function x(b,d,l,a,h){if(null===b||0===l.size&&0===a.size)return 0;var g=d._selection,c=b._selection;if(h)return 1;if(!(v.$isRangeSelection(g)&&v.$isRangeSelection(c)&&c.isCollapsed()&&g.isCollapsed()))return 0;var e=Array.from(l);a=Array.from(a);l=d._nodeMap;h=[];for(var f=0;f<e.length;f++){const k=l.get(e[f]);void 0!==k&&h.push(k)}for(e=0;e<a.length;e++)a[e][1]&&(f=l.get(a[e][0]),void 0===f||v.$isRootNode(f)||h.push(f));if(0===h.length)return 0;if(1<h.length)return a=d._nodeMap,d=a.get(g.anchor.key),
|
|
9
|
+
c=a.get(c.anchor.key),d&&c&&!b._nodeMap.has(d.__key)&&v.$isTextNode(d)&&1===d.__text.length&&1===g.anchor.offset?2:0;d=h[0];b=b._nodeMap.get(d.__key);if(!v.$isTextNode(b)||!v.$isTextNode(d)||b.__mode!==d.__mode)return 0;b=b.__text;d=d.__text;if(b===d)return 0;g=g.anchor;c=c.anchor;if(g.key!==c.key||"text"!==g.type)return 0;g=g.offset;c=c.offset;b=d.length-b.length;return 1===b&&c===g-1?2:-1===b&&c===g+1?3:-1===b&&c===g?4:0}
|
|
10
|
+
function y(b,d){let l=Date.now(),a=0;return(h,g,c,e,f,k)=>{const p=Date.now();if(k.has("historic"))return a=0,l=p,2;const m=x(h,g,e,f,b.isComposing()),u=(()=>{const r=k.has("history-push");if(!r&&k.has("history-merge"))return 0;if(null===h)return 1;var q=g._selection;const A=h._selection;if(!(0<e.size||0<f.size))return null===A&&null!==q?0:2;q=null===c||c.editor===b;return!1===r&&0!==m&&m===a&&p<l+d&&q?0:1})();l=p;a=m;return u}}
|
|
11
|
+
function z(b,d,l=1E3){const a=w.useMemo(()=>d||B(),[d]),h=w.useCallback(()=>{a.undoStack=[];a.redoStack=[];a.current=null},[a]);w.useEffect(()=>{const g=y(b,l);return t(b.addListener("command",c=>{switch(c){case "undo":c=a.redoStack;var e=a.undoStack;if(0!==e.length){var f=a.current;const k=e.pop();null!==f&&(c.push(f),b.execCommand("canRedo",!0));0===e.length&&b.execCommand("canUndo",!1);a.current=k;k.editor.setEditorState(k.editorState.clone(k.undoSelection),{tag:"historic"})}return!0;case "redo":return c=
|
|
12
|
+
a.redoStack,e=a.undoStack,0!==c.length&&(f=a.current,null!==f&&(e.push(f),b.execCommand("canUndo",!0)),e=c.pop(),0===c.length&&b.execCommand("canRedo",!1),a.current=e,e.editor.setEditorState(e.editorState,{tag:"historic"})),!0;case "clearEditor":return h(),!1;case "clearHistory":return h(),!0;default:return!1}},0),b.addListener("update",({editorState:c,prevEditorState:e,dirtyLeaves:f,dirtyElements:k,tags:p})=>{const m=a.current,u=a.redoStack,r=a.undoStack,q=null===m?null:m.editorState;if(null===m||
|
|
13
|
+
c!==q){f=g(e,c,m,f,k,p);if(1===f)0!==u.length&&(a.redoStack=[]),null!==m&&(r.push({...m,undoSelection:e.read(v.$getSelection)}),b.execCommand("canUndo",!0));else if(2===f)return;a.current={editor:b,editorState:c}}}))},[h,l,b,a])}function B(){return{current:null,redoStack:[],undoStack:[]}}exports.HistoryPlugin=function({externalHistoryState:b}){const [d]=n.useLexicalComposerContext();z(d,b);return null};exports.createEmptyHistoryState=B;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var lexical = require('lexical');
|
|
10
|
+
var React = require('react');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
function HorizontalRuleComponent() {
|
|
22
|
+
return /*#__PURE__*/React.createElement("hr", null);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class HorizontalRuleNode extends lexical.DecoratorNode {
|
|
26
|
+
static getType() {
|
|
27
|
+
return 'horizontalrule';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static clone(node) {
|
|
31
|
+
return new HorizontalRuleNode(node.__state, node.__key);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
createDOM() {
|
|
35
|
+
const div = document.createElement('div');
|
|
36
|
+
div.style.display = 'contents';
|
|
37
|
+
return div;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getTextContent() {
|
|
41
|
+
return '\n';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
isTopLevel() {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
updateDOM() {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
decorate() {
|
|
53
|
+
return /*#__PURE__*/React.createElement(HorizontalRuleComponent, null);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
function $createHorizontalRuleNode() {
|
|
58
|
+
return new HorizontalRuleNode();
|
|
59
|
+
}
|
|
60
|
+
function $isHorizontalRuleNode(node) {
|
|
61
|
+
return node instanceof HorizontalRuleNode;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
exports.$createHorizontalRuleNode = $createHorizontalRuleNode;
|
|
65
|
+
exports.$isHorizontalRuleNode = $isHorizontalRuleNode;
|
|
66
|
+
exports.HorizontalRuleNode = HorizontalRuleNode;
|
|
@@ -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
|
+
'use strict'
|
|
8
|
+
const LexicalHorizontalRuleNode = process.env.NODE_ENV === 'development' ? require('./LexicalHorizontalRuleNode.dev.js') : require('./LexicalHorizontalRuleNode.prod.js')
|
|
9
|
+
module.exports = LexicalHorizontalRuleNode;
|
|
@@ -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,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
|
+
var b=require("lexical"),c=require("react");function d(){return c.createElement("hr",null)}class e extends b.DecoratorNode{static getType(){return"horizontalrule"}static clone(a){return new e(a.__state,a.__key)}createDOM(){const a=document.createElement("div");a.style.display="contents";return a}getTextContent(){return"\n"}isTopLevel(){return!0}updateDOM(){return!1}decorate(){return c.createElement(d,null)}}exports.$createHorizontalRuleNode=function(){return new e};
|
|
8
|
+
exports.$isHorizontalRuleNode=function(a){return a instanceof e};exports.HorizontalRuleNode=e;
|
package/LexicalLinkPlugin.dev.js
CHANGED
|
@@ -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;
|
|
@@ -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
|
-
|
|
8
|
-
function p(g){var b=k.$getSelection();
|
|
9
|
-
|
|
7
|
+
var h=require("@lexical/react/LexicalComposerContext"),k=require("lexical"),m=require("lexical/LinkNode"),n=require("react");
|
|
8
|
+
function p(g){var b=k.$getSelection();null!==b&&k.$setSelection(b);b=k.$getSelection();if(null!==b)if(b=b.extract(),null===g)b.forEach(e=>{e=e.getParent();if(m.$isLinkNode(e)){const a=e.getChildren();for(let c=0;c<a.length;c++)e.insertBefore(a[c]);e.remove()}});else{let e=null,a=null;if(1===b.length){var f=b[0];if(m.$isLinkNode(f)){f.setURL(g);return}f=f.getParent();if(m.$isLinkNode(f)){a=f;f.setURL(g);return}}b.forEach(c=>{var d=c.getParent();if(d!==a&&null!==d)if(d.is(e)||(e=d,a=m.$createLinkNode(g),
|
|
9
|
+
m.$isLinkNode(d)?null===c.getPreviousSibling()?d.insertBefore(a):d.insertAfter(a):c.insertBefore(a)),m.$isLinkNode(c)){if(null!==a){d=c.getChildren();for(let l=0;l<d.length;l++)a.append(d[l])}c.remove()}else null!==a&&a.append(c)})}}module.exports=function(){const [g]=h.useLexicalComposerContext();n.useEffect(()=>g.addListener("command",(b,f)=>"toggleLink"===b?(p(f),!0):!1,0),[g]);return 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
|
-
|
|
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,21 @@
|
|
|
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?: {
|
|
14
|
+
namespace?: string,
|
|
15
|
+
decoratorEditor: DecoratorEditor,
|
|
16
|
+
nodes?: Array<Class<LexicalNode>>,
|
|
17
|
+
theme?: EditorThemeClasses,
|
|
18
|
+
onError?: (Error) => void,
|
|
19
|
+
},
|
|
20
|
+
children?: React$Node,
|
|
21
|
+
}): React$Node;
|
|
@@ -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
|
-
|
|
7
|
+
var a=require("@lexical/react/LexicalComposer"),f=require("@lexical/react/LexicalOnChangePlugin"),g=require("react");
|
|
8
8
|
module.exports=function({initialConfig:c={},children:h}){const [d,k]=g.useState(null),{decoratorEditor:b,namespace:l,theme:m,nodes:n,onError:p}=c;g.useEffect(()=>{b.isEmpty()||null===d||b.init(d)},[d]);c=g.useCallback((q,e)=>{q.isEmpty()?k(e):b.set(e)},[]);return g.createElement(a,{initialConfig:{editor:b.editor,namespace:l,nodes:n,onError:p,theme:m}},g.createElement(f,{onChange:c}),h)};
|
|
@@ -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;
|