@lexical/react 0.1.20 → 0.2.1

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.
@@ -17,4 +17,4 @@ export type LinkMatcher = (text: string) => LinkMatcherResult | null;
17
17
  export default function LexicalAutoLinkPlugin(props: {
18
18
  matchers: Array<LinkMatcher>;
19
19
  onChange?: ChangeHandler;
20
- }): React.ReactNode;
20
+ }): JSX.Element | null;
@@ -8,4 +8,4 @@
8
8
 
9
9
  export default function LexicalCharacterLimitPlugin(props: {
10
10
  charset: 'UTF-8' | 'UTF-16';
11
- }): React.ReactNode;
11
+ }): JSX.Element | null;
@@ -11,4 +11,6 @@ import {$ReadOnly} from 'utility-types';
11
11
  type Props = $ReadOnly<{
12
12
  onClear?: () => void;
13
13
  }>;
14
- export default function LexicalClearEditorPlugin(arg0: Props): React.ReactNode;
14
+ export default function LexicalClearEditorPlugin(
15
+ arg0: Props,
16
+ ): JSX.Element | null;
@@ -51,6 +51,6 @@ export function CollaborationPlugin(arg0: {
51
51
  providerFactory: ProviderFactory;
52
52
  shouldBootstrap: boolean;
53
53
  username?: string;
54
- }): React.ReactNode;
54
+ }): JSX.Element | null;
55
55
  export declare var CollaborationContext: React.Context<CollaborationContextType>;
56
56
  export function useCollaborationContext(): CollaborationContextType;
