RTE AEM6.2 By default Addition of p tag - aem

I tried removing the p tag from RTE of AEM(6.2) by adding the property removeSingleParagraphContainer :true in rte text node.It removes the p tag from first paragraph but as soon as we enter the next paragarph the p tag gets added.It seems the component needed to be customized from out of box.
Is there any other way can we achieve this.
The functionality which I require is that no tag should get added until users selects a specific formatter tag from paraformat.
Thanks for the Help!

I've struggled with this issue once upon a time. As far as I know there is no way to do it with configuration. You'll need custom code to get rid of these <p>'s.
One thing I can advise is that it's far easier to do it from within your code once already reading the property from JCR - then tweaking the aem component not to add it.

This is the default behaviour of RTE OOTB. removeSingleParagraphContainer is for backward compatibility and not the behaviour you are expecting.
By default, pressing Enter will add a <p> tag but if you press Shift+Enter (at least on Mac, not sure on Windows) you will get a <br> tag which is probably what you are expecting.
The only way to change the behaviour is to overlay the RTE control.

Related

TinyMCE invalid_elements - how to remove from HTML and from DOM

I'm having problems with removing tags from TimyMCE. (last version)
invalid_elements : 'br' or valid_elements : 'p/br'
This delete/replace the tag on ctrl+enter from html source but not from the DOM in the editor.
How can i prevent the use of invalid elements in the Editor DOM?
Simply said i want to prevent using a tag not only in the generated html source, but also in the Editor too.
What do you want to have happen when someone presses shift+enter if you don't want the <br> to be used? You can capture any keydown event in the editor and then choose what you want to do instead.
This TinyMCE Fiddle captures the keydown event and simply ignores shift+enter. You can certainly do something different if needed.
http://fiddle.tinymce.com/vogaab/1
EDIT: Based on your comment I updated the fiddle:
http://fiddle.tinymce.com/vogaab/2
...in this version I modify the event to make the event.shiftKey attribute false and then let the event finish as normal. I no longer get a <br> but instead get a <p> tag whether I use enter or shift+enter

How to stop TYPO3 from stripping <p> tags from RTE content (or touching it at all)

I have a TYPO3 which strips any <p> tags from content I create when the RTE editor is enabled for the field in question before it saves it in the DB. And it seems I cannot find a way to disable this behavior with a TypoScript. As soon as I disable the RTE editor I can save <p> tags and they get correctly rendered in the frontend. They also get correctly rendered in the frontend when I simply add them directly in the database in the tt_content table in the bodytext field.
When I switch to the edit source mode of the RTE I see all <p> tags in place. Before and after a save (also they never make it to the DB) so it looks like they get converted to (linux) line breaks or something and get converted back to <p> tags when the editor loads them in the backend. But those line breaks of course have no effect to in the frontend.
I thought this behavior would be controlled by RTE.default.proc but everything there looks good to me (p is already in the allowed tags and there is no clue why it could be stripped). I've also tried to disable the RTE.default.proc.entryHTMLparser_db and RTE.default.proc.exitHTMLparser_db as I wouldn't mind it if the HTML content as you see it in the edit source mode of the RTE (so with RTE still enabled!) would not be touched at all - in fact I would prefer it - but this had no effect. On the other hand when I add tags to the allowed tags which weren't there before (like <button>) this works so the things I try to add to RTE.default.proc aren't ignored in general.
So how can I stop TYPO3 from stripping my <p> tags from RTE content or touching it at all? I'd prefer a solution with TypoScript but meanwhile I would also be happy about an ugly hack in a sys extension as long as it works...
I'm not sure if this is a bug or not but the solution to my problem lies in p.rmTagIfNoAttrib = 1. At least in my TYPO3 version (v6.1.7 and nearly only built in extensions) I cannot find this setting in the preset TypoScript of the page or the RTE editor so I'm guessing it defaults to 0. In my logic 0 means false so I'd say the default would read as "remove tag if there is no attribute?: no!".
However TYPO3 seems to work after its own logic. Adding the following statement to the page TS sloves my problem and <p> tags are preserved:
RTE.default.proc {
entryHTMLparser_db {
tags {
p.rmTagIfNoAttrib = 1
}
}
}
The reasons for this behavior are explained in the TYPO3 manual:
Many of the transformations performed back and forth in the TYPO3 backend date back to when it was a challenge to incorporate a RTE in a browser. It was then sometimes needed to fall back an a simple <textarea> where rich text had to be presented in a simple enough way so that editors could work with it with no visual help.

