Skip to content

feat req: use markdownfield for comments #57

@chrillep

Description

@chrillep

Being able to use markdown would just add clarity / ability to create better comments

Textarea::make('comment')
->alwaysShow()
->hideFromIndex(),

 Markdown::make('comment') 
     ->alwaysShow() 
     ->hideFromIndex(), 

ref:

Markdown Field

The Markdown field provides a WYSIWYG Markdown editor for its underlying Eloquent attribute. Typically, this field will correspond to a TEXT column in your database. The Markdown field will store the raw Markdown text within the associated database column:

use Laravel\Nova\Fields\Markdown;

Markdown::make('Biography'),

By default, Markdown fields will not display their content when viewing a resource's detail page. Instead, the content will be hidden behind a "Show Content" link that will reveal the field's content when clicked. You may specify that the Markdown field should always display its content by calling the alwaysShow method on the field itself:

Markdown::make('Biography')->alwaysShow(),

The Markdown field uses the league/commonmark package to parse Markdown content. By default, it uses a parsing strategy similar to GitHub Flavoured Markdown, which does not allow certain HTML within the Markdown content. However, you can change the parsing strategy using the preset method. Currently, the following built-in presets are default, commonmark, and zero:

Markdown::make('Biography')->preset('commonmark'),

Using the preset method, you may register and use custom preset implementations:

use Illuminate\Support\Str;
use Laravel\Nova\Fields\Markdown;
use Laravel\Nova\Fields\Markdown\MarkdownPreset;

Markdown::make('Biography')->preset('github', new class implements MarkdownPreset {
    /**
     * Convert the given content from markdown to HTML.
     *
     * @param  string  $content
     * @return string
     */
    public function convert(string $content)
    {
        return Str::of($content)->markdown([
            'html_input' => 'strip',
        ]);
    }
}),

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions