Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#11552 closed Bug (invalid)

CKEDITOR 4.3.2 IE11 Permission Denied

Reported by: G Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc:

Description

So I am writing a plugin for ckeditor (@ mentions).

when you type some characters (example "@John") a drop down will appear of a list of Johns that the user can select . When the users selects the drop down they want, it needs to remove the the "@John" text and insert an element that was retrieved from the dropdown

The Code

//Set the cursor at the current book mark
    mentions.editor.getSelection().selectBookmarks(CKEDITOR_mentions.CurrentBookMarks);
    // create the text for the element to insert
    var html = '<span style="background-color: #d8dfea;" data-personid="' + id + '" data-type="' + type + '" href="#">' + name + '</span>&nbsp;&nbsp;';
    // Create the Element to insert
    var newElement = CKEDITOR.dom.element.createFromHtml(html, mentions.editor.document);
    //Insert the element
    mentions.editor.insertElement(newElement);
    //Get a new bookmark
    var tempBookMark = mentions.editor.getSelection().createBookmarks(true);
    //remove the text that the editor is replacing
    RemoveText(mentions.editor, mentions.char_input.join(''));
    // set the focus back to the saved book mark position
    mentions.editor.getSelection().selectBookmarks(tempBookMark);
    //focas on that position
    mentions.editor.focus();

Function that removes the text

function RemoveText(ed, idontwant) {
    var edata = ed.getData();
    var replaced_text = edata.replace(idontwant, ""); // you could also use a regex in the replace 
    ed.setData(replaced_text);
}

The issue

This works just fine on chrome however on IE11 after the text has been removed, when I try to access the mentions.editor.getSelection() I get "permission denied" error. I cannot set the bookmark and the focus is moved to the start of the ckeditor.

Change History (4)

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

Status: newpending
Version: 4.3.2

As I explained on Stackoverflow without a full sample it is impossible to guess what's wrong. The issue may be in your code and may be in CKEditor too.

comment:2 Changed 6 years ago by G

Thanks Reinmar, I have updated Stackoverflow ticket with some more details. Not Sure if I should update here also. Thanks G

Last edited 6 years ago by G (previous) (diff)

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

Keywords: IE11 removed
Resolution: invalid
Status: pendingclosed

I posted an answer on SO. In short, selection does not work right after setting data. Although, I'm not 100% sure that it's the only issue in your code.

comment:4 Changed 6 years ago by G

Genius, Thank you Reinmar, that solved my problem.

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