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

@jzo/markdown

v0.0.2

Published

基于react-markdown,react-markdown-editor-lite,markdown-navbar封装组件支持预览和编辑,代码高亮。

Downloads

10

Readme


title: Markdown sidemenu: false

JMarkdown.Editor 组件

这个组件自带了一些 Pro 的配置,你一般都需要改掉它的信息。

import React, { useState } from "react";
import JMarkdown from "@jzo/markdown";

export default () => {
  const valueInit = `
~~~jsx
  import { Button, Menu } from 'antd';
  import React from 'react';
  import HeaderDropdown from '@/components/HeaderDropdown';

  export default () => {
    const menuHeaderDropdown = (
      <Menu selectedKeys={[]}>
        <Menu.Item key="center">个人中心</Menu.Item>
        <Menu.Item key="settings">个人设置</Menu.Item>
        <Menu.Divider />
        <Menu.Item key="logout">退出登录</Menu.Item>
      </Menu>
    );
    return (
      <HeaderDropdown overlay={menuHeaderDropdown}>
        <Button>hover 展示菜单</Button>
      </HeaderDropdown>
    );
  };
  </JMarkdown> ~~~
  `;

  const [value, setValue] = useState(valueInit);
  const onEditor = (e) => {
    setValue(e);
  };

  return <JMarkdown.Editor value={value} onChange={onEditor} />;
};

API

| 参数 | 说明 | 类型 | 默认值 | | ---------------- | ------------------------------------------------------- | ---------------------------- | ------ | | value | 输入框的值 | string | - | | onChange | 值修改后触发 | (value) => void | - | | theme | 皮肤 | string | - | | hideMarkNav | 是否开启目录 | boolean | false | | headingTopOffset | 相对于窗顶位移的锚定 | number | 0 | | ordered | 标题是否包含数字前缀 | boolean | true | | remarkPlugins | 插件列表 | (visible: boolean) => void | - | | components | 将标记名映射到组件的对象 | object | {} | | config | 工具栏设置 | object | {} | | onImageUpload | 上传返回图片地址 | () => Promise | - | | markdownProps | 组件参数 https://github.com/remarkjs/react-markdown | - | - |

JMarkdown 展示

一个带补全数据的输入框,支持收起和展开 Input

/**
 * background: '#f0f2f5'
 */
import { Button, Menu } from "antd";
import React from "react";
import JMarkdown from "@jzo/markdown";

export default () => {
  const value = `## 展示菜单
  | 参数          | 说明                                                    | 类型      | 默认值 |
| ------------- | ------------------------------------------------------- | --------- | ------ |
| value         | 输入框的值                                              | string  | -      |
| theme         | 皮肤                                                    | string  | -      |
| components    | 将标记名映射到组件的对象                                | object  | {}     |
| remarkPlugins | 输入框默认是否显示,只有第一次生效                      | boolean | -      |
| 其他          | 组件参数 [https://github.com/remarkjs/react-markdown]() | -       | -      |
  ~~~jsx
  import { Button, Menu } from 'antd';
  import React from 'react';
  import HeaderDropdown from '@/components/HeaderDropdown';

  export default () => {
    const menuHeaderDropdown = (
      <Menu selectedKeys={[]}>
        <Menu.Item key="center">个人中心</Menu.Item>
        <Menu.Item key="settings">个人设置</Menu.Item>
        <Menu.Divider />
        <Menu.Item key="logout">退出登录</Menu.Item>
      </Menu>
    );
    return (
      <HeaderDropdown overlay={menuHeaderDropdown}>
        <Button>hover 展示菜单</Button>
      </HeaderDropdown>
    );
  };
  </JMarkdown> ~~~

  ### 个人中心
  `;
  return <JMarkdown>{value}</JMarkdown>;
};

API

| 参数 | 说明 | 类型 | 默认值 | | ------------- | ------------------------------------------------------- | --------- | ------ | | value | 输入框的值 | string | - | | theme | 皮肤 | string | - | | components | 将标记名映射到组件的对象 | object | {} | | remarkPlugins | 输入框默认是否显示,只有第一次生效 | boolean | - | | plugins | 插件列表 |array | [] | 其他 | 组件参数 https://github.com/remarkjs/react-markdown | - | - |

plugins 插件列表

[ "header", "font-bold", "font-italic", "font-underline", "font-strikethrough", "list-unordered", "list-ordered", "block-quote", "block-wrap", "block-code-inline", "block-code-block", "table", "image", "link", "clear", "logger", "mode-toggle", "full-screen", "tab-insert", ]

theme 皮肤

a11yDark,a11yLight,agate,anOldHope ,androidstudio ,arduinoLight, arta, ascetic, atelierCaveDark, atelierCaveLight, atelierDuneDark, atelierDuneLight, atelierEstuaryDark, atelierEstuaryLight, atelierForestDark, atelierForestLight, atelierHeathDark, atelierHeathLight, atelierLakesideDark, atelierLakesideLight, atelierPlateauDark, atelierPlateauLight, atelierSavannaDark, atelierSavannaLight, atelierSeasideDark, atelierSeasideLight, atelierSulphurpoolDark, atelierSulphurpoolLight, atomOneDarkReasonable, atomOneDark, atomOneLight, brownPaper, codepenEmbed, colorBrewer, darcula, dark, defaultStyle, docco, dracula, far, foundation, githubGist, github, gml, googlecode, gradientDark, grayscale, gruvboxDark, gruvboxLight, hopscotch, hybrid, idea, irBlack, isblEditorDark, isblEditorLight, kimbieDark, kimbieLight, lightfair, lioshi, magula, monoBlue, monokaiSublime, monokai, nightOwl, nnfxDark, nnfx, nord, obsidian, ocean, paraisoDark, paraisoLight, pojoaque, purebasic, qtcreatorDark, qtcreatorLight, railscasts, rainbow, routeros, schoolBook, shadesOfPurple, solarizedDark, solarizedLight, srcery ,sunburst ,tomorrowNightBlue ,tomorrowNightBright ,tomorrowNightEighties ,tomorrowNight ,tomorrow ,vs ,vs2015 ,xcode ,xt256 ,zenburn

注意

样式冲突请用重写样式解决

卸载内置插件

import JMarkdown , { Plugins } from "@jzo/markdown";
JMarkdown.unuse(Plugins.Header); // header
JMarkdown.unuse(Plugins.FontBold); // font-bold

编写插件

函数组件

同样可以使用函数组件来编写插件

import React from 'react';
import JMarkdown from "@jzo/markdown";

const Counter = ({editor, editorConfig, config, pluginName}) => {
  console.log(editor,editorConfig,config,pluginName)

  const [num, setNum] = React.useState(config.start);

  const handleClick = () => {
    // 调用API,往编辑器中插入一个数字
    editor.insertText(num);
    // 更新一下自身的state
    setNum(num + 1);
  }
  return (
    <span
      className="button button-type-counter"
      title="Counter"
      onClick={handleClick}
    >
      123213213
    </span>
  );
}
// 如果需要的话,可以在这里定义默认选项
Counter.defaultConfig = {
  start: 0
}
// 定义按钮被防止在哪个位置,默认为左侧,还可以放置在右侧(right)
Counter.align = 'left';
// 这里定义插件名称,注意不能重复
Counter.pluginName = 'counter';


// 使用:
JMarkdown.Editor.use(Counter, {
  start: 10
});

更新

0.0.1 组件发布 0.0.2 修改REANME.md说明