Remove remaining deprecated hooks (#3782)

This commit is contained in:
John Flockton
2023-03-06 20:20:24 +00:00
committed by GitHub
parent f161f677ac
commit 8033d76969
17 changed files with 1 additions and 350 deletions

View File

@ -40,13 +40,6 @@ module.name_mapper='^@lexical/overflow' -> '<PROJECT_ROOT>/packages/lexical-over
module.name_mapper='^@lexical/markdown' -> '<PROJECT_ROOT>/packages/lexical-markdown/flow/LexicalMarkdown.js.flow'
module.name_mapper='^@lexical/mark' -> '<PROJECT_ROOT>/packages/lexical-mark/flow/LexicalMark.js.flow'
module.name_mapper='^@lexical/react/DEPRECATED_useLexicalEditor' -> '<PROJECT_ROOT>/packages/lexical-react/flow/DEPRECATED_useLexicalEditor.js.flow'
module.name_mapper='^@lexical/react/DEPRECATED_useLexicalRichText' -> '<PROJECT_ROOT>/packages/lexical-react/flow/DEPRECATED_useLexicalRichText.js.flow'
module.name_mapper='^@lexical/react/DEPRECATED_useLexicalPlainText' -> '<PROJECT_ROOT>/packages/lexical-react/flow/DEPRECATED_useLexicalPlainText.js.flow'
module.name_mapper='^@lexical/react/DEPRECATED_useLexicalCanShowPlaceholder' -> '<PROJECT_ROOT>/packages/lexical-react/flow/DEPRECATED_useLexicalCanShowPlaceholder.js.flow'
module.name_mapper='^@lexical/react/DEPRECATED_useLexicalCharacterLimit' -> '<PROJECT_ROOT>/packages/lexical-react/flow/DEPRECATED_useLexicalCharacterLimit.js.flow'
module.name_mapper='^@lexical/react/DEPRECATED_useLexicalHistory' -> '<PROJECT_ROOT>/packages/lexical-react/flow/DEPRECATED_useLexicalHistory.js.flow'
module.name_mapper='^@lexical/react/LexicalComposer' -> '<PROJECT_ROOT>/packages/lexical-react/flow/LexicalComposer.js.flow'
module.name_mapper='^@lexical/react/LexicalComposerContext' -> '<PROJECT_ROOT>/packages/lexical-react/flow/LexicalComposerContext.js.flow'
module.name_mapper='^@lexical/react/LexicalNestedComposer' -> '<PROJECT_ROOT>/packages/lexical-react/flow/LexicalNestedComposer.js.flow'

View File

@ -46,8 +46,7 @@ module.exports = {
'<rootDir>/packages/lexical-overflow/src/index.ts',
'^@lexical/plain-text$':
'<rootDir>/packages/lexical-plain-text/src/index.ts',
'^@lexical/react/DEPRECATED_useLexicalRichText$':
'<rootDir>/packages/lexical-react/src/DEPRECATED_useLexicalRichText.ts',
'^@lexical/react/LexicalAutoEmbedPlugin$':
'<rootDir>/packages/lexical-react/src/LexicalAutoEmbedPlugin.tsx',
'^@lexical/react/LexicalAutoLinkPlugin$':

View File

@ -1,25 +0,0 @@
/**
* 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
* @format
*/
import type {
EditorState,
EditorThemeClasses,
LexicalEditor,
LexicalNode,
} from 'lexical';
declare export function useLexical<EditorContext>(editorConfig?: {
namespace?: string,
onError: (error: Error) => void,
theme?: EditorThemeClasses,
context?: EditorContext,
nodes?: Array<Class<LexicalNode>>,
parentEditor?: LexicalEditor,
}): [LexicalEditor, (null | HTMLElement) => void, boolean];

View File

@ -1,15 +0,0 @@
/**
* 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
* @format
*/
import type {LexicalEditor} from 'lexical';
declare export function useLexicalCanShowPlaceholder(
editor: LexicalEditor,
): boolean;

View File

@ -1,31 +0,0 @@
/**
* 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
* @format
*/
import type {LexicalEditor, LexicalNode} from 'lexical';
import type {OverflowNode} from '@lexical/overflow';
type OptionalProps = {
strlen?: (input: string) => number,
remainingCharacters?: (characters: number) => void,
};
declare export function useCharacterLimit(
editor: LexicalEditor,
maxCharacters: number,
optional: OptionalProps,
): void;
declare function findOffset(
text: string,
maxCharacters: number,
strlen: (input: string) => number,
): number;
declare function $wrapOverflowedNodes(offset: number): void;
declare function $wrapNode(node: LexicalNode): OverflowNode;
declare function $unwrapNode(node: OverflowNode): LexicalNode | null;
declare export function mergePrevious(overflowNode: OverflowNode): void;

View File

@ -1,34 +0,0 @@
/**
* 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
* @format
*/
import type {
EditorState,
GridSelection,
LexicalEditor,
NodeSelection,
RangeSelection,
} from 'lexical';
type HistoryStateEntry = {
editor: LexicalEditor,
editorState: EditorState,
undoSelection?: RangeSelection | NodeSelection | GridSelection | null,
};
export type HistoryState = {
current: null | HistoryStateEntry,
redoStack: Array<HistoryStateEntry>,
undoStack: Array<HistoryStateEntry>,
};
declare export function useLexicalHistory(
editor: LexicalEditor,
externalHistoryState?: HistoryState,
delay?: number,
): () => void;
declare export function createEmptyHistoryState(): HistoryState;

View File

@ -1,17 +0,0 @@
/**
* 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
* @format
*/
import type {HistoryState} from '@lexical/react/DEPRECATED_useLexicalHistory';
import type {EditorState, LexicalEditor} from 'lexical';
declare export function useLexicalPlainText(
editor: LexicalEditor,
externalHistoryState?: HistoryState,
): void;

View File

@ -1,17 +0,0 @@
/**
* 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
* @format
*/
import type {HistoryState} from '@lexical/react/DEPRECATED_useLexicalHistory';
import type {EditorState, LexicalEditor} from 'lexical';
declare export function useLexicalRichText(
editor: LexicalEditor,
externalHistoryState?: HistoryState,
): void;

View File

@ -1,41 +0,0 @@
/**
* 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,
EditorThemeClasses,
Klass,
LexicalEditor,
LexicalNode,
} from 'lexical';
import {createEditor} from 'lexical';
import {useMemo} from 'react';
import {useLexicalEditor} from './DEPRECATED_useLexicalEditor';
export function useLexical(editorConfig: {
disableEvents?: boolean;
editorState?: EditorState;
namespace: string;
nodes?: ReadonlyArray<Klass<LexicalNode>>;
onError: (error: Error) => void;
parentEditor?: LexicalEditor;
readOnly?: boolean;
theme?: EditorThemeClasses;
}): [LexicalEditor, (arg0: null | HTMLElement) => void, boolean] {
const editor = useMemo(
() => createEditor(editorConfig), // Init
// eslint-disable-next-line react-hooks/exhaustive-deps
[],
);
const [rootElementRef, showPlaceholder] = useLexicalEditor(editor);
return [editor, rootElementRef, showPlaceholder];
}

View File

@ -1,15 +0,0 @@
/**
* 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';
import {useCanShowPlaceholder} from './shared/useCanShowPlaceholder';
export function useLexicalCanShowPlaceholder(editor: LexicalEditor): boolean {
return useCanShowPlaceholder(editor);
}

View File

@ -1,9 +0,0 @@
/**
* 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 {mergePrevious, useCharacterLimit} from './shared/useCharacterLimit';

View File

@ -1,28 +0,0 @@
/**
* 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';
import {useCallback} from 'react';
import {useLexicalCanShowPlaceholder} from './DEPRECATED_useLexicalCanShowPlaceholder';
export function useLexicalEditor(
editor: LexicalEditor,
): [(rootElement: null | HTMLElement) => void, boolean] {
const showPlaceholder = useLexicalCanShowPlaceholder(editor);
const rootElementRef = useCallback(
(rootElement: null | HTMLElement) => {
editor.setRootElement(rootElement);
},
[editor],
);
return [rootElementRef, showPlaceholder];
}

View File

@ -1,24 +0,0 @@
/**
* 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 {HistoryState} from '@lexical/history';
import type {LexicalEditor} from 'lexical';
import {useHistory} from './shared/useHistory';
export {createEmptyHistoryState} from '@lexical/history';
export type {HistoryState};
export function useLexicalHistory(
editor: LexicalEditor,
externalHistoryState?: HistoryState,
delay = 1000,
): void {
return useHistory(editor, externalHistoryState, delay);
}

View File

@ -1,21 +0,0 @@
/**
* 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 {HistoryState} from './DEPRECATED_useLexicalHistory';
import type {LexicalEditor} from 'lexical';
import {useLexicalHistory} from './DEPRECATED_useLexicalHistory';
import {usePlainTextSetup} from './shared/usePlainTextSetup';
export function useLexicalPlainText(
editor: LexicalEditor,
externalHistoryState?: HistoryState,
): void {
usePlainTextSetup(editor);
useLexicalHistory(editor, externalHistoryState);
}

View File

@ -1,21 +0,0 @@
/**
* 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 {HistoryState} from './DEPRECATED_useLexicalHistory';
import type {LexicalEditor} from 'lexical';
import {useLexicalHistory} from './DEPRECATED_useLexicalHistory';
import {useRichTextSetup} from './shared/useRichTextSetup';
export function useLexicalRichText(
editor: LexicalEditor,
externalHistoryState?: HistoryState,
): void {
useRichTextSetup(editor);
useLexicalHistory(editor, externalHistoryState);
}

View File

@ -37,30 +37,6 @@ glob('packages/**/flow/*.flow', options, function (error1, files) {
.replace(/from 'lexical'/g, "from 'Lexical'")
.replace(/from 'lexical'/g, "from 'Lexical'")
.replace(/from 'lexical\/LinkNode'/g, "from 'LexicalLinkNode'")
.replace(
/from '@lexical\/react\/DEPRECATED_useLexicalEditor'/g,
"from 'DEPRECATED_useLexicalEditor'",
)
.replace(
/from '@lexical\/react\/DEPRECATED_useLexicalRichText'/g,
"from 'DEPRECATED_useLexicalRichText'",
)
.replace(
/from '@lexical\/react\/DEPRECATED_useLexicalPlainText'/g,
"from 'DEPRECATED_useLexicalPlainText'",
)
.replace(
/from '@lexical\/react\/DEPRECATED_useLexicalCanShowPlaceholder'/g,
"from 'DEPRECATED_useLexicalCanShowPlaceholder'",
)
.replace(
/from '@lexical\/react\/DEPRECATED_useLexicalCharacterLimit'/g,
"from 'DEPRECATED_useLexicalCharacterLimit'",
)
.replace(
/from '@lexical\/react\/DEPRECATED_useLexicalHistory'/g,
"from 'DEPRECATED_useLexicalHistory'",
)
.replace(/from '@lexical\/react\/Lexical/g, "from 'Lexical")
.replace(/from '@lexical\/utils\/'/g, "from 'LexicalUtils")
.replace(/from '@lexical\/clipboard\'/g, "from 'LexicalClipboard'")

View File

@ -36,25 +36,6 @@
"@lexical/markdown": ["./packages/lexical-markdown/src/"],
"@lexical/mark": ["./packages/lexical-mark/src/"],
"@lexical/react/DEPRECATED_useLexicalEditor": [
"./packages/lexical-react/src/DEPRECATED_useLexicalEditor.ts"
],
"@lexical/react/DEPRECATED_useLexicalRichText": [
"./packages/lexical-react/src/DEPRECATED_useLexicalRichText.ts"
],
"@lexical/react/DEPRECATED_useLexicalPlainText": [
"./packages/lexical-react/src/DEPRECATED_useLexicalPlainText.ts"
],
"@lexical/react/DEPRECATED_useLexicalCanShowPlaceholder": [
"./packages/lexical-react/src/DEPRECATED_useLexicalCanShowPlaceholder.ts"
],
"@lexical/react/DEPRECATED_useLexicalCharacterLimit": [
"./packages/lexical-react/src/DEPRECATED_useLexicalCharacterLimit.ts"
],
"@lexical/react/DEPRECATED_useLexicalHistory": [
"./packages/lexical-react/src/DEPRECATED_useLexicalHistory.ts"
],
"@lexical/react/LexicalComposer": [
"./packages/lexical-react/src/LexicalComposer.tsx"
],