public CodeMirrorEditor(String id, String mode, IModel<String> model) {
super(id, model);
this.mode = mode;
boolean enableCodeMirror = isCodeMirrorSupported();
container = new WebMarkupContainer("editorContainer");
container.setOutputMarkupId(true);
add(container);
WebMarkupContainer toolbar = new WebMarkupContainer("toolbar");
toolbar.setVisible(enableCodeMirror);
container.add(toolbar);
customButtons = new RepeatingView("custom-buttons");
toolbar.add(customButtons);
WebMarkupContainer editorParent = new WebMarkupContainer("editorParent");
if (enableCodeMirror) {
editorParent.add(
AttributeModifier.replace(
"style", "border: 1px solid black; padding-bottom: 3px"));
}
container.add(editorParent);
editor = new TextArea<String>("editor", model);
editorParent.add(editor);
editor.setOutputMarkupId(true);
if (enableCodeMirror) {
editor.add(new CodeMirrorBehavior());
} else {
editor.add(AttributeModifier.replace("style", "width:100%"));
}
}