Skip to main content
Nintex Community Menu Bar
Question

inserting values into a richtext field (CKEditor)

  • Jul 11, 2024 1:08 PM UTC
  • 2 replies
  • 47 views
  • Translate All

Forum|alt.badge.img+1

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 (https://ckeditor.com/old/forums/CKEditor-3.x/heres-how-insert-text-and-tags-cursor), I get stuck at the very first step -> getting the CKEditor instance in javascript.

This should work

var oEditor = CKEDITOR.instances.yourEditorID;<br><br><br>

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

Can someone point me the way?




This topic has been closed for replies.

2 replies

Forum|alt.badge.img+5
  • Nintex Employee
  • Jul 11, 2024 1:24 PM UTC

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){
CKEDITOR.instances[‘YourEditorID’].insertText(text);
}

It’s possible that the default editor ID is “editor1”.

Example HTML Markup:

Event Name

I hope this puts you back in business.

Translate

Forum|alt.badge.img+1
  • Author
  • Jul 11, 2024 1:24 PM UTC

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(‘

  • a new html list entry
  • another one
    • ’);

Translate