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

xmind-generator

v1.0.1

Published

A javascript module that creates mindmaps and generates Xmind files.

Downloads

794

Readme

xmind-generator

xmind-generator is a javascript module that creates mind maps and generates Xmind files.

Contents

Install

Install xmind-generator with your favorite package manager:

npm i xmind-generator

Usage

Build document

import { Topic, RootTopic, Relationship, Summary, Marker, Workbook, writeLocalFile, readLocalImage } from 'xmind-generator'
// Note: `readImageFile` helper is only available in the Node.js runtime
const image = await readImageFile(path.resolve(__dirname, 'xmind.jpeg'))
const workbook = Workbook(
  RootTopic('Grill House')
    .image(image)
    .children([
      Topic('Salad')
        .markers([Marker.Arrow.refresh])
        .children([
          Topic('Garden Salad')
            // Note: ref (aka "reference") is only used in building procedure, is not saved in exported Xmind file.
            .ref('topic:baz')
            .labels(['Lemon Vinaigrette', 'Ginger Dressing']),
          Topic('Tomato Salad').ref('topic:qux')
        ])
        .summaries([Summary('Get 10% off', { from: 'topic:baz', to: 'topic:qux' })]),
      Topic('Starters')
        .ref('topic:bar')
        .note('With free soft drink')
        .children([
          Topic('Smoked Bacon').ref('topic:fred'),
          Topic('Fried Chicken').ref('topic:thud').labels(['Hot Chilli'])
        ])
    ])
    .relationships([
      Relationship('', { from: 'Salad', to: 'topic:bar' }),
      Relationship('Special', { from: 'topic:fred', to: 'topic:thud' })
    ])
    .summaries([Summary('Fresh and Delicious', { from: 'Salad', to: 'topic:bar' })])
)

Export and save to a local Xmind file

// Write to a local Xmind file
// Note: `writeLocalFile` helper is only available in the Node.js runtime
writeLocalFile(workbook, '...path to a file with the `.xmind` file extension')

// To use in a browser's JavaScript runtime, the ArrayBuffer to Xmind file can be
// generated by the `archive` method, then downloaded with the `.xmind` file extension
workbook.archive() // ArrayBuffer of document

Interface

The main component of an Xmind document is a Workbook object, which contains multiple mind maps. Each mind map is formed as a hierarchical tree structure consisting of a set of Topic objects as its nodes, where a RootTopic object represents the root node as well as the containing mind map.

The RootTopic and Topic builders create nodes in the mind map structure. The RootTopic builder specifically builds the root node, which connects to other nodes through the children method.

Workbook(
 RootTopic('Grill House')
 // Give the node a reference
 .ref('topic:inf')
 .children([
   Topic('Salad'),
   Topic('Starters')
 ])
)
// For building a multiple sheets structure,
// pass an array of `RootTopic` builders to `Workbook`

.markers(MarkerId[])

Define markers.

Topic('Salad').markers([Marker.Arrow.refresh, Marker.Task.quarter])

.note(string)

Defines plain note Text.

Topic('Salad').note('This is a note')

.labels(string[])

Define array of labels.

Topic('Salad').labels(['Lemon Vinaigrette', 'Ginger Dressing'])

.image(ImageSource)

Defines an image for the topic. ImageSource can accept ArrayBuffer, Buffer, Uint8Array and base64 encoded string.

Topic('Salad').image('data:image/png;base64,...')

.summaries(Summary[])

Applies summaries.

// You can use either a reference string or topic title as an indicator, and make sure they are unique.
Topic('Grill House').summaries([Summary('summary title..', { from: 'topic:foo', to: 'topic:bar' })])

.relationships(Relationship[])

Applies relationships.

// Note: `relationships` method is only available on the `RootTopic` builder
RootTopic('Grill House').relationships([Relationship('title...', { from: 'topic:foo', to: 'topic:bar' })])

Example

License

MIT © Xmind LTD