mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Merge branch 'master' into fix-1186
This commit is contained in:
@ -8,7 +8,11 @@ class MarkdownEditor {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.textDirection = document.getElementById('page-editor').getAttribute('text-direction');
|
||||
|
||||
const pageEditor = document.getElementById('page-editor');
|
||||
this.pageId = pageEditor.getAttribute('page-id');
|
||||
this.textDirection = pageEditor.getAttribute('text-direction');
|
||||
|
||||
this.markdown = new MarkdownIt({html: true});
|
||||
this.markdown.use(mdTasksLists, {label: true});
|
||||
|
||||
@ -98,7 +102,9 @@ class MarkdownEditor {
|
||||
}
|
||||
|
||||
codeMirrorSetup() {
|
||||
let cm = this.cm;
|
||||
const cm = this.cm;
|
||||
const context = this;
|
||||
|
||||
// Text direction
|
||||
// cm.setOption('direction', this.textDirection);
|
||||
cm.setOption('direction', 'ltr'); // Will force to remain as ltr for now due to issues when HTML is in editor.
|
||||
@ -266,17 +272,18 @@ class MarkdownEditor {
|
||||
}
|
||||
|
||||
// Insert image into markdown
|
||||
let id = "image-" + Math.random().toString(16).slice(2);
|
||||
let placeholderImage = window.baseUrl(`/loading.gif#upload${id}`);
|
||||
let selectedText = cm.getSelection();
|
||||
let placeHolderText = ``;
|
||||
let cursor = cm.getCursor();
|
||||
const id = "image-" + Math.random().toString(16).slice(2);
|
||||
const placeholderImage = window.baseUrl(`/loading.gif#upload${id}`);
|
||||
const selectedText = cm.getSelection();
|
||||
const placeHolderText = ``;
|
||||
const cursor = cm.getCursor();
|
||||
cm.replaceSelection(placeHolderText);
|
||||
cm.setCursor({line: cursor.line, ch: cursor.ch + selectedText.length + 3});
|
||||
|
||||
let remoteFilename = "image-" + Date.now() + "." + ext;
|
||||
let formData = new FormData();
|
||||
const remoteFilename = "image-" + Date.now() + "." + ext;
|
||||
const formData = new FormData();
|
||||
formData.append('file', file, remoteFilename);
|
||||
formData.append('uploaded_to', context.pageId);
|
||||
|
||||
window.$http.post('/images/gallery/upload', formData).then(resp => {
|
||||
const newContent = `[](${resp.data.url})`;
|
||||
@ -302,7 +309,7 @@ class MarkdownEditor {
|
||||
}
|
||||
|
||||
actionInsertImage() {
|
||||
let cursorPos = this.cm.getCursor('from');
|
||||
const cursorPos = this.cm.getCursor('from');
|
||||
window.ImageManager.show(image => {
|
||||
let selectedText = this.cm.getSelection();
|
||||
let newText = "[](" + image.url + ")";
|
||||
@ -313,7 +320,7 @@ class MarkdownEditor {
|
||||
}
|
||||
|
||||
actionShowImageManager() {
|
||||
let cursorPos = this.cm.getCursor('from');
|
||||
const cursorPos = this.cm.getCursor('from');
|
||||
window.ImageManager.show(image => {
|
||||
this.insertDrawing(image, cursorPos);
|
||||
}, 'drawio');
|
||||
@ -321,7 +328,7 @@ class MarkdownEditor {
|
||||
|
||||
// Show the popup link selector and insert a link when finished
|
||||
actionShowLinkSelector() {
|
||||
let cursorPos = this.cm.getCursor('from');
|
||||
const cursorPos = this.cm.getCursor('from');
|
||||
window.EntitySelectorPopup.show(entity => {
|
||||
let selectedText = this.cm.getSelection() || entity.name;
|
||||
let newText = `[${selectedText}](${entity.link})`;
|
||||
@ -357,7 +364,7 @@ class MarkdownEditor {
|
||||
}
|
||||
|
||||
insertDrawing(image, originalCursor) {
|
||||
let newText = `<div drawio-diagram="${image.id}"><img src="${image.url}"></div>`;
|
||||
const newText = `<div drawio-diagram="${image.id}"><img src="${image.url}"></div>`;
|
||||
this.cm.focus();
|
||||
this.cm.replaceSelection(newText);
|
||||
this.cm.setCursor(originalCursor.line, originalCursor.ch + newText.length);
|
||||
@ -365,9 +372,13 @@ class MarkdownEditor {
|
||||
|
||||
// Show draw.io if enabled and handle save.
|
||||
actionEditDrawing(imgContainer) {
|
||||
if (document.querySelector('[drawio-enabled]').getAttribute('drawio-enabled') !== 'true') return;
|
||||
let cursorPos = this.cm.getCursor('from');
|
||||
let drawingId = imgContainer.getAttribute('drawio-diagram');
|
||||
const drawingDisabled = document.querySelector('[drawio-enabled]').getAttribute('drawio-enabled') !== 'true';
|
||||
if (drawingDisabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const cursorPos = this.cm.getCursor('from');
|
||||
const drawingId = imgContainer.getAttribute('drawio-diagram');
|
||||
|
||||
DrawIO.show(() => {
|
||||
return window.$http.get(window.baseUrl(`/images/base64/${drawingId}`)).then(resp => {
|
||||
|
@ -4,22 +4,24 @@ import DrawIO from "../services/drawio";
|
||||
/**
|
||||
* Handle pasting images from clipboard.
|
||||
* @param {ClipboardEvent} event
|
||||
* @param {WysiwygEditor} wysiwygComponent
|
||||
* @param editor
|
||||
*/
|
||||
function editorPaste(event, editor) {
|
||||
function editorPaste(event, editor, wysiwygComponent) {
|
||||
if (!event.clipboardData || !event.clipboardData.items) return;
|
||||
let items = event.clipboardData.items;
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (items[i].type.indexOf("image") === -1) continue;
|
||||
for (let clipboardItem of event.clipboardData.items) {
|
||||
if (clipboardItem.type.indexOf("image") === -1) continue;
|
||||
event.preventDefault();
|
||||
|
||||
let id = "image-" + Math.random().toString(16).slice(2);
|
||||
let loadingImage = window.baseUrl('/loading.gif');
|
||||
let file = items[i].getAsFile();
|
||||
const id = "image-" + Math.random().toString(16).slice(2);
|
||||
const loadingImage = window.baseUrl('/loading.gif');
|
||||
const file = clipboardItem.getAsFile();
|
||||
|
||||
setTimeout(() => {
|
||||
editor.insertContent(`<p><img src="${loadingImage}" id="${id}"></p>`);
|
||||
uploadImageFile(file).then(resp => {
|
||||
|
||||
uploadImageFile(file, wysiwygComponent).then(resp => {
|
||||
editor.dom.setAttrib(id, 'src', resp.thumbs.display);
|
||||
}).catch(err => {
|
||||
editor.dom.remove(id);
|
||||
@ -33,9 +35,12 @@ function editorPaste(event, editor) {
|
||||
/**
|
||||
* Upload an image file to the server
|
||||
* @param {File} file
|
||||
* @param {WysiwygEditor} wysiwygComponent
|
||||
*/
|
||||
function uploadImageFile(file) {
|
||||
if (file === null || file.type.indexOf('image') !== 0) return Promise.reject(`Not an image file`);
|
||||
async function uploadImageFile(file, wysiwygComponent) {
|
||||
if (file === null || file.type.indexOf('image') !== 0) {
|
||||
throw new Error(`Not an image file`);
|
||||
}
|
||||
|
||||
let ext = 'png';
|
||||
if (file.name) {
|
||||
@ -43,11 +48,13 @@ function uploadImageFile(file) {
|
||||
if (fileNameMatches.length > 1) ext = fileNameMatches[1];
|
||||
}
|
||||
|
||||
let remoteFilename = "image-" + Date.now() + "." + ext;
|
||||
let formData = new FormData();
|
||||
const remoteFilename = "image-" + Date.now() + "." + ext;
|
||||
const formData = new FormData();
|
||||
formData.append('file', file, remoteFilename);
|
||||
formData.append('uploaded_to', wysiwygComponent.pageId);
|
||||
|
||||
return window.$http.post(window.baseUrl('/images/gallery/upload'), formData).then(resp => (resp.data));
|
||||
const resp = await window.$http.post(window.baseUrl('/images/gallery/upload'), formData);
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
function registerEditorShortcuts(editor) {
|
||||
@ -370,7 +377,10 @@ class WysiwygEditor {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.textDirection = document.getElementById('page-editor').getAttribute('text-direction');
|
||||
|
||||
const pageEditor = document.getElementById('page-editor');
|
||||
this.pageId = pageEditor.getAttribute('page-id');
|
||||
this.textDirection = pageEditor.getAttribute('text-direction');
|
||||
|
||||
this.plugins = "image table textcolor paste link autolink fullscreen imagetools code customhr autosave lists codeeditor media";
|
||||
this.loadPlugins();
|
||||
@ -397,6 +407,9 @@ class WysiwygEditor {
|
||||
}
|
||||
|
||||
getTinyMceConfig() {
|
||||
|
||||
const context = this;
|
||||
|
||||
return {
|
||||
selector: '#html-editor',
|
||||
content_css: [
|
||||
@ -586,7 +599,7 @@ class WysiwygEditor {
|
||||
});
|
||||
|
||||
// Paste image-uploads
|
||||
editor.on('paste', event => editorPaste(event, editor));
|
||||
editor.on('paste', event => editorPaste(event, editor, context));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import 'codemirror/mode/diff/diff';
|
||||
import 'codemirror/mode/go/go';
|
||||
import 'codemirror/mode/htmlmixed/htmlmixed';
|
||||
import 'codemirror/mode/javascript/javascript';
|
||||
import 'codemirror/mode/lua/lua';
|
||||
import 'codemirror/mode/markdown/markdown';
|
||||
import 'codemirror/mode/nginx/nginx';
|
||||
import 'codemirror/mode/php/php';
|
||||
@ -38,12 +39,13 @@ const modeMap = {
|
||||
javascript: 'javascript',
|
||||
json: {name: 'javascript', json: true},
|
||||
js: 'javascript',
|
||||
php: 'php',
|
||||
lua: 'lua',
|
||||
md: 'markdown',
|
||||
mdown: 'markdown',
|
||||
markdown: 'markdown',
|
||||
nginx: 'nginx',
|
||||
powershell: 'powershell',
|
||||
php: 'php',
|
||||
py: 'python',
|
||||
python: 'python',
|
||||
ruby: 'ruby',
|
||||
|
@ -16,6 +16,7 @@ function mounted() {
|
||||
addRemoveLinks: true,
|
||||
dictRemoveFile: trans('components.image_upload_remove'),
|
||||
timeout: Number(window.uploadTimeout) || 60000,
|
||||
maxFilesize: Number(window.uploadLimit) || 256,
|
||||
url: function() {
|
||||
return _this.uploadUrl;
|
||||
},
|
||||
|
@ -51,15 +51,22 @@
|
||||
margin: $-xs $-s $-xs 0;
|
||||
}
|
||||
.align-right {
|
||||
float: right !important;
|
||||
text-align: right !important;
|
||||
}
|
||||
img.align-right, table.align-right {
|
||||
text-align: right;
|
||||
float: right !important;
|
||||
margin: $-xs 0 $-xs $-s;
|
||||
}
|
||||
.align-center {
|
||||
text-align: center;
|
||||
}
|
||||
img.align-center {
|
||||
display: block;
|
||||
}
|
||||
img.align-center, table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
height:auto;
|
||||
|
@ -60,6 +60,39 @@ return [
|
||||
'search_created_after' => 'Erstellt nach',
|
||||
'search_set_date' => 'Datum auswählen',
|
||||
'search_update' => 'Suche aktualisieren',
|
||||
|
||||
/*
|
||||
* Shelves
|
||||
*/
|
||||
'shelf' => 'Regal',
|
||||
'shelves' => 'Regale',
|
||||
'shelves_long' => 'Bücherregal',
|
||||
'shelves_empty' => 'Es wurden noch keine Regale angelegt',
|
||||
'shelves_create' => 'Erzeuge ein Regal',
|
||||
'shelves_popular' => 'Beliebte Regale',
|
||||
'shelves_new' => 'Kürzlich erstellte Regale',
|
||||
'shelves_popular_empty' => 'Die beliebtesten Regale werden hier angezeigt.',
|
||||
'shelves_new_empty' => 'Die neusten Regale werden hier angezeigt.',
|
||||
'shelves_save' => 'Regal speichern',
|
||||
'shelves_books' => 'Bücher in diesem Regal',
|
||||
'shelves_add_books' => 'Buch zu diesem Regal hinzufügen',
|
||||
'shelves_drag_books' => 'Bücher hier hin ziehen um sie dem Regal hinzuzufügen',
|
||||
'shelves_empty_contents' => 'Diesem Regal sind keine Bücher zugewiesen',
|
||||
'shelves_edit_and_assign' => 'Regal bearbeiten um Bücher hinzuzufügen',
|
||||
'shelves_edit_named' => 'Bücherregal :name bearbeiten',
|
||||
'shelves_edit' => 'Bücherregal bearbeiten',
|
||||
'shelves_delete' => 'Bücherregal löschen',
|
||||
'shelves_delete_named' => 'Bücherregal :name löschen',
|
||||
'shelves_delete_explain' => "Sie sind im Begriff das Bücherregal mit dem Namen ':name' zu löschen. Enthaltene Bücher werden nicht gelöscht.",
|
||||
'shelves_delete_confirmation' => 'Sind Sie sicher, dass Sie dieses Bücherregal löschen wollen?',
|
||||
'shelves_permissions' => 'Regal-Berechtigungen',
|
||||
'shelves_permissions_updated' => 'Regal-Berechtigungen aktualisiert',
|
||||
'shelves_permissions_active' => 'Regal-Berechtigungen aktiv',
|
||||
'shelves_copy_permissions_to_books' => 'Kopiere die Berechtigungen zum Buch',
|
||||
'shelves_copy_permissions' => 'Berechtigungen kopieren',
|
||||
'shelves_copy_permissions_explain' => 'Hiermit werden die Berechtigungen des aktuellen Regals auf alle enthaltenen Bücher übertragen. Überprüfen Sie vor der Aktivierung, ob alle Berechtigungsänderungen am aktuellen Regal gespeichert wurden.',
|
||||
'shelves_copy_permission_success' => 'Regal-Berechtigungen wurden zu :count Büchern kopiert',
|
||||
|
||||
/**
|
||||
* Books
|
||||
*/
|
||||
|
@ -9,6 +9,13 @@ return [
|
||||
'no_pages_recently_created' => 'Du hast bisher keine Seiten angelegt.',
|
||||
'no_pages_recently_updated' => 'Du hast bisher keine Seiten aktualisiert.',
|
||||
|
||||
/**
|
||||
* Shelves
|
||||
*/
|
||||
'shelves_delete_explain' => "Du bist im Begriff das Bücherregal mit dem Namen ':name' zu löschen. Enthaltene Bücher werden nicht gelöscht.",
|
||||
'shelves_delete_confirmation' => 'Bist du sicher, dass du dieses Bücherregal löschen willst?',
|
||||
'shelves_copy_permissions_explain' => 'Hiermit werden die Berechtigungen des aktuellen Regals auf alle enthaltenen Bücher übertragen. Überprüfe vor der Aktivierung, ob alle Berechtigungsänderungen am aktuellen Regal gespeichert wurden.',
|
||||
|
||||
/**
|
||||
* Books
|
||||
*/
|
||||
|
@ -27,7 +27,7 @@ return [
|
||||
'email' => 'Email',
|
||||
'password' => 'Wachtwoord',
|
||||
'password_confirm' => 'Wachtwoord Bevestigen',
|
||||
'password_hint' => 'Minimaal 5 tekens',
|
||||
'password_hint' => 'Minimaal 6 tekens',
|
||||
'forgot_password' => 'Wachtwoord vergeten?',
|
||||
'remember_me' => 'Mij onthouden',
|
||||
'ldap_email_hint' => 'Geef een email op waarmee je dit account wilt gebruiken.',
|
||||
@ -73,4 +73,4 @@ return [
|
||||
'email_not_confirmed_click_link' => 'Klik op de link in de e-mail die vlak na je registratie is verstuurd.',
|
||||
'email_not_confirmed_resend' => 'Als je deze e-mail niet kunt vinden kun je deze met onderstaande formulier opnieuw verzenden.',
|
||||
'email_not_confirmed_resend_button' => 'Bevestigingsmail Opnieuw Verzenden',
|
||||
];
|
||||
];
|
||||
|
@ -21,7 +21,9 @@
|
||||
<a @click="updateLanguage('Java')">Java</a>
|
||||
<a @click="updateLanguage('JavaScript')">JavaScript</a>
|
||||
<a @click="updateLanguage('JSON')">JSON</a>
|
||||
<a @click="updateLanguage('Lua')">Lua</a>
|
||||
<a @click="updateLanguage('PHP')">PHP</a>
|
||||
<a @click="updateLanguage('Powershell')">Powershell</a>
|
||||
<a @click="updateLanguage('MarkDown')">MarkDown</a>
|
||||
<a @click="updateLanguage('Nginx')">Nginx</a>
|
||||
<a @click="updateLanguage('Python')">Python</a>
|
||||
@ -48,4 +50,4 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -38,8 +38,9 @@
|
||||
<div class="form-group">
|
||||
<label for="user-language">{{ trans('settings.users_preferred_language') }}</label>
|
||||
<select name="setting[language]" id="user-language">
|
||||
|
||||
@foreach(trans('settings.language_select') as $lang => $label)
|
||||
<option @if(setting()->getUser($user, 'language') === $lang) selected @endif value="{{ $lang }}">{{ $label }}</option>
|
||||
<option @if(setting()->getUser($user, 'language', config('app.default_locale')) === $lang) selected @endif value="{{ $lang }}">{{ $label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user