Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Master] Fix integration with vue js #12

Merged
merged 5 commits into from
Dec 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add v-pre to skip vue js compilation
  • Loading branch information
amaelftah committed Dec 1, 2019
commit 6565e0e75cd49573eeabf66effc7646004041f2f
2 changes: 1 addition & 1 deletion src/LaravelTrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function renderContainer()
return function () {
$tag = $this->config['containerElement'] ?? 'span';

return "<$tag id='container-{$this->config['id']}'> $this->html </$tag>";
return "<$tag v-pre id='container-{$this->config['id']}'> $this->html </$tag>";
};
}
}
10 changes: 5 additions & 5 deletions tests/Unit/LaravelTrixTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class LaravelTrixTest extends TestCase
public function it_returns_default_trix_html()
{
$expected = <<<EOT
<span id='container-post-description-1'> <laravel-trix-instance-style style='display:none;'> </laravel-trix-instance-style><input id='post-description-1' value='' name='post-trixFields[description]' type='hidden'><input id='attachment-post-description-1' value='[]' name='attachment-post-trixFields[description]' type='hidden'><trix-editor class='trix-content' input='post-description-1' data-config='{"id":"post-description-1","modelClass":"Te7aHoudini\\\LaravelTrix\\\Tests\\\Models\\\Post","field":"description"}'></trix-editor> </span>
<span v-pre id='container-post-description-1'> <laravel-trix-instance-style style='display:none;'> </laravel-trix-instance-style><input id='post-description-1' value='' name='post-trixFields[description]' type='hidden'><input id='attachment-post-description-1' value='[]' name='attachment-post-trixFields[description]' type='hidden'><trix-editor class='trix-content' input='post-description-1' data-config='{"id":"post-description-1","modelClass":"Te7aHoudini\\\LaravelTrix\\\Tests\\\Models\\\Post","field":"description"}'></trix-editor> </span>
EOT;

$this->assertEquals(
Expand Down Expand Up @@ -61,7 +61,7 @@ public function it_hides_button_icons()
public function it_changes_id()
{
$expected = <<<EOT
<span id='container-foo'> <laravel-trix-instance-style style='display:none;'> </laravel-trix-instance-style><input id='foo' value='' name='post-trixFields[description]' type='hidden'><input id='attachment-foo' value='[]' name='attachment-post-trixFields[description]' type='hidden'><trix-editor class='trix-content' input='foo' data-config='{"id":"foo","modelClass":"Te7aHoudini\\\LaravelTrix\\\Tests\\\Models\\\Post","field":"description"}'></trix-editor> </span>
<span v-pre id='container-foo'> <laravel-trix-instance-style style='display:none;'> </laravel-trix-instance-style><input id='foo' value='' name='post-trixFields[description]' type='hidden'><input id='attachment-foo' value='[]' name='attachment-post-trixFields[description]' type='hidden'><trix-editor class='trix-content' input='foo' data-config='{"id":"foo","modelClass":"Te7aHoudini\\\LaravelTrix\\\Tests\\\Models\\\Post","field":"description"}'></trix-editor> </span>
EOT;

$this->assertTrue(
Expand All @@ -85,7 +85,7 @@ public function it_changes_disk()
public function it_change_container_element()
{
$expected = <<<EOT
<fooElement id='container-post-description-1'> <laravel-trix-instance-style style='display:none;'> </laravel-trix-instance-style><input id='post-description-1' value='' name='post-trixFields[description]' type='hidden'><input id='attachment-post-description-1' value='[]' name='attachment-post-trixFields[description]' type='hidden'><trix-editor class='trix-content' input='post-description-1' data-config='{"containerElement":"fooElement","id":"post-description-1","modelClass":"Te7aHoudini\\\LaravelTrix\\\Tests\\\Models\\\Post","field":"description"}'></trix-editor> </fooElement>
<fooElement v-pre id='container-post-description-1'> <laravel-trix-instance-style style='display:none;'> </laravel-trix-instance-style><input id='post-description-1' value='' name='post-trixFields[description]' type='hidden'><input id='attachment-post-description-1' value='[]' name='attachment-post-trixFields[description]' type='hidden'><trix-editor class='trix-content' input='post-description-1' data-config='{"containerElement":"fooElement","id":"post-description-1","modelClass":"Te7aHoudini\\\LaravelTrix\\\Tests\\\Models\\\Post","field":"description"}'></trix-editor> </fooElement>
EOT;

$this->assertTrue(
Expand All @@ -97,7 +97,7 @@ public function it_change_container_element()
public function it_renders_correct_id_for_new_model()
{
$expected = <<<EOT
<span id='container-post-description-new-model'> <laravel-trix-instance-style style='display:none;'> </laravel-trix-instance-style><input id='post-description-new-model' value='' name='post-trixFields[description]' type='hidden'><input id='attachment-post-description-new-model' value='[]' name='attachment-post-trixFields[description]' type='hidden'><trix-editor class='trix-content' input='post-description-new-model' data-config='{"id":"post-description-new-model","modelClass":"Te7aHoudini\\\LaravelTrix\\\Tests\\\Models\\\Post","field":"description"}'></trix-editor> </span>
<span v-pre id='container-post-description-new-model'> <laravel-trix-instance-style style='display:none;'> </laravel-trix-instance-style><input id='post-description-new-model' value='' name='post-trixFields[description]' type='hidden'><input id='attachment-post-description-new-model' value='[]' name='attachment-post-trixFields[description]' type='hidden'><trix-editor class='trix-content' input='post-description-new-model' data-config='{"id":"post-description-new-model","modelClass":"Te7aHoudini\\\LaravelTrix\\\Tests\\\Models\\\Post","field":"description"}'></trix-editor> </span>
EOT;

$this->assertTrue(
Expand All @@ -109,7 +109,7 @@ public function it_renders_correct_id_for_new_model()
public function it_returns_new_model_using_app_make()
{
$expected = <<<'EOT'
<span id='container-foomodel-BarField-new-model'> <laravel-trix-instance-style style='display:none;'> </laravel-trix-instance-style><input id='foomodel-BarField-new-model' value='' name='foomodel-trixFields[BarField]' type='hidden'><input id='attachment-foomodel-BarField-new-model' value='[]' name='attachment-foomodel-trixFields[BarField]' type='hidden'><trix-editor class='trix-content' input='foomodel-BarField-new-model' data-config='{"id":"foomodel-BarField-new-model","modelClass":"FooModel","field":"BarField"}'></trix-editor> </span>
<span v-pre id='container-foomodel-BarField-new-model'> <laravel-trix-instance-style style='display:none;'> </laravel-trix-instance-style><input id='foomodel-BarField-new-model' value='' name='foomodel-trixFields[BarField]' type='hidden'><input id='attachment-foomodel-BarField-new-model' value='[]' name='attachment-foomodel-trixFields[BarField]' type='hidden'><trix-editor class='trix-content' input='foomodel-BarField-new-model' data-config='{"id":"foomodel-BarField-new-model","modelClass":"FooModel","field":"BarField"}'></trix-editor> </span>
EOT;

$this->assertTrue(
Expand Down