区分说明
fork于 https://github.com/xmindltd/xmind-generator.git
添加了一些自定义属性:用于修改xmind的样式和布局属性。
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'
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')
.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
writeLocalFile(workbook, '...path to a file with the `.xmind` file extension')
workbook.archive()
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')
.ref('topic:inf')
.children([
Topic('Salad'),
Topic('Starters')
])
)
.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.
Topic('Grill House').summaries([Summary('summary title..', { from: 'topic:foo', to: 'topic:bar' })])
.relationships(Relationship[])
Applies relationships.
RootTopic('Grill House').relationships([Relationship('title...', { from: 'topic:foo', to: 'topic:bar' })])
Example
License
MIT © Xmind LTD