Opened 12 years ago

Closed 12 years ago

#9220 closed Bug (fixed)

Extra BR added after pasting in the first line

Reported by: Piotrek Koszuliński Owned by: Garry Yao
Priority: Normal Milestone: CKEditor 4.0
Component: Core : Pasting Version: 4.0
Keywords: Cc:

Description

  1. Manually add three text paragraphs within editor;
  2. Make selection like following:
    <p>f[oo</p>
    <p>bar</p>
    <p>ba]z</p>
    
  3. Copy and paste it, in place
  • Actual Result: One extra line space is added after the pasted first line.

Attachments (1)

looped_left_arr.ogv (205.2 KB) - added by Piotrek Koszuliński 12 years ago.

Download all attachments as: .zip

Change History (16)

comment:1 Changed 12 years ago by Piotrek Koszuliński

Owner: set to Piotrek Koszuliński
Status: newassigned

comment:2 Changed 12 years ago by Piotrek Koszuliński

Status: assignedreview

comment:3 Changed 12 years ago by Garry Yao

Status: reviewreview_failed

The removing the padding BR at the end of pseudo block, must not be handled simply by the "data filter", it should be a coordination between the "html" and "data" filter, the current impl fails the following tc:

  1. Load the following source:
    <div>foo^
    <p>bar</p>
    </div>
    
  2. Shift-enter to create two BRs
  3. Switch to source mode.
  4. Switch to wysiwyg mode now.
  5. Repeat 3-4.
  • Actual: BRs start to loose on each switch.

Besides, we shall have some tests for such a change.

Last edited 12 years ago by Garry Yao (previous) (diff)

comment:4 Changed 12 years ago by Piotrek Koszuliński

Status: review_failedreview

I did some tests and I noticed that FF doesn't append <br> if one already is at the end of pseudo block. Thus, I had to fix the code that it removes filler only if it's single one.

Also, I decided to do this in both direction - toHtml and toDataSource. Thanks to this if we'll press shift+enter once in Garry's case (what causes incorrect FF behaviour :|), then we won't see it after switching to source mode. The same after setting: <div>foo<br><p>bar</p></div> and switching from source mode to wysiwyg.

I updated tests in t/9220@tests.

PS. On IE8 when shift+enter pressed once (in Garry's case) strange things start to happen. I'll attach a movie showing how left arrow is looped in paragraph for this HTML: <div>foo<br><p>bar</p></div>. That's not a part of this ticket, but needs new one.

Changed 12 years ago by Piotrek Koszuliński

Attachment: looped_left_arr.ogv added

comment:5 Changed 12 years ago by Garry Yao

Status: reviewreview_failed

With the current patch, if first paragraph in ticket TC has duo BR at the end, the issue is still reproducible.

comment:6 Changed 12 years ago by Garry Yao

Owner: changed from Piotrek Koszuliński to Garry Yao
Status: review_failedassigned

I intend to take over this ticket as the padding BR logic has some historical concern that requires some awareness of v3 tickets.

comment:7 Changed 12 years ago by Garry Yao

Status: assignedreview

Opened review t/9220b at both dev and test, features bogus handling at the end of pseudo block, changes illustrated as:

  • core/editable.js - protected the data as "clip", to avoid loosing whitespace and brs through parsing.
  • core/htmldataprocessor.js - the main chunk, it revised the block filter, to consider bogus inside of pseudo-block, the blockFilter is to remove bogus inside of a block, and the brFilter is to append filler after line-break BR.
  • core/htmlparser/fragment.js - Required because of the above changes, to trim correctly the whitespace at the end of pseudo-block, raise the robustness of the enter filtering system, it mainly concerns the following sample of HTML emitted by IE8:
    foo
    <b>
    <p>bar</p>
    </b>
    
  • plugins/bbcode/plugin.js - Required because of the new assignment of type "fragment" to parser's root node.
  • plugins/list/plugin.js - The changes there is to revert the some legacy list filtering logic that is not anymore require, exactly on topic of the pseudo block.
  • plugins/wysiwygarea/plugin.js - Revert the change of an additional bogus br at the end of editable, also handled by core now.
Last edited 12 years ago by Garry Yao (previous) (diff)

comment:8 Changed 12 years ago by Piotrek Koszuliński

Reviewing...

comment:9 Changed 12 years ago by Piotrek Koszuliński

Status: reviewreview_failed
  1. One selection test is failing on FF.
  2. There are no tests for issues mentioned in this ticket.
  3. I think that some functions should be documented more clearly. E.g.:
    • rtrim / fragment.js
    • blockFilter / htmldataprocessor
    • parse.onText / htmlparser - nbsps as separate nodes case - how and why (in fact it's a good question)
  4. I don't like the idea of wrapping content that's going to be inserted in some markers. That's hacking our own code. This idea is returning like a boomerang all the time and I constantly have mixed feelings about it. The real problem is that we're using dataProcessor for other purpose than it was created. Dunno if we've got enough time to rework it now, but IMO we definitely should at least add second mode for insertion data processing.
  5. I believe that changes proposed in t/9220b may not be compatible with #9292. In #9292 I avoided preserving ltrimming insertion data, so please review my ticket, because we've got to make a decision what goes first.

comment:10 Changed 12 years ago by Garry Yao

Status: review_failedreview
  1. Still to be checked...
  2. htmldataprocessor.html#test bogus nodes (in)output in pseudo block
  3. The documentation for rtrim / fragment.js and blockFilter / htmldataprocessor are enough for me, regard NBSP separation in parse.onText / htmlparser, I've committed new change, to remove it from the parser, leaving it to be handled by the processor instead, so it's usage is much clearer now.
  4. Unless you can sniff the side effects from the wrapping marker, I see it the only way for impl. when a new filtering system is still in empty talk.
  5. The changes are not "conflicting" with #9292, but it's overlapping, so it's enough to just loose the change from #9292 on editable.js

comment:11 Changed 12 years ago by Garry Yao

I've checked the selection test failure on Fx, it's related to the change, but it looks like the problem is instead the feature itself, the selection change event on data ready, which doesn't look like a right decision, as theoretically no selection is available at that moment when the DOM is reloaded (on set data), I have no RED after the removal, so I propose a commit to remove it.

comment:12 Changed 12 years ago by Piotrek Koszuliński

Status: reviewreview_failed

I pushed imnor code corrections.

R- because of failing tests (possibly came out after rebasing):

Regarding documentation - it's enough for you, because you know the code / you're its author. I, a person who only knows basic concepts and tests, have a lot harder. Especially that this isn't a trivial algorithm or some business logic, which code can be read as a book. It's pretty complicated and not obvious piece of code doing complicated and not obvious things. Without thorough documentation it cannot be understood in other way than just by reading every single line and every single case. That's why I asked about few more words about it :).

comment:13 Changed 12 years ago by Garry Yao

Status: review_failedreview

Because the review is getting harder, I have to recreate the branch, with the minimal changes targeting the ticket TC, the tests are not changed, but are also squashed for easier review.

Also to make the logic clearer, I've explained future more of the bogus/filler handling logic in code comments.

comment:14 Changed 12 years ago by Piotrek Koszuliński

Status: reviewreview_passed

I've force-pushed both branches - rebased dev and added missing spaces and aligned columns in tests.

  • 100% green.
  • Cases mentioned in this issue passing on Chrome, FF, IE8 and Opera.

R+!

comment:15 Changed 12 years ago by Garry Yao

Resolution: fixed
Status: review_passedclosed
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy