Releases: tonysm/rich-text-laravel
Releases · tonysm/rich-text-laravel
1.4.0
1.3.0
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: #20 - NEW: Attachments now have a
toHtml(): stringmethod which allows for easily rendering them. We can now doAttachment::fromAttachable($user)->toHtml()which renders the<rich-text-attachment>tag. Same PR as above: #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(),
);
});
}
}1.2.0
1.1.0
1.0.2
1.0.1
1.0.0
1.0.0-RC1
1.0.0-BETA
First beta release.
- CHANGED: The most notable change was replacing the ad hoc Global ID implementation with the
tonysm/globalid-laravelpackage.
0.0.3
Changelog
- CHANGED: more documentation (see the README.md)
- NEW: the package now recommends keeping the rich text content outside of the main entity on its own
rich_textstable, which uses the newRichTextpolymorphic model that the package ships with. The behavior is documented at theThe RichText Modelsection on the readme. The old behavior of using the custom cast directly still works (in fact, the RichText model uses that same approach). You can find more about this in the PR and in the RFC issue.