,
> {
// Clipboard Events
- onCopy?: DOMHandler;
- onCopyCapture?: DOMHandler
;
- onCut?: DOMHandler
;
- onCutCapture?: DOMHandler
;
- onPaste?: DOMHandler
;
- onPasteCapture?: DOMHandler
;
+ onCopy?: DOMHandler
;
+ onCopyCapture?: DOMHandler
;
+ onCut?: DOMHandler
;
+ onCutCapture?: DOMHandler
;
+ onPaste?: DOMHandler
;
+ onPasteCapture?: DOMHandler
;
// Composition Events
- onCompositionEnd?: DOMHandler
;
- onCompositionEndCapture?: DOMHandler
;
- onCompositionStart?: DOMHandler
;
- onCompositionStartCapture?: DOMHandler
;
- onCompositionUpdate?: DOMHandler
;
- onCompositionUpdateCapture?: DOMHandler
;
+ onCompositionEnd?: DOMHandler
;
+ onCompositionEndCapture?: DOMHandler
;
+ onCompositionStart?: DOMHandler
;
+ onCompositionStartCapture?: DOMHandler
;
+ onCompositionUpdate?: DOMHandler
;
+ onCompositionUpdateCapture?: DOMHandler
;
// Focus Events
- onFocus?: DOMHandler
;
- onFocusCapture?: DOMHandler
;
- onBlur?: DOMHandler
;
- onBlurCapture?: DOMHandler
;
+ onFocus?: DOMHandler
;
+ onFocusCapture?: DOMHandler
;
+ onBlur?: DOMHandler
;
+ onBlurCapture?: DOMHandler
;
// Form Events
onDOMBeforeInput?: DOMHandler
;
- onBeforeInput?: DOMHandler
;
- onBeforeInputCapture?: DOMHandler
;
- onInput?: DOMHandler
;
- onInputCapture?: DOMHandler
;
- onReset?: DOMHandler
;
- onResetCapture?: DOMHandler
;
- onSubmit?: DOMHandler
;
- onSubmitCapture?: DOMHandler
;
- onInvalid?: DOMHandler
;
- onInvalidCapture?: DOMHandler
;
+ onBeforeInput?: DOMHandler
;
+ onBeforeInputCapture?: DOMHandler
;
+ onInput?: DOMHandler
;
+ onInputCapture?: DOMHandler
;
+ onReset?: DOMHandler
;
+ onResetCapture?: DOMHandler
;
+ onSubmit?: DOMHandler
;
+ onSubmitCapture?: DOMHandler
;
+ onInvalid?: DOMHandler
;
+ onInvalidCapture?: DOMHandler
;
// Image Events
- onLoad?: DOMHandler
;
- onLoadCapture?: DOMHandler
;
+ onLoad?: DOMHandler
;
+ onLoadCapture?: DOMHandler
;
// Keyboard Events
- onKeyDown?: DOMHandler
;
- onKeyDownCapture?: DOMHandler
;
- onKeyPress?: DOMHandler
;
- onKeyPressCapture?: DOMHandler
;
- onKeyUp?: DOMHandler
;
- onKeyUpCapture?: DOMHandler
;
+ onKeyDown?: DOMHandler
;
+ onKeyDownCapture?: DOMHandler
;
+ onKeyPress?: DOMHandler
;
+ onKeyPressCapture?: DOMHandler
;
+ onKeyUp?: DOMHandler
;
+ onKeyUpCapture?: DOMHandler
;
// Media Events
- onAbort?: DOMHandler
;
- onAbortCapture?: DOMHandler
;
- onCanPlay?: DOMHandler
;
- onCanPlayCapture?: DOMHandler
;
- onCanPlayThrough?: DOMHandler
;
- onCanPlayThroughCapture?: DOMHandler
;
- onDurationChange?: DOMHandler
;
- onDurationChangeCapture?: DOMHandler
;
- onEmptied?: DOMHandler
;
- onEmptiedCapture?: DOMHandler
;
- onEncrypted?: DOMHandler
;
- onEncryptedCapture?: DOMHandler
;
- onEnded?: DOMHandler
;
- onEndedCapture?: DOMHandler
;
- onLoadedData?: DOMHandler
;
- onLoadedDataCapture?: DOMHandler
;
- onLoadedMetadata?: DOMHandler
;
- onLoadedMetadataCapture?: DOMHandler
;
- onLoadStart?: DOMHandler
;
- onLoadStartCapture?: DOMHandler
;
- onPause?: DOMHandler
;
- onPauseCapture?: DOMHandler
;
- onPlay?: DOMHandler
;
- onPlayCapture?: DOMHandler
;
- onPlaying?: DOMHandler
;
- onPlayingCapture?: DOMHandler
;
- onProgress?: DOMHandler
;
- onProgressCapture?: DOMHandler
;
- onRateChange?: DOMHandler
;
- onRateChangeCapture?: DOMHandler
;
- onSeeked?: DOMHandler
;
- onSeekedCapture?: DOMHandler
;
- onSeeking?: DOMHandler
;
- onSeekingCapture?: DOMHandler
;
- onStalled?: DOMHandler
;
- onStalledCapture?: DOMHandler
;
- onSuspend?: DOMHandler
;
- onSuspendCapture?: DOMHandler
;
- onTimeUpdate?: DOMHandler
;
- onTimeUpdateCapture?: DOMHandler
;
- onVolumeChange?: DOMHandler
;
- onVolumeChangeCapture?: DOMHandler
;
- onWaiting?: DOMHandler
;
- onWaitingCapture?: DOMHandler
;
-
- // MouseEvents
- onAuxClick?: DOMHandler
;
- onAuxClickCapture?: DOMHandler
;
- onClick?: DOMHandler
;
- onClickCapture?: DOMHandler
;
- onContextMenu?: DOMHandler
;
- onContextMenuCapture?: DOMHandler
;
- onDoubleClick?: DOMHandler
;
- onDoubleClickCapture?: DOMHandler
;
- onDrag?: DOMHandler
;
- onDragCapture?: DOMHandler
;
- onDragEnd?: DOMHandler
;
- onDragEndCapture?: DOMHandler
;
- onDragEnter?: DOMHandler
;
- onDragEnterCapture?: DOMHandler
;
- onDragExit?: DOMHandler
;
- onDragExitCapture?: DOMHandler
;
- onDragLeave?: DOMHandler
;
- onDragLeaveCapture?: DOMHandler
;
- onDragOver?: DOMHandler
;
- onDragOverCapture?: DOMHandler
;
- onDragStart?: DOMHandler
;
- onDragStartCapture?: DOMHandler
;
- onDrop?: DOMHandler
;
- onDropCapture?: DOMHandler
;
- onMouseDown?: DOMHandler
;
- onMouseDownCapture?: DOMHandler
;
- onMouseEnter?: DOMHandler
;
- onMouseLeave?: DOMHandler
;
- onMouseMove?: DOMHandler
;
- onMouseMoveCapture?: DOMHandler
;
- onMouseOut?: DOMHandler
;
- onMouseOutCapture?: DOMHandler
;
- onMouseOver?: DOMHandler
;
- onMouseOverCapture?: DOMHandler
;
- onMouseUp?: DOMHandler
;
- onMouseUpCapture?: DOMHandler
;
+ onAbort?: DOMHandler
;
+ onAbortCapture?: DOMHandler
;
+ onCanPlay?: DOMHandler
;
+ onCanPlayCapture?: DOMHandler
;
+ onCanPlayThrough?: DOMHandler
;
+ onCanPlayThroughCapture?: DOMHandler
;
+ onDurationChange?: DOMHandler
;
+ onDurationChangeCapture?: DOMHandler
;
+ onEmptied?: DOMHandler
;
+ onEmptiedCapture?: DOMHandler
;
+ onEncrypted?: DOMHandler
;
+ onEncryptedCapture?: DOMHandler
;
+ onEnded?: DOMHandler
;
+ onEndedCapture?: DOMHandler
;
+ onLoadedData?: DOMHandler
;
+ onLoadedDataCapture?: DOMHandler
;
+ onLoadedMetadata?: DOMHandler
;
+ onLoadedMetadataCapture?: DOMHandler
;
+ onLoadStart?: DOMHandler
;
+ onLoadStartCapture?: DOMHandler
;
+ onPause?: DOMHandler
;
+ onPauseCapture?: DOMHandler
;
+ onPlay?: DOMHandler
;
+ onPlayCapture?: DOMHandler
;
+ onPlaying?: DOMHandler
;
+ onPlayingCapture?: DOMHandler
;
+ onProgress?: DOMHandler
;
+ onProgressCapture?: DOMHandler
;
+ onRateChange?: DOMHandler
;
+ onRateChangeCapture?: DOMHandler
;
+ onSeeked?: DOMHandler
;
+ onSeekedCapture?: DOMHandler
;
+ onSeeking?: DOMHandler
;
+ onSeekingCapture?: DOMHandler
;
+ onStalled?: DOMHandler
;
+ onStalledCapture?: DOMHandler
;
+ onSuspend?: DOMHandler
;
+ onSuspendCapture?: DOMHandler
;
+ onTimeUpdate?: DOMHandler
;
+ onTimeUpdateCapture?: DOMHandler
;
+ onVolumeChange?: DOMHandler
;
+ onVolumeChangeCapture?: DOMHandler
;
+ onWaiting?: DOMHandler
;
+ onWaitingCapture?: DOMHandler
;
+
+ // React.MouseEvents
+ onAuxClick?: DOMHandler
;
+ onAuxClickCapture?: DOMHandler
;
+ onClick?: DOMHandler
;
+ onClickCapture?: DOMHandler
;
+ onContextMenu?: DOMHandler
;
+ onContextMenuCapture?: DOMHandler
;
+ onDoubleClick?: DOMHandler
;
+ onDoubleClickCapture?: DOMHandler
;
+ onDrag?: DOMHandler
;
+ onDragCapture?: DOMHandler
;
+ onDragEnd?: DOMHandler
;
+ onDragEndCapture?: DOMHandler
;
+ onDragEnter?: DOMHandler
;
+ onDragEnterCapture?: DOMHandler
;
+ onDragExit?: DOMHandler
;
+ onDragExitCapture?: DOMHandler
;
+ onDragLeave?: DOMHandler
;
+ onDragLeaveCapture?: DOMHandler
;
+ onDragOver?: DOMHandler
;
+ onDragOverCapture?: DOMHandler
;
+ onDragStart?: DOMHandler
;
+ onDragStartCapture?: DOMHandler
;
+ onDrop?: DOMHandler
;
+ onDropCapture?: DOMHandler
;
+ onMouseDown?: DOMHandler
;
+ onMouseDownCapture?: DOMHandler
;
+ onMouseEnter?: DOMHandler
;
+ onMouseLeave?: DOMHandler
;
+ onMouseMove?: DOMHandler
;
+ onMouseMoveCapture?: DOMHandler
;
+ onMouseOut?: DOMHandler
;
+ onMouseOutCapture?: DOMHandler
;
+ onMouseOver?: DOMHandler
;
+ onMouseOverCapture?: DOMHandler
;
+ onMouseUp?: DOMHandler
;
+ onMouseUpCapture?: DOMHandler
;
// Selection Events
- onSelect?: DOMHandler
;
- onSelectCapture?: DOMHandler
;
+ onSelect?: DOMHandler
;
+ onSelectCapture?: DOMHandler
;
// Touch Events
- onTouchCancel?: DOMHandler
;
- onTouchCancelCapture?: DOMHandler
;
- onTouchEnd?: DOMHandler
;
- onTouchEndCapture?: DOMHandler
;
- onTouchMove?: DOMHandler
;
- onTouchMoveCapture?: DOMHandler
;
- onTouchStart?: DOMHandler
;
- onTouchStartCapture?: DOMHandler
;
+ onTouchCancel?: DOMHandler
;
+ onTouchCancelCapture?: DOMHandler
;
+ onTouchEnd?: DOMHandler
;
+ onTouchEndCapture?: DOMHandler
;
+ onTouchMove?: DOMHandler
;
+ onTouchMoveCapture?: DOMHandler
;
+ onTouchStart?: DOMHandler
;
+ onTouchStartCapture?: DOMHandler
;
// Pointer Events
- onPointerDown?: DOMHandler
;
- onPointerDownCapture?: DOMHandler
;
- onPointerMove?: DOMHandler
;
- onPointerMoveCapture?: DOMHandler
;
- onPointerUp?: DOMHandler
;
- onPointerUpCapture?: DOMHandler
;
- onPointerCancel?: DOMHandler
;
- onPointerCancelCapture?: DOMHandler
;
- onPointerEnter?: DOMHandler
;
- onPointerEnterCapture?: DOMHandler
;
- onPointerLeave?: DOMHandler
;
- onPointerLeaveCapture?: DOMHandler
;
- onPointerOver?: DOMHandler
;
- onPointerOverCapture?: DOMHandler
;
- onPointerOut?: DOMHandler
;
- onPointerOutCapture?: DOMHandler
;
- onGotPointerCapture?: DOMHandler
;
- onGotPointerCaptureCapture?: DOMHandler
;
- onLostPointerCapture?: DOMHandler
;
- onLostPointerCaptureCapture?: DOMHandler
;
+ onPointerDown?: DOMHandler
;
+ onPointerDownCapture?: DOMHandler
;
+ onPointerMove?: DOMHandler
;
+ onPointerMoveCapture?: DOMHandler
;
+ onPointerUp?: DOMHandler
;
+ onPointerUpCapture?: DOMHandler
;
+ onPointerCancel?: DOMHandler
;
+ onPointerCancelCapture?: DOMHandler
;
+ onPointerEnter?: DOMHandler
;
+ onPointerEnterCapture?: DOMHandler
;
+ onPointerLeave?: DOMHandler
;
+ onPointerLeaveCapture?: DOMHandler
;
+ onPointerOver?: DOMHandler
;
+ onPointerOverCapture?: DOMHandler
;
+ onPointerOut?: DOMHandler
;
+ onPointerOutCapture?: DOMHandler
;
+ onGotPointerCapture?: DOMHandler
;
+ onGotPointerCaptureCapture?: DOMHandler
;
+ onLostPointerCapture?: DOMHandler
;
+ onLostPointerCaptureCapture?: DOMHandler
;
// UI Events
- onScroll?: DOMHandler
;
- onScrollCapture?: DOMHandler
;
+ onScroll?: DOMHandler
;
+ onScrollCapture?: DOMHandler
;
// Wheel Events
- onWheel?: DOMHandler
;
- onWheelCapture?: DOMHandler
;
+ onWheel?: DOMHandler
;
+ onWheelCapture?: DOMHandler
;
// Animation Events
- onAnimationStart?: DOMHandler
;
- onAnimationStartCapture?: DOMHandler
;
- onAnimationEnd?: DOMHandler
;
- onAnimationEndCapture?: DOMHandler
;
- onAnimationIteration?: DOMHandler
;
- onAnimationIterationCapture?: DOMHandler
;
+ onAnimationStart?: DOMHandler
;
+ onAnimationStartCapture?: DOMHandler
;
+ onAnimationEnd?: DOMHandler
;
+ onAnimationEndCapture?: DOMHandler
;
+ onAnimationIteration?: DOMHandler
;
+ onAnimationIterationCapture?: DOMHandler
;
// Transition Events
- onTransitionEnd?: DOMHandler
;
- onTransitionEndCapture?: DOMHandler
;
+ onTransitionEnd?: DOMHandler
;
+ onTransitionEndCapture?: DOMHandler
;
}
diff --git a/packages/core/src/types/plugin/InjectProps.ts b/packages/core/src/types/plugin/InjectProps.ts
index a9828bb371..7fc4e39ca8 100644
--- a/packages/core/src/types/plugin/InjectProps.ts
+++ b/packages/core/src/types/plugin/InjectProps.ts
@@ -1,4 +1,4 @@
-import { CSSProperties } from 'react';
+import React from 'react';
import { Value } from '@udecode/slate';
import { AnyObject } from '@udecode/utils';
@@ -47,7 +47,7 @@ export interface InjectProps {
* Style key to override.
* @default nodeKey
*/
- styleKey?: keyof CSSProperties;
+ styleKey?: keyof React.CSSProperties;
/**
* Transform the className.
@@ -73,7 +73,7 @@ export interface InjectProps {
* Transform the style.
* @default { ...style, [styleKey]: value }
*/
- transformStyle?: (options: TransformOptions) => CSSProperties;
+ transformStyle?: (options: TransformOptions) => React.CSSProperties;
/**
* List of supported node values.
diff --git a/packages/core/src/types/plugin/KeyboardHandler.ts b/packages/core/src/types/plugin/KeyboardHandler.ts
index f8c937f7fe..79c0899e46 100644
--- a/packages/core/src/types/plugin/KeyboardHandler.ts
+++ b/packages/core/src/types/plugin/KeyboardHandler.ts
@@ -1,4 +1,4 @@
-import { KeyboardEvent } from 'react';
+import React from 'react';
import { Value } from '@udecode/slate';
import { PlateEditor } from '../PlateEditor';
@@ -9,6 +9,7 @@ export type KeyboardHandler<
P = PluginOptions,
V extends Value = Value,
E extends PlateEditor = PlateEditor,
-> = DOMHandler;
+> = DOMHandler
;
-export type KeyboardHandlerReturnType = DOMHandlerReturnType;
+export type KeyboardHandlerReturnType =
+ DOMHandlerReturnType;
diff --git a/packages/core/src/types/plugin/PlatePlugin.ts b/packages/core/src/types/plugin/PlatePlugin.ts
index fa92318eac..76c9b12a95 100644
--- a/packages/core/src/types/plugin/PlatePlugin.ts
+++ b/packages/core/src/types/plugin/PlatePlugin.ts
@@ -1,4 +1,4 @@
-import { FC, ReactNode } from 'react';
+import React from 'react';
import { Value } from '@udecode/slate';
import { AnyObject, WithRequired } from '@udecode/utils';
@@ -161,15 +161,15 @@ export type PlatePlugin<
/**
* Render a component above `Editable`.
*/
- renderAboveEditable?: FC<{
- children: ReactNode;
+ renderAboveEditable?: React.FC<{
+ children: React.ReactNode;
}>;
/**
* Render a component above `Slate`.
*/
- renderAboveSlate?: FC<{
- children: ReactNode;
+ renderAboveSlate?: React.FC<{
+ children: React.ReactNode;
}>;
/**
diff --git a/packages/core/src/utils/getRenderNodeProps.ts b/packages/core/src/utils/getRenderNodeProps.ts
index 55812a3b48..51cb0718da 100644
--- a/packages/core/src/utils/getRenderNodeProps.ts
+++ b/packages/core/src/utils/getRenderNodeProps.ts
@@ -1,6 +1,6 @@
import { Value } from '@udecode/slate';
import { AnyObject } from '@udecode/utils';
-import clsx from 'clsx';
+import { clsx } from 'clsx';
import { PlateRenderNodeProps } from '../types/PlateRenderNodeProps';
import { WithPlatePlugin } from '../types/plugin/PlatePlugin';
diff --git a/packages/core/src/utils/hotkeys.ts b/packages/core/src/utils/hotkeys.ts
index 996016b56b..b60d998017 100644
--- a/packages/core/src/utils/hotkeys.ts
+++ b/packages/core/src/utils/hotkeys.ts
@@ -1,4 +1,4 @@
-import { KeyboardEvent } from 'react';
+import React from 'react';
import { isComposing, TReactEditor } from '@udecode/slate-react';
import { IS_APPLE } from '@udecode/utils';
import { isKeyHotkey } from 'is-hotkey';
@@ -62,7 +62,7 @@ const create = (key: string) => {
const isApple = apple && isKeyHotkey(apple);
const isWindows = windows && isKeyHotkey(windows);
- return (event: KeyboardEvent) => {
+ return (event: React.KeyboardEvent) => {
if (isGeneric && isGeneric(event)) return true;
if (IS_APPLE && isApple && isApple(event)) return true;
if (!IS_APPLE && isWindows && isWindows(event)) return true;
@@ -74,7 +74,7 @@ const createComposing =
(key: string) =>
(
editor: TReactEditor,
- event: KeyboardEvent,
+ event: React.KeyboardEvent,
{
composing,
}: {
diff --git a/packages/core/src/utils/pipeHandler.ts b/packages/core/src/utils/pipeHandler.ts
index 5d6ff55327..299b6f73fd 100644
--- a/packages/core/src/utils/pipeHandler.ts
+++ b/packages/core/src/utils/pipeHandler.ts
@@ -1,4 +1,4 @@
-import { SyntheticEvent } from 'react';
+import React from 'react';
import { Value } from '@udecode/slate';
import { PlateEditor } from '../types/PlateEditor';
@@ -9,7 +9,7 @@ import { TEditableProps } from '../types/slate-react/TEditableProps';
* Check if an event is overrided by a handler.
*/
export const isEventHandled = <
- EventType extends SyntheticEvent,
+ EventType extends React.SyntheticEvent,
>(
event: EventType,
handler?: (event: EventType) => void | boolean
diff --git a/packages/core/src/utils/pluginInjectProps.ts b/packages/core/src/utils/pluginInjectProps.ts
index e7656e8c92..2f698e4e13 100644
--- a/packages/core/src/utils/pluginInjectProps.ts
+++ b/packages/core/src/utils/pluginInjectProps.ts
@@ -1,7 +1,7 @@
-import { CSSProperties } from 'react';
+import React from 'react';
import { EElement, EText, isElement, Value } from '@udecode/slate';
import { AnyObject, isDefined } from '@udecode/utils';
-import clsx from 'clsx';
+import { clsx } from 'clsx';
import { TransformOptions } from '../types';
import { PlateEditor } from '../types/PlateEditor';
@@ -26,12 +26,12 @@ export interface GetInjectPropsOptions {
/**
* Existing style.
*/
- style?: CSSProperties;
+ style?: React.CSSProperties;
}
export interface GetInjectPropsReturnType extends AnyObject {
className?: string;
- style?: CSSProperties;
+ style?: React.CSSProperties;
}
/**
diff --git a/packages/core/src/utils/pluginRenderElement.tsx b/packages/core/src/utils/pluginRenderElement.tsx
index 2863d1b9cc..9d6a8fe074 100644
--- a/packages/core/src/utils/pluginRenderElement.tsx
+++ b/packages/core/src/utils/pluginRenderElement.tsx
@@ -1,4 +1,4 @@
-import React, { ReactNode } from 'react';
+import React from 'react';
import { Value } from '@udecode/slate';
import { DefaultElement } from 'slate-react';
@@ -47,7 +47,9 @@ export const pluginRenderElement = (
}
});
- let component: ReactNode = {children};
+ let component: React.ReactNode = (
+ {children}
+ );
injectAboveComponents.forEach((withHOC) => {
const hoc = withHOC({ ...nodeProps, key } as any);
diff --git a/packages/core/src/utils/withHOC.spec.tsx b/packages/core/src/utils/withHOC.spec.tsx
index bde3593b50..58334ac51c 100644
--- a/packages/core/src/utils/withHOC.spec.tsx
+++ b/packages/core/src/utils/withHOC.spec.tsx
@@ -1,4 +1,4 @@
-import React, { ReactNode } from 'react';
+import React from 'react';
import { render } from '@testing-library/react';
import { withHOC } from './withHOC';
@@ -8,15 +8,16 @@ describe('withHOC', () => {
type DummyRef = { myRef: string };
type DummyProps = { myProp: string };
- const HOC = React.forwardRef(
- ({ children, ...props }, ref) => (
-
- {JSON.stringify(props)}
- {JSON.stringify(ref)}
- {children}
-
- )
- );
+ const HOC = React.forwardRef<
+ DummyRef,
+ DummyProps & { children: React.ReactNode }
+ >(({ children, ...props }, ref) => (
+
+ {JSON.stringify(props)}
+ {JSON.stringify(ref)}
+ {children}
+
+ ));
const Component = React.forwardRef((props, ref) => (
diff --git a/packages/cursor/src/components/CursorOverlay.tsx b/packages/cursor/src/components/CursorOverlay.tsx
index 84feb4cfe1..f355b66867 100644
--- a/packages/cursor/src/components/CursorOverlay.tsx
+++ b/packages/cursor/src/components/CursorOverlay.tsx
@@ -1,4 +1,4 @@
-import React, { RefObject } from 'react';
+import React from 'react';
import {
ClassNames,
UnknownObject,
@@ -67,7 +67,7 @@ export interface CursorOverlayProps<
* Container the overlay will be rendered in.
* If set, all returned overlay positions will be relative to this container.
*/
- containerRef?: RefObject
;
+ containerRef?: React.RefObject;
/**
* Whether to refresh the cursor overlay positions on container resize.
diff --git a/packages/cursor/src/hooks/useCursorOverlayPositions.ts b/packages/cursor/src/hooks/useCursorOverlayPositions.ts
index 1d68495e0b..7e55da40d1 100644
--- a/packages/cursor/src/hooks/useCursorOverlayPositions.ts
+++ b/packages/cursor/src/hooks/useCursorOverlayPositions.ts
@@ -1,4 +1,4 @@
-import { useCallback, useMemo, useRef, useState } from 'react';
+import React from 'react';
import {
UnknownObject,
useEditorRef,
@@ -23,15 +23,15 @@ export const useCursorOverlayPositions = ({
}: CursorOverlayProps = {}) => {
const editor = useEditorRef();
- const selectionRectCache = useRef>(
+ const selectionRectCache = React.useRef>(
new WeakMap()
);
- const [selectionRects, setSelectionRects] = useState<
+ const [selectionRects, setSelectionRects] = React.useState<
Record
>({});
- const updateSelectionRects = useCallback(() => {
+ const updateSelectionRects = React.useCallback(() => {
// We have a container ref but the ref is null => container
// isn't mounted to we can't calculate the selection rects.
if (!containerRef?.current) return;
@@ -91,7 +91,7 @@ export const useCursorOverlayPositions = ({
updateSelectionRects();
});
- const cursors = useMemo(
+ const cursors = React.useMemo(
() =>
getCursorOverlayState({
selectionRects,
diff --git a/packages/cursor/src/hooks/useRefreshOnResize.ts b/packages/cursor/src/hooks/useRefreshOnResize.ts
index 74f1aebd8d..c8ac3255b5 100644
--- a/packages/cursor/src/hooks/useRefreshOnResize.ts
+++ b/packages/cursor/src/hooks/useRefreshOnResize.ts
@@ -1,24 +1,24 @@
-import { MutableRefObject, useCallback, useEffect } from 'react';
+import React from 'react';
import { Range } from 'slate';
import { CursorOverlayProps } from '../components';
import { SelectionRect } from '../types';
import { useRequestReRender } from './useRequestReRender';
-export interface UseRefreshOnResizeOptions
+export interface useRefreshOnResizeOptions
extends Pick {
- selectionRectCache: MutableRefObject>;
+ selectionRectCache: React.MutableRefObject>;
}
export const useRefreshOnResize = ({
containerRef,
refreshOnResize,
selectionRectCache,
-}: UseRefreshOnResizeOptions) => {
+}: useRefreshOnResizeOptions) => {
const requestReRender = useRequestReRender();
// Reset the selection rect cache and request re-render.
- const refresh = useCallback(
+ const refresh = React.useCallback(
(sync = false) => {
selectionRectCache.current = new WeakMap();
requestReRender(sync);
@@ -27,7 +27,7 @@ export const useRefreshOnResize = ({
);
// Refresh on container resize
- useEffect(() => {
+ React.useEffect(() => {
if (!refreshOnResize || !containerRef?.current) {
return;
}
diff --git a/packages/cursor/src/hooks/useRequestReRender.ts b/packages/cursor/src/hooks/useRequestReRender.ts
index 835e6fc752..ddf9a8ba2b 100644
--- a/packages/cursor/src/hooks/useRequestReRender.ts
+++ b/packages/cursor/src/hooks/useRequestReRender.ts
@@ -1,10 +1,10 @@
-import { useCallback, useEffect, useRef, useState } from 'react';
+import React from 'react';
export const useRequestReRender = () => {
- const [, setUpdateCounter] = useState(0);
- const animationFrameRef = useRef(null);
+ const [, setUpdateCounter] = React.useState(0);
+ const animationFrameRef = React.useRef(null);
- const requestReRender = useCallback((immediate = false) => {
+ const requestReRender = React.useCallback((immediate = false) => {
if (animationFrameRef.current && !immediate) {
return;
}
@@ -25,14 +25,14 @@ export const useRequestReRender = () => {
setUpdateCounter((state) => state + 1);
}, []);
- useEffect(() => {
+ React.useEffect(() => {
if (animationFrameRef.current) {
cancelAnimationFrame(animationFrameRef.current);
animationFrameRef.current = null;
}
});
- useEffect(
+ React.useEffect(
() => () => {
if (animationFrameRef.current) {
cancelAnimationFrame(animationFrameRef.current);
diff --git a/packages/cursor/src/types.ts b/packages/cursor/src/types.ts
index f6850d8983..b992ac85fe 100644
--- a/packages/cursor/src/types.ts
+++ b/packages/cursor/src/types.ts
@@ -1,4 +1,4 @@
-import { CSSProperties } from 'react';
+import React from 'react';
import { UnknownObject } from '@udecode/plate-common';
import { Range } from 'slate';
@@ -30,6 +30,6 @@ export interface CursorOverlayState>
}
export type CursorData = {
- style?: CSSProperties;
- selectionStyle?: CSSProperties;
+ style?: React.CSSProperties;
+ selectionStyle?: React.CSSProperties;
};
diff --git a/packages/dnd/src/components/Scroller/DndScroller.tsx b/packages/dnd/src/components/Scroller/DndScroller.tsx
index bd0bcb0909..640a0ea976 100644
--- a/packages/dnd/src/components/Scroller/DndScroller.tsx
+++ b/packages/dnd/src/components/Scroller/DndScroller.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect } from 'react';
+import React from 'react';
import { dndStore } from '../../dndStore';
import { Scroller, ScrollerProps } from './Scroller';
@@ -7,7 +7,7 @@ export function DndScroller(props: Partial) {
const isDragging = dndStore.use.isDragging();
const [show, setShow] = React.useState(false);
- useEffect(() => {
+ React.useEffect(() => {
if (isDragging) {
const timeout = setTimeout(() => {
setShow(true);
diff --git a/packages/dnd/src/components/Scroller/ScrollArea.tsx b/packages/dnd/src/components/Scroller/ScrollArea.tsx
index 1564a65daa..d873c6afbb 100644
--- a/packages/dnd/src/components/Scroller/ScrollArea.tsx
+++ b/packages/dnd/src/components/Scroller/ScrollArea.tsx
@@ -1,10 +1,4 @@
-import React, {
- CSSProperties,
- HTMLAttributes,
- RefObject,
- useEffect,
- useRef,
-} from 'react';
+import React from 'react';
import throttle from 'lodash/throttle.js';
import raf from 'raf';
@@ -23,8 +17,8 @@ export interface ScrollAreaProps {
zIndex?: number;
minStrength?: number;
strengthMultiplier?: number;
- containerRef?: RefObject;
- scrollAreaProps?: HTMLAttributes;
+ containerRef?: React.RefObject;
+ scrollAreaProps?: React.HTMLAttributes;
}
export function ScrollArea({
@@ -37,16 +31,16 @@ export function ScrollArea({
containerRef,
scrollAreaProps,
}: ScrollAreaProps) {
- const ref = useRef();
+ const ref = React.useRef();
- const scaleYRef = useRef(0);
- const frameRef = useRef(null);
+ const scaleYRef = React.useRef(0);
+ const frameRef = React.useRef(null);
const direction = placement === 'top' ? -1 : 1;
// Drag a fixed, invisible box of custom height at the top, and bottom
// of the window. Make sure to show it only when dragging something.
- const style: CSSProperties = {
+ const style: React.CSSProperties = {
position: 'fixed',
height,
width: '100%',
@@ -122,7 +116,7 @@ export function ScrollArea({
updateScrolling(e);
};
- useEffect(() => {
+ React.useEffect(() => {
if (!enabled) {
stopScrolling();
}
diff --git a/packages/dnd/src/components/useDraggable.ts b/packages/dnd/src/components/useDraggable.ts
index f3a57e6768..a39411a280 100644
--- a/packages/dnd/src/components/useDraggable.ts
+++ b/packages/dnd/src/components/useDraggable.ts
@@ -1,4 +1,4 @@
-import React, { useRef, useState } from 'react';
+import React from 'react';
import { TEditor, TElement } from '@udecode/plate-common';
import { ConnectDragSource, DropTargetMonitor } from 'react-dnd';
@@ -27,8 +27,8 @@ export const useDraggableState = (props: {
}): DraggableState => {
const { element, onDropHandler } = props;
- const nodeRef = useRef(null);
- const [isHovered, setIsHovered] = useState(false);
+ const nodeRef = React.useRef(null);
+ const [isHovered, setIsHovered] = React.useState(false);
const { dropLine, isDragging, dragRef } = useDndBlock({
id: element.id as string,
nodeRef,
diff --git a/packages/dnd/src/components/useWithDraggable.ts b/packages/dnd/src/components/useWithDraggable.ts
index fc1cf5b87d..a3f91db2e7 100644
--- a/packages/dnd/src/components/useWithDraggable.ts
+++ b/packages/dnd/src/components/useWithDraggable.ts
@@ -1,4 +1,4 @@
-import { useMemo } from 'react';
+import React from 'react';
import {
findNodePath,
PlateRenderElementProps,
@@ -36,9 +36,12 @@ export const useWithDraggable = ({
draggableProps,
}: WithDraggableOptions & PlateRenderElementProps) => {
const readOnly = useReadOnly();
- const path = useMemo(() => findNodePath(editor, element), [editor, element]);
+ const path = React.useMemo(
+ () => findNodePath(editor, element),
+ [editor, element]
+ );
- const filteredOut = useMemo(
+ const filteredOut = React.useMemo(
() =>
path &&
((Number.isInteger(level) && level !== path.length - 1) ||
diff --git a/packages/dnd/src/components/withDraggable.tsx b/packages/dnd/src/components/withDraggable.tsx
index 48b8528b77..a70acbaf03 100644
--- a/packages/dnd/src/components/withDraggable.tsx
+++ b/packages/dnd/src/components/withDraggable.tsx
@@ -1,4 +1,4 @@
-import React, { forwardRef } from 'react';
+import React from 'react';
import { AnyObject, PlateRenderElementProps } from '@udecode/plate-common';
import { useWithDraggable, WithDraggableOptions } from './useWithDraggable';
@@ -9,7 +9,7 @@ export const withDraggable = (
options?: WithDraggableOptions
) =>
// eslint-disable-next-line react/display-name
- forwardRef((props, ref) => {
+ React.forwardRef((props, ref) => {
const { disabled, draggableProps } = useWithDraggable({
...options,
...props,
diff --git a/packages/dnd/src/hooks/useDndNode.ts b/packages/dnd/src/hooks/useDndNode.ts
index 01993a8caa..77b173866a 100644
--- a/packages/dnd/src/hooks/useDndNode.ts
+++ b/packages/dnd/src/hooks/useDndNode.ts
@@ -1,4 +1,4 @@
-import { useState } from 'react';
+import React from 'react';
import { TEditor, useEditorRef } from '@udecode/plate-common';
import { DropTargetMonitor } from 'react-dnd';
import { getEmptyImage } from 'react-dnd-html5-backend';
@@ -50,7 +50,7 @@ export const useDndNode = ({
}: UseDndNodeOptions) => {
const editor = useEditorRef();
- const [dropLine, setDropLine] = useState('');
+ const [dropLine, setDropLine] = React.useState('');
const [{ isDragging }, dragRef, preview] = useDragNode(editor, {
id,
diff --git a/packages/emoji/src/utils/EmojiLibrary/EmojiFloatingGrid.ts b/packages/emoji/src/utils/EmojiLibrary/EmojiFloatingGrid.ts
index 0b0512d944..65313eae23 100644
--- a/packages/emoji/src/utils/EmojiLibrary/EmojiFloatingGrid.ts
+++ b/packages/emoji/src/utils/EmojiLibrary/EmojiFloatingGrid.ts
@@ -1,27 +1,27 @@
-import { createRef, RefObject } from 'react';
+import React from 'react';
import { EmojiCategoryList } from '../../types';
import { AGridSection, Grid, IGrid } from '../Grid/index';
export type EmojiFloatingGridType = IGrid<
- RefObject,
+ React.RefObject,
EmojiCategoryList
>;
export class EmojiFloatingGrid extends Grid<
- RefObject,
+ React.RefObject,
EmojiCategoryList
> {
public createRootRef() {
- return createRef();
+ return React.createRef();
}
}
export class EmojiGridSectionWithRoot extends AGridSection<
- RefObject,
+ React.RefObject,
EmojiCategoryList
> {
protected createRootRef() {
- this._root = createRef();
+ this._root = React.createRef();
}
}
diff --git a/packages/emoji/src/utils/EmojiObserver.ts b/packages/emoji/src/utils/EmojiObserver.ts
index 7e2a8ad484..793cc5f288 100644
--- a/packages/emoji/src/utils/EmojiObserver.ts
+++ b/packages/emoji/src/utils/EmojiObserver.ts
@@ -1,4 +1,4 @@
-import { MutableRefObject } from 'react';
+import React from 'react';
import { EmojiCategoryList } from '../types';
import { IEmojiFloatingLibrary } from './EmojiLibrary/index';
@@ -30,7 +30,7 @@ export type SetFocusedAndVisibleSectionsType = (
) => void;
export type ObserverCategoriesType = {
- ancestorRef: MutableRefObject;
+ ancestorRef: React.MutableRefObject;
emojiLibrary: IEmojiFloatingLibrary;
setFocusedAndVisibleSections: SetFocusedAndVisibleSectionsType;
};
diff --git a/packages/emoji/src/utils/EmojiPicker/EmojiPickerState.ts b/packages/emoji/src/utils/EmojiPicker/EmojiPickerState.ts
index e731398cee..10858473c0 100644
--- a/packages/emoji/src/utils/EmojiPicker/EmojiPickerState.ts
+++ b/packages/emoji/src/utils/EmojiPicker/EmojiPickerState.ts
@@ -1,4 +1,4 @@
-import { Dispatch, Reducer, useReducer } from 'react';
+import React from 'react';
import { EmojiCategory, EmojiCategoryList } from '../../types';
import { Emoji } from '../EmojiLibrary/index';
@@ -36,10 +36,10 @@ const initialState: EmojiPickerStateProps = {
export const EmojiPickerState = (): [
EmojiPickerStateProps,
- Dispatch