var resetValues = {};
function resetValue(editor,option) {
var text = resetValues[editor.id];
if (option=="Reset") {
text = "\n" + text;
editor.setContent(text);
} else if (option=="Convert") {
text = "\n" + text.replace(/\n/g, "
");
editor.setContent(text);
} else if (option=="Revert") {
CKEDITOR.instances[editor].destroy()
var obj = document.getElementById(editor.id);
obj.value = text;
}
}
var sURLPREFIX = "/";
var sREVISIONPREFIX = "";
var sREVISIONPREFIXNOHOST = sREVISIONPREFIX.replace(sURLPREFIX,"");
//var revPrefixStr = ""; // separate so it is not replaced by HttpHandler.subst
function fitSaveCallback(id, html, body) {
// make sure the user did not delete the FIT_CK comment
if (html.indexOf("")<0) {
html = "" + html;
}
// get rid of REVISIONPREFIX (ie: smileys) as the revision number will change in future
// tried using revPrefixStr, but it was putting <REVISIONPREFIX> when changing from RTF to console
html = html.replace(sREVISIONPREFIX,"");
html = html.replace(sREVISIONPREFIXNOHOST,"");
return html;
}
var ckEnabled = {};
function ckEnabledRemove(arr,id) {
var newArray = {};
for (var key in arr) {
if (!arr[i]==key) {
newArray[key] = arr[key];
}
}
return newArray;
}
var CKINIT = false;
function toggleEditor(id) {
if (typeof ClassicEditor !== 'undefined') {
var obj = document.getElementById(id);
if (!ckEnabled[id]) {
resetValues[id] = obj.value;
//convert any old TINY codes to CK
if (obj.value.indexOf("")>=0) {
obj.value = obj.value.replace("","");
}
if (obj.value.indexOf("")<0) { // make sure field starts with tag
if (obj.value.indexOf('\n') > -1) {
var q2 = confirm("You have existing text which does not appear to be from the RTF editor ("+id+"). All newlines will be removed by this editor.\n\nIf you do not like the result, use the custom FIT options (first icon) to convert your original text!\n\nContinue ?");
if (q2==false) {
return false;
}
}
obj.value = "" + obj.value;
//setCaretTo(obj,16); //does not seem to work on Firefox
}
//ClassicEditor.builtinPlugins.map( plugin => console.error(plugin.pluginName ));
ClassicEditor
.create( obj, {
// toolbar: [ 'heading', '|', 'strikethrough', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote' ],
// heading: {
// options: [
// { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
// { model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
// { model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' }
// ]
// }
} )
.then( editor => {
console.log( editor );
ckEnabled[id]=editor;
} )
.catch( error => {
console.log( error );
} );
} else {
var ed = ckEnabled[id];
ed.destroy();
ckEnabled = ckEnabledRemove(ckEnabled,id);
if (!checkValidRtfContent(obj.value)) {
obj.value=""; // otherwise, nothing there - don't want to see FIT_TINY tag in regular console
}
}
}
}
function checkRtfTags() {
for(i=0; i")<0) {
// obj.value = "" + obj.value;
// }
//}
// untested change but needs to be tested if we ever use v5
if (ckEnabled[id]) {
var obj = document.getElementById(element.id);
if (obj) {
var str = CKEDITOR.instances[element.id].getData();
if (str.indexOf("")<0) {
str = "" + str;
CKEDITOR.instances[element.id].setData(str);
}
}
}
}
}
}
// initialize any that need it
function initTiny() {
//var count;
for(i=0; i0) { // testspec stuff prefixes with tc1, tr2, ..
def = def.substr(index);
}
if (rtfDefaultFields.indexOf(def)>=0) {
// defaults to rtf through settings
//setTimeout("toggleEditor('"+element.id+"');",10*count++);
var obj = document.getElementById(element.id);
if (obj.value.length == 0 || obj.value.indexOf("") >= 0 || obj.value.indexOf("") >= 0) {
//only enable editor if field is blank or contains rich text
toggleEditor(element.id);
}
} else if (element.id.length>0) {
var obj = document.getElementById(element.id);
if (obj && obj.value.indexOf("")>=0) {
// defaults to rtf cause data was edited there before
toggleEditor(element.id);
}
}
}
}
}