the checked ones are APIs that are supported by the current version.
the unchecked ones are under develpment.
npm install xmind
var xmind = require('xmind');
// `xmind` here is an object:
// {
// open: Workbook.open,
// save: Workbook.save,
// CONST: CONST,
// utils: utils,
// DomMixin: DomMixin,
// Workbook: Workbook,
// Sheet: Sheet,
// Topic: Topic,
// Relationship: Relationship,
// Legend: Legend
// }
-
xmind.open(filename)
this method returns an Workbook instance, which can be considered as an xmind document.
var workbook = xmind.open(filename);
-
xmind.save(workbook, filename)
save workbook(xmind document) to a file.
all kinds of CONSTs, attribute names, tag names, other values, etc.
all kinds of helper functions
-
utils.getCurrentTimestamp()
-
utils.getDefaultSheetName(index)
-
utils.getDefaultTopicName(structureClass)
-
utils.findChildNode(doc, tagName, attrs)
-
utils.findChildNodes(doc, tagName, attrs)
-
utils.eachChildNode(doc, tagName, attrs, callback)
-
utils.findOrCreateChildNode(doc, tagName, attrs)
-
utils.removeChildNode(doc, tagName, attrs)
all the constructors below is inherited from DomMixin. it provides some helper functions on Dom.
it requires all the sub-constructors instances to have a doc
attribute. and the doc
attribute must be an instance of xmldom DocumentElement or Element.
-
instance.getAttribute(name)
-
instance.setAttribute(name, value)
-
instance.removeAttribute(name)
-
instance.eachChildNode(tagName, attrs, callback)
-
instance.findOrCreateChildNode(tagName, attrs)
-
instance.getModifiedTime()
-
instance.setModifiedTime(timestamp/Date instance or number(timestamp)/)
-
instance.getTitle()
-
instance.setTitle(title)
-
instance.getPosition()
-
instance.setPosition(position)
-
instance.destroy()
-
instance.toPlainObject()
-
instance.toJSON()
instance
can be:
- Workbook instance
- Sheet instance
- Topic instance
- Relationship instance
- Legend instance
- any other constructors with a
doc
property which is an xmldom Node instance.
var Workbook = xmind.Workbook;
var workbook = new xmind.Workbook({
/*
* options:
* // when creating a new one {
* - firstSheetName
* - rootTopicName
* // }
* // when loading from an existing one {
* - doc
* - stylesDoc
* - attachments
* // }
*/
});
-
Workbook.open(filename)
-
Workbook.save(workbook, filename)
-
workbook.getPrimarySheet()
-
workbook.addSheet(options)
options: {
id: sheetId,
title: sheetName,
rootTopicId: rootTopicId,
rootTopicName: rootTopicName,
theme: theme,
}
-
workbook.moveSheet(fromIndex, toIndex)
-
workbook.removeSheet(/* id or index or Sheet instance */)
-
workbook.save(filename)
var Sheet = xmind.Sheet;
var sheet = new Sheet({
/*
* options:
* - workbook(required)
* // when creating a new one {
* - title
* - rootTopicName
* - theme
* // }
* // when loading from an existing one {
* - doc
* // }
*/
});
-
sheet.getTheme()
-
sheet.setTheme(theme)
-
sheet.getRootTopic()
-
sheet.addLegend()
-
sheet.removeLegend()
-
sheet.addMarkerDescription(markerId, description)
-
sheet.removeMarkerDescription(markerId)
-
sheet.addRelationship(options)
options: {
id: id,
sourceId: sourceId,
targetId: targetId,
title: title
}
-
sheet.removeRelationship(relationship/*index, id, instance or sourceId, targetId*/)
var Topic = xmind.Topic;
var topic = new Topic({
/*
* options:
* - sheet(required)
* - parent
* - type
* // when creating a new one {
* - title
* - structure
* // }
* // when loading from an existing one {
* - doc
* // }
*/
});
-
Topic.getTopic(topic/*id or instance*/, sheet)
-
topic.getBranch()
-
topic.setBranch(value)
-
topic.setBranchFolded()
-
topic.addChild(/*instance or options*/)
-
topic.removeChild(child/*id or instance*/, dryrun)
-
topic.isAncestorOf(targetTopic)
-
topic.moveTo(targetTopic)
-
topic.getNotes()
-
topic.setNotes(notes)
-
topic.getLabels()
-
topic.setLabels(labels)
-
topic.getHyperlink()
-
topic.setHyperlink(hyperlink)
-
topic.removeHyperlink()
-
topic.getMarkers()
-
topic.setMarkers(markers)
-
topic.addMarker(id)
-
topic.removeMarker(id)
var Relationship = xmind.Relationship;
var relationship = new Relationship({
/*
* options:
* - sheet(required)
* // when creating a new one {
* // }
* // when loading from an existing one {
* - doc
* // }
*/
});
-
relationship.getSource()
-
relationship.setSource(value)
-
relationship.getTarget()
-
relationship.setTarget(value)
var Legend = xmind.Legend;
var legend = new Legend({
/*
* options:
* - sheet(required)
* // when creating a new one {
* - title
* // }
* // when loading from an existing one {
* - doc
* // }
*/
});
-
Legend.DEFAULT_VISIBILITY
-
Legend.DEFAULT_POSITION
-
legend.addMarkerDescription(markerId, description)
-
legend.removeMarkerDescription(markerId)
-
legend.getVisibility()
-
legend.setVisibility(value)
instance.addXXXX()
andinstance.getXXXX()
usually returns theXXXXX
addedinstance.removeXXXX()
,instance.setXXXX()
, etc. usually returns instance itself