mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-07 15:26:48 +08:00
parent
ad48cd3e48
commit
09c6d6c722
@ -33,6 +33,15 @@ class Attachments {
|
|||||||
this.container.addEventListener('event-emit-select-edit-back', event => {
|
this.container.addEventListener('event-emit-select-edit-back', event => {
|
||||||
this.stopEdit();
|
this.stopEdit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.container.addEventListener('event-emit-select-insert', event => {
|
||||||
|
const insertContent = event.target.closest('[data-drag-content]').getAttribute('data-drag-content');
|
||||||
|
const contentTypes = JSON.parse(insertContent);
|
||||||
|
window.$events.emit('editor::insert', {
|
||||||
|
html: contentTypes['text/html'],
|
||||||
|
markdown: contentTypes['text/plain'],
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadList() {
|
reloadList() {
|
||||||
|
@ -563,6 +563,12 @@ class MarkdownEditor {
|
|||||||
this.cm.setCursor(cursorPos.line + prependLineCount, cursorPos.ch);
|
this.cm.setCursor(cursorPos.line + prependLineCount, cursorPos.ch);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Insert editor content at the current location
|
||||||
|
window.$events.listen('editor::insert', (eventContent) => {
|
||||||
|
const markdown = getContentToInsert(eventContent);
|
||||||
|
this.cm.replaceSelection(markdown);
|
||||||
|
});
|
||||||
|
|
||||||
// Focus on editor
|
// Focus on editor
|
||||||
window.$events.listen('editor::focus', () => {
|
window.$events.listen('editor::focus', () => {
|
||||||
this.cm.focus();
|
this.cm.focus();
|
||||||
|
@ -401,6 +401,11 @@ function listenForBookStackEditorEvents(editor) {
|
|||||||
editor.setContent(content);
|
editor.setContent(content);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Insert editor content at the current location
|
||||||
|
window.$events.listen('editor::insert', ({html}) => {
|
||||||
|
editor.insertContent(html);
|
||||||
|
});
|
||||||
|
|
||||||
// Focus on the editor
|
// Focus on the editor
|
||||||
window.$events.listen('editor::focus', () => {
|
window.$events.listen('editor::focus', () => {
|
||||||
editor.focus();
|
editor.focus();
|
||||||
|
@ -265,6 +265,7 @@ return [
|
|||||||
'attachments_link_url' => 'Link to file',
|
'attachments_link_url' => 'Link to file',
|
||||||
'attachments_link_url_hint' => 'Url of site or file',
|
'attachments_link_url_hint' => 'Url of site or file',
|
||||||
'attach' => 'Attach',
|
'attach' => 'Attach',
|
||||||
|
'attachments_insert_link' => 'Add Attachment Link to Page',
|
||||||
'attachments_edit_file' => 'Edit File',
|
'attachments_edit_file' => 'Edit File',
|
||||||
'attachments_edit_file_name' => 'File Name',
|
'attachments_edit_file_name' => 'File Name',
|
||||||
'attachments_edit_drop_upload' => 'Drop files or click here to upload and overwrite',
|
'attachments_edit_drop_upload' => 'Drop files or click here to upload and overwrite',
|
||||||
|
@ -10,13 +10,22 @@
|
|||||||
<a href="{{ $attachment->getUrl() }}" target="_blank">{{ $attachment->name }}</a>
|
<a href="{{ $attachment->getUrl() }}" target="_blank">{{ $attachment->name }}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-fill justify-flex-end">
|
<div class="flex-fill justify-flex-end">
|
||||||
|
<button component="event-emit-select"
|
||||||
|
option:event-emit-select:name="insert"
|
||||||
|
type="button"
|
||||||
|
title="{{ trans('entities.attachments_insert_link') }}"
|
||||||
|
class="drag-card-action text-center text-primary">@icon('link') </button>
|
||||||
<button component="event-emit-select"
|
<button component="event-emit-select"
|
||||||
option:event-emit-select:name="edit"
|
option:event-emit-select:name="edit"
|
||||||
option:event-emit-select:id="{{ $attachment->id }}"
|
option:event-emit-select:id="{{ $attachment->id }}"
|
||||||
type="button"
|
type="button"
|
||||||
|
title="{{ trans('common.edit') }}"
|
||||||
class="drag-card-action text-center text-primary">@icon('edit')</button>
|
class="drag-card-action text-center text-primary">@icon('edit')</button>
|
||||||
<div component="dropdown" class="flex-fill relative">
|
<div component="dropdown" class="flex-fill relative">
|
||||||
<button refs="dropdown@toggle" type="button" class="drag-card-action text-center text-neg">@icon('close')</button>
|
<button refs="dropdown@toggle"
|
||||||
|
type="button"
|
||||||
|
title="{{ trans('common.delete') }}"
|
||||||
|
class="drag-card-action text-center text-neg">@icon('close')</button>
|
||||||
<div refs="dropdown@menu" class="dropdown-menu">
|
<div refs="dropdown@menu" class="dropdown-menu">
|
||||||
<p class="text-neg small px-m mb-xs">{{ trans('entities.attachments_delete') }}</p>
|
<p class="text-neg small px-m mb-xs">{{ trans('entities.attachments_delete') }}</p>
|
||||||
<button refs="ajax-delete-row@delete" type="button" class="text-primary small delete">{{ trans('common.confirm') }}</button>
|
<button refs="ajax-delete-row@delete" type="button" class="text-primary small delete">{{ trans('common.confirm') }}</button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user