From ebb6b2827d0496303852f524a551592295dd0040 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 13 Nov 2016 22:51:59 -0500 Subject: Replace SimpleMDE with custom Markdown editor --- app/Helper/FormHelper.php | 38 ++++++++++++++++++++++++++++++++++++++ app/Helper/TaskHelper.php | 15 +-------------- 2 files changed, 39 insertions(+), 14 deletions(-) (limited to 'app/Helper') diff --git a/app/Helper/FormHelper.php b/app/Helper/FormHelper.php index eca1f317..6d915526 100644 --- a/app/Helper/FormHelper.php +++ b/app/Helper/FormHelper.php @@ -181,6 +181,44 @@ class FormHelper extends Base return $html; } + /** + * Display a markdown editor + * + * @access public + * @param string $name Field name + * @param array $values Form values + * @param array $errors Form errors + * @param array $attributes + * @return string + */ + public function textEditor($name, $values = array(), array $errors = array(), array $attributes = array()) + { + if (! isset($attributes['css'])) { + $attributes['css'] = ''; + } + + $attrHtml = ''; + $attributes['css'] .= $this->errorClass($errors, $name); + + foreach ($attributes as $attribute => $value) { + $attrHtml .= sprintf(' %s="%s"', $attribute, $value); + } + + $html = sprintf( + '', + $name, + isset($values[$name]) ? $this->helper->text->e($values[$name]) : '', + t('Preview'), + t('Write'), + t('Write your text in Markdown'), + $attrHtml + ); + + $html .= $this->errorList($errors, $name); + + return $html; + } + /** * Display file field * diff --git a/app/Helper/TaskHelper.php b/app/Helper/TaskHelper.php index 1dce7c54..92a9228c 100644 --- a/app/Helper/TaskHelper.php +++ b/app/Helper/TaskHelper.php @@ -50,20 +50,7 @@ class TaskHelper extends Base public function selectDescription(array $values, array $errors) { $html = $this->helper->form->label(t('Description'), 'description'); - $html .= '
'; - $html .= $this->helper->form->textarea( - 'description', - $values, - $errors, - array( - 'placeholder="'.t('Leave a description').'"', - 'tabindex="2"', - 'data-mention-search-url="'.$this->helper->url->href('UserAjaxController', 'mention', array('project_id' => $values['project_id'])).'"' - ), - 'markdown-editor' - ); - - $html .= '
'; + $html .= $this->helper->form->textEditor('description', $values, $errors, array('tabindex' => 2)); return $html; } -- cgit v1.2.3