Skip to main content
Topic: Quote Line Breaks Bonanza (Read 2392 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Quote Line Breaks Bonanza

I think there was a discussion about this in the past, but I also think something has changed.  If I quote a post that already has a quote it puts an extraneous extra line break between the new quote line and the exist quote line.  Ok, that's a little annoying but tolerable.  Except it puts it between every old quote.  So quote a post with nest quotes?  They all get extra line breaks.  Soon the screen is filled with blank lines.

This is using the full editor w/o the wiz mode btw.  Using the quick reply at the bottom does not show this behavior.  Also in the full editor if you toggle from wiz to source mode and back these extra line breaks get added every time you toggle modes.  I think this is not the desired behavior especially since quick reply doesn't work this way.

ETA:  Beta 2 did not have this behavior
Last Edit: July 05, 2014, 01:16:19 pm by scripple

Re: Quote Line Breaks Bonanza

Reply #1

It's something in jquery.sceditor.bbcode.min.js as bringing the version from beta 2 back fixes the problem.

Re: Quote Line Breaks Bonanza

Reply #2

Something changed in sceditor between 144 and 145.  I'm not sure if they have a bug or if it doesn't like the way Elk talks to it.  The change is in bbcode.js from 144 to 145.  The relevant part of the code is here (from 144 with debug prints by me).

Code: [Select]
				while($(parentLastChild).hasClass('sceditor-ignore'))
parentLastChild = parentLastChild.previousSibling;

// If this is
// A br/block element inside an inline element.
// The last block level as the last block level is collapsed.
// Is an li element.
// Is IE and the tag is BR. IE never collapses BR's
if(parentIsInline || parentLastChild !== element || tag === 'li' || (tag === 'br' && $.sceditor.ie)) {
content += '\n';
console.log('Content 1:', content);
}

// Check for <div>text<div>This needs a newline prepended</div></div>
console.log('Tag', tag);
console.log('PS', previousSibling);
if(previousSibling) console.log('LC', previousSibling.nodeName.toLowerCase());
console.log('INLINE', $.sceditor.dom.isInline(previousSibling, true));
if('br' !== tag && previousSibling && previousSibling.nodeName.toLowerCase() !== 'br' && $.sceditor.dom.isInline(previousSibling, true)) {
content = '\n' + content;
console.log('Content 2:', content);
}
}

Lots of debug on my part there, but basically when quoting a post that already has a quote (or switching from source to wiz mode and back when there are quotes) 145 evaluates things such that "Content 2" is printing which is when the extra line feed is inserted.  The change is what it's seeing as previousSibling.  In 144 it sees 'br' so it skips that block.  In 145 it see 'cite' as it's somehow double parsing the quote string.

I've attached prints of the firebug console for a run with the debug statements from above using 144 (out1.txt) and 145 (out2.txt).  If you compare them in your favorite diff program and look above where "Content 2" is printed you'll see what I'm talking about.  Hopefully whoever wrote the elkarte plugin for sceditor can make sense of what is happening here.

Re: Quote Line Breaks Bonanza

Reply #3

I tried to play with it, but I'm almost completely lost... :-[

 emanuele feels the person is @Spuds O:-)
Bugs creator.
Features destroyer.
Template killer.

Re: Quote Line Breaks Bonanza

Reply #4

I'll take a look, the editor is a notorious for adding in newlines. I know it has problems with how or what it sees as block level elements as well and there are a few issues open against the editor.  Well in this case at least we know it kind-of worked in the previous version so there is hope.

@scripple thanks for all that debugging, that helps a bunch.

Re: Quote Line Breaks Bonanza

Reply #5

Thanks for taking a look.  Happy to mark the spot and let the expert have at it.

Re: Quote Line Breaks Bonanza

Reply #6

I added a test fix to the site at http://elkarte.spudsdesign.com/community/  ... have not had time to fully test it, running out the door now but wanted to try something.  This just looks to see if its a nested blockquote and then prevents sceditor from adding in the newline like it does on block elements.  Don't like having to edit the editor directly but can't think of a way to prevent it any other way ATM

Re: Quote Line Breaks Bonanza

Reply #7

Seems to work.  Removes both newlines but that's fine with me.  (By both I mean there was one to put the quote bracket on it's own line and then the annoying extra one to put a blank line after it.)  I do wonder if the second '\n' + content if statement was a hack to fix something in the old way code was parsed.  And now it should be gone?  Because if I simply remove content = '\n' + content; it works fine on quotes just like it used to.  I'm not sure if it would affect other elements negatively or not.

Re: Quote Line Breaks Bonanza

Reply #8

Glad it works  :)

I actually tried some of the 1.4.6. code back in 1.4.5 as it had some fixes for extra lines appearing, so that content + '\n\ area is the latest.  Unfortunately that did not fix this particular issue, maybe it will help in some other cases.  There is a thread about it in the sceditor repo, seems like different browsers flag things differently so its just a mess really.

What I added in was to prevent adding in the newline if the current blockquote was a child of another blockquote, one of those if you can't really fix it, then prevent it !

Re: Quote Line Breaks Bonanza

Reply #9

Yeah seems to be moving backwards.  But really it looks like a mess in general.  Bleh.  Right now I'm just using the version from beta 2.

 

Re: Quote Line Breaks Bonanza

Reply #10

Looks like what I added was a bit to aggressive in preventing newlines in quotes :P close to all of them lol

Updated the test site again, should be better about preventing the bonanza but still not leaking newlines on toggles etc