freshinteractive/fresh-tap

A Laravel Nova field.

0.0.4 2023-11-09 21:37 UTC

This package is auto-updated.

Last update: 2024-11-10 00:46:18 UTC


README

A custom Laravel Nova Field for Fresh Tap.

Fresh Tap is a framework-agnostic Custom Element WYSIWYG Editor build on top of Tiptap and Vue.

Installation

composer require freshinteractive/fresh-tap

Usage

<?php

namespace App\Nova;

...
use Freshinteractive\FreshTap\FreshTap;
...

class YourResource extends Resource
{
    ...
    
    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        ...,
        FreshTap::make('Content')
                ->previewUrl('https://your-preview-url-here.com/page-content-will-live-on')
                ->previewSelector('.css-selector')
                ->previewWrapperElement([
                    'element' => 'div',
                    'attributes' => [
                        'class' => 'your-wrapper-class'
                    ]
                ])
                ->keepEmptyParagraphLineBreaks(),
                ->editorStyles("
                    .FreshTapEditor .ProseMirror { display: grid; grid-template-columns: 100%; gap: 20px; }
                ")
    }
}

Notes:

None of the methods are required. Just `FreshTap::make('Content')` works.

When using `->editorStyles()make sure that your styles are prepended with.FreshTapEditor .ProseMirror`. These styles will only be applied to the instance of the editor that it is implemented on.