0

in CKEditor : as per my requirement, i just want to select the element by its Id and scroll to that position.

i've written code which is working fine in FF but i am not getting solution for IE.

bellow is the code for FF :

Ele = EditorInstance.document.getById(Id);
EditorInstance.getSelection().selectElement(Ele);
Ele.scrollIntoView();
j0k
  • 22,600
  • 28
  • 79
  • 90
pks
  • 101
  • 2
  • 16
  • possible duplicate of [getSelection() not working in IE](http://stackoverflow.com/questions/5421892/getselection-not-working-in-ie) – Andreas Louv Nov 21 '12 at 13:58
  • 1
    `Node.getSelection()` doesn't work in < IE9, you can use `document.selection.createRange();` – Andreas Louv Nov 21 '12 at 13:58
  • @NULL: Do not confuse native and CKEditor's APIs. CKEditor provides number of methods that should work on all supported browsers. @user1...: IMO, you just have to focus the editor (`editorInstance.focus()`) before selecting anything. IE won't work without this. If that won't help, please tell us which element you want to select. – Reinmar Nov 21 '12 at 17:48

2 Answers2

0

i've tried the bellow code and its working...

        Ele = EditorInstance.document.getById(Id);            

        EditorInstance.focus(); 
        var element = EditorInstance.document.getBody().getLast();
        var selection = EditorInstance.getSelection();
        selection.selectElement(Ele); 
        selection.scrollIntoView();
pks
  • 101
  • 2
  • 16
0

Based on http://dev.ckeditor.com/ticket/7561 & http://dev.ckeditor.com/attachment/ticket/7561/7561.patch

A patch like this works too..

Index: _source/plugins/selection/plugin.js
===================================================================
--- a/public/ckeditor-3.6.4/_source/plugins/selection/plugin.js
+++ b/public/ckeditor-3.6.4/_source/plugins/selection/plugin.js
@@ -710,7 +710,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        }
                        catch ( e )
                        {
-                               this.isInvalid = true;
+                               document.getWindow().focus();
                        }
                }
pixelhandler
  • 615
  • 4
  • 11