Skip to content

Commit

Permalink
Merge pull request #734 from livewire/editor
Browse files Browse the repository at this point in the history
Editor
  • Loading branch information
calebporzio authored Nov 25, 2024
2 parents 356c307 + 5c1295b commit e787bb0
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/flux-lite.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"/flux.js": "d3ef0a7e"
"/flux.js": "79511b07",
"/flux.css": "0e2b9c8b"
}
42 changes: 41 additions & 1 deletion src/AssetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@ public function registerAssetRoutes()
? $this->pretendResponseIsFile(__DIR__.'/../../flux-pro/dist/flux.min.js', 'text/javascript')
: $this->pretendResponseIsFile(__DIR__.'/../../flux/dist/flux-lite.min.js', 'text/javascript');
});

Route::get('/flux/editor.css', function () {
if (! Flux::pro()) throw new \Exception('Flux Pro is required to use the Flux editor.');

return $this->pretendResponseIsFile(__DIR__.'/../../flux-pro/dist/editor.css', 'text/css');
});

Route::get('/flux/editor.js', function () {
if (! Flux::pro()) throw new \Exception('Flux Pro is required to use the Flux editor.');

return $this->pretendResponseIsFile(__DIR__.'/../../flux-pro/dist/editor.js', 'text/javascript');
});

Route::get('/flux/editor.min.js', function () {
if (! Flux::pro()) throw new \Exception('Flux Pro is required to use the Flux editor.');

return $this->pretendResponseIsFile(__DIR__.'/../../flux-pro/dist/editor.min.js', 'text/javascript');
});
}

public static function scripts()
Expand All @@ -74,11 +92,33 @@ public static function styles()
? json_decode(file_get_contents(__DIR__.'/../../flux-pro/dist/manifest.json'), true)
: json_decode(file_get_contents(__DIR__.'/../../flux/dist/manifest.json'), true);

$versionHash = $manifest['/flux.js'];
$versionHash = $manifest['/flux.css'];

return '<link rel="stylesheet" href="/flux/flux.css?id='. $versionHash . '">';
}

public static function editorScripts()
{
$manifest = json_decode(file_get_contents(__DIR__.'/../../flux-pro/dist/manifest.json'), true);

$versionHash = $manifest['/editor.js'];

if (config('app.debug')) {
return '<script src="/flux/editor.js?id='. $versionHash . '" defer></script>';
} else {
return '<script src="/flux/editor.min.js?id='. $versionHash . '" defer></script>';
}
}

public static function editorStyles()
{
$manifest = json_decode(file_get_contents(__DIR__.'/../../flux-pro/dist/manifest.json'), true);

$versionHash = $manifest['/editor.css'];

return '<link rel="stylesheet" href="/flux/editor.css?id='. $versionHash . '">';
}

public function pretendResponseIsFile($file, $contentType = 'application/javascript; charset=utf-8')
{
$lastModified = filemtime($file);
Expand Down
10 changes: 10 additions & 0 deletions src/FluxManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ public function scripts()
return AssetManager::scripts();
}

public function editorStyles()
{
return AssetManager::editorStyles();
}

public function editorScripts()
{
return AssetManager::editorScripts();
}

public function classes($styles = null)
{
$builder = new ClassBuilder;
Expand Down
5 changes: 3 additions & 2 deletions stubs/resources/views/flux/tooltip/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
@props([
'interactive' => null,
'position' => 'top',
'align' => 'center',
'content' => null,
'kbd' => null,
])

<ui-tooltip position="{{ $position }} {{ $align }}" {{ $attributes }} data-flux-tooltip>
<ui-tooltip position="{{ $position }} {{ $align }}" {{ $attributes }} data-flux-tooltip @if ($interactive) interactive @endif>
{{ $slot }}

<?php if ($content !== null): ?>
<flux:tooltip.content>{{ $content }}</flux:tooltip.content>
<flux:tooltip.content :$kbd>{{ $content }}</flux:tooltip.content>
<?php endif; ?>
</ui-tooltip>

0 comments on commit e787bb0

Please sign in to comment.