mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-09 10:22:51 +03:00
Extracted page form js and added better page content linking
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="edit-area flex-fill flex">
|
||||
<textarea id="html" name="html" rows="5"
|
||||
<textarea id="html-editor" name="html" rows="5"
|
||||
@if($errors->has('html')) class="neg" @endif>@if(isset($model) || old('html')){{htmlspecialchars( old('html') ? old('html') : $model->html)}}@endif</textarea>
|
||||
@if($errors->has('html'))
|
||||
<div class="text-neg text-small">{{ $errors->first('html') }}</div>
|
||||
@@ -36,68 +36,4 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
//ImageManager.show('#image-manager');
|
||||
|
||||
tinymce.init({
|
||||
selector: '.edit-area textarea',
|
||||
content_css: [
|
||||
'/css/app.css',
|
||||
'//fonts.googleapis.com/css?family=Roboto:400,400italic,500,500italic,700,700italic,300italic,100,300'
|
||||
],
|
||||
body_class: 'page-content',
|
||||
relative_urls: false,
|
||||
statusbar: false,
|
||||
menubar: false,
|
||||
//height: 700,
|
||||
extended_valid_elements: 'pre[*]',
|
||||
plugins: "image table textcolor paste link imagetools fullscreen code hr",
|
||||
toolbar: "code undo | styleselect | hr bold italic underline strikethrough superscript subscript | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image link | fullscreen",
|
||||
content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}",
|
||||
style_formats: [
|
||||
{title: "Header 1", format: "h1"},
|
||||
{title: "Header 2", format: "h2"},
|
||||
{title: "Header 3", format: "h3"},
|
||||
{title: "Header 4", format: "h4"},
|
||||
{title: "Paragraph", format: "p"},
|
||||
{title: "Blockquote", format: "blockquote"},
|
||||
{title: "Code Block", icon: "code", format: "pre"}
|
||||
],
|
||||
file_browser_callback: function(field_name, url, type, win) {
|
||||
ImageManager.show(function(image) {
|
||||
win.document.getElementById(field_name).value = image.url;
|
||||
if ("createEvent" in document) {
|
||||
var evt = document.createEvent("HTMLEvents");
|
||||
evt.initEvent("change", false, true);
|
||||
win.document.getElementById(field_name).dispatchEvent(evt);
|
||||
} else {
|
||||
win.document.getElementById(field_name).fireEvent("onchange");
|
||||
}
|
||||
});
|
||||
}
|
||||
// setup: function(editor) {
|
||||
// editor.addButton('full', {
|
||||
// title: 'Expand Editor',
|
||||
// icon: 'fullscreen',
|
||||
// onclick: function() {
|
||||
// var container = $(editor.getContainer()).toggleClass('fullscreen');
|
||||
// var isFull = container.hasClass('fullscreen');
|
||||
// var iframe = container.find('iframe').first();
|
||||
// var height = isFull ? $(window).height()-110 : 600;
|
||||
// iframe.css('height', height + 'px');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<image-manager></image-manager>
|
@@ -1,10 +1,3 @@
|
||||
<h1>{{$page->name}}</h1>
|
||||
@if(count($page->children) > 0)
|
||||
<h4 class="text-muted">Sub-pages</h4>
|
||||
<div class="page-list">
|
||||
@foreach($page->children as $childPage)
|
||||
<a href="{{ $childPage->getUrl() }}">{{ $childPage->name }}</a>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
<h1 id="bkmrk-page-title">{{$page->name}}</h1>
|
||||
|
||||
{!! $page->html !!}
|
@@ -37,22 +37,31 @@
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<div class="page-content anim fadeIn">
|
||||
|
||||
<div class="pointer-container" id="pointer">
|
||||
<div class="pointer anim">
|
||||
<i class="zmdi zmdi-link"></i>
|
||||
<input readonly="readonly" type="text" placeholder="url">
|
||||
<button class="button icon" title="Copy Link" data-clipboard-text=""><i class="zmdi zmdi-copy"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('pages/page-display')
|
||||
|
||||
<hr>
|
||||
|
||||
<p class="text-muted small">
|
||||
Created {{$page->created_at->diffForHumans()}} @if($page->createdBy) by {{$page->createdBy->name}} @endif
|
||||
<br>
|
||||
Last Updated {{$page->updated_at->diffForHumans()}} @if($page->createdBy) by {{$page->updatedBy->name}} @endif
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
|
||||
@include('pages/sidebar-tree-list', ['book' => $book])
|
||||
<div class="side-nav faded">
|
||||
<h4>Page Navigation</h4>
|
||||
<ul class="page-nav-list">
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -64,45 +73,46 @@
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
// Set up document navigation
|
||||
var pageNav = $('.page-nav-list');
|
||||
var pageContent = $('.page-content');
|
||||
var headers = pageContent.find('h1, h2, h3, h4, h5, h6');
|
||||
if(headers.length > 5) {
|
||||
headers.each(function() {
|
||||
var header = $(this);
|
||||
var tag = header.prop('tagName');
|
||||
var listElem = $('<li></li>').addClass('nav-'+tag);
|
||||
var link = $('<a></a>').text(header.text().trim()).attr('href', '#');
|
||||
listElem.append(link);
|
||||
pageNav.append(listElem);
|
||||
link.click(function(e) {
|
||||
e.preventDefault();
|
||||
header.smoothScrollTo();
|
||||
})
|
||||
});
|
||||
$('.side-nav').fadeIn();
|
||||
} else {
|
||||
$('.side-nav').hide();
|
||||
}
|
||||
|
||||
|
||||
// Set up link hooks
|
||||
// Set up pointer
|
||||
var $pointer = $('#pointer').detach();
|
||||
var pageId = {{$page->id}};
|
||||
headers.each(function() {
|
||||
var text = $(this).text().trim();
|
||||
var link = '/link/' + pageId + '#' + encodeURIComponent(text);
|
||||
var linkHook = $('<a class="link-hook"><i class="zmdi zmdi-link"></i></a>')
|
||||
.attr({"data-content": link, href: link, target: '_blank'});
|
||||
linkHook.click(function(e) {
|
||||
e.preventDefault();
|
||||
goToText(text);
|
||||
});
|
||||
$(this).append(linkHook);
|
||||
var isSelection = false;
|
||||
|
||||
$pointer.find('input').click(function(e){$(this).select();e.stopPropagation();});
|
||||
new ZeroClipboard( $pointer.find('button').first()[0] );
|
||||
|
||||
$(document.body).find('*').on('click focus', function(e) {
|
||||
if(!isSelection) {
|
||||
$pointer.detach();
|
||||
}
|
||||
});
|
||||
|
||||
$('.page-content [id^="bkmrk"]').on('mouseup keyup', function(e) {
|
||||
var selection = window.getSelection();
|
||||
if(selection.toString().length === 0) return;
|
||||
// Show pointer and set link
|
||||
var $elem = $(this);
|
||||
var link = window.location.protocol + "//" + window.location.host + '/link/' + pageId + '#' + $elem.attr('id');
|
||||
$pointer.find('input').val(link);
|
||||
$pointer.find('button').first().attr('data-clipboard-text', link);
|
||||
$elem.before($pointer);
|
||||
$pointer.show();
|
||||
e.stopPropagation();
|
||||
|
||||
isSelection = true;
|
||||
setTimeout(function() {
|
||||
isSelection = false;
|
||||
}, 100);
|
||||
});
|
||||
|
||||
function goToText(text) {
|
||||
$('.page-content').find(':contains("'+text+'")').smoothScrollTo();
|
||||
var idElem = $('.page-content').find('#' + text).first();
|
||||
if(idElem.length !== 0) {
|
||||
idElem.smoothScrollTo();
|
||||
} else {
|
||||
$('.page-content').find(':contains("'+text+'")').smoothScrollTo();
|
||||
}
|
||||
}
|
||||
|
||||
if(window.location.hash) {
|
||||
@@ -110,7 +120,6 @@
|
||||
goToText(text);
|
||||
}
|
||||
|
||||
//$('[data-toggle="popover"]').popover()
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@@ -3,14 +3,12 @@
|
||||
<head>
|
||||
<title>BookStack</title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link rel="stylesheet" href="/css/app.css">
|
||||
<link rel="stylesheet" href="/css/styles.css">
|
||||
<link href='//fonts.googleapis.com/css?family=Roboto:400,400italic,500,500italic,700,700italic,300italic,100,300' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" href="/bower/material-design-iconic-font/dist/css/material-design-iconic-font.min.css">
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script src="/js/common.js"></script>
|
||||
|
||||
</head>
|
||||
<body class="@yield('body-class')">
|
||||
|
||||
|
Reference in New Issue
Block a user