codicastudio/unlayer-editor

A random Codica Studio package.

1.0.0 2020-09-25 01:54 UTC

This package is auto-updated.

Last update: 2024-04-25 12:41:53 UTC


README

Adds a Laravel Nova field for Unlayer to compose emails and landing pages.

Installation

You can install the package in to a Laravel app that uses Nova via composer:

composer require idf/nova-unlayer-field

Usage

This package assumes that your Model has an attribute to store design config (it's better to use json or longtext SQL type to store it).

On submit, the package sends two fields:

  • design (stringified json object)
  • html code. If you want to store HTML to your model, please use savingCallback()
public function fields()
{
    return [ 
        Unlayer::make('Content', 'design')->config([
            'projectId' => config('unlayer.project_id'),
            'templateId' => config('unlayer.newsletter_template_id'), // Optional, used only if bound attribute is empty (e.g. $newsletter->design)
            'displayMode' => 'email', // Optional, "email" by default
            'locale' => app()->getLocale(), // Optional
        ]),
     ];
}

Options

  • ->config(array|callable $config): Specify Unlayer config.
  • ->savingCallback(?callable $callback): Specify callback on saving a Model. Useful to store HTML result HTML code.
  • ->height(string $height): Set height of the editor (with units). E.g. '1000px' (800px by default).

Changelog

Please see Releases for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Compiling Assets

# Compile and minify your assets:
npm run prod

# Compile your assets for local development:
npm run dev

# Run the NPM "watch" command to auto-compile your assets when they are changed:
npm run watch