Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#13069 closed Bug (fixed)

editable.insertHtml and editable.insertElement behave different with and without range parameter

Reported by: Piotr Jasiun Owned by: Piotr Jasiun
Priority: Normal Milestone: CKEditor 4.5.0 Beta
Component: General Version: 4.3 Beta
Keywords: Cc:

Description

If we pass range parameter to editable.insertHtml or editable.insertElement these methods use editable.insert*IntoRange which are low level methods (do not save snapshot, do not focus editor, do not scroll view). If we do not add the range parameter then editable.insert*IntoSelection methods are used which are high level methods (focus editor, save snapshot, scroll view). Because editable.insert*IntoRange and editable.insert*IntoSelection are different level API, this does not make sens that insert* works differently depending on the third parameter. It is unclear that editor will not do the snapshot if you give the range parameter and unclear how to use these methods (what addition operations should be done if range parameter is passed). To solve this problem editable.insertHtml and editable.insertElement should save snapshot (and do the rest of the needed operations) does not matter if range is passed or not.

Since this weird behavior is not documented I report this ticket as a bug.

Change History (4)

comment:1 Changed 3 years ago by Piotr Jasiun

Owner: set to Piotr Jasiun
Status: newreview

After changes we have 4 cases:

  • insert[Element|Html]IntoRange - low level methods which just insert data into given range and do nothing more,
  • insert[Element|Html] (without range parameter) - which insert data into current selection, select it and do undo snapshot,
  • insert[Element|Html] (with range parameter) - which insert data into the given range, select it and do undo snapshot; note that this is totally different case then insert[Element|Html]IntoRange, here the range parameter is only to handle situation where we can not select range where we want to insert HTML,
  • insert[Element|Html]IntoSelection - which are just aliases for the insert[Element|Html]; in my opinion these methods may be marked as deprecated (actually one of then, the other could be removed, because it was introduced in 4.5).

Working on these changes I realized that there was in fact a mess. The only red test after changes was about intoRange parameter of the afterInsertHtml. This parameter was set when user use insertHtml with the range parameter what did not make sense when user wanted to have that range selected (intoRange was created to mark that insertion is not in the current selection and the inserted content (eg. widget) should not be selected).

The only change which is not backward compatible is that insertElement with the range do additional operations. To keep the previous behavior user need to use insertElementIntoRange.

Changes in t/13069.

comment:2 Changed 3 years ago by Piotr Jasiun

Milestone: CKEditor 4.5.0CKEditor 4.5.0 Beta

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

Resolution: fixed
Status: reviewclosed

I removed the insertHtmlIntoSelection method and marked insertElementIntoSelection as deprecated.

Merged to major with git:b06d8e3.

comment:4 Changed 3 years ago by Piotr Jasiun

Cool. Thanks. :)

Note: See TracTickets for help on using tickets.
© 2003 – 2017 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy