Fixed Inline code not working correctly

Same problem here with Firefox (did not test with others)

Linebreak before and after shouldn't happen and did not happen before (older versions).
 
I believe this is the result of a bugfix where injecting tags which wrap new lines would get the editor into a bad state. I think it isn't handling newlines when the selected text is the entire line.
 
So for reasons that do not make sense to me, I have tracked it down to this line:

JavaScript:
selectedHtml = ed.html.getSelected();

If you have this editor content:

HTML:
<p>test test test</p>

And you select only the middle test the result of ed.html.getSelected() is:

HTML:
<p>test</p>

The end result being what we insert into the editor is:

HTML:
[ICODE]<p>test</p>[/ICODE]

Which will look like this:

Code:
[ICODE]
test
[/ICODE]

The behaviour somewhat makes sense - after all, if the actual editor content looked like this:

HTML:
<p><strong>test test test</strong></p>

You would want the selection to include <strong> because otherwise that formatting could be lost (depending on what you're doing with the selection).

We did use a different approach in 2.2.11 but that had other issues:

At this point it feels tempting to just remove the outer <p></p> if we're working with an inline tag, as we are here.

I hate working with this editor.
 
Idris Elba Table Flip GIF
 
You are probably old enough to get this.. but it's a certain time.
Mc Hammer GIF


Either into submission.. or into non-existence!
 
I don't know how it works or what causes it. I can just select any tekst, also in your lines also.

I can only just type some words like this and then select and put into icode.

and the same happens instantly, very odd. You can see it on the little block icode on top of the line.

I hate working with this editor.
I believe you instantly, I hear more people about that editor. :)
 
I hate working with this editor.
ed.html.getSelected is a buggy mess and behaves differently depending on the browser. It has some questionable behavior as you've discovered around the entire-line selection.

I published my work-around for the behavior you've documented in this post. I think this is the 4th or maybe 5th iteration of patching how XF.EditorHelpers.wrapSelectionText works because Froala is just hard to work with. :(

At least this version I haven't had to patch since February!

At this point it feels tempting to just remove the outer <p></p> if we're working with an inline tag, as we are here.
I think that is really the only sane thing todo in this stage.
 
Last edited:
This is an interesting thing.

Since you say "depending on the browser", could it have caused this issue too since 2.2.7?
This not only happens on 1 row, if you place a bunch of text, go back to the first line, and then add some smilies, the first get on the next line, the rest totally even on the bottom of the alinea instead of the next line, so very odd.

There is some discussion about it being a browser issue, which could be the case, but then why not before 2.2.7 and maybe it's the same cause as the icode issue, so who knows.
 
I published my work-around for the behavior you've documented in this post. I think this is the 4th or maybe 5th iteration of patching how XF.EditorHelpers.wrapSelectionText works because Froala is just hard to work with. :(

At least this version I haven't had to patch since February!
I missed that workaround.

I just implemented it and, while it helps with this issue, what actually happens now is this is inserted (in Safari and Firefox):

HTML:
test <p>[ICODE]test[/ICODE]</p> test

So it produces:

Code:
test
[ICODE]test[/ICODE]
 test
 
This is an interesting thing.

Since you say "depending on the browser", could it have caused this issue too since 2.2.7?
Froala has a bunch of dubious per-browser-type behavior that is hard to troubleshoot. It wouldn't surprise me if it was related.

I missed that workaround.

I just implemented it and, while it helps with this issue, what actually happens now is this is inserted (in Safari and Firefox):
It adds a 5th parameter to wrapSelectionText the inline flag. Did you patch the [icode] (and [ispoiler]) handler to set that 5th argument so it strips out the <p> tag?
 
Top Bottom