How do i update an element inside a ckeditor 5 dynamically using javascript innerHTML - ckeditor

I want to automatically load up adverts inside the body of my blog website
For Example:
<div class="dynamic-ads-div"></div>
After loading up ckeditor 5, i want to replace the above element with an advert code from platforms like ezoic, google, etc. I have tried to put the code directly in the blog post body, but ckeditor keeps filtering, after rigorous research, i could only preserve the custom html elements like <ins>, but any form of script tags are filtered out, i want to use the approach of loading up ckeditor before adding the advert code dynamically, I tried editor:
document.querySelectorAll(".dynamic-ads-div").forEach(ads => { ads.innerHTML = '<script src="LINK_TO_ADS_PLATFORM"></script><custom-element></custom-element><script>INIT_ADS_CODE</script>' }).
Ckeditor completely ignores the above code.
Any form of help will be greatly appreciated; If you can help me preserve the script tags, or help me insert content dynamically after loading up ckeditor.
Thanks

Related

How to set automatically highlite.js style for all pre tag

Everyone
I am making blogging site using quill.js. To view post in frontside I am using highlite.js.
In following image first 2 block are displayed with default side just <pre> tag.
and last one with <pre><code class="dart">{code}</code></pre>
My question is
I don't want to add manually html with <code class="dart">
I want automatic set styling by using just tag
I read all document but not found any specific answer how to set?
please any one?
I found answer. Using custom selector.
document.querySelectorAll('pre').forEach((block) => {
hljs.highlightBlock(block);
});

Orchard CKEditor not rendering on custom text areas

I have a custom module that works with a custom data type and part.
In my edit view I have some textareas but these are no rendered by CKEditor.
Only BodyPart html text areas are rendered (like in pages & blog posts).
How can I do this?
References: https://orchardckeditor.codeplex.com/
CKEditor needs to be initialized, either sneak in somewhere this javascript line
CKEDITOR.replace(textarea);
or append class ckeditor for auto-initialization
<textarea class="ckeditor"></textarea>
If it doesn't work you may also need to add script requirement to your edit view
Script.Require("CKEditor");

Get CKEditor contents without updating the textarea

Fairly new to CKEditor here. I'm aware that you need to call the updateElement() method for CKEditor to send the current editor content to the related textarea element. From there, you can call the getData() function to get the content. (Although I don't understand why there are two steps to get the editor content, instead of one.)
However, I want to get the current content directly from the editor, without changing the related textarea content. Is there a CKEditor method to achieve that, or is it a case of using jQuery to find the editor content?
The getData method will return the raw HTML from the editor.

How to insert custom html into Joomla header

I am using file_get_contents to acquire html. From the html page I extract the css, and js. Right now I am using a very expensive function.
$css_elements = $doc->getElementsByTagName('link');
foreach ($css_elements as $css_element) {
$Jdocument->addStyleSheet($css_element->getAttribute('href'));
}
I would like to save the csss links to a file, and then read the file and add the links as a whole to the head tag of the HTML page.
I was wondering is Joomla has an in build function that allows for one to add unwrapped text to the head tag.
Thanx everyone!
I recommend using the Flexi Custom Code module to do this in Joomla:
http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-modules/15251
This module allows us to insert any code like php, javascript PHP, CSS and html at site modules positions. For example, It's can be used for simple code, simple function, embed code, adsense code, affiliation code and others copy and paste codes for Joomla site.
Main Features:
1. Available for PHP, HTML, JAVASCRIPT and CSS codes
2. Available to set the target of this module
3. Easy and flexible

I am using HTML snippet in to Highlight HTML and Javascript code in blog Joomla. but it's executed after saving it

while creating a article I want to show some HTML code as part of content, but after saving that article that particular snippet of HTML code get executed.
I am using joomla 1.5 | code citation extension for insert code in article. Is there any solution?
You should turn off HTML stripping, or include it as a Custom HTML Module, and writing the position in the article with load position. to load the custom HTML you've put in the Module. i.e.
{loadposition YourModulePosition}
Will load anything you place within a Custom HTML Module.
The correct way should be to paste the code into the wysiwyg (design view, not raw code view) - as long as you have a decent editor the angle brackets should be converted to html entities and it should just work.
The built-in Geshi plugin - though a little dated - is usually all that is needed to make add colored highlighting. The plugin is a little dated but after inserting your code all you need to do to make it work is add:
<pre class="html"> ... </pre>
around your html. Chenge HTML to js, css, etc depending upon the code to be shown.

Resources