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

markdown-to-flowchart

v1.0.0

Published

A markdown-to-flowchart library.

Downloads

6

Readme

Markdown 转 Flowchart

一个将 Markdown 中包含的 Mermaid 语法转换为浏览器中的交互式流程图的 JavaScript 库。

特性

  • 将包含 Mermaid 流程图的 Markdown 转换为可视化的流程图。
  • 提供下载、缩放以及居中流程图等交互功能。
  • 支持通过 CDN 和 npm 安装。

入门指南

安装

使用 npm

如果你使用的是现代 JavaScript 模块打包器如 Webpack 或 Rollup,可以通过 npm 安装:

npm install markdown-to-flowchart

使用 CDN

对于简单的脚本或者没有使用模块打包器的项目,可以直接从 CDN 引入库:

<!-- 引入 MarkdownToFlowchart 库 -->
<script src="https://your-cdn-url-here/dist/markdownToFlowchart.umd.js"></script>

使用方法

基本示例

在 HTML 中引入库,并在脚本中初始化 MarkdownToFlowchart 实例:

<!-- 你的 HTML 结构在这里 -->

<script>
  document.addEventListener("DOMContentLoaded", () => {
    const markdownContent = `
      # 示例文档
      这是一个示例文档,其中包含了流程图:
      \`\`\`mermaid
      graph TD
          A[开始] --> B[步骤1]
          B --> C{条件?}
          C -->|是| D[步骤2]
          C -->|否| E[结束]
      \`\`\`
    `;
    let MarkdownToFlowchartInstance = new MarkdownToFlowchart(
      markdownContent,
      'markdown-content',
      () => {
        console.log('渲染完成');
        setTimeout(() => {
          // MarkdownToFlowchartInstance.updateRender(markdownContent2)
        }, 5000);
      }
    );
    // 为按钮添加事件监听器
    document.getElementById('download-btn').addEventListener('click', () => {
      MarkdownToFlowchartInstance.downloadImage();
    });
    document.getElementById('zoom-in-btn').addEventListener('click', () => {
      MarkdownToFlowchartInstance.zoomIn();
    });
    document.getElementById('zoom-out-btn').addEventListener('click', () => {
      MarkdownToFlowchartInstance.zoomOut();
    });
    document.getElementById('center-btn').addEventListener('click', () => {
      MarkdownToFlowchartInstance.centerElement();
    });
  });
</script>

API 参考

构造函数

new MarkdownToFlowchart(markdownContent, containerId, callback)

  • markdownContent: 包含 Mermaid 流程图的 Markdown 字符串。
  • containerId: 渲染内容将被放置的 DOM 元素的 ID。
  • callback: 可选的回调函数,在渲染完成后被调用。

方法

  • downloadImage(): 下载当前流程图为图片。
  • zoomIn(): 增加流程图的缩放比例。
  • zoomOut(): 减少流程图的缩放比例。
  • centerElement(): 在容器内居中流程图。

贡献

欢迎贡献!如果发现任何问题或者有新特性请求,请提交 Pull Request 或者打开 Issue。

许可证

此项目采用 MIT 许可证 - 详情请参见 LICENSE 文件。