?
avatar schnuti
schnuti
2 Jul 2016

Would someone else than me want a possibility to manipulate the parameters for the Tinymce editor?

I want other settings for another component than com_content primarily in frontend. The 3 textareas are for authors and not designers ;). I can force the use of Tinymce in the form. (editor="tinymce")

I have a suggestion but it might be other smarter ways available to override part of, or the whole method "onDisplay in tinymce.php"

I allow override for a component but still allow a override in the template.

    if (!$declaredJs)
    {
       $app    = JFactory::getApplication();

       // Include override
       $override1 = JPATH_THEMES . '/'.$app->getTemplate(). '/html/plg_editors_tinymce/tinymce.php';
       $override2 = JPATH_COMPONENT_ADMINISTRATOR . '/helpers/tinymce.php';

       if (JFile::exists($override1))
       {
          include $override1;
       }
       elseif (JFile::exists($override2))
       {
          include $override2;
       }
       else
       {
  1. Without override for an article - max toolbar.

screen shot 2016-07-02 at 12 24 52

  1. With override for an article - modified to a minimum.

screen shot 2016-07-02 at 12 25 56

This does not belong to the suggesttion but might be of interest. I added inline editing with Tinymce to my component. I added it to com_content article view only to show the effect in the screenshot. A real inline editing for articles is not in general possible. There are "read more" and other plug ins that are in the way. With my component I can save it directly with an ajax call.

screen shot 2016-07-02 at 12 39 10

I would make a PR if there is interest. I tried to fork the plug in but had some trouble with the toggle button and it would be easier to hang on the standard plug in.

avatar schnuti schnuti - open - 2 Jul 2016
avatar dgt41
dgt41 - comment - 2 Jul 2016

I think is far easier to create your own editor instead of trying to put more functionality into Joomla's distributed tinyMCE.
Pros: you put whatever makes sense for you
Against: you have to keep manually updating it, if bugs found

The idea is to keep the javascript files from the distributed files from Joomla, so all you have to do is create a plugin (an xml and a php file).

avatar schnuti
schnuti - comment - 2 Jul 2016

You are right, if I'm alone finding the need for a 3.p extension annoying, when you only want to set a couple of parameters TO REDUCE functionality. My own plug in would not be availible for others. As I wrote, I would probably loose the toggle button; but that's not importanbt since there is a popup with the raw text.

avatar Fedik
Fedik - comment - 3 Jul 2016

There is a better way to override the options, it is use addScriptOptions
Of course for this is required changes in tinyMCE to work with it

avatar infograf768
infograf768 - comment - 3 Jul 2016

What would be a real improvement is the ability to define access levels not only in Extended mode but between Simple, Extended and Advanced.

avatar schnuti
schnuti - comment - 4 Jul 2016

I now have a working fork of the tinymce.php ( a new plugin ) where i'm completely rewriting the "onDisplay" method. I'm still using the tinymce media folder. It takes some time to find out which plugins I need to keep (or even add)

@infograf768
As a first step I think you are right but the code has to be reworked. It's hardcoded. A "designer", in smaller projects a Siuper User, could log in as a second user to get the authors rnenu/toolbar. I think, I wouid preferr only two different settings for frontend and backend where you can set all settings as now for the Extended mode (maybe some more) . Only the defaults would be different.

B/C problem?

I'm not trying to replace the 3.p Tinymce extension only some improvement for the standard installations and component developers. Remember the goal of "horizontal" extensions? That I agree with,

avatar schnuti
schnuti - comment - 4 Jul 2016

It came to me
Wouldn¨t it be possible to add a few parameters to the Extended mode to make it possible to generate what now is Advanced and Simple? This should be B/C and what @infograf768 suggested?

avatar schnuti
schnuti - comment - 4 Jul 2016

@Fedik

There is a better way to override the options, it is use addScriptOptions
Of course for this is required changes in tinyMCE to work with it

I don¨'t think it's a good idea to change a library type. Maintenance?

avatar Fedik
Fedik - comment - 4 Jul 2016

to change a library type

no need to change the library , I meant change tinyMCE plugin code ?
see staging...Fedik:tinymce-scriptoptions I tried something,

in result you can change the default options at runtime (after onDisplay was called, and before Document will be rendered):

$editorOptions = $doc->getSriptOptions('plg_editor_tinymce');
$editorOptions['tinyMCE']['toolbar1'] = 'bla bla';
$editorOptions['tinyMCE']['plugins'] = 'foo bar';
$doc->addScriptOptions('plg_editor_tinymce', $editorOptions);
avatar schnuti
schnuti - comment - 4 Jul 2016

@Fedik
Great! As I understand it, you added a js ini in front of tinyMCE. I'm a js foo , without the bar. :bowtie:
Is it possible to add a toolbar2? It's the second row in the tinyMCE's toolbar and to control the menubar? e.g. I set the menubar to "menubar: false,:" if I don't need it. i.e.I try to come out with a single toolbar if possible.
How can I test it? Hack the files?

avatar Fedik
Fedik - comment - 4 Jul 2016

Is it possible to add a toolbar2?

you can modify any options

How can I test it? Hack the files?

well, yes, hack them ?

and can try to make a changes for tinyMCE options in plugin, at onBeforeRender event

public function onBeforeRender()
{
  $doc = JFactory::getDocument();
  $editorOptions = $doc->getScriptOptions('plg_editor_tinymce');
  $editorOptions['tinyMCE']['menubar'] = false;
  $editorOptions['tinyMCE']['toolbar1']  = 'bold italic underline strikethrough';
  $doc->addScriptOptions('plg_editor_tinymce', $editorOptions);
 }

But it was just a test

avatar schnuti
schnuti - comment - 4 Jul 2016

OK thanks! I'll test and come back. It can take some time though.

avatar schnuti
schnuti - comment - 5 Jul 2016

@Fedik
I ran article creation in backend with the changes made to the files.
First it faild with Error
Call to undefined method JDocumentHtml::addScriptOptions()
The method was missing in my J3.5.1 installation. Found it on Github.
Now it runs through but without editor.
The js code in the header is missing.
"tinymce.init({
directionality: "ltr",
..."

The 2 js files are loaded.
If I activate my plugin, I find the data in the doc ready to override.
Something more missing?

avatar Fedik
Fedik - comment - 5 Jul 2016

sorry, I forgot to mention that it will work only on 3.6 (or latest staging) with patch staging...Fedik:tinymce-scriptoptions

The js code in the header is missing.

yes because it moved to ..init.js file

avatar schnuti
schnuti - comment - 5 Jul 2016

So there is something more needed from 3.6? I have created the ..ini.js from your patch and it is loaded into the HTML header.

avatar Fedik
Fedik - comment - 5 Jul 2016

there also some changes in tinymce.php onDisplay

avatar schnuti
schnuti - comment - 6 Jul 2016

@Fedik

there also some changes in tinymce.php onDisplay

Hmm? I have implemented all the code from your patch + the new JDocumentHtml. ?

avatar Fedik
Fedik - comment - 6 Jul 2016

I have implemented all the code from your patch

then it is all ?

avatar schnuti
schnuti - comment - 6 Jul 2016

@Fedik
I installed a new Joomla instance from staging and implemented the patch + the override-plugin.
Maybe I overlook that the editor was loaded since it now starts in toggled mood. ( bug?! ), Clicking the toggle button shows the editor but not overridden. I get the standard layout. I use your example code. I also checked that the code runs and this line executes.
$doc->addScriptOptions('plg_editor_tinymce', $editorOptions);
The array is modified, I chacked that.!

avatar Fedik
Fedik - comment - 8 Jul 2016

then all should work, or my test patch not as good as I thought ?

avatar schnuti
schnuti - comment - 10 Jul 2016

@Fedik
I guess my problem is, that I used the modified 3.5.1 modified plugin code in the staging instance. I've seen that there are other changes made to the plugin that might be important for it to work. I'll test it more in a few days. I've bin working om my fork of the tinymce editor plugin. Now I have everything I wanted and more. I have three levels (as Joomla), single toolbar, normal and advanced. I can control who is to use wich level in frontend and backend with only 4 settings. User group multiselects.

It makes real fun to modify the tinyMce parameter and add a few js plugins. One of the reasons for my idea was to at least remove all image and videobuttons used in the editor. I have that separated, table controlled. But now I got interested in integrating elFinder with tinyMce. elFinder is a media manager I use in parallel anyway. (K2 is using it) What I have done, should also be possible with your onBeforeRender plugin. And less update problems. ?

avatar schnuti
schnuti - comment - 14 Jul 2016

@Fedik
I do not know exactly what the problem was. Only that there is a bug in the ini.js An infinite loop as variable i stays at 0. (i++)

Now I have the full toolbar set and see this without system plugin.

max_tinymce

And this with activated override through the system plugin.

modified_tinymce

I hope you propose this for Joomla core. Let me know if you make a PR. I'll be glad to test it.

avatar brianteeman
brianteeman - comment - 14 Jul 2016

It will definitely be interesting to see a method in core to configure
tinymce differently for different users

avatar schnuti
schnuti - comment - 14 Jul 2016

@brianteeman
If Fediks code comes to a PR, I'll try to write an understandable doc how to achive different toolbar(s)/menubar for tinyMCE on usergroup level (I think user is to fine graded.). I used to be a fan of parameter settings but this interest has bin reduced lately. To allow to set all possible combinations for tinyMCE, the settings list would be long and complicated. It's of course also possible to make it component/view dependent with e.g. specific buttons/tinyMCE plug ins. It's up to the site implementor, SuperUser and developer.

avatar Fedik
Fedik - comment - 16 Jul 2016

For "allow tinyMCE options override" I have made pull request #11157, @schnuti please test

About configure tinymce differently for different users,
it is "a bit" more complex task ?

avatar schnuti
schnuti - comment - 17 Jul 2016

I suppose a change to the tinyMCE plugin, to allow settings for users/user groups, is to complex for the J 3.x series. It should though be an issue for 4.x

I close this as we have a PR and this issue is referenced there.

avatar schnuti schnuti - close - 17 Jul 2016
avatar schnuti schnuti - change - 17 Jul 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-07-17 19:48:39
Closed_By schnuti

Add a Comment

Login with GitHub to post a comment