use of org.xwiki.edit.EditException in project xwiki-platform by xwiki.
the class EditorWikiComponent method render.
@Override
protected String render() throws EditException {
try {
XWikiContext xcontext = this.xcontextProvider.get();
XWikiDocument editorDocument = xcontext.getWiki().getDocument(this.getDocumentReference(), xcontext);
BaseObject editorObject = editorDocument.getXObject(EDITOR_CLASS_REFERENCE);
String editorCode = editorObject.getStringValue("code");
// Make sure the editor code is executed with the rights of the editor document author.
XWikiDocument sdoc = editorDocument;
// the data that has been put on the script context).
return xcontext.getDoc().getRenderedContent(editorCode, editorDocument.getSyntax().toIdString(), false, sdoc, xcontext);
} catch (Exception e) {
throw new EditException("Failed to render the editor code.", e);
}
}
use of org.xwiki.edit.EditException in project xwiki-platform by xwiki.
the class TextAreaClass method displayEdit.
@Override
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
String editorType = getEditorType(context);
EditorManager editorManager = Utils.getComponent(EditorManager.class);
Editor<SyntaxContent> editor = editorManager.getDefaultEditor(SyntaxContent.class, editorType);
Map<String, Object> parameters = new HashMap<>();
String fieldName = prefix + name;
parameters.put("id", fieldName);
parameters.put("name", fieldName);
parameters.put("cols", getSize());
parameters.put("rows", getRows());
parameters.put("disabled", isDisabled());
parameters.put("sourceDocumentReference", object.getDocumentReference());
Syntax syntax = "puretext".equals(editorType) ? Syntax.PLAIN_1_0 : getObjectDocumentSyntax(object, context);
SyntaxContent syntaxContent = new SyntaxContent(object.getStringValue(name), syntax);
try {
buffer.append(editor.render(syntaxContent, parameters));
} catch (EditException e) {
LOGGER.error("Failed to display the text area property.", e);
}
}
Aggregations