The Freeplane scripting API is an object oriented layer over the Freeplane internals.
It is meant to be upwards compatible and it grows with new Freeplane features. If you miss a special Freeplane feature in the API please create a change request in our bug tracker.
The interface is completely defined by the Proxy interface with its numerous subinterfaces.
In addition to the wrapper layer there are two extensions:
This Groovy class is the base class of all formulas and Groovy scripts. It provides some methods you may find convenient.
The following utility classes that also are listed in FreeplaneScriptBaseClass might be useful. Where available use the shortcut (e.g.
Class | Shortcut |
---|---|
UITools | ui |
LogUtils | logger |
HtmlUtils | htmlUtils |
TextUtils | textUtils |
MenuUtils | menuUtils |
ConfigProperties | config |
FreeplaneVersion | - |
Each script is given two variables:
Proxy.Node node Proxy.Controller c
In formulas and Groovy scripts all methods and properties of the node variable are directly available so you can write children.size() instead of node.children.size().
A very important usability improvement, not only for formula writers, is the introduction of the class Convertible that is returned now by some methods/properties:
A Convertible tries everything possible to convert an object to the requested target type. For instance node.to.date will return a date even if the node object is a String "2013-03-13" instead of a Date. This will work even with Maps imported from a data type agnostic FreeMind.
Convertible can get in your way sometimes if all what you want is the raw string (e.g. of a note). If you need that use these methods/attributes instead:
Some attributes have been changed from type String to Object which avoids ugly conversions back and forth between Strings, Dates and Number:
Other attributes are still String valued but their setters accept other Objects as well. This requires a conversion of course.
The existence of a comprehensive API doesn't prohibit access to internal interfaces. For most scripts this should not be necessary but especially add-on writers may need more than the scripting API. But note that these internal interfaces might change without further notice between two stable Freeplane versions (but probably not between minor versions). Also note that for understanding the internal interfaces you have to dive into the code. Setting up a proper development environment is therefore indispensable.