Page 1 of 15

Highlight plugin calls

Posted: Sat Dec 27, 2014 5:54 pm
by Tata
Little idea:
how would it be possible to have all calls styled by a pre-defined colour different from the pre9-defined webpage text color?
Or even with a tooltip with configurable hint, warning etc.
E.g.
Heading
{{{COMMENT: plugin-call();}}}
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat."

Re: Highlight plugin calls

Posted: Sat Dec 27, 2014 6:20 pm
by cmb
Tata wrote:how would it be possible to have all calls styled by a pre-defined colour different from the pre9-defined webpage text color?
That would be nice. I have seen this several times done by users, not rarely causing the plugin call to fail due to markup inside the {{{ }}}.

However, this would have to be done for each editor individually to be working before the page is saved, and I'm not sure if it's feasible at all. If it would be okay to highlight the plugin call only after saving, we could do that similar to replacing a surrounding <p> with a <div>. In both cases adding an appropriate CSS class (which would have to be styled in the template's stylesheet) might be sufficient.

A quick draft: find the following in cmsimple/adminfuncs.php (line 922ff):

Code: Select all

    $text = preg_replace(
        '/<p>({{{.*?}}}|#CMSimple .*?#)<\/p>/isu', '<div>$1</div>', $text
    );
Replace with:

Code: Select all

    $text = preg_replace(
        '/<(?:p|div)>({{{.*?}}}|#CMSimple .*?#)<\/(?:p|div)>/isu', '<div class="xh_plugin_call">$1</div>', $text
    );
Anyhow, I'll put it on the roadmap for XH 1.7.

Re: Highlight plugin calls

Posted: Sat Dec 27, 2014 10:10 pm
by Tata
Tested with 1.6.4 - works but only with the comment "PLUGIN:". With pure {{{plugincall();}}} it doesn't work at all.
However, the plugin output is then styled too. E.g. the call

Code: Select all

{{{twocents('guestbook');}}}
makes the Guestbook styled the same way as defined in xh_plugin_call.

Re: Highlight plugin calls

Posted: Sun Dec 28, 2014 12:12 pm
by cmb
Tata wrote:Tested with 1.6.4 - works but only with the comment "PLUGIN:". With pure {{{plugincall();}}} it doesn't work at all.
I had tested with {{{slideshow('slides', 'order=fixed');}}}, and that worked. However, it won't work, if the plugin call is written inline or if it is put in an already styled element, for instance. There is room for improvement, even though we may not be able to catch all cases.
Tata wrote:However, the plugin output is then styled too.
Yes, indeed. To avoid that, the styling of the plugin call must not be put into the template's stylesheet, but rather in a separate stylesheet, which has to be referenced in plugins/tinymce/inits/init_*.js. For instance,replace:

Code: Select all

    content_css : "%STYLESHEET%",
with:

Code: Select all

    content_css : "%STYLESHEET%, ./plugins/tinymce/inits/editor.css",
AFAIK for CKEditor there is a similar mechanism.

Re: Highlight plugin calls

Posted: Sun Dec 28, 2014 1:23 pm
by Tata
Works fine but still only with "PLUGIN: ". At least on my website.

Re: Highlight plugin calls

Posted: Wed Apr 05, 2017 3:16 pm
by Tata
Tested right now with v1.6.9.
Adjusted the above suggested code to

Code: Select all

   if(!$adm == "true"){
        $text = preg_replace('/<(?:p|div)>({{{.*?}}}|#CMSimple .*?#)<\/(?:p|div)>/isu', '<div class="xh_plugin_call">$1</div>', $text);
    }else{
        $text = preg_replace('/<(?:p|div)>({{{.*?}}}|#CMSimple .*?#)<\/(?:p|div)>/isu', '<div>$1</div>', $text);
    }
    and saving editor.css in ./plugins/tinymce/inits

Code: Select all

.xh_plugin_call{display: inline-block; background: yellow; color: red; border: 1px solid red;}
.xh_plugin_call:before{content: "PLUGIN CALL: "; color: red; font-weight: bold;}
.xh_plugin_call:after{content: " DON'T TOUCH!!!"; color: red; font-weight: bold;} 
I get
[ external image ]
As you see, it works without "PLUGIN" and it acts only while logged in. Normally the plugin call is executed.
However, it doesn't work if there are other plugins installed. Or it seems that the problem is somewhere in content.htm. With Original content file it works. When I add a content from another website, it doesn't work.

Re: Highlight plugin calls

Posted: Wed Apr 05, 2017 4:56 pm
by Holger
Another idea:
what about something like this: http://sdk.ckeditor.com/samples/placeholder.html ?
Once you have entered a PluginCall it gets highlighted and you can only edit the contents with a double click.

Re: Highlight plugin calls

Posted: Wed Apr 05, 2017 5:34 pm
by Tata
Well, this would be fine. But it would require to use CKRditor instead of tinyMCE, which is somehow more flexible to me.

Re: Highlight plugin calls

Posted: Wed Apr 05, 2017 9:55 pm
by cmb
Holger wrote:what about something like this: http://sdk.ckeditor.com/samples/placeholder.html ?
Great! IMHO much better than just highlighting plugin calls. Thank!
Tata wrote:But it would require to use CKRditor instead of tinyMCE, which is somehow more flexible to me.
There might be a similar solution readily available for TinyMCE (I couldn't find one, though), or we may write one ourselves (Calleditor_XH is actually somewhat similar). Note, however, that TinyMCE 3 (our default editor so far) is going to be replaced by TinyMCE 4 in XH 1.7, which is quite different to TinyMCE 3, it seems.

Re: Highlight plugin calls

Posted: Thu Apr 06, 2017 6:30 am
by Tata
This method seems not to work with v1.7.0. There are no warnings returned, but the styling is not adopted by the editor.
The Calleditor would be fine. But it didn't read all plugins installed, instead it offered some plugins I don't have installed at all. Also the problem is not in writing the plugin call. The purpose is in styling already inserted plugin call.