Skip to content

Commit

Permalink
Add converted TypeScript definitions (facebook#1378)
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm authored and acywatson committed Apr 9, 2022
1 parent 9bacffd commit 06f4602
Show file tree
Hide file tree
Showing 37 changed files with 1,458 additions and 11 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
packages/**/dist/*.js
packages/**/config/*.js
packages/**/*.js.flow
packages/**/*.d.ts
packages/playwright
packages/playwright-core
packages/babel-plugin-transform-stylex
Expand Down
9 changes: 9 additions & 0 deletions packages/lexical-react/LexicalAutoFormatterPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

export default function LexicalAutoFormatterPlugin(): React.ReactNode;
20 changes: 20 additions & 0 deletions packages/lexical-react/LexicalAutoLinkPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

type ChangeHandler = (url: string | null, prevUrl: string | null) => void;
type LinkMatcherResult = {
text: string;
url: string;
length: number;
index: number;
};
export type LinkMatcher = (text: string) => LinkMatcherResult | null;
export default function LexicalAutoLinkPlugin(props: {
matchers: Array<LinkMatcher>;
onChange?: ChangeHandler;
}): React.ReactNode;
11 changes: 11 additions & 0 deletions packages/lexical-react/LexicalCharacterLimitPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

export default function LexicalCharacterLimitPlugin(props: {
charset: 'UTF-8' | 'UTF-16';
}): React.ReactNode;
14 changes: 14 additions & 0 deletions packages/lexical-react/LexicalClearEditorPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
*/

import {$ReadOnly} from 'utility-types';
type Props = $ReadOnly<{
onClear?: () => void;
}>;
export default function LexicalClearEditorPlugin(arg0: Props): React.ReactNode;
49 changes: 49 additions & 0 deletions packages/lexical-react/LexicalCollaborationPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import type {Doc, RelativePosition} from 'yjs';
export type UserState = {
anchorPos: null | RelativePosition;
focusPos: null | RelativePosition;
name: string;
color: string;
focusing: boolean;
};
export type ProviderAwareness = {
getLocalState: () => UserState;
setLocalState: (arg0: UserState) => void;
getStates: () => Array<UserState>;
on: (type: 'update', cb: () => void) => void;
off: (type: 'update', cb: () => void) => void;
};
export interface Provider {
connect(): void | Promise<void>;
disconnect(): void;
awareness: ProviderAwareness;
on(type: 'sync', cb: (isSynced: boolean) => void): void;
on(type: 'status', cb: (arg0: {status: string}) => void): void;
// $FlowFixMe: temp
on(type: 'update', cb: (arg0: any) => void): void;
off(type: 'sync', cb: (isSynced: boolean) => void): void;
// $FlowFixMe: temp
off(type: 'update', cb: (arg0: any) => void): void;
off(type: 'status', cb: (arg0: {status: string}) => void): void;
}
type CollaborationContextType = {
clientID: number;
color: string;
name: string;
yjsDocMap: Map<string, Doc>;
};
export function CollaborationPlugin(arg0: {
id: string;
providerFactory: (id: string, yjsDocMap: Map<string, Doc>) => Provider;
shouldBootstrap: boolean;
}): React.ReactNode;
export declare var CollaborationContext: React.Context<CollaborationContextType>;
export function useCollaborationContext(): CollaborationContextType;
22 changes: 22 additions & 0 deletions packages/lexical-react/LexicalComposer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import {Class} from 'utility-types';
import type {EditorThemeClasses, LexicalEditor, LexicalNode} from 'lexical';
type Props = {
initialConfig?: {
editor?: LexicalEditor | null;
isReadOnly?: boolean;
namespace?: string;
nodes?: Array<Class<LexicalNode>>;
theme?: EditorThemeClasses;
onError?: (arg0: Error) => void;
};
children: React.ReactNode;
};
export default function LexicalComposer(arg0: Props): React.ReactNode;
24 changes: 24 additions & 0 deletions packages/lexical-react/LexicalComposerContext.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import type {EditorThemeClasses, LexicalEditor} from 'lexical';
export type LexicalComposerContextType = {
getTheme: () => EditorThemeClasses | null | undefined;
};
export type LexicalComposerContextWithEditor = [
LexicalEditor,
LexicalComposerContextType,
];
export declare var LexicalComposerContext: React.Context<
LexicalComposerContextWithEditor | null | undefined
>;
export function createLexicalComposerContext(
parent: LexicalComposerContextWithEditor | null | undefined,
theme: EditorThemeClasses | null | undefined,
): LexicalComposerContextType;
export function useLexicalComposerContext(): LexicalComposerContextWithEditor;
32 changes: 32 additions & 0 deletions packages/lexical-react/LexicalContentEditable.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import {$ReadOnly} from 'utility-types';
export type Props = $ReadOnly<{
ariaActiveDescendantID?: string;
ariaAutoComplete?: string;
ariaControls?: string;
ariaDescribedBy?: string;
ariaExpanded?: boolean;
ariaLabel?: string;
ariaLabelledBy?: string;
ariaMultiline?: boolean;
ariaOwneeID?: string;
ariaRequired?: string;
autoCapitalize?: boolean;
autoComplete?: boolean;
autoCorrect?: boolean;
className?: string;
readOnly?: boolean;
role?: string;
style?: StyleSheetList;
spellCheck?: boolean;
tabIndex?: number;
testid?: string;
}>;
export default function LexicalContentEditable(props: Props): React.ReactNode;
9 changes: 9 additions & 0 deletions packages/lexical-react/LexicalHashtagPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

export default function LexicalHashtagPlugin(): React.ReactNode;
29 changes: 29 additions & 0 deletions packages/lexical-react/LexicalHistoryPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import type {
EditorState,
GridSelection,
LexicalEditor,
NodeSelection,
RangeSelection,
} from 'lexical';
export type HistoryStateEntry = {
editor: LexicalEditor;
editorState: EditorState;
undoSelection?: RangeSelection | NodeSelection | GridSelection | null;
};
export type HistoryState = {
current: null | HistoryStateEntry;
redoStack: Array<HistoryStateEntry>;
undoStack: Array<HistoryStateEntry>;
};
export function HistoryPlugin(arg0: {
externalHistoryState?: HistoryState;
}): React.ReactNode;
export function createEmptyHistoryState(): HistoryState;
23 changes: 23 additions & 0 deletions packages/lexical-react/LexicalHorizontalRuleNode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import type {LexicalNode} from 'lexical';
import {DecoratorNode} from 'lexical';
export declare class HorizontalRuleNode extends DecoratorNode<React.ReactNode> {
getType(): string;
clone(node: HorizontalRuleNode): HorizontalRuleNode;
createDOM(): HTMLElement;
getTextContent(): '\n';
isTopLevel(): true;
updateDOM(): false;
decorate(): React.ReactNode;
}
export function $createHorizontalRuleNode(): HorizontalRuleNode;
export function $isHorizontalRuleNode(
node: LexicalNode | null | undefined,
): boolean;
9 changes: 9 additions & 0 deletions packages/lexical-react/LexicalLinkPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

export default function LexicalLinkPlugin(): null;
9 changes: 9 additions & 0 deletions packages/lexical-react/LexicalListPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

export default function ListPlugin(): null;
20 changes: 20 additions & 0 deletions packages/lexical-react/LexicalNestedComposer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import {Class} from 'utility-types';
import type {DecoratorEditor, EditorThemeClasses, LexicalNode} from 'lexical';
export default function LexicalNestedComposer(arg0: {
initialConfig?: {
namespace?: string;
decoratorEditor: DecoratorEditor;
nodes?: Array<Class<LexicalNode>>;
theme?: EditorThemeClasses;
onError?: (arg0: Error) => void;
};
children?: React.ReactNode;
}): React.ReactNode;
12 changes: 12 additions & 0 deletions packages/lexical-react/LexicalOnChangePlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import type {EditorState, LexicalEditor} from 'lexical';
export default function OnChangePlugin(arg0: {
onChange: (editorState: EditorState, editor: LexicalEditor) => void;
}): null;
15 changes: 15 additions & 0 deletions packages/lexical-react/LexicalPlainTextPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import type {EditorState} from 'lexical';
type InitialEditorStateType = null | string | EditorState | (() => void);
export default function PlainTextPlugin(arg0: {
contentEditable: React.ReactNode;
initialEditorState?: InitialEditorStateType;
placeholder: React.ReactNode;
}): React.ReactNode;
15 changes: 15 additions & 0 deletions packages/lexical-react/LexicalRichTextPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import type {EditorState} from 'lexical';
type InitialEditorStateType = null | string | EditorState | (() => void);
export default function RichTextPlugin(arg0: {
contentEditable: React.ReactNode;
initialEditorState?: InitialEditorStateType;
placeholder: React.ReactNode;
}): React.ReactNode;
9 changes: 9 additions & 0 deletions packages/lexical-react/LexicalTablePlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

export default function LexicalTablePlugin(): null;
17 changes: 17 additions & 0 deletions packages/lexical-react/LexicalTreeView.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import type {LexicalEditor} from 'lexical';
export default function TreeView(props: {
timeTravelPanelClassName: string;
timeTravelPanelSliderClassName: string;
timeTravelPanelButtonClassName: string;
timeTravelButtonClassName: string;
viewClassName: string;
editor: LexicalEditor;
}): React.ReactNode;
11 changes: 0 additions & 11 deletions packages/lexical-react/flow/LexicalHashtagPlugin.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,4 @@
* @flow strict
*/

import type {LexicalEditor, TextNode} from 'lexical';

declare function getHashtagRegexStringChars(): $ReadOnly<{
alpha: string,
alphanumeric: string,
hashChars: string,
}>;

declare function getHashtagRegexString(): string;
declare function textNodeTransform(node: TextNode): void;
declare function useHashtags(editor: LexicalEditor): void;
declare export default function LexicalHashtagPlugin(): React$Node;
Loading

0 comments on commit 06f4602

Please sign in to comment.