]> BookStack Code Mirror - bookstack/commitdiff
Merge pull request #1437 from NootoNooto/patch-2
authorDan Brown <redacted>
Sun, 19 May 2019 14:36:05 +0000 (15:36 +0100)
committerGitHub <redacted>
Sun, 19 May 2019 14:36:05 +0000 (15:36 +0100)
Added Dutch translations for some new texts

app/Entities/Repos/PageRepo.php
app/Uploads/ImageRepo.php
resources/assets/js/components/markdown-editor.js
resources/assets/js/components/wysiwyg-editor.js
resources/assets/sass/_layout.scss
resources/assets/sass/_pages.scss
resources/views/pages/form.blade.php
resources/views/search/all.blade.php
tests/Unit/HelpersTest.php [moved from tests/HelpersTest.php with 100% similarity]
tests/Unit/PageRepoTest.php [new file with mode: 0644]

index 1aeee8daeab9bc66c694f112995f0074ecee74fb..208aa5fa309444dabd61839a3fdc43b2d0a536b3 100644 (file)
@@ -422,25 +422,29 @@ class PageRepo extends EntityRepo
             return [];
         }
 
-        $tree = collect([]);
-        foreach ($headers as $header) {
-            $text = $header->nodeValue;
-            $tree->push([
+        $tree = collect($headers)->map(function($header) {
+            $text = trim(str_replace("\xc2\xa0", '', $header->nodeValue));
+            if (strlen($text) > 30) {
+                $text = substr($text, 0, 27) . '...';
+            }
+
+            return [
                 'nodeName' => strtolower($header->nodeName),
                 'level' => intval(str_replace('h', '', $header->nodeName)),
                 'link' => '#' . $header->getAttribute('id'),
-                'text' => strlen($text) > 30 ? substr($text, 0, 27) . '...' : $text
-            ]);
-        }
+                'text' => $text,
+            ];
+        })->filter(function($header) {
+            return strlen($header['text']) > 0;
+        });
 
         // Normalise headers if only smaller headers have been used
-        if (count($tree) > 0) {
-            $minLevel = $tree->pluck('level')->min();
-            $tree = $tree->map(function ($header) use ($minLevel) {
-                $header['level'] -= ($minLevel - 2);
-                return $header;
-            });
-        }
+        $minLevel = $tree->pluck('level')->min();
+        $tree = $tree->map(function ($header) use ($minLevel) {
+            $header['level'] -= ($minLevel - 2);
+            return $header;
+        });
+
         return $tree->toArray();
     }
 
index 38dd3066b2c5a7b0deb835aa8e9e7a0444e0a9ab..da0b7d379eddd2fb4a227dd071af248c2ba44d07 100644 (file)
@@ -230,7 +230,7 @@ class ImageRepo
     {
         $image->thumbs = [
             'gallery' => $this->getThumbnail($image, 150, 150, false),
-            'display' => $this->getThumbnail($image, 840, null, true)
+            'display' => $this->getThumbnail($image, 1680, null, true)
         ];
     }
 
