<commit_before>package org.minimalj.frontend.impl.json;

import org.minimalj.model.Rendering;
import org.minimalj.model.Rendering.RenderType;

public class JsonText extends JsonComponent {

	public JsonText(Object object) {
		super("Text");
		if (object != null) {
			put(JsonInputComponent.VALUE, object.toString());
		}
	}

	public JsonText(Rendering rendering) {
		super("Text");
		if (rendering != null) {
			RenderType renderType = rendering.getPreferredRenderType(RenderType.HMTL, RenderType.PLAIN_TEXT);
			String s = rendering.render(renderType);
			// Security: should the rendered string be checked for attacks?
			// the value is later inserted in the html page as innerHtml
			put(renderType == RenderType.HMTL ? "htmlValue" : JsonInputComponent.VALUE, s);
		}
	}
}
<commit_msg>JsonText: support html text<commit_after>package org.minimalj.frontend.impl.json;

import org.minimalj.model.Rendering;
import org.minimalj.model.Rendering.RenderType;
import org.minimalj.util.StringUtils;

public class JsonText extends JsonComponent {

	public JsonText(Object object) {
		super("Text");
		if (object != null) {
			String string = object.toString();
			if (StringUtils.isHtml(string)) {
				put("htmlValue", string);
			} else {
				put(JsonInputComponent.VALUE, string);
			}
		}
	}

	public JsonText(Rendering rendering) {
		super("Text");
		if (rendering != null) {
			RenderType renderType = rendering.getPreferredRenderType(RenderType.HMTL, RenderType.PLAIN_TEXT);
			String s = rendering.render(renderType);
			// Security: should the rendered string be checked for attacks?
			// the value is later inserted in the html page as innerHtml
			put(renderType == RenderType.HMTL ? "htmlValue" : JsonInputComponent.VALUE, s);
		}
	}
}

{'fraction_non_alphanumeric': 0.11353211009174312, 'fraction_numerical': 0.0, 'mean_word_length': 4.487421383647798, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '135627', 'n_tokens_mistral': 584, 'n_tokens_neox': 534, 'n_words': 131}