@elementor/editor-floating-panels

中文文档
4.4.1发布于 2026/11/16GPL-3.0-or-laterTypeScriptESM + CJS构建来源已验证近 30 天下载 7562

A generic floating panel framework for the Elementor Editor that provides the primitives for rendering panels on the canvas. The panels can be dragged and resized freely within the viewport, independent of any specific feature concern.

原始使用文档
文档目录6 节
  1. Usage
  2. isDraggable
  3. isResizable
  4. isDocked
  5. keepMounted
  6. defaults

Editor Floating Panels

A generic floating panel framework for the Elementor Editor that provides the primitives for rendering panels on the canvas. The panels can be dragged and resized freely within the viewport, independent of any specific feature concern.

The panes are persisted and survive reloads. The state stores open/closed, position, size, and z-index in localStorage.

Usage

import {
    createFloatingPanel,
    init,
    registerFloatingPanel,

    FloatingPanelBody,
    FloatingPanelFooter,
    FloatingPanelHeader,
} from '@elementor/editor-floating-panels';

init();

const myPanel = createFloatingPanel( {
    id: 'my-panel',
    title: 'My Panel',
    icon: MyIcon,
    component: MyPanelComponent,
    isDraggable: true,
    isResizable: true,
    defaults: {
        width: 320,
        height: 480,
        minWidth: 240,
        minHeight: 320,
        corner: 'block-start-inline-start',
        initialPosition: {
            insetBlockStart: 80,
            insetInlineStart: 200
        },
    },
} );

registerFloatingPanel( myPanel.panel );

function MyPanelComponent() {
    return (
        <>
            <FloatingPanelHeader
                panelId="my-panel"
                title="My Panel"
                actions={ [ /* ... */ ] }
            />
            <FloatingPanelBody>
                { /* ... */ }
            </FloatingPanelBody>
            <FloatingPanelFooter>
                { /* ... */ }
            </FloatingPanelFooter>
        </>
    );
}

isDraggable

When isDraggable is true, the panel header acts as a drag handle — the user can reposition the panel freely. When false (the default), the header renders without drag interaction and the panel stays at its initialPosition (see defaults.initialPosition).

Programmatic positioning via setPosition from useFloatingPanelActions works regardless of isDraggable.

isResizable

When isResizable is true, edge and corner resize handles render on the panel — the user can resize freely within the viewport and the minimums defined in defaults (minWidth / minHeight). When false (the default), no resize handles render and the panel stays at its declared or persisted size.

Programmatic sizing via setSize from useFloatingPanelActions works regardless of isResizable.

isDocked

When isDocked is true, the panel is pinned to the inline end for as long as it is open, the same way the Navigator is when it is docked. It uses its width and the full height under the top bar. The editor canvas narrows by that width. The inner edge can be dragged to change the width. That width is kept across reloads. The panel cannot be moved or undocked, and isDraggable or isResizable do not add the floating handles. Closing the panel hides it and returns the width to the canvas. When omitted, the panel keeps the previous floating behavior.

keepMounted

When keepMounted is true, closing the panel hides it and leaves its component mounted. Use this when the panel hosts an iframe that must keep its session. When omitted or false, closing the panel unmounts the component.

openFloatingPanel( id ) and closeFloatingPanel( id ) open and close a registered panel from outside React.

defaults

defaults is required and defines the panel's initial dimensions and (optionally) its initial position.

FieldPurpose
widthInitial panel width (in pixels).
heightInitial panel height (in pixels).
minWidthMinimum width the panel can be resized to.
minHeightMinimum height the panel can be resized to.
corner (optional)Viewport corner anchor. One of block-start-inline-start, block-start-inline-end, block-end-inline-start, block-end-inline-end. Default: block-start-inline-start.
initialPosition (optional)Offsets on the two insets that match corner. Used only when no persisted position exists. Other keys are ignored.

Sizes use physical names (width/height) because Elementor renders in horizontal writing mode only. Position uses logical inset names because it is direction-sensitive (e.g. RTL).

LogicalPosition stores all four insets (insetInlineStart, insetInlineEnd, insetBlockStart, insetBlockEnd). Only the pair matching corner is used for rendering and interaction; inactive insets are 0.

cornerActive insetsDefault initialPosition
block-start-inline-startinsetInlineStart, insetBlockStart{ insetInlineStart: 24, insetBlockStart: 80 }
block-start-inline-endinsetInlineEnd, insetBlockStart{ insetInlineEnd: 24, insetBlockStart: 80 }
block-end-inline-startinsetInlineStart, insetBlockEnd{ insetInlineStart: 24, insetBlockEnd: 80 }
block-end-inline-endinsetInlineEnd, insetBlockEnd{ insetInlineEnd: 24, insetBlockEnd: 80 }

Example for bottom-right anchoring:

defaults: {
    width: 360,
    height: 600,
    minWidth: 280,
    minHeight: 400,
    corner: 'block-end-inline-end',
    initialPosition: {
        insetBlockEnd: 80,
        insetInlineEnd: 24
    },
}

When persisted state exists, the persisted position, corner, and size override initialPosition, corner, width, and height. The resize minimums (minWidth/minHeight) are always derived from defaults.

Call init() once during editor bootstrap, before any createFloatingPanel call, to register the slice, sync persisted state, and mount the host into the editor's top location.

版本与发布记录

@elementor/editor-floating-panels 共发布 223 个版本,首次发布于 2026/07/06;过去 12 个月发布了 223 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.4.1latest2026/11/16今天
4.5.0-1192build2026/11/16今天
4.5.0-11912026/11/16今天
4.5.0-11902026/11/16今天
4.5.0-11892026/11/16今天
4.5.0-11882026/11/151 天前

其他发布通道:beta → 4.4.0-beta3,build → 4.5.0-1192。

关于 @elementor/editor-floating-panels 的常见问题

@elementor/editor-floating-panels 是什么?

A generic floating panel framework for the Elementor Editor that provides the primitives for rendering panels on the canvas. The panels can be dragged and resized freely within the viewport, independent of any specific feature concern.

如何安装 @elementor/editor-floating-panels?

在项目目录运行 npm install @elementor/editor-floating-panels,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.3.1)、react-dom(^18.3.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@elementor/editor-floating-panels 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@elementor/editor-floating-panels 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@elementor/editor-floating-panels 可以商用吗?

@elementor/editor-floating-panels 使用 GPL-3.0-or-later 许可。强 Copyleft:分发包含该代码的软件时,整个作品需以 GPL-3.0 兼容许可开源,并附带专利与反锁定条款。仅内部使用不触发此义务。以上为概括,不构成法律意见,请以许可原文为准。

@elementor/editor-floating-panels 的下载量有多少?

根据 npm 官方下载统计,@elementor/editor-floating-panels 在 2026/10/14 – 2026/11/12 这 30 天内被下载 7,562 次,日均约 252 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@elementor/editor-floating-panels 还在维护吗?

最新版本 4.4.1 发布于 2026/11/16(今天);至今共发布 223 个版本,其中过去 12 个月发布了 223 个;首次发布于 2026/07/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。