CKEditor for ASP.NET & custom tags - asp.net

I need to edit an ascx file's content with CKEditor. The content of ascx is mostly pure html code. It also has a custom tags in it (I use a custom framework and its own custom tags, ie: )
CKEditor erases those custom tags automatically (since they are not valid HTML codes).
How can I add/define framework's custom tags into CKEditor so it would not erase them.
PS: those custom tags don't need to be rendered in HTML view as long as they stay in the source code.

You need to modify CKEDITOR.dtd object so editor will know this tag and correctly parse HTML and process DOM. See ckeditor how to allow for .insertHtml("<customTag myAttr='value'"></customTag>")

CKEditor's protectedSource feature solved my problem. the custom tag sits in regular html code and CKEditor ignores it which is exactly what I want. I will be using CKEditor for text modification only.
//example custom tag: <inc:module src="module_name" runat="server" />
// protect <inc:* /></*
config.protectedSource.push(/<([\S]+)[^>]*inc:*>.*<\/\1>/g);
// protect <inc:* />
config.protectedSource.push(/<[^>]+inc:[^>\/]*\/>/g);

Related

How can I add a css file into my TinyMCE template?

My question is about Tinymce Template Plugin.
I have been developing a CMS with ASP.NET MVC. I can insert a template by using “insert template plugin”, but I can not insert a css file.
The template I will insert should be more developed. When I add a css file, it does not work. For example, <link rel=“stylesheet” type=“text/css” href=“theme.css”>. This link is my template I want to use.
And then I am saving this content into my database. This link can not be saved into my database. It can not be seen.
I used content_css ,the template looks good in the editor, but when I look at the page, it looks very bad because the css files does not work. In addition to all of these, when I look at the table of database (column : content) there are not css links (<link href...)
What should I do for this problem ? Thanks for your help.
CSS links belong in the head of the document, it is not valid HTML to add the link tag to the body. The Template Plugin allows you to add fairly involved HTML to the HTML body so you don't have to build that chunk of HTML over and over again. Please read the documentation for Templates: https://www.tiny.cloud/docs/plugins/template/
When you apply CSS in content_CSS it only affects how TinyMCE looks in the iFrame that the editor lives in. You need to get the CSS into the head of the page you are bringing over from your databse.

Inject code to the <head> tag of the TinyMCE iframe on WordPress

Is it possible to inject code to the TinyMCE WordPress editor via hooks? Specifically, I want to insert code within the <head> tag of the <iframe>. Something similar to the add_action( 'wp_head', 'function_name' ).
The content I'll add is a dynamically generated CSS (based on an ACF Options Page repeater field). I tried to create a *.php file with header("Content-type: text/css") header in it + the CSS content and then use the add_editor_style() function but when I call the file in a href attribute it seems like the WordPress functions (including ACF's get_field()) are not defined.
I also tried using data URI strings like data:text/css,.color_1{color:... but add_editor_style() ignores invalid URLs.
There are two settings in the TinyMCE configuration that you can use to pass CSS to the editor:
content_css
https://www.tinymce.com/docs/configure/content-appearance/#content_css
content_style
https://www.tinymce.com/docs/configure/content-appearance/#content_style
You can use the tiny_mce_before_init filter (via add_filter) to inject CSS into the editor using one of these configuration options.
As a WordPress plugin would be running in PHP perhaps you could process the needed CSS into a string on the server and pass it in via content_style?

How to add custom html tag in CKEditor?

I want to add a custom tag like this:
<myTag>text</myTag>
How do I apply HTML properties to a custom tag?
Navigate to /admin/config/content/formats/manage/full_html
Tick on "Limit allowed HTML tags and correct faulty HTML".
You will get an option to put your custom tag with allowed attributes.
Add your new tag(s) separated by space, eg: <mytag attribute-1 attribute-2>
Hope this helps.

Can I Add Meta Tags on page with Google Tag Manager?

I have added Tag Manager script on my page. So can I add more meta tags to my page.
I means can there will be Tag manager script and meta tags on page or from both of these I should use script or tags?
Thanks
Dalvir
I assume you mean HTML meta tags like keywords, description etc.
You can add them via the tag manager by inserting a custom html/javascript tag that creates additional meta tags via js in the page header. However that will probably won't do you much good, as search engine spiders etc. will probably not pick up meta-tags that have been inserted via javascript and browsers are unlikely to respect tags that have been injected after the page started rendering.
So theoretically it'S possible, but I cannot conceive a use case where it would make sense.
I use this little badboy when I need to populate meta-tags, seems to work like a wee charm.
<script>
var m = document.createElement('meta');
m.name = 'your-name';
m.content = 'your-content';
document.head.appendChild(m);
</script>

Changing content in cufontext tag within a wordpress theme

I have installed a WordPress theme which features headings like 'our sponsors' or 'featured posts'. When I inspect the element using google chrome, it shows that it is within a tag called 'cufontext' which I have never come across before (i think it is to do with javascript).
Is it possible to change the content within the cufontext tag so that it says something different like 'about me' instead of 'our sponsors'?
Thanks
Cufon is a font-replacement technique that uses javascript to write fonts from a font file to your browser.
So those <cufon> tags are generated when page renders and are not in the template files.
Simply find where 'our sponsors' text is located and replace it to your likings.
The most possible location for that text is:
in post / page as a title
in the template as static text

Resources