Opened 14 years ago
Closed 12 years ago
#8033 closed Bug (invalid)
Fake element get to many paragraphs
Reported by: | datalink | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | Core : Parser | Version: | |
Keywords: | Cc: | d.efrcz@… |
Description
I've written a little plugin for a google map. It places a div with the map source inside. The div has class "googlemapsframe" and if it's opened in editor it is replaced by fake element.
HTML source is:
<div class="googlemapsframe" style="height: 300px; width: 500px"> ... GOOGLE MAP SOURCE ... </div>
After fake element replacing editor produces:
<p> <div class="googlemapsframe" style="height: 300px; width: 500px" width="500"> ... GOOGLE MAP SOURCE ... </div> </p>
And after saving and reopening editor produce new paragraphs before and behind fake element.
First reopen:
<p> </p> <p> <div class="googlemapsframe" style="height: 300px; width: 500px" width="500"> ... GOOGLE MAP SOURCE ... </div> </p> <p> </p>
Second reopen:
<p> </p> <p> </p> <p> <div class="googlemapsframe" style="height: 300px; width: 500px" width="500"> ... GOOGLE MAP SOURCE ... </div> </p> <p> </p> <p> </p>
And so on.
Another problem is the width="500" that is set from createFakeElement function. Should I open a new ticket for it?
Attachments (2)
Change History (10)
comment:1 Changed 14 years ago by
Status: | new → pending |
---|
Changed 14 years ago by
Attachment: | fakediv.zip added |
---|
comment:2 Changed 14 years ago by
No, it's not reproducable in another way. I attach a cutted version of the plugin.
Set extraPlugins:'fakediv' and this
<div class="myfakedivsframe" style="width: 350px; height: 200px"> </div>
to editor. On every switch to source there are new paragraphs before and behind. Also there is width="350" as a new attribute.
comment:3 Changed 13 years ago by
I have same problem with my own plugin, that requires : [ 'dialog', 'fakeobjects' ] and use method editor.createFakeParserElement.
Problem disappears, if you use iframe without iframe plugin or changes to br new lines. But I use, of course, p formating and iframe.
comment:4 Changed 12 years ago by
Cc: | d.efrcz@… added |
---|---|
Component: | General → Core : Parser |
Keywords: | fakeobjects added |
Version: | 3.6 → 3.6.5 (SVN - trunk) |
Hi again, do you need any additional info?
comment:5 Changed 12 years ago by
Keywords: | fakeobjects removed |
---|---|
Version: | 3.6.5 (SVN - trunk) |
There are 2 problems I see with this code:
Extra width/height - This is happening because you are trying to change fake element width/height to original element width/height. This is impossible or to be more specific there is no easy way to do it.
To change fake element dimensions you have to modify cke_fakediv class and not fake element.
Please check out the attached plugin it contains code in comments in afterInit method. This code changes initial width and height but the problem is that it will work only after you switch to source for the second time.
MY conclusion here is that you can and should only give fixed dimensions in CSS class (cke_fakediv in this case).
Extra paragraphs - As mentioned by @garry.yao in post below, 3rd argument passed to method createFakeParserElement should be real element - div in this case.
I would like to hear how other members of CKSource see this and if I'm wrong what is the proper solution.
comment:6 Changed 12 years ago by
The plugin provided has misused a param of specifying the real element name of the fake element, the correct usage would be:
// The 3th argument is to be specified as the real element name. var fakeElement = editor.createFakeParserElement( realElement, 'cke_fakediv', 'div', true );
comment:7 Changed 12 years ago by
Thanks @garry.yao, I have missed that.
Ok so the final outcome for this issue is:
- You can only set fixed width/height in CSS class. It's impossible to set elements dimensions in CSS class as nothing is known about the element at the moment CSS class creation.
There is a possibility but it works only second time you switch to source and back so it is almost the same as if it didn't work.
- Changing the element name to real element helped. There are no extra paragraphs or similar issues.
There is just one problem left when div is empty or has only one it will get removed. If it has anything more like two it will be left untouched.
<div class="myfakedivsframe" style="width: 350px; height: 200px"> </div>
comment:8 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
Based on the above comment I'm closing this ticket as invalid.
For problem with one in div element a new ticket was opened - #9418
As you said the issue occurs when you use your plug-in. Most obvious answer is that you have done something wrong in it.
Can this issue be reproduced in some sort of simplified test case, not only in your plug-in?