Opened 11 years ago

Closed 11 years ago

#9292 closed Bug (fixed)

Browser error when calling insertText(' ') in V4

Reported by: Teresa Monahan Owned by: Piotrek Koszuliński
Priority: Must have (possibly next milestone) Milestone: CKEditor 4.0
Component: General Version: 4.0
Keywords: IBM Cc: Damian, Satya Minnekanti


To Reproduce:

  • Open any V4 CKEditor sample
  • Enter the following in the browser console and run the code:
    CKEDITOR.instances.editor1.insertText(' ')

Problem: An error occurs and the space is not inserted into the editor.

When running CKEditor V4 in source mode, the error is:

TypeError: maybeBlockData is undefined
.../core/editable.js             Line 1436

This testcase works as expected in 3.6.x.

Change History (4)

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

Milestone: CKEditor 4.0
Owner: set to Piotrek Koszuliński
Priority: NormalHigh
Status: newassigned

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

Status: assignedreview

Created branches t/9292 @ dev&tests.

This TC revealed two issues:

  1. That spaces at the ends of data inserted by insertText are not properly preserved.
  2. That insertHtml crashes when inserting space(s).

Fix for 1. was trivial, but 2. is really problematic.

First of all - htmlDataProcessor ltrims passed data. I don't know the reason, but I guess that this has something to do with IE doing the same (so behaviour is unified between browsers). At the beginning I tried to preserve these spaces (what was a little bit tricky thanks to IEs removing them by default), so browsers' auto-spaces-merging may do the rest of the job.

Unfortunately, as usual, it turned out that there are many differences between browsers. IEs don't merge spaces replacing them with  , other browsers seem to somehow merge inserted spaces with existing, but they don't do this ideally. I decided that'd better to avoid implementing white-spaces merging now and I only fixed the insertHtml( ' ' ) issue.

Resulted behaviour is close to v3's.

PS. Don't be surprised by weird spaces handling in insertHtml comparing to how it should work for pasting. Pasted data are "htmlified" first, because they come from pastebin (editable element), so e.g. subsequent spaces are replaced with nbsps before data are passed to the insertHtml.

comment:3 Changed 11 years ago by Frederico Caldeira Knabben

Status: reviewreview_passed

I've just made a minor change in a regex.

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

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