I do use bueditor due to the possibility to add php code to buttons (e.g. to create a list of nodes etc). Is this possible with markItUp module, too?

Comments

Garrett Albright’s picture

I'm inclined to mark this as "won't fix." Can you convince me why this would actually be a good idea?

Roi Danton’s picture

Category: support » feature

Example: My module creates buttons with the views module and own functions to insert nodes/tax terms/views/fields etc into the textfield the editor is attached to. To enable this usage the editor has to support PHP for his buttons. I haven't looked into the markItUP code so I don't know if this would need a redesign of this module. I like to work with BUEditor but this editor is more promising since it uses the jQuery functions.

Besides that please have in mind to help sun with his WYSIWYG api efforts as all editor module writers should do to make Drupal the ultimate cms software. ;) So the wysiwyg module will support this editor in future, too (don't be confused, wysiwyg api is not limited to wysiwyg editors ;) ). Thx!

Garrett Albright’s picture

Maybe I'm not understanding what you're asking. You want to be able to add buttons to the button bar which will insert bits of PHP code? Or you want to be able to click a button and fetch a response from a PHP script in the server and insert that? Or…? Spell it out for me.

And yes, WYSIWYG API support is definitely on the radar for the near future. But for now it'll continue to be a separate module.

Roi Danton’s picture

Ah sorry, the second one.

I want to add buttons which contain lists that are created using PHP code. E.g. in my case to have a list of certain nodes/terms/fields or the output of a view inside that button. Then the user clicks on it and a tag is included.
So I'd like to use PHP function to create a button. E.g. in BUEditor (/admin/settings/bueditor/1) you do it by entering "php:" into the button code. Unfortunately to enable this markitup has to support the addition of buttons with the help of an admin form before. But this is presumable not the way markitup is intended to work. :/

Garrett Albright’s picture

I don't think that'll be difficult, though. Just have your module add its own JavaScript file which alters the mySettings global variable to add your button. Check out the set.js file in your set of choice; it's pretty simple. (Too simple, in fact…)

The button will disappear when the set is changed when someone changes the input filter, but perhaps there's a way around that - I'll figure that out soon, hold tight.

Roi Danton’s picture

Thanks for the follow up. Some things are still not clear to me.

1. Alter mySettings object

As far as I understand I could alter the markItUp set object the admin has defined by calling a javascript file with my module. Unfortunately I don't know whats the name of the currently active global set object and I don't know when to call my javascript file (should only be called when the editor appears). I assume your module saves the set.js file the admin has chosen for each input format (haven't looked into details of your code yet) but doesn't save the name of the global set object inside the set.js file?

2. Using custom javascript

Adding custom javascript functions also seems no problem but adding a popup window (with several options for the user) could be tricky since that function which calls the popup doesn't return anything (it just calls the popup url). But the markItUp button methods like replaceWith needs functions which returns something (as I understand). beforeInsert would be no option because then the value of replaceWith will be entered as well. Maybe I'm wrong?
EDIT: Perhaps it works if openWith & closeWith have empty values and I call the popup window with afterInsert. Since the button parameters (textarea object etc) are passed to this function I should be able to insert the choice of the user with my own javascript function into the correct textarea.

Garrett Albright’s picture

Ya know, let me see how the new refactored version of the module turns out, 'cuz even I'm not entirely sure. Once I know that, I'll give you a better answer.