Skip to content

Latest commit

 

History

History
362 lines (239 loc) · 6.62 KB

api.md

File metadata and controls

362 lines (239 loc) · 6.62 KB

xmind-sdk-javascript manual & documentation

NOTICE

the checked ones are APIs that are supported by the current version.

the unchecked ones are under develpment.

installation

npm install xmind

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.

CONST

all kinds of CONSTs, attribute names, tag names, other values, etc.

utils

all kinds of helper functions

properties

  • 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)

DomMixin

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.

constructor properties

instance properties

  • 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.

Workbook

creating an 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
     *   // }
     */
});

constructor properties

  • Workbook.open(filename)

  • Workbook.save(workbook, filename)

instance properties

  • 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)

Sheet

creating an instance

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
     *   // }
     */
});

constructor properties

instance properties

  • 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*/)

Topic

creating an instance

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
     *   // }
     */
});

constructor properties

  • Topic.getTopic(topic/*id or instance*/, sheet)

instance properties

  • 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)

Relationship

creating an instance

var Relationship = xmind.Relationship;
var relationship = new Relationship({
    /*
     * options:
     *   - sheet(required)
     *   // when creating a new one {
     *   // }
     *   // when loading from an existing one {
     *      - doc
     *   // }
     */
});

constructor properties

instance properties

  • relationship.getSource()

  • relationship.setSource(value)

  • relationship.getTarget()

  • relationship.setTarget(value)

Legend

creating an instance

var Legend = xmind.Legend;
var legend = new Legend({
    /*
     * options:
     *   - sheet(required)
     *   // when creating a new one {
     *      - title
     *   // }
     *   // when loading from an existing one {
     *      - doc
     *   // }
     */
});

constructor properties

  • Legend.DEFAULT_VISIBILITY
  • Legend.DEFAULT_POSITION

instance properties

  • legend.addMarkerDescription(markerId, description)

  • legend.removeMarkerDescription(markerId)

  • legend.getVisibility()

  • legend.setVisibility(value)

notes

  • instance.addXXXX() and instance.getXXXX() usually returns the XXXXX added
  • instance.removeXXXX(), instance.setXXXX(), etc. usually returns instance itself

home