Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

Commit

Permalink
Fix compatibility with the newly renamed Bard Mutator
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksleight committed Oct 22, 2021
1 parent 3de9d84 commit a91d87b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.2.2 (2021-10-18)

- [fix] Fix compatibility with the newly renamed Bard Mutator

## 1.2.1 (2021-10-18)

- [fix] Don't add blank class attributes to regular paragraphs
Expand Down
17 changes: 14 additions & 3 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Statamic\Statamic;
use Statamic\Fieldtypes\Bard\Augmentor;
use Composer\InstalledVersions;
use JackSleight\BardMutator\Facades\Mutator;

class ServiceProvider extends AddonServiceProvider
{
Expand All @@ -25,16 +24,28 @@ public function boot()
'bard-paragraph-style' => config('bard-paragraph-style'),
]);

if (InstalledVersions::isInstalled('jacksleight/bard-mutator')) {
if (InstalledVersions::isInstalled('jacksleight/statamic-bard-mutator')) {
$this->bootStatamicBardMutator();
} else if (InstalledVersions::isInstalled('jacksleight/bard-mutator')) {
$this->bootBardMutator();
} else {
$this->bootStandalone();
}
}

protected function bootStatamicBardMutator()
{
\JackSleight\StatamicBardMutator\Facades\Mutator::node('paragraph', function ($tag, $node) {
if (isset($node->attrs->class)) {
$tag[0]['attrs']['class'] = $node->attrs->class;
}
return $tag;
});
}

protected function bootBardMutator()
{
Mutator::node('paragraph', function ($tag, $node) {
\JackSleight\BardMutator\Facades\Mutator::node('paragraph', function ($tag, $node) {
if (isset($node->attrs->class)) {
$tag[0]['attrs']['class'] = $node->attrs->class;
}
Expand Down

0 comments on commit a91d87b

Please sign in to comment.