Kendo UI Editor (jQuery) removes all contents of template HTML element

0 Answers 15 Views
Editor
Ferry v.d. Graaf
Top achievements
Rank 1
Ferry v.d. Graaf asked on 24 Jun 2021, 01:21 PM | edited on 24 Jun 2021, 02:21 PM

There is an HTML element, called "template", more information here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template. We cannot use this element in a Kendo Editor, because it will always remove all contents from this element.

It can be reproduced in your demos here: https://demos.telerik.com/kendo-ui/editor/all-tools by following these steps:

Click the "View HTML" tool/button, then add this HTML to it:

<h1>Hello</h1>
<p>This is a test</p>
<template><p>This is a template</p></template>

Click "Update".

Then open the "View HTML" tool again. You now see that the HTML has been changed to this:

<h1>Hello</h1>
<p>This is a test</p>
<template></template>
I have checked the options, but I can't find any options to change this behavior. Is it possible to fix this problem somehow? Or is this intended to work like this? If the latter, I wonder why?
Ianko
Telerik team
commented on 29 Jun 2021, 10:51 AM

Hi,

As the DOM content is being reinitialized each time it is updated the template element is not being considered for recreation. Note that in general the template element is not handled internally as it is not supported by all browsers. Also the template has its own document fragment and its recreation would be more complex that a simple DOM recreation. 

Such functionality can be addressed as a feature request at the moment. And I can log one on your behalf. However, I would like to get more details about the use case of the template inside the content. From the information provided I am not sure I can think of a proper use case about how this template can be either edited or used by the end user. Or being part of a more complex solution. 

Ferry v.d. Graaf
Top achievements
Rank 1
commented on 30 Jun 2021, 07:28 AM | edited

That makes sense, thanks for your explanation.

We have our own CMS where our developers (and sometimes customers) can change the HTML, CSS and javascript of every page. We use the Kendo Editor for places where we need a WYSIWYG editor. For one of our customers, our developers used the <template> element for HTML that gets added dynamically with javascript (which seems to be what the element is meant for). Every time someone changes something in the HTML of that page, these <template> elements will be emptied by the editor, which breaks some of the functionality of that page.

We have stopped using the template element now and instead just use a hidden div, which works just as well. So it's not super important that this gets fixed, was just wondering if there is an easy fix available for the template element.
Ianko
Telerik team
commented on 02 Jul 2021, 05:23 AM

Hi, 

I am still not sure I understand the exact purpose and benefits to store a template element inside the content of an editor. 

If the template element cannot be edited by the end-user and the need is to have the contents of that element injected inside the editor the template element can safely exists in a custom tool configuration or just rendered in the main page where the Editor is initialized. Like in this example: https://dojo.telerik.com/@iankodj/axudeCoK/4

If the case is that the template elements are utilized in a different page, one that is created in the Kendo Editor and the template elements are not something that should be edited or part of the Kendo Editor content I suggest you to inject them programmatically via server side logic when the page is rendered.

If I am still missing the proper use-case and purpose of the template elements to be included on the Editor content area please do let me know. 

No answers yet. Maybe you can help?

Tags
Editor
Asked by
Ferry v.d. Graaf
Top achievements
Rank 1
Share this question
or