axllent/silverstripe-gfmarkdown

使用 Parsedown 进行 GitHub Flavored Markdown 编辑和渲染

安装次数: 4,757

依赖项: 0

建议者: 0

安全: 0

星标: 6

关注者: 4

分支: 5

开放问题: 0

类型:silverstripe-vendormodule

2.2.7 2023-06-02 10:21 UTC

This package is auto-updated.

Last update: 2024-09-02 01:52:26 UTC


README

此模块添加了一个字段和一个数据类型,允许在 CMS 中使用 GitHub Flavored Markdown 解析器 Parsedown 进行 HTML 渲染。

它包括 Ace 编辑器 用于 CMS 编辑。

要求

  • Silverstripe ^4.0 || ^5.0

安装

composer require axllent/silverstripe-gfmarkdown

用法

将 Markdown 数据类型用作字段数据类型,并在 CMS 中使用 MarkdownEditor 字段进行编辑。

示例

<?php

use Axllent\Gfmarkdown\Forms\MarkdownEditor;

class MyPage extends Page
{
    public static $db = array(
        'MarkdownContent' => 'Markdown'
    );

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        // If you want the Ace markdown editor in the CMS
        $fields->addFieldToTab('Root.Main',
            MarkdownEditor::create('MarkdownContent')
                ->setTheme('github')            // set theme
                ->setRows(20)                   // set number of rows in CMS
                ->setWrap(false)                // disable word wrapping
                ->setHighlightActiveLine(true)  // enable line highlighting
        );

        return $fields;
    }
}

Silverstripe 模板

<div class="content">
    $MarkdownContent  <!-- Will show as rendered html -->
</div>