Skip to content

Commit

Permalink
Export Klass from Lexical root (facebook#2533)
Browse files Browse the repository at this point in the history
  • Loading branch information
thegreatercurve authored Jun 27, 2022
1 parent 98a0505 commit ec9134c
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 30 deletions.
2 changes: 1 addition & 1 deletion packages/lexical-headless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import type {
EditorState,
EditorThemeClasses,
Klass,
LexicalEditor,
LexicalNode,
} from 'lexical';
import type {Klass} from 'shared/types';

import {createEditor} from 'lexical';

Expand Down
3 changes: 1 addition & 2 deletions packages/lexical-playground/src/nodes/PlaygroundNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
*
*/

import type {LexicalNode} from 'lexical';
import type {Klass} from 'shared/types';
import type {Klass, LexicalNode} from 'lexical';

import {CodeHighlightNode, CodeNode} from '@lexical/code';
import {HashtagNode} from '@lexical/hashtag';
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-react/src/DEPRECATED_useLexical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import type {
EditorState,
EditorThemeClasses,
Klass,
LexicalEditor,
LexicalNode,
} from 'lexical';
import type {Klass} from 'shared/types';

import {createEditor} from 'lexical';
import {useMemo} from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-react/src/LexicalComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import type {LexicalComposerContextType} from '@lexical/react/LexicalComposerContext';
import type {Klass} from 'lexical';

import {
createLexicalComposerContext,
Expand All @@ -22,7 +23,6 @@ import {
} from 'lexical';
import {useMemo} from 'react';
import * as React from 'react';
import {Klass} from 'shared/types';
import useLayoutEffect from 'shared/useLayoutEffect';

const HISTORY_MERGE_OPTIONS = {tag: 'history-merge'};
Expand Down
3 changes: 1 addition & 2 deletions packages/lexical-react/src/useLexicalTextEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
*/

import type {EntityMatch} from '@lexical/text';
import type {TextNode} from 'lexical';
import type {Klass, TextNode} from 'lexical';

import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
import {registerLexicalTextEntity} from '@lexical/text';
import {mergeRegister} from '@lexical/utils';
import {useEffect} from 'react';
import {Klass} from 'shared/types';

export function useLexicalTextEntity<T extends TextNode>(
getMatch: (text: string) => null | EntityMatch,
Expand Down
9 changes: 7 additions & 2 deletions packages/lexical-text/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
*
*/

import type {ElementNode, LexicalEditor, LexicalNode, RootNode} from 'lexical';
import type {Klass} from 'shared/types';
import type {
ElementNode,
Klass,
LexicalEditor,
LexicalNode,
RootNode,
} from 'lexical';

import {
$createTextNode,
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import type {
EditorState,
ElementNode,
Klass,
LexicalEditor,
LexicalNode,
NodeKey,
} from 'lexical';
import type {Klass} from 'shared/types';

import {
$getRoot,
Expand Down
6 changes: 5 additions & 1 deletion packages/lexical/src/LexicalEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import type {EditorState, SerializedEditorState} from './LexicalEditorState';
import type {DOMConversion, LexicalNode, NodeKey} from './LexicalNode';
import type {Klass} from 'shared/types';

import getDOMSelection from 'shared/getDOMSelection';
import invariant from 'shared/invariant';
Expand All @@ -33,6 +32,11 @@ import {RootNode} from './nodes/LexicalRootNode';

export type Spread<T1, T2> = Omit<T2, keyof T1> & T1;

export type Klass<T extends LexicalNode> = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
new (...args: any[]): T;
} & Omit<LexicalNode, 'constructor'>;

export type EditorThemeClassName = string;

export type TextNodeThemeClasses = {
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical/src/LexicalNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* eslint-disable no-constant-condition */
import type {EditorConfig, LexicalEditor} from './LexicalEditor';
import type {RangeSelection} from './LexicalSelection';
import type {Klass} from 'shared/types';
import type {Klass} from 'lexical';

import invariant from 'shared/invariant';

Expand Down
2 changes: 1 addition & 1 deletion packages/lexical/src/LexicalUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import type {
EditorThemeClasses,
IntentionallyMarkedAsDirtyElement,
Klass,
LexicalCommand,
MutatedNodes,
MutationListeners,
Expand All @@ -26,7 +27,6 @@ import type {
} from './LexicalSelection';
import type {RootNode} from './nodes/LexicalRootNode';
import type {TextFormatType, TextNode} from './nodes/LexicalTextNode';
import type {Klass} from 'shared/types';

import {IS_APPLE, IS_IOS, IS_SAFARI} from 'shared/environment';
import getDOMSelection from 'shared/getDOMSelection';
Expand Down
1 change: 1 addition & 0 deletions packages/lexical/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type {
EditorConfig,
EditorThemeClasses,
IntentionallyMarkedAsDirtyElement,
Klass,
LexicalCommand,
LexicalEditor,
NodeMutation,
Expand Down
15 changes: 0 additions & 15 deletions packages/shared/types.d.ts

This file was deleted.

3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@
"shared/invariant": ["./packages/shared/src/invariant.ts"],
"shared/warnOnlyOnce": ["./packages/shared/src/warnOnlyOnce.ts"],
"shared/environment": ["./packages/shared/src/environment.ts"],
"shared/useLayoutEffect": ["./packages/shared/src/useLayoutEffect.ts"],
"shared/types": ["./packages/shared/src/types.d.ts"]
"shared/useLayoutEffect": ["./packages/shared/src/useLayoutEffect.ts"]
}
},
"include": ["./libdefs", "./packages"],
Expand Down

0 comments on commit ec9134c

Please sign in to comment.