use of com.enonic.xp.portal.RenderMode in project xp by enonic.
the class TextRenderer method render.
@Override
public PortalResponse render(final TextComponent textComponent, final PortalRequest portalRequest) {
final RenderMode renderMode = portalRequest.getMode();
final PortalResponse.Builder portalResponseBuilder = PortalResponse.create();
portalResponseBuilder.contentType(MediaType.create("text", "html")).postProcess(false);
if (textComponent.getText().isEmpty()) {
renderEmptyTextComponent(textComponent, renderMode, portalResponseBuilder);
} else {
if (renderMode == RenderMode.EDIT) {
portalResponseBuilder.body(MessageFormat.format(COMPONENT_EDIT_MODE_HTML, textComponent.getType().toString(), textComponent.getText()));
} else {
ProcessHtmlParams params = new ProcessHtmlParams().portalRequest(portalRequest).value(textComponent.getText());
final String processedHtml = removeEmptyFigCaptionTags(service.processHtml(params));
portalResponseBuilder.body(MessageFormat.format(COMPONENT_PREVIEW_MODE_HTML, textComponent.getType().toString(), processedHtml));
}
}
return portalResponseBuilder.build();
}
Aggregations