Skip to content

Commit

Permalink
🧑‍💻 Change default editorStyles implementation from URL to local th…
Browse files Browse the repository at this point in the history
…eme path
  • Loading branch information
Log1x committed Mar 29, 2024
1 parent 308e5a0 commit bd2c3c4
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/Roots/Acorn/Assets/Concerns/Enqueuable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Roots\Acorn\Assets\Concerns;

use Illuminate\Support\Str;

trait Enqueuable
{
/**
Expand Down Expand Up @@ -83,9 +85,30 @@ public function enqueue()
*
* @return $this
*/
public function editorStyles()
public function editorStyles(bool $url = false)
{
$this->css(fn ($handle, $src) => add_editor_style($src));
$this->css(function ($handle, $src) use ($url) {
if ($url) {
add_editor_style($src);

return;
}

if (! Str::startsWith($this->path, $path = get_theme_file_path())) {
return;
}

$path = Str::of($this->path)
->after($path)
->toString();

$style = Str::of($src)
->afterLast($path)
->start($path)
->toString();

add_editor_style($style);
});

return $this;
}
Expand Down

0 comments on commit bd2c3c4

Please sign in to comment.