Hello,
When focused in the HTML editor, I set the default font and font size and add a p tag to the outermost.
Then when I try to get the editor value with editor.value() it automatically gets a space ' ' is being added, but when I read it with editor.body.innerHTML there is no space.
This does not allow you to check whether the space was added by the user.
If from now on I get the editor value with editor.body.innerHTML, could problems occur?
Or what can I do so editor.value() doesn't automatically add spaces?
Thanks
Result:
editor.value(): <p><span style="font-family:Tahoma;font-size:10pt;"> </span></p>
editor.body.innerHTML: <p><span style="font-family:Tahoma;font-size:10pt;"></span></p>
When focused in the HTML editor, I set the default font and font size and add a p tag to the outermost.
Then when I try to get the editor value with editor.value() it automatically gets a space ' ' is being added, but when I read it with editor.body.innerHTML there is no space.
This does not allow you to check whether the space was added by the user.
If from now on I get the editor value with editor.body.innerHTML, could problems occur?
Or what can I do so editor.value() doesn't automatically add spaces?
Thanks
<textarea id="editor"></textarea>
<script>
$("#editor").kendoEditor({ tools: [
"bold", "italic", "underline", "fontName", "fontSize"
]});
var editor = $("#editor").data("kendoEditor");
$(editor.body).focus(function (e) {
editor.exec("fontName", { value: "Tahoma" });
editor.exec("fontSize", { value: "10pt" });
var content = editor.value();
if (content.indexOf('<p') !== 0)
editor.value('<p>'+ content +'</p>');
console.log(editor.value());
console.log(editor.body.innerHTML);
});
</script>
Result:
editor.value(): <p><span style="font-family:Tahoma;font-size:10pt;"> </span></p>
editor.body.innerHTML: <p><span style="font-family:Tahoma;font-size:10pt;"></span></p>