TinyMCE - editor changing pasted content

Two questions and maybe they are caused by the same thing/setting.
Using TinyMCE with full corporate account. Many of the publishers are just pasting HTML into the HTML Source Editor... we are just getting this going the results are very mixed.
So if someone has a well coded page it works well - as far as we think.
But if you create a page with a couple of (or one) open div tag. Holy cow! The editor can throw divs everywhere - 30 extra on one page someone sent me. Why is the editor changing content? Can we keep this from happening? If a publisher makes an HTML mistake we would rather that the mistake shows - not be scrubbed.
Also I noticed myself when creating menus that if you put in anything inside a link tag (like a div, ul, li, dd, dt, dl, h1-6... pretty much any tag) other than a span, that the editor will either push the tag content outside of the link tag or it will change the tag to a span.
http://www.tinymce.com/wiki.php/Configuration:Cleanup/Output
Looks like the verify html is the new setting. Will report back after testing.
David - I would have marked yours as right if you answered. Looks like that works for 3.4 and below.
For version 3, use
verify_html : false
From here http://archive.tinymce.com/wiki.php/Configuration3x:verify_html

What is the best way to enable content authors to add images with captions in Expression Engine

There's a module to do this in Drupal land, but I've been frustrated with the hacks that've been necessary in Wygwam. What is the best way to go about implementing this in such a way that you don't need to totally override the default image handling in ChannelImages/Wygwam?
Assets is a good suggestion, but I believe Devdemon's channel images might be a better fit for the workflow you're suggesting.
http://www.devdemon.com/channel_images/
Clients can add (and see) a caption and more and it's fully integrated with Wygwam and other editors. Devdemon's support is also excellent.
The Assets module from Pixel & Tonic allows you to double-click on the image (or any other file) and add metadata. You then have access to the metadata in your templates.
Check the screenshot: http://pixelandtonic.com/assets
You can also add metadata using the native File Manager. Click the edit icon from the File Manager and you'll see a few fields. You can use the File Entries tag to access it.
http://expressionengine.com/user_guide/modules/file/file_tag.html
I typically use Matrix with one column for the image, one column for the caption, and if a link is needed another column for the link. This of course works best if the image is in a fixed location within your template.
On possible way to accomplish this that I have used is to run some jQuery that looks for images within a certain area, and if they have alt attributes, rewrite the image tag within a tag with a tag inside.
so:
jQuery(document).ready(function() {
$('#page-content > .wrapper img').each(function(){
if($(this).attr('alt') !== undefined && $(this).attr('alt').length > 0){
if(!$(this).parent().hasClass('content-image')){
$(this).replaceWith("<figure class='content-image "+$(this).attr('class')+"'>"+$($('<div></div>').html($(this).clone().attr('class',''))).html()+"<figcaption>"+$(this).attr('alt')+"</figcaption></figure>");
}
}
});
});
will do just that. It's looking within a #page-content div for img tags with alt attributes. And then rewriting it as
<figure><img src='....' .... /><figcaption>This is the text that was in the alt attribute</figcaption></figure>
Soooo, that kinda works. The only caveat is that you had better not use any double-quotes within your alt text, or it will break thangs. Not the cleanest of solutions, but a solution, nonetheless.

TinyMCE editor disable

How can I disable tinyMCE?
I'm not trying to make tinyMCE not exist, just trying to disable the field temporarily using PrototypeJS's Form.disable.
Is there a particular way to mark a field disabled for editing?
One option is to use the plugin 'noneditable'
Or you could investigate the 'mode: exact' setting and only setting it on the exact id of the form field you want to control.
Your use case isn't really clear, so hope the above tips work.