@lexical/react 0.3.2 → 0.3.3

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.
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import {WebsocketProvider} from 'y-websocket';
9
+ import type {Provider} from '@lexical/yjs';
10
10
  import type {Doc, RelativePosition} from 'yjs';
11
11
 
12
12
  export type UserState = {
@@ -31,7 +31,7 @@ type CollaborationContextType = {
31
31
  };
32
32
  export function CollaborationPlugin(arg0: {
33
33
  id: string;
34
- providerFactory(id: string, yjsDocMap: Map<string, Doc>): WebsocketProvider;
34
+ providerFactory(id: string, yjsDocMap: Map<string, Doc>): Provider;
35
35
  shouldBootstrap: boolean;
36
36
  username?: string;
37
37
  }): JSX.Element | null;
@@ -11,6 +11,7 @@ import type {EditorThemeClasses, LexicalEditor, LexicalNode} from 'lexical';
11
11
 
12
12
  type Props = {
13
13
  initialConfig: {
14
+ namespace: string;
14
15
  editor__DEPRECATED?: LexicalEditor | null;
15
16
  readOnly?: boolean;
16
17
  nodes?: Array<Class<LexicalNode>>;
@@ -43,6 +43,7 @@ function LexicalComposer({
43
43
  const composerContext = React.useMemo(() => {
44
44
  const {
45
45
  theme,
46
+ namespace,
46
47
  editor__DEPRECATED: initialEditor,
47
48
  nodes,
48
49
  onError
@@ -52,6 +53,7 @@ function LexicalComposer({
52
53
 
53
54
  if (editor === null) {
54
55
  const newEditor = lexical.createEditor({
56
+ namespace,
55
57
  nodes,
56
58
  onError: error => onError(error, newEditor),
57
59
  readOnly: true,
@@ -13,7 +13,7 @@ type Props = {
13
13
  initialConfig: $ReadOnly<{
14
14
  editor__DEPRECATED?: LexicalEditor | null,
15
15
  readOnly?: boolean,
16
- namespace?: string,
16
+ namespace: string,
17
17
  nodes?: $ReadOnlyArray<Class<LexicalNode>>,
18
18
  theme?: EditorThemeClasses,
19
19
  onError: (error: Error, editor: LexicalEditor) => void,
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict';var a=require("@lexical/react/LexicalComposerContext"),e=require("lexical"),k=require("react"),l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?k.useLayoutEffect:k.useEffect;
8
- exports.LexicalComposer=function({initialConfig:f,children:m}){let h=k.useMemo(()=>{const {theme:b,editor__DEPRECATED:c,nodes:n,onError:p}=f,q=a.createLexicalComposerContext(null,b);let d=c||null;if(null===d){const g=e.createEditor({nodes:n,onError:r=>p(r,g),readOnly:!0,theme:b});d=g}return[d,q]},[]);l(()=>{let b=f.readOnly,[c]=h;c.setReadOnly(b||!1)},[]);return k.createElement(a.LexicalComposerContext.Provider,{value:h},m)}
8
+ exports.LexicalComposer=function({initialConfig:f,children:m}){let h=k.useMemo(()=>{const {theme:b,namespace:c,editor__DEPRECATED:n,nodes:p,onError:q}=f,r=a.createLexicalComposerContext(null,b);let d=n||null;if(null===d){const g=e.createEditor({namespace:c,nodes:p,onError:t=>q(t,g),readOnly:!0,theme:b});d=g}return[d,r]},[]);l(()=>{let b=f.readOnly,[c]=h;c.setReadOnly(b||!1)},[]);return k.createElement(a.LexicalComposerContext.Provider,{value:h},m)}
@@ -24,7 +24,7 @@ export type Props = $ReadOnly<{
24
24
  className?: string,
25
25
  readOnly?: boolean,
26
26
  role?: string,
27
- style?: StyleSheetList,
27
+ style?: $Shape<{[string]: string | number}>,
28
28
  spellCheck?: boolean,
29
29
  tabIndex?: number,
30
30
  testid?: string,
@@ -41,6 +41,7 @@ function LexicalNestedComposer({
41
41
 
42
42
  initialEditor._parentEditor = parentEditor;
43
43
  initialEditor._nodes = parentEditor._nodes;
44
+ initialEditor._config.namespace = parentEditor._config.namespace;
44
45
  return [initialEditor, context];
45
46
  }, // We only do this for init
46
47
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  'use strict';var c=require("@lexical/react/LexicalCollaborationPlugin"),d=require("@lexical/react/LexicalComposerContext"),h=require("react");
8
- exports.LexicalNestedComposer=function({initialEditor:a,children:k,initialTheme:l}){let e=h.useContext(d.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #9; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let p=h.useMemo(()=>{const [g,m]=e,f=l||m.getTheme()||void 0,n=d.createLexicalComposerContext(e,f);void 0!==f&&(a._config.theme=f);a._parentEditor=g;a._nodes=g._nodes;return[a,n]},[]);var {yjsDocMap:b}=
9
- c.useCollaborationContext();let q=void 0!==b.get("main");b=b.has(a.getKey());return h.createElement(d.LexicalComposerContext.Provider,{value:p},!q||b?k:null)}
8
+ exports.LexicalNestedComposer=function({initialEditor:a,children:k,initialTheme:l}){let e=h.useContext(d.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #9; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let p=h.useMemo(()=>{const [f,m]=e,g=l||m.getTheme()||void 0,n=d.createLexicalComposerContext(e,g);void 0!==g&&(a._config.theme=g);a._parentEditor=f;a._nodes=f._nodes;a._config.namespace=f._config.namespace;
9
+ return[a,n]},[]);var {yjsDocMap:b}=c.useCollaborationContext();let q=void 0!==b.get("main");b=b.has(a.getKey());return h.createElement(d.LexicalComposerContext.Provider,{value:p},!q||b?k:null)}
@@ -6,9 +6,9 @@
6
6
  *
7
7
  */
8
8
 
9
- import type {EditorState} from 'lexical';
9
+ import {InitialEditorStateType} from '@lexical/plain-text';
10
+ import type {EditorState, LexicalEditor} from 'lexical';
10
11
 
11
- type InitialEditorStateType = null | string | EditorState | (() => void);
12
12
  export function PlainTextPlugin(arg0: {
13
13
  contentEditable: JSX.Element | null;
14
14
  initialEditorState?: InitialEditorStateType;
@@ -7,9 +7,13 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- import type {EditorState} from 'lexical';
10
+ import type {EditorState, LexicalEditor} from 'lexical';
11
11
 
12
- type InitialEditorStateType = null | string | EditorState | (() => void);
12
+ type InitialEditorStateType =
13
+ | null
14
+ | string
15
+ | EditorState
16
+ | ((editor: LexicalEditor) => void);
13
17
 
14
18
  declare export function PlainTextPlugin({
15
19
  contentEditable: React$Node,
@@ -6,9 +6,9 @@
6
6
  *
7
7
  */
8
8
 
9
- import type {EditorState} from 'lexical';
9
+ import {InitialEditorStateType} from '@lexical/rich-text';
10
+ import type {EditorState, LexicalEditor} from 'lexical';
10
11
 
11
- type InitialEditorStateType = null | string | EditorState | (() => void);
12
12
  export function RichTextPlugin(arg0: {
13
13
  contentEditable: JSX.Element | null;
14
14
  initialEditorState?: InitialEditorStateType;
@@ -7,9 +7,13 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- import type {EditorState} from 'lexical';
10
+ import type {EditorState, LexicalEditor} from 'lexical';
11
11
 
12
- type InitialEditorStateType = null | string | EditorState | (() => void);
12
+ type InitialEditorStateType =
13
+ | null
14
+ | string
15
+ | EditorState
16
+ | ((editor: LexicalEditor) => void);
13
17
 
14
18
  declare export function RichTextPlugin({
15
19
  contentEditable: React$Node,
package/README.md CHANGED
@@ -66,12 +66,11 @@ function onError(error) {
66
66
 
67
67
  function Editor() {
68
68
  const initialConfig = {
69
+ namespace: 'MyEditor',
69
70
  theme,
70
71
  onError,
71
72
  };
72
73
 
73
-
74
-
75
74
  return (
76
75
  <LexicalComposer initialConfig={initialConfig}>
77
76
  <LexicalPlainTextPlugin
package/package.json CHANGED
@@ -8,28 +8,28 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.3.2",
11
+ "version": "0.3.3",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.3.2",
14
- "@lexical/list": "0.3.2",
15
- "@lexical/table": "0.3.2",
16
- "@lexical/yjs": "0.3.2",
17
- "@lexical/hashtag": "0.3.2",
18
- "@lexical/selection": "0.3.2",
19
- "@lexical/utils": "0.3.2",
20
- "@lexical/dragon": "0.3.2",
21
- "@lexical/plain-text": "0.3.2",
22
- "@lexical/rich-text": "0.3.2",
23
- "@lexical/code": "0.3.2",
24
- "@lexical/text": "0.3.2",
25
- "@lexical/link": "0.3.2",
26
- "@lexical/overflow": "0.3.2",
27
- "@lexical/history": "0.3.2",
28
- "@lexical/markdown": "0.3.2",
29
- "@lexical/mark": "0.3.2"
13
+ "@lexical/clipboard": "0.3.3",
14
+ "@lexical/code": "0.3.3",
15
+ "@lexical/dragon": "0.3.3",
16
+ "@lexical/hashtag": "0.3.3",
17
+ "@lexical/history": "0.3.3",
18
+ "@lexical/link": "0.3.3",
19
+ "@lexical/list": "0.3.3",
20
+ "@lexical/mark": "0.3.3",
21
+ "@lexical/markdown": "0.3.3",
22
+ "@lexical/overflow": "0.3.3",
23
+ "@lexical/plain-text": "0.3.3",
24
+ "@lexical/rich-text": "0.3.3",
25
+ "@lexical/selection": "0.3.3",
26
+ "@lexical/table": "0.3.3",
27
+ "@lexical/text": "0.3.3",
28
+ "@lexical/utils": "0.3.3",
29
+ "@lexical/yjs": "0.3.3"
30
30
  },
31
31
  "peerDependencies": {
32
- "lexical": "0.3.2",
32
+ "lexical": "0.3.3",
33
33
  "react": ">=17.x",
34
34
  "react-dom": ">=17.x"
35
35
  },
@@ -37,5 +37,8 @@
37
37
  "type": "git",
38
38
  "url": "https://github.com/facebook/lexical",
39
39
  "directory": "packages/lexical-react"
40
+ },
41
+ "devDependencies": {
42
+ "utility-types": "^3.10.0"
40
43
  }
41
44
  }