npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kunlunxu/wf-extension-bubble-menu

v3.0.6

Published

提供基于当前编辑器选区定位的 React Bubble Menu。选区非空时显示,选区为空时隐藏。

Readme

@kunlunxu/wf-extension-bubble-menu

提供基于当前编辑器选区定位的 React Bubble Menu。选区非空时显示,选区为空时隐藏。

React 用法

组件必须位于 WriteFlowContext.Provider 内:

import { BubbleMenuPortal } from '@kunlunxu/wf-extension-bubble-menu';

<BubbleMenuPortal>
  <div className="bubble-menu">这里放置格式化操作</div>
</BubbleMenuPortal>;

BubbleMenuPortal 会:

  • 创建独立 DOM 容器。
  • 向当前 WriteFlow 实例动态注册 Bubble Menu 插件。
  • 使用 React Portal 渲染传入元素。
  • 在选区范围变化时更新子元素的 key,触发所需的 React 更新。
  • 卸载时注销插件并移除菜单。

直接创建插件

import { buildBubbleMenuPlugin } from '@kunlunxu/wf-extension-bubble-menu';

const element = document.createElement('div');
const plugin = buildBubbleMenuPlugin({
  element,
  pluginKey: 'myBubbleMenu',
  options: {
    shouldShow: () => true,
    onShow: () => {},
    onHide: () => {},
    onUpdate: () => {},
    onDestroy: () => {},
  },
});

writeFlow.registerPlugin(plugin);

显示规则

  • 选区为空时隐藏。
  • 选区非空时显示,并定位在选区顶部上方约 48px

快捷键与退出

本包不注册任何快捷键,也不拦截 Escape。菜单的按钮键盘导航、关闭逻辑和焦点管理需要由使用方实现。

当前限制

  • 默认定位未处理视口边缘碰撞、滚动容器偏移和菜单自身尺寸。
  • 不区分文本选区、NodeSelection 或 CellSelection,只依据 selection.empty 判断。
  • 每个菜单必须使用不同的 pluginKey,否则会发生插件 key 冲突。
  • options.shouldShow 虽然已经定义,但当前 update() 没有调用它,暂时不能通过该回调控制显示。