mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-26 02:10:19 +08:00
b2d48d9a7f
- Moved thumnbail loading out of repo into ImageResizer. - Updated gallery and editor image handling to show errors where possible to indicate memory issues for resizing/thumbs. - Updated gallery to load image data in a per-image basis via edit form for more resiliant thumb/data fetching. Data was previously provided via gallery listing, which could be affected by failing generation of other images. - Updated image manager double click handling to be more pleasant and not flash away the edit form. - Updated editor handlers to use main URL when thumbs fail to load.
30 lines
864 B
JavaScript
30 lines
864 B
JavaScript
/**
|
|
* @param {Editor} editor
|
|
*/
|
|
function register(editor) {
|
|
// Custom Image picker button
|
|
editor.ui.registry.addButton('imagemanager-insert', {
|
|
title: 'Insert image',
|
|
icon: 'image',
|
|
tooltip: 'Insert image',
|
|
onAction() {
|
|
/** @type {ImageManager} * */
|
|
const imageManager = window.$components.first('image-manager');
|
|
imageManager.show(image => {
|
|
const imageUrl = image.thumbs?.display || image.url;
|
|
let html = `<a href="${image.url}" target="_blank">`;
|
|
html += `<img src="${imageUrl}" alt="${image.name}">`;
|
|
html += '</a>';
|
|
editor.execCommand('mceInsertContent', false, html);
|
|
}, 'gallery');
|
|
},
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @return {register}
|
|
*/
|
|
export function getPlugin() {
|
|
return register;
|
|
}
|