Forums | Mahara Community

Support /
Friendly URLs for files


anonymous profile picture
Account deleted
Posts: 112

06 December 2013, 2:48

I tried to upgrade my tinymce on my own website.  I got as far as being able to change all of the textareas to tinymce, but I cannot actually add anything to the textarea.  Here is the modified section of code.  Can't see a way to just attach a file, so I am just posting the section that I changed (dealing with tinymce initialization.  Maybe somebody else cann easily see what the next step is (I am probably deleting something that is import that I don't realize is important):

 

// TinyMCE must be included first for some reason we're not sure about
//
// Note: we do not display tinyMCE for mobile devices
// as it doesn't work on some of them and can
// disable the editing of a textarea field
if ($SESSION->get('handheld_device') == false) {
$checkarray = array(&$javascript, &$headers);
$found_tinymce = false;
foreach ($checkarray as &$check) {
if (($key = array_search('tinymce', $check)) !== false || ($key = array_search('tinytinymce', $check)) !== false) {
if (!$found_tinymce) {
$found_tinymce = $check[$key];
$javascript_array[] = $jsroot . 'tinymce4/tinymce.min.js';

$headers[] = <<<EOF
<script type="text/javascript">
tinyMCE.init({
selector: "textarea",
extended_valid_elements : "object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode],script[src,type,language],+ul[id|type|compact],iframe[src|width|height|align|title|class|type|frameborder|allowfullscreen]",
//remove_script_host: false,
relative_urls: false,
/*
setup: function(ed) {
ed.onInit.add(function(ed) {
if (typeof(editor_to_focus) == 'string' && ed.editorId == editor_to_focus) {
ed.focus();
}
});
}
*/
});
</script>

EOF;
unset($check[$key]);
}
else {
if ($check[$key] != $found_tinymce) {
log_warn('Two differently configured tinyMCE instances have been asked for on this page! This is not possible');
}
unset($check[$key]);
}
}

// If any page adds jquery explicitly, remove it from the list

anonymous profile picture
Account deleted
Posts: 112

06 December 2013, 3:49

It looks like the API to TinyMCE changed, which is called from the file /tinywysiwyg.php.

But the question is, why do we even need to access TinyMCE from the API?  Here is the code for "saving" in TinyMCE4 using the stanard tinymce.init (from the web.php):

tinymce.init({
    plugins
:"save",
    toolbar
:"save",
    save_enablewhendirty
:true,
    save_onsavecallback
:function(){console.log("Save");}
});

Mahara does not need to go through the API.  Plus, if nobody really understands how the TinyMCE API works (aka Mahara is not taking advantage of it for items Mahara truly needs -- inserting local Mahara images), what are the advantages of using it on any level.  It just seems to make things more complicated with no benefits.

TinyMCE is supposed to be a clean replace.  In the tinymce.init settings, the element and class are  specified that are replaced with TinyMCE.  Use different class names for different screens when needed, and there is no conflict.  

For example, 

selector: "textarea"  // our full featured tinymce

selector: "input" // repeat and undo or maybe cut and paste

selector: "textarea.miniedit" // Use for tight areas, setup only the most import fuctions

There is even ways to setup inline editing (click on a header and you can edit it directly.

Melissa

 

Aaron Wells's profile picture
Posts: 896

06 December 2013, 11:38

Most of our TinyMCE integration code was written in 2008, and unfortunately we haven't revisited it very often because it works and our development resources have been occupied in other areas. I'd be glad to look at incorporating your improvements into core. Smile

Mahara does actually have at least one TinyMCE customization, which is that when you're editing a journal entry with some images as file attachments, and you click on the "insert/edit image" button, there's a drop-down menu to let you insert one of the image attachments. I think there was some intention of expanding this to other areas as well, but it's only ever been implemented for journal entries

I think some of the weirdness of our TinyMCE setup may also be related to getting TinyMCE to attach to the contents of the block config popups.

Cheers,

Aaron

23 results