Remove inline styles from django-tinymce html content - html

When I save content through django-tinymce it adds its own inline styles. However I'd like to remove this behaviour and just save the content in plain html. Can you please help me on this issue?

You can use any of tinyMCE configs like this:
Put this to your Django settings.py
(this will tell tinyMCE which elements are allowed`)
DJANGO settings.py
TINYMCE_DEFAULT_CONFIG = {
'theme': "advanced",
'valid_elements' : 'a[href|target=_blank],strong/b,div[align],br,p'
}
And push Clean Button in TinyMCE.
All TinyMCE configs is here:
Try also look at invalid_elements and invalid_styles
P.S. It would have more sense to set:
'invalid_elements': 'p[styles], span'
to remove all styles But It didn't work.
Hope it helps.

You could try writing your own implementation of a save function using
getContent({format: 'text'})
I'm no Djanjo expert but it sounds like the problem is being caused by them, and not TinyMCE itself.

Related

DOMPDF: how to force dompdf to ignore some html page content (i.e. links, <a> tags)

when I create the pdf of my page with DOMPDF, I would like to exclude something not really important or needed into the pdf file, for example the links.
Is there a way to ignore the tags?
thanks!
You can use a sanitizer like DOMPurify and configure it to disallow a tags.
// leave all safe HTML as it is and add <a> elements to block-list
var clean = DOMPurify.sanitize(dirty, {FORBID_TAGS: ['a']});
You can make them disappear by using css properties
a { display:none; }
...

How to make comments visible in UI with anchor tag

I have below code for anchor tag, the display content of tag is a comment and needs to be displayed. With below code only "383:" is coming in UI but I need complete content. I cannot modify the display content but any setting change or any other way can be considered.
383: <!--Commented by me--ENDS-->
Am using it in QLabel in PyQt5 but suggestions from any folks related to either PyQt5 or HTML can be provided.
I only know how to do it in JavaScript:
document.querySelector("a").childNodes.forEach(c => console.log(c.nodeType,c.nodeValue))
383: <!--Commented by me--ENDS-->

CSS Substring display none

Is it possible in CSS (only) to hide some text of a string?
I know there these attribute-selectores like:
[att^=val] – the “begins with” selector
But for instance, having this:
<div class="some_random_text">
This is a default text
</div>
I want to (display: none) only a certain substring - in thise case "default". I know how to do it with JS, but I'm looking for a CSS-solution only (if there is any).
Even though I guess it isn't possible to manipulate the DOM via CSS, which would be neccessary to have something like:
this is a <span class="hideThis">default</span> text
why would you need this and where does it occur?
For instance in a CMS (in my case OXID). You can add a title to a specific payment-method. Here I have
paypal
paypal (provider1)
paypal (another dude)
I want to have only PayPal visible in the frontend. The other PayPal-Paymenttypes have to remain however. Naming them all PayPal just leads to confusion.
there is the content-property. Is it somehow managable with that?
Again, no JS :-)
To answer your question - no, it's not possible using only CSS.
You can;
Edit the HTML as you suggested
this is a <.span class="hideThis">default<.span > text
Use JS to alter the elements innerHTML value
Use a pre-processing language (like PHP or ASP, whatever you are able to use) to reduce the string to a substring.
Sorry if that's not the answer you wanted, but those are your options.
It it not possible. The only thing that can actually modify the inside text is the content property. Assuming something changes in your dom, you can have rules like:
.some_random_text:after {
content: "This is a text";
}
other_select .some_random_text:after {
content: "This is a default text";
}
But sincerely, I don't get the point, as JS and consors are made for that.
It's not possible, here's the documentation on selectors: https://www.w3.org/TR/css3-selectors/#selectors

Is there a way to change class names in CSS and all instances found in HTML pages link to the CSS?

I just finished creating a site with a few HTML pages and a CSS style sheet. Near the end of the project I decided I would like to change some of the class names.
Example:
In my CSS I have .classname and in my HTML I have quite a few tags linked to that css class using
class="classname"
I would like to change .classname to .class-name in my CSS Style Sheet, however, if I do this I would have to go through thousands of lines of code in my html pages to find and change all the class names from class="classname" to class="class-name"
is there a program that can be used that allows you to change a class name in the css and it will go through all html pages and change it there as well?
I use dreamweaver. Is there a way to do this in dreamweaver?
Note: I have tried using the find and replace options in dreamweaver however this does not fully work.
I'm not able to search "class="classname"" and replace it with "class="class-name" because some tags use "class="example someclass classname test""
I'm not able to search "classname" and replace with "class-name" because "classname" can be found in between <p></p> as content and I do not want it to change here.
Thank you!
I am not familiar with DreamWeaver options, but if you have a preferred advanced text editor (I use NPP) you can use regex.
I would try an expression such as (?<=class="[^"]*)(classname)(?=[^"]*")
And replace that

Getting output to just what's in the textarea

how do i get the output to just what's in the textarea instead of tinymce adding a whole html page wrapped aound my content.
plugins : "fullpage",
theme_advanced_buttons3_add : "fullpage"
remove these options from plugin settings
actually the question should have been the other way around
tinyMCE.get("elm1").getContent();