Opened 15 years ago

Closed 15 years ago

#2751 closed Task (fixed)

Write fake object display and replacement logic for CKEditor v3

Reported by: Martin Kou Owned by: Martin Kou
Priority: Must have (possibly next milestone) Milestone: CKEditor 3.0
Component: General Version:
Keywords: Confirmed Cc:


Artur says he needs it for completing the Flash dialog, I should finish it on Monday by porting it from v2.

Attachments (1)

2751.patch (5.4 KB) - added by Artur Formella 15 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 15 years ago by Artur Formella

Keywords: Confirmed added

comment:2 Changed 15 years ago by Martin Kou

Resolution: fixed
Status: newclosed

Fixed with [2845].

comment:3 Changed 15 years ago by Martin Kou

Resolution: fixed
Status: closedreopened

Oh well, there are still a few things left to do..

  1. The width and height of placeholders needs to be put into the real objects at restoreElement() and restoreHtml().
  2. The HTML parser in protectHtml() doesn't take into account of empty tags, and then the tagDepth counter inside is buggy (doesn't affect Flash dialog).
  3. The default size of the placeholder, 80x80, shouldn't be set as inline styles - inline styles needs to be used as the final size of the real object as in point 1. Instead, it should be set in contents.css.

comment:4 Changed 15 years ago by Artur Formella

How to find fake objects in selection? Do I need to find IMG tag when I want to edit OBJECT or it will be done by API?

var element = rangeRoot.getAscendant( 'img', true );
if ( element && element.someAttribute( '_cke_fakeobject' ) && element.someAttribute( 'object' ))  //something like that

	element = restoreElement(element );
	load(element )

comment:5 Changed 15 years ago by Martin Kou

The pseudocode you wrote should work. Basically, to process the fake object in the dialog, you need to:

  1. Get the placeholder element. You can get the currently selected placeholder element by looking for an <img> tag with with "_cke_protected_html" attribute, or having "_cke_fakeobject" in its class.
  2. Convert the placeholder element into the real element via CKEDITOR.plugins.fakeobjects.restoreElement().
  3. Process the real element (e.g. change its URL, change its size, etc.)
  4. Convert the real element back to a placeholder element and insert it to the editing area.

So basically, the real element should never appear in the WYSIWYG area, it's where the placeholder element belongs to. The real element is only used when you need to process it or you need to get the HTML code output.

comment:6 Changed 15 years ago by Martin Kou

Ok, I've fixed the problems I found this afternoon. Now it should be able to retain and display the Flash plugin's sizes correctly, even after the user resized the placeholder in WYSIWYG mode. It should be possible to further simplify the code in the placeholder plugin, however.

Changed 15 years ago by Artur Formella

Attachment: 2751.patch added

comment:7 Changed 15 years ago by Artur Formella

I made a proposal patch. It is easier to check selection with additional attribute (for example _cke_real_element_type).

I added also updateFakeElement() to avoid inserting new object after each edition. We can use _cke_real_element_type in elementspath plugin.

comment:8 Changed 15 years ago by Martin Kou

The proposed patch didn't add _cke_real_element_type in protectHtml() under fakeobjects plugin, but otherwise it's good. I've added that myself, and it will be committed after I've tested the plugin for some more time.

The JavaScript error from IE at pressing OK in the Link and Anchor dialogs seems like a regression bug. CKEDITOR.dialog::restoreSelection() doesn't seem to work for now.

comment:9 Changed 15 years ago by Martin Kou

Committed 2751.patch as [2859] with a number of other bugfixes.

comment:10 Changed 15 years ago by Martin Kou

Resolution: fixed
Status: reopenedclosed

The system works in the prototype branch now. So this ticket should be closed. Any more issues with the fakeobjects system should be filed as separate tickets.

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