]> BookStack Code Mirror - bookstack/blobdiff - resources/assets/js/components/page-display.js
Added 'uk' locale
[bookstack] / resources / assets / js / components / page-display.js
index 70933ae8c309940484ecfb85c01f8a5c209086de..cbb672222c264cc1ab5114269771989f9f1aa9aa 100644 (file)
@@ -1,4 +1,4 @@
-import Clipboard from "clipboard";
+import Clipboard from "clipboard/dist/clipboard.min";
 import Code from "../services/code";
 
 class PageDisplay {
@@ -11,7 +11,6 @@ class PageDisplay {
         this.setupPointer();
         this.setupStickySidebar();
         this.setupNavHighlighting();
-        this.setupEditOnHeader();
 
         // Check the hash on load
         if (window.location.hash) {
@@ -21,7 +20,7 @@ class PageDisplay {
 
         // Sidebar page nav click event
         $('.sidebar-page-nav').on('click', 'a', event => {
-            goToText(event.target.getAttribute('href').substr(1));
+            this.goToText(event.target.getAttribute('href').substr(1));
         });
     }
 
@@ -129,7 +128,7 @@ class PageDisplay {
         let $bookTreeParent = $sidebar.parent();
 
         // Check the page is scrollable and the content is taller than the tree
-        let pageScrollable = ($(document).height() > $window.height()) && ($sidebar.height() < $('.page-content').height());
+        let pageScrollable = ($(document).height() > ($window.height() + 40)) && ($sidebar.height() < $('.page-content').height());
 
         // Get current tree's width and header height
         let headerHeight = $("#header").height() + $(".toolbar").height();
@@ -232,34 +231,6 @@ class PageDisplay {
             }
         }
     }
-    setupEditOnHeader() {
-        const headingEditIcon = document.querySelector('.heading-edit-icon');
-        if (headingEditIcon === null) {
-            // user does not have permission to edit.
-            return;
-        }
-
-        // Create a clone of the edit icon without the hidden class
-        const visibleHeadingEditIcon = headingEditIcon.cloneNode(true);
-        visibleHeadingEditIcon.style.display = '';
-
-        const headings = document.querySelector('.page-content').querySelectorAll('h1, h2, h3, h4, h5, h6');
-
-        // add an edit icon to each header.
-        for (let i = 0; i !== headings.length; ++i) {
-            const currHeading = headings[i];
-            const headingId = currHeading.id;
-
-            let editIcon = visibleHeadingEditIcon.cloneNode(true);
-
-            // get the first 50 characters.
-            let queryContent = currHeading.textContent && currHeading.textContent.substring(0, 50);
-            editIcon.href += `?content-id=${headingId}&content-text=${encodeURIComponent(queryContent)}`;
-
-            currHeading.appendChild(editIcon);
-        }
-    }
-
 }
 
-module.exports = PageDisplay;
+export default PageDisplay;