]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/plugins-imagemanager.js
Added ability to escape role "External Auth ID" commas
[bookstack] / resources / js / wysiwyg / plugins-imagemanager.js
1 /**
2  * @param {Editor} editor
3  * @param {String} url
4  */
5 function register(editor, url) {
6
7     // Custom Image picker button
8     editor.ui.registry.addButton('imagemanager-insert', {
9         title: 'Insert image',
10         icon: 'image',
11         tooltip: 'Insert image',
12         onAction() {
13             window.ImageManager.show(function (image) {
14                 const imageUrl = image.thumbs.display || image.url;
15                 let html = `<a href="${image.url}" target="_blank">`;
16                 html += `<img src="${imageUrl}" alt="${image.name}">`;
17                 html += '</a>';
18                 editor.execCommand('mceInsertContent', false, html);
19             }, 'gallery');
20         }
21     });
22 }
23
24
25 /**
26  * @param {WysiwygConfigOptions} options
27  * @return {register}
28  */
29 export function getPlugin(options) {
30     return register;
31 }