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 🙏

© 2024 – Pkg Stats / Ryan Hefner

whistle-editor

v0.2.11

Published

whistle rules editor

Downloads

17

Readme

whistle-editor

本模块是 whistle 编辑器的 React 组件,可以作为 whistle 规则及其 Values 编辑器。

安装

npm i -D whistle-editor

image

用法

import React from 'react';
import ReactDOM from 'react-dom';
import Editor from 'whistle-editor';

const plugins = {
  'whistle.test': 'http://123',
  share: 0,
};

const onChange = (e) => {
  console.log(e.getValue());
};

const editor = (
  <Editor
    value="test"
    fontSize="16px"
    theme="monokai"
    lineNumbers
    onChange={onChange}
    className="test-class"
    mode="rules"
    plugins={plugins}
  />
);

ReactDOM.render(editor, document.getElementById('root'));

其中可设属性:

  1. className: 组件样式
  2. mode: 编辑器类型,默认 txt 类型,可设类型:rules、html、js (pac|jsx|json)、css、md、html
  3. plugins: 添加插件名称及帮助文档链接,用于编辑器书写规则时自动提醒
    const plugins = {
      'whistle.coding': 1, // 没有对应帮助链接
      test: 'http://xxxx',
      test2: {
        homepage: 'http://xxxx',
        hintList: ['1', '2', '3'] | function,
        pluginVars: true | { hintList: ['1', '2', '3'] | function}
      },
      ...
    };
  4. value: 设置编辑器默认值
  5. onChange: 内容改变时触发
    const onChange = (e) => {
      console.log(e.getValue());
    };
  6. theme: 编辑器主题,默认为 cobalt,可选:
    default
    neat
    elegant
    erlang-dark
    night
    monokai
    cobalt
    eclipse
    rubyblue
    lesser-dark
    xq-dark
    xq-light
    ambiance
    blackboard
    vibrant-ink
    solarized
    dark
    solarized
    light
    twilight
    midnight
  7. fontSize: 字体大小,默认 14px
  8. lineNumbers: true | false,是否显示行数,默认为 false

开发

执行命令构建:

npm run dev

构建完成,用 Chrome 浏览器打开 dist/test.html 即可看到效果,修改代码后手动重新刷新页面即可。

发布

执行命令构建:

npm run dist

构建完成,执行发布命令:

npm publish