Adding HTML editor in Widget.

anubhavr
Giga Expert

I want to add a HTML Editor in a Widget in HTML template. How can I achieve it??

Please find the below screenshot which I wanted to add in Widget:

find_real_file.png

10 REPLIES 10

arnabwa
Giga Guru

Hi,

Insert this code in your HTML template of the widget. This is the Tiny MCE html editor that servicenow uses for the platform throughout.

I strongly believe this will do your work.

<!DOCTYPE html>
<html>
<head>
  <script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script>
  <script>tinymce.init({ selector:'textarea' });</script>
</head>
<body>
  <textarea>Next, start a free trial!</textarea>
</body>
</html>

 

Thanks,

Arnab

Thank you for the response. The following is displayed when I use the code above.

Please let me know if I'm missing something.

 

find_real_file.png

It just put a big empty area on the page for me. I manually changed one of the tinymce containers visibility from hidden to visible and then it gave me the same as you posted above.

 

Has anyone managed to get tinymce to work or have they just opted for a different WYSIWYG editor instead?

Rahul Jain11
Kilo Guru

Did you guys added the dependencies to the widget. You could find the dependency here:

 

https://cloud.tinymce.com/stable/tinymce.min.js

 

Moreover, you could find details at https://www.tinymce.com/

 

Thanks

 

Thanks for the link, didn't know we had to do that. I've tried adding the min and full file as a UI Script and added the widget dependency to the widget, and then added 

<script>tinymce.init({ selector:'textarea' });</script>

to the top of my widgets body html template, but the only result is an empty space where the standard textarea used to be. I've tried adding an alert to the init function to see if it's being called and it doesn't do anything so i feel like i'm still missing something.