Jump to content

InputField for MarkItUp! markup editor


felic
 Share

Recommended Posts

Hi,

first, i am rather new to processwire (build one website with it so far) and very excited about the possibilities it offers. 

I am playing a bit with building a inputfield module for the markup editor MarkItUp! (http://markitup.jaysalvat.com/) which i like to use instead of this WYSIWYG stuff. Base implementation of the module is going well. But of course the fun starts by providing a switch between HTML, Markdown and Textile formats according to what textformat the user has choosen within the field edit (detail tab).

As MarkItUp! organizes textformater in separate folders sets, i need to poll the textformatter setting of a field. This is where i fail. Searched the API but cannot find out how to poll related attributes and values for the field which inputfield type is set to MarkitUp.

Hope my description is precise enough. Would be great to get some advice of you guys!

Link to comment
Share on other sites

@adrain

Thanks for your answer! 

I suppose my explanation was a bit unclear. I need to get the choosen textformatters of the field the editor is applied to. So there is no known field name at this point.

But your post helped to get me on the right track. Thank you for that!

Finally i managed to get this done. Works so far. 

(Excerpt) File: InputfieldMarkItUp.module

protected $defaults = array(
  'skins' => 'simple',
  'set' => 'default' // => html
);

public function init() {
  foreach($this->defaults as $key => $value) $this->set($key, $value);

  // set 'textformatters' array to current object
  $this->set('textformatters', array());

  parent::init();
}

public function ___render() {
  $config = $this->defaults;
  
  // edit config var 'set' according to the available textformatter(s)
  if (in_array('TextformatterTextile', $this->textformatters)) {
    $config['set'] = 'textile';
  }
  ...
}
 
Next task will be how to substitute the link and image functionality, so the editor provides insertion of internal links and media stuff. This might will raise some further questions, i am afraid ;-) 
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...