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

@hufe921/canvas-editor-plugin-suggestion

v0.0.1

Published

suggestion plugin for canvas-editor

Readme

简介

canvas-editor 输入联想/短语自动提醒插件。输入时自动提取光标前的查询词, 实时匹配候选短语并以下拉面板提醒,选中后用完整短语替换已输入的查询词。 支持键盘上下导航、回车/Tab 选中、Escape 关闭,也可通过命令程序化打开。

安装

npm i @hufe921/canvas-editor-plugin-suggestion --save

使用

import Editor from '@hufe921/canvas-editor'
import suggestionPlugin from '@hufe921/canvas-editor-plugin-suggestion'

const instance = new Editor()
instance.use(suggestionPlugin, {
  dataList: [
    { id: '1', name: '患者男性,否认药物过敏史' },
    { id: '2', name: '心肺听诊未闻及明显异常' }
  ],
  onSelect: item => {
    console.log(item)
  }
})

// 程序化打开候选面板(不跟踪查询词,选中后直接插入)
instance.command.executeSuggestion(options?)

配置项

| 属性 | 类型 | 必填 | 默认值 | 说明 | | ---- | ---- | ---- | ------ | ---- | | dataList | ISuggestionItem[] \| (() => ISuggestionItem[]) | 是 | - | 候选数据(数组或返回数组的函数) | | minLength | number | 否 | 1 | 触发联想的最小查询词长度 | | max | number | 否 | 5 | 候选最多显示条数 | | match | 'prefix' \| 'contains' \| ((query, item) => boolean) | 否 | 'prefix' | 匹配方式,内置方式均大小写不敏感 | | onSelect | (item: ISuggestionItem) => void | 否 | - | 选中候选项回调 | | locale | string | 否 | 取编辑器 locale,回退 zhCN | 面板语言(内置 zhCN、en) | | lang | Partial<ISuggestionLang> | 否 | - | 覆盖对应语言的面板文案 |

interface ISuggestionItem {
  id: string
  name: string
  // 选中后实际插入的短语,缺省时插入 name
  value?: string
  [key: string]: any
}

interface ISuggestionLang {
  // 无匹配候选时的空态文案
  emptyText: string
}