Resizable

API reference for @udecode/plate-resizable

Features

  • Resizable elements with handles
  • Configurable min/max width constraints
  • Center/left/right alignment support
  • Width persistence in editor state

Installation

npm install @udecode/plate-resizable

API

useResizableState

Manages state for resizable elements.

Parameters

Collapse all

Returns

Collapse all

    Current alignment setting.

    Maximum width constraint.

    Minimum width constraint.

    Updates node width in editor state.

    Updates width in local state.

    Current width value.

useResizable

Provides resize behavior props and handlers for resizable elements.

Parameters

Collapse all

    State from useResizableState.

Returns

Collapse all

    Style props for the resizable element:

    • maxWidth: Maximum width constraint
    • minWidth: Minimum width constraint
    • position: 'relative'
    • width: Current width

    Style props for the wrapper element:

    • position: 'relative'

    Reference to the wrapper element.

useResizeHandleState

Manages state for resize handle elements.

Parameters

Collapse all

Returns

Collapse all

    Current resize direction.

    Initial cursor/touch position.

    Initial element size.

    Whether resize direction is horizontal.

    Whether resize is in progress.

    Editor read-only state.

    Update initial position.

    Update initial size.

    Update resize state.

    Hover callback.

    Hover end callback.

    Mouse down handler.

    Resize handler.

    Touch start handler.

useResizeHandle

Provides handlers and props for resize handle elements.

Parameters

Collapse all

    State from useResizeHandleState.

Returns

Collapse all

    Whether the handle should be hidden (in read-only mode).

    Props to spread on the handle element:

    • onMouseDown: Mouse down event handler
    • onMouseOut: Mouse out event handler
    • onMouseOver: Mouse over event handler
    • onTouchEnd: Touch end event handler
    • onTouchMove: Touch move event handler
    • onTouchStart: Touch start event handler