@@ -238,7 +238,7 @@ function clearEditorSkipCollab(editor, binding) {
238
238
  *
239
239
  */
240
240
  const entries = [['Cat', '255,165,0'], ['Dog', '0,200,55'], ['Rabbit', '160,0,200'], ['Frog', '0,172,200'], ['Fox', '197,200,0'], ['Hedgehog', '31,200,0'], ['Pigeon', '200,0,0'], ['Squirrel', '200,0,148'], ['Bear', '255,235,0'], ['Tiger', '86,255,0'], ['Leopard', '0,255,208'], ['Zebra', '0,243,255'], ['Wolf', '0,102,255'], ['Owl', '147,0,255'], ['Gull', '255,0,153'], ['Squid', '0,220,255']];
241
- const randomEntry = entries[Math.floor(Math.random() * (entries.length - 1 - 0 + 1) + 0)];
241
+ const randomEntry = entries[Math.floor(Math.random() * entries.length)];
242
242
  function CollaborationPlugin({
243
243
  id,
244
244
  providerFactory,
@@ -12,5 +12,5 @@ function K(b,c,a,d){g.useEffect(()=>m.mergeRegister(b.registerCommand(F.FOCUS_CO
12
12
  function L(b,c){const a=g.useMemo(()=>x.createUndoManager(c,c.root.getSharedType()),[c]);g.useEffect(()=>m.mergeRegister(b.registerCommand(F.UNDO_COMMAND,()=>{a.undo();return!0},0),b.registerCommand(F.REDO_COMMAND,()=>{a.redo();return!0},0)));return g.useCallback(()=>{a.clear()},[a])}
13
13
  function I(b){b.update(()=>{var c=F.$getRoot();if(null===c.getFirstChild()){const a=F.$createParagraphNode();c.append(a);c=document.activeElement;(null!==F.$getSelection()||null!==c&&c===b.getRootElement())&&a.select()}},{tag:"history-merge"})}
14
14
  function J(b,c){b.update(()=>{const d=F.$getRoot();d.clear();d.select()},{tag:"skip-collab"});if(null!=c.cursors&&(b=c.cursorsContainer,null!=b)){c=Array.from(c.cursors.values());for(let d=0;d<c.length;d++){var a=c[d].selection;if(a&&null!=a.selections){a=a.selections;for(let k=0;k<a.length;k++)b.removeChild(a[d])}}}}
15
- const M=[["Cat","255,165,0"],["Dog","0,200,55"],["Rabbit","160,0,200"],["Frog","0,172,200"],["Fox","197,200,0"],["Hedgehog","31,200,0"],["Pigeon","200,0,0"],["Squirrel","200,0,148"],["Bear","255,235,0"],["Tiger","86,255,0"],["Leopard","0,255,208"],["Zebra","0,243,255"],["Wolf","0,102,255"],["Owl","147,0,255"],["Gull","255,0,153"],["Squid","0,220,255"]],N=M[Math.floor(Math.random()*(M.length-1+1))],T=g.createContext({clientID:0,color:N[1],name:N[0],yjsDocMap:new Map});
15
+ const M=[["Cat","255,165,0"],["Dog","0,200,55"],["Rabbit","160,0,200"],["Frog","0,172,200"],["Fox","197,200,0"],["Hedgehog","31,200,0"],["Pigeon","200,0,0"],["Squirrel","200,0,148"],["Bear","255,235,0"],["Tiger","86,255,0"],["Leopard","0,255,208"],["Zebra","0,243,255"],["Wolf","0,102,255"],["Owl","147,0,255"],["Gull","255,0,153"],["Squid","0,220,255"]],N=M[Math.floor(Math.random()*M.length)],T=g.createContext({clientID:0,color:N[1],name:N[0],yjsDocMap:new Map});
16
16
  function U(b){const c=g.useContext(T);null!=b&&(c.name=b);return c}exports.CollaborationContext=T;exports.CollaborationPlugin=function({id:b,providerFactory:c,shouldBootstrap:a,username:d}){d=U(d);const {yjsDocMap:k,name:p,color:q}=d,[n]=e.useLexicalComposerContext(),r=g.useMemo(()=>c(b,k),[b,c,k]),[v,f]=H(n,b,r,k,p,q,a);d.clientID=f.clientID;L(n,f);K(n,r,p,q);return v};exports.useCollaborationContext=U;
@@ -17,6 +17,6 @@ type Props = {
17
17
  theme?: EditorThemeClasses;
18
18
  onError: (error: Error, editor: LexicalEditor) => void;
19
19
  };
20
- children: React.ReactNode;
20
+ children: JSX.Element | JSX.Element[] | null;
21
21
  };
22
- export default function LexicalComposer(arg0: Props): React.ReactNode;
22
+ export default function LexicalComposer(arg0: Props): JSX.Element | null;
@@ -29,4 +29,6 @@ export type Props = $ReadOnly<{
29
29
  tabIndex?: number;
30
30
  testid?: string;
31
31
  }>;
32
- export default function LexicalContentEditable(props: Props): React.ReactNode;
32
+ export default function LexicalContentEditable(
33
+ props: Props,
34
+ ): JSX.Element | null;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- export default function LexicalHashtagPlugin(): React.ReactNode;
9
+ export default function LexicalHashtagPlugin(): JSX.Element | null;
@@ -25,5 +25,5 @@ export type HistoryState = {
25
25
  };
26
26
  export function HistoryPlugin(arg0: {
27
27
  externalHistoryState?: HistoryState;
28
- }): React.ReactNode;
28
+ }): JSX.Element | null;
29
29
  export function createEmptyHistoryState(): HistoryState;
@@ -8,14 +8,14 @@
8
8
 
9
9
  import type {LexicalNode, LexicalCommand} from 'lexical';
10
10
  import {DecoratorNode} from 'lexical';
11
- export declare class HorizontalRuleNode extends DecoratorNode<React.ReactNode> {
11
+ export declare class HorizontalRuleNode extends DecoratorNode<JSX.Element | null> {
12
12
  getType(): string;
13
13
  clone(node: HorizontalRuleNode): HorizontalRuleNode;
14
14
  createDOM(): HTMLElement;
15
15
  getTextContent(): '\n';
16
16
  isTopLevel(): true;
17
17
  updateDOM(): false;
18
- decorate(): React.ReactNode;
18
+ decorate(): JSX.Element | null;
19
19
  }
20
20
  export function $createHorizontalRuleNode(): HorizontalRuleNode;
21
21
  export function $isHorizontalRuleNode(
@@ -29,7 +29,22 @@ class HorizontalRuleNode extends lexical.DecoratorNode {
29
29
  }
30
30
 
31
31
  static clone(node) {
32
- return new HorizontalRuleNode(node.__state, node.__key);
32
+ return new HorizontalRuleNode(node.__key);
33
+ }
34
+
35
+ static importDOM() {
36
+ return {
37
+ hr: node => ({
38
+ conversion: convertHorizontalRuleElement,
39
+ priority: 0
40
+ })
41
+ };
42
+ }
43
+
44
+ exportDOM() {
45
+ return {
46
+ element: document.createElement('hr')
47
+ };
33
48
  }
34
49
 
35
50
  createDOM() {
@@ -55,6 +70,13 @@ class HorizontalRuleNode extends lexical.DecoratorNode {
55
70
  }
56
71
 
57
72
  }
73
+
74
+ function convertHorizontalRuleElement() {
75
+ return {
76
+ node: $createHorizontalRuleNode()
77
+ };
78
+ }
79
+
58
80
  function $createHorizontalRuleNode() {
59
81
  return new HorizontalRuleNode();
60
82
  }
@@ -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
- var b=require("lexical"),c=require("react");const d=b.createCommand();function e(){return c.createElement("hr",null)}class f extends b.DecoratorNode{static getType(){return"horizontalrule"}static clone(a){return new f(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(e,null)}}exports.$createHorizontalRuleNode=function(){return new f};
8
- exports.$isHorizontalRuleNode=function(a){return a instanceof f};exports.HorizontalRuleNode=f;exports.INSERT_HORIZONTAL_RULE_COMMAND=d;
7
+ var b=require("lexical"),c=require("react");const d=b.createCommand();function e(){return c.createElement("hr",null)}
8
+ class f extends b.DecoratorNode{static getType(){return"horizontalrule"}static clone(a){return new f(a.__key)}static importDOM(){return{hr:()=>({conversion:g,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}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(e,null)}}function g(){return{node:h()}}function h(){return new f}
9
+ exports.$createHorizontalRuleNode=h;exports.$isHorizontalRuleNode=function(a){return a instanceof f};exports.HorizontalRuleNode=f;exports.INSERT_HORIZONTAL_RULE_COMMAND=d;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- export default function LexicalMarkdownShortcutPlugin(): React.ReactNode;
9
+ export default function LexicalMarkdownShortcutPlugin(): JSX.Element | null;
@@ -6,12 +6,10 @@
6
6
  *
7
7
  */
8
8
 
9
- import type {DecoratorEditor, EditorThemeClasses} from 'lexical';
9
+ import type {LexicalEditor, EditorThemeClasses} from 'lexical';
10
10
 
11
11
  export default function LexicalNestedComposer(arg0: {
12
- initialConfig: {
13
- decoratorEditor: DecoratorEditor;
14
- theme?: EditorThemeClasses;
15
- };
16
- children: React.ReactNode;
17
- }): React.ReactNode;
12
+ initialEditor: LexicalEditor;
13
+ initialTheme?: EditorThemeClasses;
14
+ children: JSX.Element | JSX.Element[] | null;
15
+ }): JSX.Element | null;
@@ -7,8 +7,6 @@
7
7
  'use strict';
8
8
 
9
9
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
10
- var LexicalOnChangePlugin = require('@lexical/react/LexicalOnChangePlugin');
11
- var lexical = require('lexical');
12
10
  var React = require('react');
13
11
 
14
12
  /**
@@ -20,8 +18,9 @@ var React = require('react');
20
18
  *
21
19
  */
22
20
  function LexicalNestedComposer({
23
- initialConfig = {},
24
- children
21
+ initialEditor,
22
+ children,
23
+ initialTheme
25
24
  }) {
26
25
  const parentContext = React.useContext(LexicalComposerContext.LexicalComposerContext);
27
26
 
@@ -31,45 +30,24 @@ function LexicalNestedComposer({
31
30
  }
32
31
  }
33
32
 
34
- const [nestedEditor, setNestedEditor] = React.useState(null);
35
- const {
36
- decoratorEditor
37
- } = initialConfig;
38
- React.useEffect(() => {
39
- if (!decoratorEditor.isEmpty() && nestedEditor !== null) {
40
- decoratorEditor.init(nestedEditor);
41
- } // eslint-disable-next-line react-hooks/exhaustive-deps
42
-
43
- }, [nestedEditor]);
44
33
  const composerContext = React.useMemo(() => {
45
34
  const [parentEditor, parentContextContext] = parentContext;
46
- const composerTheme = initialConfig.theme || parentContextContext.getTheme() || undefined;
35
+ const composerTheme = initialTheme || parentContextContext.getTheme() || undefined;
47
36
  const context = LexicalComposerContext.createLexicalComposerContext(parentContext, composerTheme);
48
- const editor = lexical.createEditor({
49
- context,
50
- namespace: parentEditor._config.namespace,
51
- nodes: Array.from(parentEditor._nodes.values()).map(registeredNode => registeredNode.klass),
52
- onError: parentEditor._onError,
53
- parentEditor,
54
- theme: composerTheme
55
- });
56
- return [editor, context];
37
+
38
+ if (composerTheme !== undefined) {
39
+ initialEditor._config.theme = composerTheme;
40
+ }
41
+
42
+ initialEditor._parentEditor = parentEditor;
43
+ initialEditor._nodes = parentEditor._nodes;
44
+ return [initialEditor, context];
57
45
  }, // We only do this for init
58
46
  // eslint-disable-next-line react-hooks/exhaustive-deps
59
47
  []);
60
- const onChange = React.useCallback((editorState, nextNestedEditor) => {
61
- if (!editorState.isEmpty()) {
62
- decoratorEditor.set(nextNestedEditor);
63
- } else {
64
- setNestedEditor(nextNestedEditor);
65
- }
66
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
67
- []);
68
48
  return /*#__PURE__*/React.createElement(LexicalComposerContext.LexicalComposerContext.Provider, {
69
49
  value: composerContext
70
- }, /*#__PURE__*/React.createElement(LexicalOnChangePlugin, {
71
- onChange: onChange
72
- }), children);
50
+ }, children);
73
51
  }
74
52
 
75
53
  module.exports = LexicalNestedComposer;
@@ -7,12 +7,10 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
- import type {DecoratorEditor, EditorThemeClasses, LexicalNode} from 'lexical';
10
+ import type {LexicalEditor, EditorThemeClasses, LexicalNode} from 'lexical';
11
11
 
12
12
  declare export default function LexicalNestedComposer({
13
- initialConfig: $ReadOnly<{
14
- decoratorEditor: DecoratorEditor,
15
- theme?: EditorThemeClasses,
16
- }>,
17
13
  children: React$Node,
14
+ initialEditor: LexicalEditor,
15
+ initialTheme?: EditorThemeClasses,
18
16
  }): 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
- var a=require("@lexical/react/LexicalComposerContext"),d=require("@lexical/react/LexicalOnChangePlugin"),m=require("lexical"),n=require("react");
8
- module.exports=function({initialConfig:h={},children:p}){const e=n.useContext(a.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #72; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");const [f,q]=n.useState(null),{decoratorEditor:g}=h;n.useEffect(()=>{g.isEmpty()||null===f||g.init(f)},[f]);const t=n.useMemo(()=>{const [b,c]=e,k=h.theme||c.getTheme()||void 0,l=a.createLexicalComposerContext(e,k);return[m.createEditor({context:l,
9
- namespace:b._config.namespace,nodes:Array.from(b._nodes.values()).map(r=>r.klass),onError:b._onError,parentEditor:b,theme:k}),l]},[]),u=n.useCallback((b,c)=>{b.isEmpty()?q(c):g.set(c)},[]);return n.createElement(a.LexicalComposerContext.Provider,{value:t},n.createElement(d,{onChange:u}),p)};
7
+ var b=require("@lexical/react/LexicalComposerContext"),c=require("react");
8
+ module.exports=function({initialEditor:a,children:g,initialTheme:h}){const d=c.useContext(b.LexicalComposerContext);if(null==d)throw Error("Minified Lexical error #72; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");const m=c.useMemo(()=>{const [f,k]=d,e=h||k.getTheme()||void 0,l=b.createLexicalComposerContext(d,e);void 0!==e&&(a._config.theme=e);a._parentEditor=f;a._nodes=f._nodes;return[a,l]},[]);return c.createElement(b.LexicalComposerContext.Provider,
9
+ {value:m},g)};
@@ -9,7 +9,7 @@
9
9
  import type {EditorState} from 'lexical';
10
10
  type InitialEditorStateType = null | string | EditorState | (() => void);
11
11
  export default function PlainTextPlugin(arg0: {
12
- contentEditable: React.ReactNode;
12
+ contentEditable: JSX.Element | null;
13
13
  initialEditorState?: InitialEditorStateType;
14
- placeholder: React.ReactNode;
15
- }): React.ReactNode;
14
+ placeholder: JSX.Element | null;
15
+ }): JSX.Element | null;
@@ -9,7 +9,7 @@
9
9
  import type {EditorState} from 'lexical';
