diff --git a/README.md b/README.md index 8c6b8ac..d02766e 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,6 @@ if you want to hide buttons or toolbar you can do this. for more configuration r | hideToolbar | Boolean | True or False | hides the the toolbar | hideTools | Array | ['text-tools', 'block-tools', 'file-tools', 'history-tools'] | hides group of buttons | hideButtonIcons | Array | ['attach', 'bold', 'italic', 'strike', 'link', 'heading-1', 'quote', 'code', 'bullet-list', 'number-list', 'decrease-nesting-level', 'increase-nesting-level'] | hides a single button -| hideTools | Array | ['text-tools', 'block-tools', 'file-tools', 'history-tools'] | hides group of buttons | disk | String | 'local' or 's3' or 'any-disk' | sets the attachment storage per field | id | String | 'any-value-you-want' | the id of input which renders [trix. check this link](https://github.com/basecamp/trix#integrating-with-forms) . current id follows this convention `(model lowered class name)-field-modelId` like `post-content-1` or `post-content-new-model` | containerElement | String | valid html tag like `span` or `div` | default container tag is set to `span` you can change it as you want diff --git a/resources/views/trixassets.blade.php b/resources/views/trixassets.blade.php index e3aee73..e7c0f62 100644 --- a/resources/views/trixassets.blade.php +++ b/resources/views/trixassets.blade.php @@ -120,4 +120,17 @@ function laravelTrixConfig (event) { return JSON.parse(event.target.getAttribute("data-config")); } +window.onload = function() { + var laravelTrixInstanceStyles = document.getElementsByTagName('laravel-trix-instance-style'); + + var style = document.createElement('style'); + style.type = 'text/css'; + + for (var tag of laravelTrixInstanceStyles) { + style.innerHTML += tag.textContent + ' '; + } + + document.getElementsByTagName('head')[0].appendChild(style); +} + \ No newline at end of file diff --git a/src/LaravelTrix.php b/src/LaravelTrix.php index b08442e..ce8cd69 100644 --- a/src/LaravelTrix.php +++ b/src/LaravelTrix.php @@ -59,7 +59,7 @@ public function renderContainer() return function () { $tag = $this->config['containerElement'] ?? 'span'; - return "<$tag id='container-{$this->config['id']}'> $this->html "; + return "<$tag v-pre id='container-{$this->config['id']}'> $this->html "; }; } } diff --git a/src/LaravelTrixServiceProvider.php b/src/LaravelTrixServiceProvider.php index 005c823..619a584 100644 --- a/src/LaravelTrixServiceProvider.php +++ b/src/LaravelTrixServiceProvider.php @@ -24,7 +24,7 @@ public function boot() 'prefix' => 'laravel-trix', ], function () { Route::post('attachment', config('laravel-trix.store_attachment_action'))->name('laravel-trix.store'); - Route::delete('attachment/{url}', config('laravel-trix.destroy_attachment_action'))->name('laravel-trix.destroy'); + Route::delete('attachment/{attachment}', config('laravel-trix.destroy_attachment_action'))->name('laravel-trix.destroy'); }); $this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-trix'); diff --git a/src/Pipes/Styles.php b/src/Pipes/Styles.php index 12ab182..b5cc24c 100644 --- a/src/Pipes/Styles.php +++ b/src/Pipes/Styles.php @@ -13,7 +13,7 @@ public function handle(LaravelTrix $trix, \Closure $next) $this->hideTools($trix); $this->hideButtonIcons($trix); - $trix->html = ""; + $trix->html = " {$trix->html} "; return $next($trix); } diff --git a/tests/Feature/TrixAttachmentControllerTest.php b/tests/Feature/TrixAttachmentControllerTest.php index c0ce9e1..4437fe6 100644 --- a/tests/Feature/TrixAttachmentControllerTest.php +++ b/tests/Feature/TrixAttachmentControllerTest.php @@ -18,7 +18,7 @@ public function it_can_store_attachment_request() { Storage::fake('fooDisk'); - $response = $this->json('POST', 'laravel-trix/attachment', [ + $response = $this->json('POST', route('laravel-trix.store'), [ 'file' => UploadedFile::fake()->image('foo.jpg'), 'modelClass' => Post::class, 'field' => 'fooField', @@ -44,7 +44,7 @@ public function it_destroy_attachment() 'disk' => 'fooDisk', ]); - $this->delete('laravel-trix/attachment/randomImage.jpg'); + $this->delete(route('laravel-trix.destroy', ['attachment' => 'randomImage.jpg'])); $this->assertTrue( TrixAttachment::where('attachment', 'randomImage.jpg') diff --git a/tests/Unit/LaravelTrixTest.php b/tests/Unit/LaravelTrixTest.php index 2abca8f..d56cfa0 100644 --- a/tests/Unit/LaravelTrixTest.php +++ b/tests/Unit/LaravelTrixTest.php @@ -12,7 +12,7 @@ class LaravelTrixTest extends TestCase public function it_returns_default_trix_html() { $expected = << + EOT; $this->assertEquals( @@ -25,7 +25,7 @@ public function it_returns_default_trix_html() public function it_hides_toolbar() { $expected = <<<'EOT' - + #container-post-description-1 trix-toolbar{display:none;} EOT; $this->assertTrue( @@ -37,7 +37,7 @@ public function it_hides_toolbar() public function it_hides_tools() { $expected = <<<'EOT' - + #container-post-description-1 .trix-button-group--foo,#container-post-description-1 .trix-button-group--bar{display:none;} EOT; $this->assertTrue( @@ -49,7 +49,7 @@ public function it_hides_tools() public function it_hides_button_icons() { $expected = <<<'EOT' - + #container-post-description-1 .trix-button--icon-foo,#container-post-description-1 .trix-button--icon-bar{display:none;} EOT; $this->assertTrue( @@ -61,7 +61,7 @@ public function it_hides_button_icons() public function it_changes_id() { $expected = << + EOT; $this->assertTrue( @@ -85,7 +85,7 @@ public function it_changes_disk() public function it_change_container_element() { $expected = << + EOT; $this->assertTrue( @@ -97,7 +97,7 @@ public function it_change_container_element() public function it_renders_correct_id_for_new_model() { $expected = << + EOT; $this->assertTrue( @@ -109,7 +109,7 @@ public function it_renders_correct_id_for_new_model() public function it_returns_new_model_using_app_make() { $expected = <<<'EOT' - + EOT; $this->assertTrue(