* Create a registry that has three types of behaviours:
* - style-like (no bias change, inherits inside)
* - link-like (bias away, with priority overriding containers).
* - spell-like (metadata, never inherits)
*/
AnnotationRegistry registry = root.createExtension();
registry.registerBehaviour(STYLE_KEY, new DefaultAnnotationBehaviour(AnnotationFamily.CONTENT));
registry.registerBehaviour(LINK_KEY, new AnnotationBehaviour() {
public BiasDirection getBias(StringMap<Object> left, StringMap<Object> right,
CursorDirection cursor) {
assert left.containsKey(LINK_KEY) && right.containsKey(LINK_KEY);
return left.get(LINK_KEY) == null ? BiasDirection.LEFT : BiasDirection.RIGHT; // away
}
public double getPriority() {
return 10.0; // higher than default
}
public InheritDirection replace(StringMap<Object> inside, StringMap<Object> outside,
ContentType type) {
return InheritDirection.INSIDE;
}
public AnnotationFamily getAnnotationFamily() {
return AnnotationFamily.CONTENT;
}
});
registry.registerBehaviour(SPELL_KEY, AnnotationBehaviour.REPLACE_NEITHER);
useCaretAnnotations();
return registry;
}