Replace SimpleMDE with custom Markdown editor
This commit is contained in:
@@ -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(
|
||||
'<texteditor name="%s" text="%s" label-preview="%s" label-write="%s" placeholder="%s" %s></texteditor>',
|
||||
$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
|
||||
*
|
||||
|
||||
@@ -50,20 +50,7 @@ class TaskHelper extends Base
|
||||
public function selectDescription(array $values, array $errors)
|
||||
{
|
||||
$html = $this->helper->form->label(t('Description'), 'description');
|
||||
$html .= '<div class="markdown-editor-container">';
|
||||
$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 .= '</div>';
|
||||
$html .= $this->helper->form->textEditor('description', $values, $errors, array('tabindex' => 2));
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="50"')) ?>
|
||||
|
||||
<?= $this->form->label(t('Description'), 'description') ?>
|
||||
<?= $this->form->textarea('description', $values, $errors, array(), 'markdown-editor') ?>
|
||||
<?= $this->form->textEditor('description', $values, $errors) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<?= $this->form->checkbox('hide_in_dashboard', t('Hide tasks in this column in the dashboard'), 1) ?>
|
||||
|
||||
<?= $this->form->label(t('Description'), 'description') ?>
|
||||
<?= $this->form->textarea('description', $values, $errors, array(), 'markdown-editor') ?>
|
||||
<?= $this->form->textEditor('description', $values, $errors) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<?= $this->form->checkbox('hide_in_dashboard', t('Hide tasks in this column in the dashboard'), 1, $values['hide_in_dashboard'] == 1) ?>
|
||||
|
||||
<?= $this->form->label(t('Description'), 'description') ?>
|
||||
<?= $this->form->textarea('description', $values, $errors, array(), 'markdown-editor') ?>
|
||||
<?= $this->form->textEditor('description', $values, $errors) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||
|
||||
@@ -6,20 +6,7 @@
|
||||
<?= $this->form->hidden('task_id', $values) ?>
|
||||
<?= $this->form->hidden('user_id', $values) ?>
|
||||
|
||||
<div class="markdown-editor-small">
|
||||
<?= $this->form->textarea(
|
||||
'comment',
|
||||
$values,
|
||||
$errors,
|
||||
array(
|
||||
'autofocus',
|
||||
'required',
|
||||
'placeholder="'.t('Leave a comment').'"',
|
||||
'data-mention-search-url="'.$this->url->href('UserAjaxController', 'mention', array('project_id' => $task['project_id'])).'"',
|
||||
),
|
||||
'markdown-editor'
|
||||
) ?>
|
||||
</div>
|
||||
<?= $this->form->textEditor('comment', $values, $errors, array('autofocus' => true, 'required' => true)) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||
|
||||
@@ -3,21 +3,12 @@
|
||||
</div>
|
||||
|
||||
<form class="popover-form" method="post" action="<?= $this->url->href('CommentController', 'update', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'comment_id' => $comment['id'])) ?>" autocomplete="off">
|
||||
|
||||
<?= $this->form->csrf() ?>
|
||||
<?= $this->form->hidden('id', $values) ?>
|
||||
<?= $this->form->hidden('task_id', $values) ?>
|
||||
<?= $this->form->hidden('user_id', $values) ?>
|
||||
|
||||
<div class="markdown-editor-small">
|
||||
<?= $this->form->textarea(
|
||||
'comment',
|
||||
$values,
|
||||
$errors,
|
||||
array('autofocus', 'required', 'placeholder="'.t('Leave a comment').'"'),
|
||||
'markdown-editor'
|
||||
) ?>
|
||||
</div>
|
||||
<?= $this->form->textEditor('comment', $values, $errors, array('autofocus' => true, 'required' => true)) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||
|
||||
@@ -3,20 +3,7 @@
|
||||
<?= $this->form->hidden('task_id', $values) ?>
|
||||
<?= $this->form->hidden('user_id', $values) ?>
|
||||
|
||||
<div class="markdown-editor-small">
|
||||
<?= $this->form->textarea(
|
||||
'comment',
|
||||
$values,
|
||||
$errors,
|
||||
array(
|
||||
'data-markdown-editor-disable-toolbar="true"',
|
||||
'required',
|
||||
'placeholder="'.t('Leave a comment').'"',
|
||||
'data-mention-search-url="'.$this->url->href('UserAjaxController', 'mention', array('project_id' => $task['project_id'])).'"',
|
||||
),
|
||||
'markdown-editor'
|
||||
) ?>
|
||||
</div>
|
||||
<?= $this->form->textEditor('comment', $values, $errors, array('required' => true)) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<?= $this->form->csrf() ?>
|
||||
<?= $this->form->hidden('id', $values) ?>
|
||||
<?= $this->form->hidden('name', $values) ?>
|
||||
<?= $this->form->textarea('description', $values, $errors, array(), 'markdown-editor') ?>
|
||||
<?= $this->form->textEditor('description', $values, $errors, array('autofocus' => true)) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="50"')) ?>
|
||||
|
||||
<?= $this->form->label(t('Description'), 'description') ?>
|
||||
<?= $this->form->textarea('description', $values, $errors, array(), 'markdown-editor') ?>
|
||||
<?= $this->form->textEditor('description', $values, $errors) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="50"')) ?>
|
||||
|
||||
<?= $this->form->label(t('Description'), 'description') ?>
|
||||
<?= $this->form->textarea('description', $values, $errors, array(), 'markdown-editor') ?>
|
||||
<?= $this->form->textEditor('description', $values, $errors) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||
|
||||
Reference in New Issue
Block a user