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 Proxy interface

The interface is completely defined by the Proxy interface with its numerous subinterfaces.

In addition to the wrapper layer there are two extensions:

## FreeplaneScriptBaseClass

This Groovy class is the base class of all formulas and Groovy scripts. It provides some methods you may find convenient.

## Utilities

The following utility classes that also are listed in FreeplaneScriptBaseClass might be useful. Where available use the shortcut (e.g.

ui
instead of
UITools
) since this requires no imports:

Class | Shortcut
--- | ---
UITools | ui
LogUtils | logger
HtmlUtils | htmlUtils
TextUtils | textUtils
MenuUtils | menuUtils
ConfigProperties | config
FreeplaneVersion | -

## Entry points

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()`.

## Convertible

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:

- `node.to`
- `node['attr_name']`
- `node.attributes.values`
- `node.note`
- `node.details`

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:

- `node.text` returns the raw text, `node.plainText` is the same as `node.to.plain`.
- `node.attributes.getFirst('attr_name')`
- `node.attributes.map.values` returns all values if there are no duplicated keys. From 1.3.2 use `node.attributes.collect { it.value }` instead.
- `node.noteText`
- `node.detailsText`

## Extended Setters

Some attributes have been changed from type String to Object which avoids ugly conversions back and forth between Strings, Dates and Number:

- It's `node.setText(Object)` although `node.getText()` returns an String. Better use the attribute `node.object` which is symmetric in getter and setter types.
- Attribute values are not restricted to String (anymore).

Other attributes are still String valued but their setters accept other Objects as well. This requires a conversion of course.

- `node.note` has a HTML string but `node.setNote()` accepts an Object and `node.getNote()` returns a Convertible for the plain text note.
- The same holds for `node.details` which also has a HTML string value but it's `node.setDetails(Object)` and `node.getDetails()` returns a Convertible.

## Access to Freeplane's internals

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.