Skip to content

Commit

Permalink
* providing an implicit fallback to the original KB markdown rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
imfx77 committed Jun 24, 2024
1 parent 7cdd416 commit 6d85078
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Helper/WysiwygMDEditorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
namespace Kanboard\Plugin\WysiwygMDEditor\Helper;

use Kanboard\Core\Base;
use Kanboard\Core\Markdown;

class WysiwygMDEditorHelper extends Base
{
const FORCE_FALLBACK_IMPL = '__{WysiwygMDEditor_FORCE_FALLBACK_IMPL}__';

/**
* HTML escaping
*
Expand Down Expand Up @@ -47,6 +50,16 @@ public function implode($glue, array $list)
*/
public function markdown($text, $isPublicLink = false)
{
$isForceFallbackImpl = str_starts_with($text, WysiwygMDEditorHelper::FORCE_FALLBACK_IMPL);

if ($isForceFallbackImpl) {
// the original KB impl
$parser = new Markdown($this->container, $isPublicLink);
$parser->setMarkupEscaped(MARKDOWN_ESCAPE_HTML);
$parser->setBreaksEnabled(true);
return $parser->text($text ? str_replace(WysiwygMDEditorHelper::FORCE_FALLBACK_IMPL, '', $text) : '');
}

$returnText = '';
$returnText .= '<textarea class="WysiwygMDEditor-MarkdownTextContainer" style="display: none" ';
$returnText .= 'renderTheme="' . $this->configModel->get('WysiwygMDEditor_easymde_render_theme', 'dimmed') . '" ';
Expand Down

0 comments on commit 6d85078

Please sign in to comment.