I needed to solve this relatively quickly so I have investigated further and created a workaround based on a nice bit of code produced by @GunterEibl
here: https://asdw.de/en/scriptcase-und-tinymce-mit-benutzerdefinierten-init-parametern/
This code is a little old so I had some problems getting it to work at first because Scriptcase have made some subsequent changes (as have tinyMCE).
The TinyMCE help pages are very good at guiding you through it.
Here is my revised version: (I’ve left some messy echo and comment lines in there as it might help you if you want to reimplement… I needed them to follow the thread and debug!)
I also set the code up as functions as I intend to put them in a lib once I’m finished debugging
Notes
- TinyMCE is just a javascript library that effectively hijacks any field and overlays the editor (Which is very configurable)
- The Scriptcase file location is different from when Gunther did the original (see $tinyFolder line below)
- Unfortunately this workaround needs to be applied to EVERY field that uses the editor, so its a bit messy and so the REAL solution needs Scriptcase to allow for a bit of extra configuration in their Editor HTML setup (2 lines see final paragraph)
—First Function----
TinyMCEInitialise(); // This just sets up the TinyMCE based on the one in the SC libs
function TinyMCEInitialise(){
//--------------------------
// get TinyMCE lib location
//--------------------------
$prodFolder = $_SESSION['scriptcase']['tinyMCE_Test']['glo_nm_path_prod'];
$tinyFolder = $prodFolder."/third/tinymce/js/tinymce/";
// Declare tinyMCE - the one in Scriptcase
$msg = "<script src='".$tinyFolder."tinymce.min.js'></script>";
//echo "<br>-----<br>";
//echo htmlspecialchars($msg);
//echo "<br>-----<br>";
echo ($msg);
}
Then every field you want as an editor you need to say which field to hijack and initialise the editor
BasicEditor("#id_sc_field_tester"); // this is the field to hijack… found using google console on the form page.
— Second Function----
function BasicEditor($element){
//--------------------------
// Install tinyMCE with plugins
//--------------------------
$msg = "<script>";
$msg.= "tinymce.init({ ";
$msg.= "selector: '".$element."',";
$msg.= "pagebreak_separator: '<div style= page-break-before: avoid !important;></div>',";
$msg.= "paste_data_images: false,"; // STOP paste of Images into the html
$msg.= "menubar : 'file edit insert view format table tools ',";
$msg.= "plugins : 'advlist,autolink,link,image,lists,charmap,print,preview,hr,anchor,pagebreak,searchreplace,wordcount,visualblocks,visualchars,code,fullscreen,insertdatetime,media,nonbreaking,table,directionality,emoticons,template,paste,textcolor,colorpicker,textpattern,contextmenu',";
$msg.= 'toolbar1: "undo,redo,separator,styleselect,separator,bold,italic,separator,alignleft,aligncenter,alignright,alignjustify,separator,bullist,numlist,outdent,indent,separator,fullpage,link,image,template",';
$msg .="})";
//$msg.="content_css: 'css/content.css'})";
$msg.= "</script>";
//echo htmlspecialchars($msg);
echo($msg);
}
Warning
I did find the coding to be a bit fiddly and errors in the Javascript (Echod above) cause it not to works. Best advice is to just get a basic editor working first by following the TinyMCE help pages… then add the extras.
For the record, the only 2 lines Scriptcase would need to add to their own TinyMCE init function would be:
$msg.= “pagebreak_separator: ‘<div style= page-break-before: avoid !important;>’,”;
$msg.= “paste_data_images: false,”; // STOP paste of Images into the html
to fix both the pasting of pictures and correcting the pagebreak comment nonsense. (This is a TinyMCE bit of nonsense)
Good luck.