rich-text-laravel

Integrates the Trix Editor with Laravel. Inspired by the Action Text gem from Rails.

MIT License

Downloads
21.8K
Stars
326
Committers
3

Bot releases are hidden (Show)

rich-text-laravel - 3.1.0 Latest Release

Published by tonysm 6 months ago

What's Changed

Full Changelog: https://github.com/tonysm/rich-text-laravel/compare/3.0.0...3.1.0

rich-text-laravel - 3.0.0

Published by tonysm 7 months ago

What's Changed

Full Changelog: https://github.com/tonysm/rich-text-laravel/compare/2.2.0...3.0.0


Upgrade Guide

In 2.2.0 we introduced a new recommended way to encrypt data, which uses Laravel's Crypt::encryptString() instead of Crypt::encrypt(). This is now the default in v3. If you're migrating from 2.x and have existing data stored encrypted, but not using the recommendation in the 2.2.0 release note, you must migrate them (see instructions below).

Migrating Existing Encrypted Data

If you only have encrypted rich text attributes in your application, you may create a new migration and loop through the stored data, encrypting and decrypting it:

DB::table('rich_texts')->whereNotNull('body')->eachById(function ($richText) {
  DB::table('rich_texts')
    ->where('id', $richText->id)
    ->update([
      'body' => Crypt::encryptString(Crypt::decrypt($richText->body)),
    ]);
});

If you have a mix of encrypted and plain text rich text attributes, you will have to check if the $richText->field and $richText->record_type fields match the entities and attribute that are using encryption:

DB::table('rich_texts')
  ->whereNotNull('body')
  ->where('field', 'content')
  ->where('record_type', (new Post())->getMorphClass())
  ->eachById(function ($richText) {
    DB::table('rich_texts')
      ->where('id', $richText->id)
      ->update([
        'body' => Crypt::encryptString(Crypt::decrypt($richText->body)),
      ]);
  });
rich-text-laravel - 2.2.0

Published by tonysm 7 months ago

What's Changed

Full Changelog: https://github.com/tonysm/rich-text-laravel/compare/2.1.0...2.2.0


Upgrade Guide

It's now recommended that you add a RichTextLaravel::encryptAsString() to your AppServiceProvider::boot method. If you have existing data stored encrypted, you'll have to migrate them manually (see instructions below). This is an opt-in feature, but it's highly recommended to store encrypted rich text attributes as string (the default way will serialize the value before encrypting, which is not needed).

In the next major version, we'll switch to encrypt as string by default.

Migrating Existing Encrypted Data

If you only have encrypted rich text attributes in your application, you may create a new migration and loop through the stored data, encrypting and decrypting it:

DB::table('rich_texts')->whereNotNull('body')->eachById(function ($richText) {
  DB::table('rich_texts')
    ->where('id', $richText->id)
    ->update([
      'body' => Crypt::encryptString(Crypt::decrypt($richText->body)),
    ]);
});

Make sure you add the RichTextLaravel::encryptAsString() to your AppServiceProvider::boot method.

If you have a mix of encrypted and plain text rich text attributes, you will have to check if the $richText->field and $richText->record_type fields match the entities and attribute that are using encryption:

DB::table('rich_texts')
  ->whereNotNull('body')
  ->where('field', 'content')
  ->where('record_type', (new Post())->getMorphClass())
  ->eachById(function ($richText) {
    DB::table('rich_texts')
      ->where('id', $richText->id)
      ->update([
        'body' => Crypt::encryptString(Crypt::decrypt($richText->body)),
      ]);
  });
rich-text-laravel - 2.1.0

Published by tonysm 8 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/tonysm/rich-text-laravel/compare/2.0.3...2.1.0

rich-text-laravel - 2.0.3

Published by tonysm 8 months ago

What's Changed

Full Changelog: https://github.com/tonysm/rich-text-laravel/compare/2.0.2...2.0.3

rich-text-laravel - 2.0.2

Published by tonysm 8 months ago

What's Changed

Full Changelog: https://github.com/tonysm/rich-text-laravel/compare/2.0.1...2.0.2

rich-text-laravel - 2.0.1

Published by tonysm 8 months ago

Changelog

  • FIXED: Fixed the importmap command when installing in a project during Importmap Laravel
rich-text-laravel - 2.0.0

Published by tonysm 8 months ago

What's Changed

Full Changelog: https://github.com/tonysm/rich-text-laravel/compare/1.7.0...2.0.0


Upgrade Guide

A few things changed from v1. There are some breaking changes, but most are renamings.

Rename the Rich Text Property

Rename all your $richTextFields properties to $richTextAttributes on all your models using it

Rename the Styles Component

Rename the <x-rich-text-trix-styles /> to <x-rich-text::styles />

Rename the Published Trix Input Component

Rename the <x-trix-field /> to <x-trix-input /> (both the file and its usages)

