Incorporating CKEditor on a UserControl within our web application has been successful in loading default templates both locally and on the server. However, I encountered an issue when attempting to fetch templates from a database table, convert them into JSON format, and write them to a JavaScript file for integration with CKEDITOR.template_files.
The generated JS content in the file looks like this:
CKEDITOR.addTemplates('templateskey',{imagesPath:'',templates:[{title:'LCH - Complaint', image:'', description:'Message Template - Complaints', html:'HtmlContent'}]});
The challenge arises on the server where the dynamically created JS file appears to be blocked due to loading over HTTPS or being unable to locate the file.
[blocked] The page at 'https://...' was loaded over HTTPS, but ran insecure content from 'http://...' (page not found URL): this content should also be loaded over HTTPS.
Subsequently, CKEDITOR.config cannot load the "templatesKey" template and throws the error:
Uncaught TypeError: Cannot read property 'imagesPath' of undefined
To address this issue, I have downloaded the ASP.Net version of CKEditor and integrated it into my project. In the code-behind, I am setting myCKEditor.TemplatesFiles and myCKEditor.Templates as follows:
myCKEditor.TemplatesFiles = "['" + relativePath + "']";
myCKEditor.Templates = "templateskey";
Could the problem stem from the dynamic generation of the JS file or from the templates plugin loading content over HTTP instead of HTTPS? Is there a more efficient method to add templates dynamically to CKEditor?