#6751 closed Bug (fixed)
Paste from Word - Leading space disappears (in formatted block)
Reported by: | Frédéric Arène | Owned by: | Garry Yao |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 3.5.3 |
Component: | Plugin : Paste from Word | Version: | 3.2 |
Keywords: | Cc: | farene@… |
Description
When I paste from Word formatted text like this one :
<span>A b<b> c d</b></span>
it outputs this in CKEditor :
<p> A b<b>c d</b></p>
...with the formatting rendered, it's like that : A b c d -> A bc d
The space betwwen 'b' and 'c' disappeared, (probably somewhere in the htmlWriter).
Attachments (4)
Change History (18)
Changed 14 years ago by
Attachment: | TextToPaste.doc added |
---|
comment:1 Changed 14 years ago by
Cc: | farene@… added |
---|
comment:3 Changed 14 years ago by
Keywords: | MSWord space formatted removed |
---|---|
Version: | 3.4.3 (SVN - trunk) → 3.2 |
Does not occur in CKEditor 3.1.1,
Changed 14 years ago by
Attachment: | disappearing_spaces_example2.docx added |
---|
Yet another example of more disappearing spaces.
comment:4 Changed 14 years ago by
Comment added another example of more spaces that disappears when pasting from word. In the example all spaces after words between styling disappear.
trailing space also disappears if first word in document is styled, but the trailing space is not. i.e. <p><b>A<b> B</p> -> <p><b>A<b>B</p> (that is not in the example document.)
Changed 14 years ago by
comment:5 Changed 14 years ago by
Check the attached file for one more example (I have used different fonts to reproduce it).
comment:6 follow-up: 7 Changed 14 years ago by
The problem here is occuring in the function parser.onText() in core\htmlparser\fragment.js
The problem occurs when a span element has been parsed, the code in on text will then call trimLeft, this will cause the space to disappear. This is the code that trims it away (from fragment.js)
if ( !currentNode._.hasInlineStarted && !inPre ) { text = CKEDITOR.tools.ltrimSpecial( text ); //text = CKEDITOR.tools.ltrim( text ); if ( text.length === 0 ) return; }
I tried to understand and fix this, but I really dont understand why it is trimmed, I made a local tweak in my installation for this, but it would be great if one of the core developers could have a look at this.
I ended up trimming, if and only if there are more than one space. Ugly fix, but it solves my problem.
comment:7 Changed 14 years ago by
the commented out code is the original code, ltrimSpecial looks like this, if anyone is intrested.
ltrimSpecial : (function() { //do not delete a single space, as it probably should be there. var trimRegex = /^[ ]{2,}|^[\t\n\r]+/g; return function( str ) { return str.replace( trimRegex, '' ) ; }; })(),
comment:8 Changed 14 years ago by
Keywords: | HasPatch added |
---|---|
Milestone: | → CKEditor 3.5.3 |
Changed 14 years ago by
Attachment: | 6751.patch added |
---|
comment:9 follow-up: 10 Changed 14 years ago by
Keywords: | HasPatch removed |
---|---|
Owner: | set to Garry Yao |
Status: | confirmed → review |
@toma25 It's not the parser::onText that is not doing anything wrong as whitespace works well when loading from source.
Proposing context-sensitive parsing as the filter might choose to re-parse the inner html of potentially any element.
comment:10 Changed 14 years ago by
Replying to garry.yao:
@toma25 It's not the parser::onText that is not doing anything wrong as whitespace works well when loading from source.
Proposing context-sensitive parsing as the filter might choose to re-parse the inner html of potentially any element.
Will not argue against you, as I wrote, the code supplied is probably not the right fix, but it did solve my problem. Again, I suggest that one of the developers that understand the code takes a look at this.
comment:11 Changed 14 years ago by
@toma25 Thanks for the input, we've taken your patch into consideration, pls trust the team and wait for the ticket to be fixed.
comment:12 Changed 14 years ago by
Status: | review → review_passed |
---|
comment:13 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | review_passed → closed |
Fixed with [6557].
comment:14 Changed 11 years ago by
Component: | Core : Pasting → Plugin : Paste from Word |
---|
Very simple MSWord document to reproduce the bug.