You are not logged in.
#1 2009-03-05 17:42:10
- Fabio Di Vito
- Member
- Registered: 2009-03-04
- Posts: 5
p tags around hr,table,div etc.
hi at all
First of all, I speak English pretty bad, but I try it anyway
My problem:
- I write blabla bla in the text editor
- I press enter
- I make a horizontal line
the result looks like this:
<p> blabla bla </ p>
<p> <hr /> </ p>
The same happens with tables or divs.
here an example of my configuration editor:
Code:
tinyMCE.init({
mode: "none",
theme: "advanced",
plugins : "save,sbypage,paste,table,contextmenu",
theme_advanced_buttons1_add : "sbypage,cancel",
theme_advanced_buttons1 :"formatselect,bold,italic,underline,separator,link,unlink",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,selectall,separator,undo,redo,separator,justifyleft,justifycenter,justifyright,justifyfull",
theme_advanced_buttons3 : "tablecontrols,visualaid,bullist,numlist,hr",
theme_advanced_toolbar_location: "external",
language : "de",
forced_root_block : false,
save_oncancelcallback : "SBYFRAME.cancelText"
});I hope you can help me.
Answers in German would be great.
But I am grateful for every answer, whether English or German!
Fabio Di Vito
Last edited by Fabio Di Vito (2009-03-05 17:45:10)
Offline
#2 2009-03-06 13:51:01
- Fabio Di Vito
- Member
- Registered: 2009-03-04
- Posts: 5
Re: p tags around hr,table,div etc.
The problem with the table is solved.
We worked with version 3.2.1.
The version 3.2.2, make a table no longer in a p tag.
With an hr or div tag, the problem still.
Has anyone this problem?
We are grateful for any response.
Fabio Di Vito
Offline
#3 2009-03-06 17:15:59
- Fabio Di Vito
- Member
- Registered: 2009-03-04
- Posts: 5
Re: p tags around hr,table,div etc.
I noticed that Internet Explorer 7 add hr and divs correctly.
Firefox 3 makes problems.
Only firefox3 makes a p tag around a hr or div.
I thought that I should mention.
I wish a nice day.
Fabio Di Vito
Offline
#5 2009-03-11 09:36:59
- Fabio Di Vito
- Member
- Registered: 2009-03-04
- Posts: 5
Re: p tags around hr,table,div etc.
Thanks for the answer, Spock.
I was not sure whether it was a bug, or whether we have done something wrong.
I have another question, sorry.
I have created a separate button.
This button creates a div with content.
My problem:
I write the text.
Press Enter.
Click on my button.
The div with the content is inserted.
Around the div is now a p tag.
I Can not paste the div after the p tag?
Thank you for your efforts.
Here's the code of the button:
Code:
setup : function(ed) {
// Add a custom button
ed.addButton('mybutton', {
title : 'My button',
image : '../img/tiny_buttons/example.gif',
onclick : function() {
// Add you own code to execute something on click
ed.selection.setContent('<div class="box"><h3>Boxtitel</h3><div class="boxfarbe"><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy incidunt ut laoreet</p></div></div>');
}
});
}Offline
#7 2009-03-11 13:21:09
- Fabio Di Vito
- Member
- Registered: 2009-03-04
- Posts: 5
Re: p tags around hr,table,div etc.
Thanks for your answer.
It is good to know that it works.
We will try it now.
I tell you about it if it works.
Thank you again.
Fabio Di Vito
Offline
#8 2009-03-31 11:00:16
- Vtherry
- Member
- Registered: 2009-03-31
- Posts: 2
Re: p tags around hr,table,div etc.
Hi, I seem to have a related problem : when I insert a template, the editor wraps my DIV in a P.
spocke wrote:
We will probably fix the HR issue soon. Divs on the other hand can contain or be contained in anything.
i checked that on the http://validator.w3.org/check (XHTML1.0 Transitional) and it tells me that there is an error when a DIV is inside a P.
Do you think the good solution is to use :
tinyMCE.init({ forced_root_block : false, force_br_newlines : true, force_p_newlines : false }); ??
Thank you
Vincent
Offline
#10 2009-04-15 06:00:50
- WYSIWTF
- Member
- Registered: 2009-04-15
- Posts: 1
Re: p tags around hr,table,div etc.
Yeah the paragraph tags around the HR is a huge problem with clients, I didn't have a lot of time to fix the issue properly so I just made a quick fix that works for us. Here's how I solved it: I edited the tiny_mce.js file:
I found the method that inserts a blockquote. Grab the code inside this method and put it inside the method that inserts an HR. Now, in your new HR method change all references from BLOCKQUOTE to HR. Then near the end of the method where you see this comment:
Code:
// Add non BQ element to BQ bq.appendChild(dom.remove(e));
change to:
Code:
// Add non BQ element to BQ e.parentNode.insertBefore(e, bq);
This will insert an HR tag after the paragraph the cursor is in! Problem solved.
To clarify the problem and solution, take a look at this:
A client would type in a paragraph and insert an hr, the resulting HTML would look like this:
Code:
<p>This is my happy paragraph of text.</p><p><hr />Some new text.</p>
Which is annoying, but really really annoying when the client saves the data and it turns into this:
Code:
<p>This is my happy paragraph of text.</p><p></p><hr /><p></p><p>Some new text.</p>
Lots of new spaces, and the client goes berserk.
With my fix it will ensure that the HR is inserted outside of any paragraph tag, and there are no more surprises when the client saves the content.
Last edited by WYSIWTF (2009-04-15 06:07:10)
Offline
#11 2009-04-15 09:55:22
- Felix Riesterer
- Administrator
- From: Germany
- Registered: 2005-12-30
- Posts: 4601
- Website
Re: p tags around hr,table,div etc.
It is my true opinion that any use of <hr /> elements should be banned since it has nothing to do with content - it is a purely visual thing and as such should be handled via CSS!
Offline
#12 2009-04-15 22:25:23
- eworbit
- Member
- Registered: 2008-04-02
- Posts: 17
Re: p tags around hr,table,div etc.
I finally figured out how to sniper out a specifically selected node (such as a pesky paragraphs) with this code:
ed.addButton('removenode', {
title : 'Remove This Node',
image : '/jscripts/remove_this_node.gif',
onclick : function() { ed.dom.remove(ed.selection.getNode(),true); }
});
But the path bar (theme_advanced_path_location) doesn't get refreshed until I click away. What method call can I use to refresh it?
Thanks,
-eric
Offline
#13 2009-05-20 22:47:27
- duran_dal
- Member
- Registered: 2006-05-18
- Posts: 11
Re: p tags around hr,table,div etc.
How's it going with the issue with <hr /> that ends up inside <p></p> ?
I have tested the effect and sometimes it can also cause information to be lost at clean up.
1. Go to http://tinymce.moxiecode.com/examples/full.php
2. Clear all text
3. Enter Hello World
4. Set the fore-color of Hello to red (works with any formatting)
5. Put the carret at the begining of the line and press Enter
6. Go up to the top row
7. Insert a <hr />
8. Post
The result looks like this:
<p><span style="color: #ff0000;">
<hr />
<p> </p>
</span></p>
<p> </p>
<p><span style="color: #ff0000;">Hello</span> World</p>
This can have some strange effects in Internet Explorer and the clean up ![]()
The only way (that I've found) to get round this issue is the set "forced_root_block" to "false", but that is bad and it messes up the table-plugin when you try to align the table and it's content.
Regards
/Micke
Offline
#14 2009-12-10 22:34:02
- jjj3
- Member
- Registered: 2009-12-07
- Posts: 9
Re: p tags around hr,table,div etc.
Hi everyone, I have a very similar problem, to reproduce, start with a clean editor, type something, select text and change formatting, click somewhere in the text and insert a hr, the editor generates this code:
Code:
<p><span style="font-family: Courier New;">hello w <hr /> orld</span></p>
anyone has a hint on how to solve this? I'm aiming at something like this:
Code:
<p><span style="font-family: Courier New;">hello w</span> <hr /> <span style="font-family: Courier New;">orld</span></p>
or like this:
Code:
<p><span style="font-family: Courier New;">hello w</span></p> <hr /> <p><span style="font-family: Courier New;">orld</span></p>
the generated html won't display correctly on safari/chrome.
Thanks!
Offline
#15 2009-12-10 23:31:54
Re: p tags around hr,table,div etc.
Actually HR is not a valid child of P so it should be:
<p><span style="font-family: Courier New;">hello w</span></p>
<hr />
<p><span style="font-family: Courier New;">orld</span></p>
Best regards,
Spocke - Main developer of TinyMCE
Offline
#16 2009-12-11 17:54:37
- jjj3
- Member
- Registered: 2009-12-07
- Posts: 9
Re: p tags around hr,table,div etc.
Hi, I found that the table plugin inserted the table correctly, closing span tags and the current paragraph, inserting the table and opening another paragraph and span with the previous styles.
So, I stole part of the code from there and modified the advanced hr plugin:
plugins/advhr/js/rule.js
Code:
var AdvHRDialog = {
init : function(ed) {
var dom = ed.dom, f = document.forms[0], n = ed.selection.getNode(), w;
w = dom.getAttrib(n, 'width');
// by juan, changed to 100 default.
f.width.value = w ? parseInt(w) : (dom.getStyle('width') || '100');
f.size.value = dom.getAttrib(n, 'size') || parseInt(dom.getStyle('height')) || '';
f.noshade.checked = !!dom.getAttrib(n, 'noshade') || !!dom.getStyle('border-width');
// by juan, changed to % by default
selectByValue(f, 'width2', w.indexOf('px') != -1 ? 'px' : '%');
},
update : function() {
var ed = tinyMCEPopup.editor, h, f = document.forms[0], st = '';
h = '<hr';
if (f.size.value) {
h += ' size="' + f.size.value + '"';
st += ' height:' + f.size.value + 'px;';
}
if (f.width.value) {
h += ' width="' + f.width.value + (f.width2.value == '%' ? '%' : '') + '"';
st += ' width:' + f.width.value + (f.width2.value == '%' ? '%' : 'px') + ';';
}
if (f.noshade.checked) {
h += ' noshade="noshade"';
st += ' border-width: 1px; border-style: solid; border-color: #CCCCCC; color: #ffffff;';
}
if (ed.settings.inline_styles)
h += ' style="' + tinymce.trim(st) + '"';
h += ' />';
// added by juan (borrowed from table plugin)
var bm = ed.selection.getBookmark(), patt = '';
ed.execCommand('mceInsertContent', false, '<br class="_mce_marker" />');
tinymce.each('h1,h2,h3,h4,h5,h6,p'.split(','), function(n) {
if (patt)
patt += ',';
patt += n + ' ._mce_marker';
});
tinymce.each(ed.dom.select(patt), function(n) {
ed.dom.split(ed.dom.getParent(n, 'h1,h2,h3,h4,h5,h6,p'), n);
});
ed.dom.setOuterHTML(ed.dom.select('._mce_marker')[0], h);
ed.selection.moveToBookmark(bm);
ed.addVisual();
// end added by juan
//ed.execCommand("mceInsertContent", false, h);
tinyMCEPopup.close();
}
};
tinyMCEPopup.requireLangPack();
tinyMCEPopup.onInit.add(AdvHRDialog.init, AdvHRDialog);I also changed the default values to 100%, I wanted it to behave more similar to the standard hr button.
It's not very well tested right now but it seems to work fine.
Offline
#17 2009-12-11 21:56:46
- jjj3
- Member
- Registered: 2009-12-07
- Posts: 9
Re: p tags around hr,table,div etc.
It almost works, if you insert an hr and then before doing anything else you press enter, it keeps inserting hr tags.
I guess it's because I pasted that piece of code from the table plugin and it's like inserting new rows.
Anyone knows how to fix it? Thanks!
Offline
#18 2010-02-04 22:59:06
- mfeola
- Member
- Registered: 2010-02-04
- Posts: 2
Re: p tags around hr,table,div etc.
i am working on umbraco 4 and i am currently running into this issue. The client wants to be able to insert and move around lots of pieces at different times and one of those pieces is a horizontal rule and it would be a lot better for them to be able to use the button rather than inserting a macro that has a horizontal rule on it (sometimes they want a separator, sometimes they don't depending on how they feel the content runs between macros and paragraphs)
is there any update that i have to download to get this fix or is the official fix not available yet?
Offline
#19 2010-02-04 23:03:59
- jjj3
- Member
- Registered: 2009-12-07
- Posts: 9
Re: p tags around hr,table,div etc.
Sorry, no updates from me and no official fix that I know of. I might go back to this issue some day.
Offline
#20 2010-02-05 17:05:35
- mfeola
- Member
- Registered: 2010-02-04
- Posts: 2
Re: p tags around hr,table,div etc.
its weird... i did some more testing and here is what i found so far
it works if you click the insert HR button in IE (although it will add an empty paragraph tag after it sometimes) and save and publish.
and it works if you click the insert HR button in firefox and then click the HTML editor and then click to update and save and publish.
but it doesnt work if you are in firefox and you just click the insert HR button and then immediately click to save and publish, that is when the HR gets removed.
Last edited by mfeola (2010-02-05 17:06:27)
Offline
© 2003-2010