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

react-jsmind

v1.0.6

Published

一个基于jsMind的react思维导图组件

Downloads

21

Readme

jsMind React 版

reactjsmind node size webpack jsMind

此项目是基于jsMind封装的 React 版本,方便开发者直接以组件形式使用。

  1. 安装
npm install react-jsmind

// # or

yarn add react-jsmind
  1. 基本使用

react-jsmind-demo

import ReactJsMind from 'react-jsmind'
import 'react-jsmind/dist/index.min.css'

const App = () => {
  const mindRef: any = useRef(null)
  const [editable, setEditable] = useState(true)
  const getData = () => {
    if (mindRef.current) {
      const data = mindRef.current.getData()
      alert(JSON.stringify(data))
    }
  }
  const NodeTreeData = {
    meta: { name: 'mind图', author: 'Your Name', version: '0.8.5' },
    format: 'node_tree',
    data: {
      id: 'root',
      topic: '😊根节点',
      children: [
        {
          id: '1',
          topic: '子节点1',
          direction: 'left',
          expanded: true,
          'background-color': '#03BF8A',
          children: [
            { id: '2', topic: '子节点2' },
            { id: '3', topic: '子节点3' },
          ],
          data: { width: 100, type: 'rect' }, // 自定义业务数据
        },
      ],
    },
  }
  const enableEdit = () => {
    setEditable(!editable)
  }
  const onNodeClick = (node) => {
    console.log('点击的节点', node)
  }
  return (
    <div style={{ width: '100%', height: 800 }}>
      <div className='btns'>
        <button onClick={getData}>获取数据</button>
        <button onClick={enableEdit}>{editable ? '关闭' : '开启'}编辑</button>
      </div>
      <ReactJsMind ref={mindRef} options={{ editable }} data={NodeTreeData} onClick={onNodeClick} />
    </div>
  )
}
  1. 特性说明

    1. 默认情况下,ReactJsMind 组件会自动渲染一个 id 为 jsmind_container 的容器且充满父容器,因此需要在父容器定义宽高。

    2. ReactJsMind 组件 options 参数配置请参考jsMind 参数配置; data 参数配置请参考jsMind 数据格式

    3. ReactJsMind 组件支持onClickonMouseOveronMouseOutonMouseLeaveonMouseLeaveonContextMenuonKeyUpondblClickonExpand 事件

    4. ReactJsMind 组件只对外暴露了如下几种常用方法, 可以通过 mindRef.current调用, 如果想要其他方法,通过 mindRef.current.getInstance() 获取到 jsMind 实例后调用,具体参考jsMind 节点操作方法

| 方法名 | 参数 | 描述 | | :--------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------: | | screenShot | | 导出为 png 图片 (不含水印) | | getData | | 获取脑图数据 | | getSelectedNode | | 获取选中的节点 | | expandAll | | 展开所有节点 | | addNode | (parent_node, node_id, topic, data, direction):parent_node:父节点node_id:唯一标识topic: 名称data: 数据direction: 'left' | 'right' | 添加节点 | | removeNode | node | 删除节点 | | setNodeColor | (nodeId, bg_color, fg_color):bg_color:React.CSSProperties['color'] 背景色fg_color: React.CSSProperties['color'] 前景色 | 设置节点背景色 | | setNodeFontStyle | (nodeId, size, weight, style):size: React.CSSProperties['fontSize'],weight: React.CSSProperties['fontWeight']style: React.CSSProperties['fontStyle'] | 设置节点字体样式 | | getInstance | | 获取 jsMind 实例 |