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

@apigo.cc/editor

v1.0.2

Published

基于 CodeMirror 6 的代码编辑器 Web Component。

Downloads

208

Readme

@apigo.cc/editor API 手册

基于 CodeMirror 6 的代码编辑器 Web Component。


1. 引入方式 (UMD 优先)

在 HTML 中引入脚本即刻注册 <CodeEditor> 标签。

<!-- 引入依赖链(或使用 loader.js) -->
<script src="https://cdn.jsdelivr.net/npm/@apigo.cc/[email protected]/dist/state.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@apigo.cc/[email protected]/dist/base.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@apigo.cc/[email protected]/dist/editor.min.js"></script>

<script>
    // 直接使用全局 CodeEditor 类
    console.log(CodeEditor);
</script>

2. 核心用法

直接使用

<CodeEditor id="ed" lang="javascript" value="console.log('Hello');"></CodeEditor>

<script>
    ed.addEventListener('change', e => {
        console.log('最新内容:', e.detail);
    });
</script>

AutoForm 集成

引入 editor 后,AutoForm 自动解锁 type: 'code'

State.schema = [
    { name: 'script', label: '代码', type: 'code', setting: { lang: 'json' } }
];

3. API 参考

属性 (Attributes)

  • lang: javascript, json, html
  • theme: dark, light
  • readonly: 布尔属性。
  • .value: 获取或设置编辑器文本。

开发者提示 (AI 必读)

  1. 自动依赖: 引入 editor 即代表引入了 base/bootstrap。
  2. 全局变量: UMD 模式下,CodeEditor 类自动挂载到 window
  3. 数据同步: 修改 .value 属性会同步更新编辑器视图。