index 770b4af5054a7b2665e23a6026a83f47bd326bca..5fa16ef6e78b522266ccf47c2a7f218357447780 100644 (file)
@@ -180,9 +180,20 @@ class MarkdownEditor {
 
         // Handle image paste
         cm.on('paste', (cm, event) => {
-            if (!event.clipboardData || !event.clipboardData.items) return;
-            for (let i = 0; i < event.clipboardData.items.length; i++) {
-                uploadImage(event.clipboardData.items[i].getAsFile());
+            const clipboardItems = event.clipboardData.items;
+            if (!event.clipboardData || !clipboardItems) return;
+
+            // Don't handle if clipboard includes text content
+            for (let clipboardItem of clipboardItems) {
+                if (clipboardItem.type.includes('text/')) {
+                    return;
+                }
+            }
+
+            for (let clipboardItem of clipboardItems) {
+                if (clipboardItem.type.includes("image")) {
+                    uploadImage(clipboardItem.getAsFile());
+                }
             }
         });
 
index 46fe967e0d8be829145685f4f4f23acd0ad8409f..614cfb80f149fdba130ee19645973f6cb426b2fe 100644 (file)
@@ -8,11 +8,20 @@ import DrawIO from "../services/drawio";
  * @param editor
  */
 function editorPaste(event, editor, wysiwygComponent) {
-    if (!event.clipboardData || !event.clipboardData.items) return;
+    const clipboardItems = event.clipboardData.items;
+    if (!event.clipboardData || !clipboardItems) return;
 
-    for (let clipboardItem of event.clipboardData.items) {
-        if (clipboardItem.type.indexOf("image") === -1) continue;
-        event.preventDefault();
+    // Don't handle if clipboard includes text content
+    for (let clipboardItem of clipboardItems) {
+        if (clipboardItem.type.includes('text/')) {
+            return;
+        }
+    }
+
+    for (let clipboardItem of clipboardItems) {
+        if (!clipboardItem.type.includes("image")) {
+            continue;
+        }
 
         const id = "image-" + Math.random().toString(16).slice(2);
         const loadingImage = window.baseUrl('/loading.gif');
index 9bb4e1c70dcba36a6351b97e153a44090de80cb2..4be6edb56f3632b2b2d76f9cc1627f4b8328c188 100644 (file)
@@ -59,7 +59,7 @@
 }
 
 @include smaller-than($m) {
-  .grid.third {
+  .grid.third:not(.no-break) {
     grid-template-columns: 1fr 1fr;
   }
   .grid.half:not(.no-break), .grid.left-focus:not(.no-break), .grid.right-focus:not(.no-break) {
@@ -81,7 +81,7 @@
 }
 
 @include smaller-than($s) {
-  .grid.third {
+  .grid.third:not(.no-break) {
     grid-template-columns: 1fr;
   }
 }
index d02f59e37665bc3c627a3804244fdaafc3363dce..c58f6ef476e55cac1498e5dc41ba09b4ac21ecc7 100755 (executable)
   }
 }
 
-@include smaller-than($m) {
+@include smaller-than($s) {
   .page-edit-toolbar {
     overflow-x: scroll;
     overflow-y: visible;
-    z-index: 12;
   }
   .page-edit-toolbar .grid.third {
     display: block;
   }
 }
 
-@include smaller-than($m) {
-  .page-edit-toolbar #save-button {
-    position: fixed;
-    z-index: 30;
-    border-radius: 50%;
-    width: 56px;
-    height: 56px;
-    font-size: 24px;
-    right: $-m;
-    bottom: $-s;
-    box-shadow: $bs-hover;
-    background-color: currentColor;
-    svg {
-      fill: #FFF;
-    }
-    span {
-      display: none;
-    }
+.page-save-mobile-button {
+  position: fixed;
+  z-index: 30;
+  border-radius: 50%;
+  width: 56px;
+  height: 56px;
+  font-size: 24px;
+  right: $-m;
+  bottom: $-s;
+  box-shadow: $bs-hover;
+  background-color: currentColor;
+  text-align: center;
+  svg {
+    fill: #FFF;
+    margin-right: 0;
   }
 }
 
index 34ded389ca9b9a9bdd1214eb796a8575925cedc3..4a473e53636016c3bca1ae671d18d86ffe0131de 100644 (file)
@@ -12,7 +12,7 @@
 
     {{--Header Bar--}}
     <div class="primary-background-light toolbar page-edit-toolbar">
-        <div class="grid third v-center">
+        <div class="grid third no-break v-center">
 
             <div class="action-buttons text-left px-m py-xs">
                 <a href="{{ back()->getTargetUrl() }}" class="text-button text-primary">@icon('back')<span class="hide-under-l">{{ trans('common.back') }}</span></a>
@@ -49,7 +49,7 @@
                     <span>{{-- Prevents button jumping on menu show --}}</span>
                 </div>
 
-                <button type="submit" id="save-button" class="float-left text-primary text-button text-pos-hover">@icon('save')<span>{{ trans('entities.pages_save') }}</span></button>
+                <button type="submit" id="save-button" class="float-left text-primary text-button text-pos-hover hide-under-m">@icon('save')<span>{{ trans('entities.pages_save') }}</span></button>
             </div>
         </div>
     </div>
         @endif
 
     </div>
+
+    <button type="submit" id="save-button-mobile" title="{{ trans('entities.pages_save') }}" class="text-primary text-button hide-over-m page-save-mobile-button">@icon('save')</button>
 </div>
\ No newline at end of file
index fba67abf9e20c5866e5a1d4413d26bc03c43960b..03c0b93e71a9acdc5fe11c4e5aa02fa06a377c9f 100644 (file)
             <div>
                 <div v-pre class="card content-wrap">
                     <h1 class="list-heading">{{ trans('entities.search_results') }}</h1>
+                    <form action="{{ baseUrl('/search') }}" method="GET"  class="search-box flexible hide-over-l">
+                        <input value="{{$searchTerm}}" type="text" name="term" placeholder="{{ trans('common.search') }}">
+                        <button type="submit">@icon('search')</button>
+                        <button v-if="searching" v-cloak class="search-box-cancel text-neg" v-on:click="clearSearch" type="button">@icon('close')</button>
+                    </form>
                     <h6 class="text-muted">{{ trans_choice('entities.search_total_results_found', $totalResults, ['count' => $totalResults]) }}</h6>
                     <div class="book-contents">
                         @include('partials.entity-list', ['entities' => $entities, 'showPath' => true])
diff --git a/tests/Unit/PageRepoTest.php b/tests/Unit/PageRepoTest.php
new file mode 100644 (file)
index 0000000..36addcb
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+namespace Tests;
+
+use BookStack\Entities\Repos\PageRepo;
+
+class PageRepoTest extends TestCase
+{
+    /**
+     * @var PageRepo $pageRepo
+     */
+    protected $pageRepo;
+
+    protected function setUp()
+    {
+        parent::setUp();
+        $this->pageRepo = app()->make(PageRepo::class);
+    }
+
+    public function test_get_page_nav_does_not_show_empty_titles()
+    {
+        $content = '<h1 id="testa">Hello</h1><h2 id="testb">&nbsp;</h2><h3 id="testc"></h3>';
+        $navMap = $this->pageRepo->getPageNav($content);
+
+        $this->assertCount(1, $navMap);
+        $this->assertArraySubset([
+            'nodeName' => 'h1',
+            'link' => '#testa',
+            'text' => 'Hello'
+        ], $navMap[0]);
+    }
+
+}
\ No newline at end of file