inserting values into a richtext field (CKEditor)

edited February 2018 in Questions
Hi all,
I'm trying to find a way to insert value from "outside" into a richtext field (CKEditor) via JS snippet. While there are some examples available regarding normal CKEditor usage (, I get stuck at the very first step -> getting the CKEditor instance in javascript.

This should work
var oEditor = CKEDITOR.instances.yourEditorID;

but "instances" is empty in my skuid page (normal Field Editor showing rich text editor).

Can someone point me the way?


  • Matthew LeahyMatthew Leahy ✭✭✭
    edited February 2018
    Hi Andre,

    If I'm understanding the issue correctly, here is a solution employed by one of my fellow engineers.

    Example JS Snippet:

    function insertIntoEditor(text){

    It's possible that the default editor ID is "editor1".

    Example HTML Markup:

    <a onclick="insertIntoEditor('{Event_Edition__c.Name}')">Event Name</a> 

    I hope this puts you back in business.

  • edited February 2018
    Thanks Matthew,
    accessing the editor with "editor1" didn't work for me.

    Looks like editor IDs are "inherited" from the field editor ID, which can't be influenced at design-time within the skuid page editor (as for as I know). So there is no dedicated ID that can be used.

    Instead I used the following , which obviously only works for one (the first) editor instance within the page.
    var params = arguments[0],
        $ = skuid.$;

    var editor = $('div[class*="cke_editable"]').first(); 
    var editorId = editor.attr('id');

    CKEDITOR.instances[editorId].insertHtml('<ul><li><b>a new html list entry</b></li><li>another one</li><ul>');

Sign In or Register to comment.