10
10
  type InitialEditorStateType = null | string | EditorState | (() => void);
11
11
  export default function RichTextPlugin(arg0: {
12
- contentEditable: React.ReactNode;
12
+ contentEditable: JSX.Element | null;
13
13
  initialEditorState?: InitialEditorStateType;
14
- placeholder: React.ReactNode;
15
- }): React.ReactNode;
14
+ placeholder: JSX.Element | null;
15
+ }): JSX.Element | null;
@@ -14,4 +14,4 @@ export default function TreeView(props: {
14
14
  timeTravelButtonClassName: string;
15
15
  viewClassName: string;
16
16
  editor: LexicalEditor;
17
- }): React.ReactNode;
17
+ }): JSX.Element | null;
package/package.json CHANGED
@@ -8,26 +8,27 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.1.20",
11
+ "version": "0.2.1",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.1.20",
14
- "@lexical/list": "0.1.20",
15
- "@lexical/table": "0.1.20",
16
- "@lexical/yjs": "0.1.20",
17
- "@lexical/hashtag": "0.1.20",
18
- "@lexical/selection": "0.1.20",
19
- "@lexical/utils": "0.1.20",
20
- "@lexical/dragon": "0.1.20",
21
- "@lexical/plain-text": "0.1.20",
22
- "@lexical/rich-text": "0.1.20",
23
- "@lexical/code": "0.1.20",
24
- "@lexical/text": "0.1.20",
25
- "@lexical/link": "0.1.20",
26
- "@lexical/overflow": "0.1.20",
27
- "@lexical/history": "0.1.20"
13
+ "@lexical/clipboard": "0.2.1",
14
+ "@lexical/list": "0.2.1",
15
+ "@lexical/table": "0.2.1",
16
+ "@lexical/yjs": "0.2.1",
17
+ "@lexical/hashtag": "0.2.1",
18
+ "@lexical/selection": "0.2.1",
19
+ "@lexical/utils": "0.2.1",
20
+ "@lexical/dragon": "0.2.1",
21
+ "@lexical/plain-text": "0.2.1",
22
+ "@lexical/rich-text": "0.2.1",
23
+ "@lexical/code": "0.2.1",
24
+ "@lexical/text": "0.2.1",
25
+ "@lexical/link": "0.2.1",
26
+ "@lexical/overflow": "0.2.1",
27
+ "@lexical/history": "0.2.1",
28
+ "@lexical/markdown": "0.2.1"
28
29
  },