rich-text-laravel - 2.0.0-beta.4

Published by tonysm 8 months ago

What's Changed

Full Changelog: https://github.com/tonysm/rich-text-laravel/compare/2.0.0-beta.3...2.0.0-beta.4

rich-text-laravel - 2.0.0-beta.3

Published by tonysm 8 months ago

What's Changed

  • The new <x-rich-text::styles /> now supports a theme property. It defaults to default and there's a tweaked richtextlaravel theme that is intended to work better on Tailwind/Breeze projects.

Full Changelog: https://github.com/tonysm/rich-text-laravel/compare/2.0.0-beta.2...2.0.0-beta.3

rich-text-laravel - 2.0.0-beta.2

Published by tonysm 9 months ago

What's Changed

Full Changelog: https://github.com/tonysm/rich-text-laravel/compare/2.0.0-beta.1...2.0.0-beta.2


If you're upgrading from 1.x, rename all your $richTextFields properties to $richTextAttributes instead:

sed -i 's/richTextFields/richTextAttributes/' app/**/*.php
rich-text-laravel - 2.0.0-beta.1

Published by tonysm 9 months ago

Changelog

  • CHANGED: The styles component has changed from <x-rich-text-trix-styles /> to <x-rich-text::styles />
  • CHANGED: The Trix component that's published on new apps has changed from <x-trix-field /> to <x-trix-input /> (only affects new installations)
  • CHANGED: The new styles component now supports a breeze flag, which makes some tweaks on the default Trix styles so it looks better on Breeze installs (including dark mode), which can be used like <x-rich-text::styles breeze />
  • CHANGED: Installation and styles were bumped to Trix v2
rich-text-laravel - 1.7.0

Published by tonysm over 1 year ago

Changelog

  • CHANGED: Support for Laravel 10
rich-text-laravel - 1.6.1

Published by tonysm over 1 year ago

Changelog

rich-text-laravel - 1.6.0

Published by tonysm over 2 years ago

Changelog

  • CHANGED: The richtext:install command was modified to work with the new Vite setup from Laravel. I also took the time to make it look better. It works with the old Mix installs from Laravel 8 still and, of course, it works when using the Importmap Laravel as well.
rich-text-laravel - 1.5.0

Published by tonysm over 2 years ago

Changelog

  • CHANGED: The install command now publishes the Trix overrides styles to a resources/css/_trix.css which, based on the app's setup, can do two things: a) automatically add the import line to the resources/css/app.css file; or b) tell the developer to add the import or do whatever they want with the file
  • CHANGED: The install command now also is a bit smarter and detects when the application is using Importmap Laravel and installs JS dependencies using that instead of always assuming NPM.
  • NEW: There's a new <x-rich-text-trix-styles /> Blade Component that can be used to output the Trix core styles (copied from the Trix repository) instead of using a CDN
  • NEW: A new <x-trix-field /> Blade Component is now published to the application's resources/views/components. This makes for a nice starting point.
rich-text-laravel - 1.4.1

Published by tonysm over 2 years ago

Changelog

rich-text-laravel - 1.4.0

Published by tonysm over 2 years ago

Changelog

  • CHANGED: Laravel 9 support
  • CHANGED: Bumps the tonysm/globalid-laravel package to ^1.1.0
rich-text-laravel - 1.3.0

Published by tonysm over 2 years ago

Changelog

  • NEW: There's a new Content::attachables() method which allows pulling all the attachables of a document right away without having to pluck them out of the attachaments. Previously: $message->content->attachments()->pluck('attachable'), Now: $message->content->attachables(). PR: https://github.com/tonysm/rich-text-laravel/pull/20
  • NEW: Attachments now have a toHtml(): string method which allows for easily rendering them. We can now do Attachment::fromAttachable($user)->toHtml() which renders the <rich-text-attachment> tag. Same PR as above: https://github.com/tonysm/rich-text-laravel/pull/20

Here's an example of how we can use the Attachment->toHtml() method to parse the document and create attachments from the backend:

class Message extends Model
{
  public static function booted()
  {
    static::creating(function (Message $message) {
      // Scan the document looking for @-mentions and replace them
      // with a `<rich-text-attachment>` for the mentioned user...

      $message->content = preg_replace_callback(
        '/\B\@(\w+)/',
        function ($matches) {
          if ($user = User::where('username', $matches[1])->first()) {
            return Attachment::fromAttachable($user)->toHtml();
          }

          return $matches[0];
        },
        $message->content->toHtml(),
      );
    });
  }
}
rich-text-laravel - 1.2.0

Published by tonysm almost 3 years ago

Changelog

  • NEW: Better handles deeply nested lists and lists inside lists
  • CHANGED: [internal] Most of the methods of the plain text converter were supposed to be private. This is technically BC, but I don't think it was worth a major version.
Package Rankings
Top 7.43% on Packagist.org
Related Projects