Opened 12 years ago
Closed 12 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 |
Description
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 12 years ago by
Milestone: | → CKEditor 4.0 |
---|---|
Owner: | set to Piotrek Koszuliński |
Priority: | Normal → High |
Status: | new → assigned |
comment:2 Changed 12 years ago by
Status: | assigned → review |
---|
comment:3 Changed 12 years ago by
Status: | review → review_passed |
---|
I've just made a minor change in a regex.
comment:4 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | review_passed → closed |
Masterised with https://github.com/ckeditor/ckeditor-dev/commit/704fdb4
Created branches t/9292 @ dev&tests.
This TC revealed two issues:
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 theinsertHtml( ' ' )
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 theinsertHtml
.