29
30
  "peerDependencies": {
30
- "lexical": "0.1.20",
31
+ "lexical": "0.2.1",
31
32
  "react": ">=17.x",
32
33
  "react-dom": ">=17.x"
33
34
  },
@@ -1,14 +0,0 @@
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
-
9
- import type {DecoratorMap, DecoratorStateValue} from 'lexical';
10
- export default function useLexicalDecoratorMap<V extends DecoratorStateValue>(
11
- decoratorMap: DecoratorMap,
12
- key: string,
13
- initialValue: (() => V) | V,
14
- ): [V, (arg0: DecoratorStateValue) => void];
@@ -1,83 +0,0 @@
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
- const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
21
-
22
- /**
23
- * Copyright (c) Meta Platforms, Inc. and affiliates.
24
- *
25
- * This source code is licensed under the MIT license found in the
26
- * LICENSE file in the root directory of this source tree.
27
- *
28
- *
29
- */
30
- const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
31
- var useLayoutEffect = useLayoutEffectImpl;
32
-
33
- /**
34
- * Copyright (c) Meta Platforms, Inc. and affiliates.
35
- *
36
- * This source code is licensed under the MIT license found in the
37
- * LICENSE file in the root directory of this source tree.
38
- *
39
- *
40
- */
41
-
42
- function getInitialMapValue(decoratorMap, key, initialValue) {
43
- // $FlowFixMe: Flow struggles with the generic
44
- const value = decoratorMap.get(key);
45
-
46
- if (value !== undefined) {
47
- return value;
48
- }
49
-
50
- return typeof initialValue === 'function' ? initialValue() : initialValue;
51
- }
52
-
53
- function useLexicalDecoratorMap(decoratorMap, key, initialValue) {
54
- const [latestValue, setReactValue] = react.useState(() => getInitialMapValue(decoratorMap, key, initialValue));
55
- const [, triggerUpdate] = react.useState();
56
- useLayoutEffect(() => {
57
- const prevValue = decoratorMap.get(key);
58
-
59
- if (prevValue !== latestValue) {
60
- decoratorMap.set(key, latestValue);
61
- }
62
- }, [key, latestValue, decoratorMap]);
63
- useLayoutEffect(() => {
64
- if (lexical.isDecoratorArray(latestValue)) {
65
- return latestValue.observe(() => {
66
- triggerUpdate({});
67
- });
68
- }
69
- }, [latestValue]);
70
- useLayoutEffect(() => {
71
- return decoratorMap.observe((changedKey, value) => {
72
- if (changedKey === key) {
73
- decoratorMap._map.set(changedKey, value);
74
-
75
- setReactValue(value);
76
- }
77
- });
78
- }, [decoratorMap, key]); // $FlowFixMe: needs refining
79
-
80
- return [latestValue, setReactValue];
81
- }
82
-
83
- module.exports = useLexicalDecoratorMap;
@@ -1,9 +0,0 @@
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 useLexicalDecoratorMap = process.env.NODE_ENV === 'development' ? require('./useLexicalDecoratorMap.dev.js') : require('./useLexicalDecoratorMap.prod.js')
9
- module.exports = useLexicalDecoratorMap;
@@ -1,16 +0,0 @@
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 {DecoratorMap, DecoratorStateValue} from 'lexical';
11
-
12
- declare export default function useLexicalDecoratorMap<V: DecoratorStateValue>(
13
- decoratorMap: DecoratorMap,
14
- key: string,
15
- initialValue: (() => V) | V,
16
- ): [V, (DecoratorStateValue) => void];
@@ -1,8 +0,0 @@
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 e=require("lexical"),f=require("react"),l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?f.useLayoutEffect:f.useEffect;
8
- module.exports=function(a,d,g){const [b,h]=f.useState(()=>{var c=a.get(d);c=void 0!==c?c:"function"===typeof g?g():g;return c}),[,m]=f.useState();l(()=>{a.get(d)!==b&&a.set(d,b)},[d,b,a]);l(()=>{if(e.isDecoratorArray(b))return b.observe(()=>{m({})})},[b]);l(()=>a.observe((c,k)=>{c===d&&(a._map.set(c,k),h(k))}),[a,d]);return[b,h]};