mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Input WYSIWYG: Aligned newline handling with old descriptions
To ensure consistenent behaviour before/after changes. Added tests to cover.
This commit is contained in:
parent
a21ca44633
commit
ed5d67e609
@ -15,7 +15,7 @@ trait HasHtmlDescription
|
||||
*/
|
||||
public function descriptionHtml(): string
|
||||
{
|
||||
$html = $this->description_html ?: '<p>' . e($this->description) . '</p>';
|
||||
$html = $this->description_html ?: '<p>' . nl2br(e($this->description)) . '</p>';
|
||||
return HtmlContentFilter::removeScriptsFromHtmlString($html);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
<main class="content-wrap card">
|
||||
<h1 class="break-text">{{$book->name}}</h1>
|
||||
<div refs="entity-search@contentView" class="book-content">
|
||||
<p class="text-muted">{!! $book->descriptionHtml() !!}</p>
|
||||
<div class="text-muted break-text">{!! $book->descriptionHtml() !!}</div>
|
||||
@if(count($bookChildren) > 0)
|
||||
<div class="entity-list book-contents">
|
||||
@foreach($bookChildren as $childElement)
|
||||
|
@ -24,7 +24,7 @@
|
||||
<main class="content-wrap card">
|
||||
<h1 class="break-text">{{ $chapter->name }}</h1>
|
||||
<div refs="entity-search@contentView" class="chapter-content">
|
||||
<p class="text-muted break-text">{!! $chapter->descriptionHtml() !!}</p>
|
||||
<div class="text-muted break-text">{!! $chapter->descriptionHtml() !!}</div>
|
||||
@if(count($pages) > 0)
|
||||
<div class="entity-list book-contents">
|
||||
@foreach($pages as $page)
|
||||
|
@ -28,7 +28,7 @@
|
||||
</div>
|
||||
|
||||
<div class="book-content">
|
||||
<p class="text-muted">{!! $shelf->descriptionHtml() !!}</p>
|
||||
<div class="text-muted break-text">{!! $shelf->descriptionHtml() !!}</div>
|
||||
@if(count($sortedVisibleShelfBooks) > 0)
|
||||
@if($view === 'list')
|
||||
<div class="entity-list">
|
||||
|
@ -403,4 +403,15 @@ class BookShelfTest extends TestCase
|
||||
$resp = $this->asEditor()->get($shelf->getUrl('/create-book'));
|
||||
$this->withHtml($resp)->assertElementContains('form a[href="' . $shelf->getUrl() . '"]', 'Cancel');
|
||||
}
|
||||
|
||||
public function test_show_view_displays_description_if_no_description_html_set()
|
||||
{
|
||||
$shelf = $this->entities->shelf();
|
||||
$shelf->description_html = '';
|
||||
$shelf->description = "My great\ndescription\n\nwith newlines";
|
||||
$shelf->save();
|
||||
|
||||
$resp = $this->asEditor()->get($shelf->getUrl());
|
||||
$resp->assertSee("<p>My great<br>\ndescription<br>\n<br>\nwith newlines</p>", false);
|
||||
}
|
||||
}
|
||||
|
@ -278,6 +278,17 @@ class BookTest extends TestCase
|
||||
$this->assertEquals($expected, $book->description_html);
|
||||
}
|
||||
|
||||
public function test_show_view_displays_description_if_no_description_html_set()
|
||||
{
|
||||
$book = $this->entities->book();
|
||||
$book->description_html = '';
|
||||
$book->description = "My great\ndescription\n\nwith newlines";
|
||||
$book->save();
|
||||
|
||||
$resp = $this->asEditor()->get($book->getUrl());
|
||||
$resp->assertSee("<p>My great<br>\ndescription<br>\n<br>\nwith newlines</p>", false);
|
||||
}
|
||||
|
||||
public function test_show_view_has_copy_button()
|
||||
{
|
||||
$book = $this->entities->book();
|
||||
|
@ -31,6 +31,17 @@ class ChapterTest extends TestCase
|
||||
$resp->assertSee($chapter->description_html, false);
|
||||
}
|
||||
|
||||
public function test_show_view_displays_description_if_no_description_html_set()
|
||||
{
|
||||
$chapter = $this->entities->chapter();
|
||||
$chapter->description_html = '';
|
||||
$chapter->description = "My great\ndescription\n\nwith newlines";
|
||||
$chapter->save();
|
||||
|
||||
$resp = $this->asEditor()->get($chapter->getUrl());
|
||||
$resp->assertSee("<p>My great<br>\ndescription<br>\n<br>\nwith newlines</p>", false);
|
||||
}
|
||||
|
||||
public function test_delete()
|
||||
{
|
||||
$chapter = Chapter::query()->whereHas('pages')->first();
|
||||
|
Loading…
Reference in New Issue
Block a user