Smirftsch Posted October 10, 2023 Share Posted October 10, 2023 I'm still learning and reading, and I haven't yet figured out how to really configure the html purifier. For now its bothering me that media elements (such as video) are plain stripped out (added with TinyMCE), so in order to be able using these it seems I need to whitelist those manually. After some reading I found this github topic, but I'm not sure yet how to really use that information, so perhaps someone can enlighten me which steps I have to take and someone can give me a more detailed instruction how and where to really add these hooks, and/or if and how it is maybe possible to switch to the in the topic mentioned html5 version of it? Link to comment Share on other sites More sharing options...
ngrmm Posted October 10, 2023 Share Posted October 10, 2023 @Smirftsch which version of TinyMCE are you using? I usually use CKEditor and there you can allow extra Content in the options of the field. I think with TinyMCE you can whitelist html tags in the module settings. This would effect pasted content. Link to comment Share on other sites More sharing options...
Smirftsch Posted October 11, 2023 Author Share Posted October 11, 2023 This would be the included version 6.1.5 And yes, I've been using CKEditor so far as well, but regarding the age of the included version and the annoying handling of extensions/plugins I thought to give TinyMCE a try in my new project and I am quite satisfied so far. Well, there is no such setting (or I must have missed it), there are some settings which make sense like invalid styles and tools to be removed from the toolbar to make it usable in PW without the user having a chance to confuse things, but nothing like whitelisting specific html. Also the pastefilter whitelist, but I want to make use of the media tool (button) from TinyMCE, which just inserts the corresponding html5 code. Besides, I am pretty sure it is in the purifier because it seems to be no problem when disabling it- which I don't want to for obvious reasons. Link to comment Share on other sites More sharing options...
ngrmm Posted October 11, 2023 Share Posted October 11, 2023 You have to look for it in the module settings, not in the field settings Pastefilter whitelist is the section. Paste in this: p, strong, em, hr, br, u, s, h1, h2, h3, h4, h5, h6, ul, ol, li, blockquote, cite, a[href|id], a[target=_blank], img[src|alt], img[class=align_left|align_right|align_center], table[border], thead, tbody, tfoot, tr[rowspan], td[colspan], th[colspan], colgroup, col, sup, sub, figure, figcaption, code, pre, b=strong, i=em, video I just added video at the end of the default tags. I guess that the purifier will ignore this tags. Link to comment Share on other sites More sharing options...
Smirftsch Posted October 11, 2023 Author Share Posted October 11, 2023 Thanks, and yes, I was in the module settings and I've also seen the pastefilter. Nevertheless I tried that idea, but as I was afraid this seems to have no effect at all. Checking again what is written in the template regarding the pastefilter: Quote Reduces most pasted content to its basic semantic HTML to avoid messy tags and attributes from ending up in the editor due to a paste operation. Allowed elements and attributes are configurable in the InputfieldTinyMCE module settings. Pastefilter is only applied to content copied externally, from outside the TinyMCE field. For some reason the github link I added in my first post was removed: https://github.com/processwire/processwire-requests/issues/226 in which there is a request for making the purifier to configurable, but I don't fully understand this, therefor my request here. Link to comment Share on other sites More sharing options...
ngrmm Posted October 11, 2023 Share Posted October 11, 2023 strange, It worked for me. I pasted this and it got stripped with the default settings. After adding video to the pastefilter whitelist it stays. Which tags get stripped for you? <video width="320" height="240" controls> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support the video tag. </video> Link to comment Share on other sites More sharing options...
Smirftsch Posted October 12, 2023 Author Share Posted October 12, 2023 All except: Your browser does not support the video tag. Everything is kept once Purifier is disabled. Having source and video in the pastefilter whitelist doesn't make any difference for me ? Edit: something seems to be going absolutely wrong here, even when disabling purifier and pastefilter or editing pastefilter removing "i=em" a sourcecode insertion like this: <i style="font-size:24px" class="fa"></i> becomes <em class="fa" style="font-size: 24px;"></em> so for some reason these settings are obviously not applied. Guess I am opening another topic for this issue. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now