Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat req: use markdownfield for comments #57

Open
chrillep opened this issue Nov 22, 2022 · 0 comments
Open

feat req: use markdownfield for comments #57

chrillep opened this issue Nov 22, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@chrillep
Copy link
Contributor

chrillep commented Nov 22, 2022

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',
        ]);
    }
}),
@luisdalmolin luisdalmolin added the enhancement New feature or request label Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants