From bd2c3c4dbfaeea7550d66a40a7098fac4d58c67a Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 28 Mar 2024 21:31:25 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Change=20de?= =?UTF-8?q?fault=20`editorStyles`=20implementation=20from=20URL=20to=20loc?= =?UTF-8?q?al=20theme=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Acorn/Assets/Concerns/Enqueuable.php | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Roots/Acorn/Assets/Concerns/Enqueuable.php b/src/Roots/Acorn/Assets/Concerns/Enqueuable.php index e4f47f7a..0a4306ab 100644 --- a/src/Roots/Acorn/Assets/Concerns/Enqueuable.php +++ b/src/Roots/Acorn/Assets/Concerns/Enqueuable.php @@ -2,6 +2,8 @@ namespace Roots\Acorn\Assets\Concerns; +use Illuminate\Support\Str; + trait Enqueuable { /** @@ -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; }