2022-02-06 00:15:58 +01:00
|
|
|
/**
|
|
|
|
* @param {Editor} editor
|
|
|
|
* @param {String} url
|
|
|
|
*/
|
|
|
|
function register(editor, url) {
|
|
|
|
|
|
|
|
// Custom Image picker button
|
|
|
|
editor.ui.registry.addButton('imagemanager-insert', {
|
2022-02-06 22:17:08 +01:00
|
|
|
title: 'Insert image',
|
2022-02-06 00:15:58 +01:00
|
|
|
icon: 'image',
|
2022-02-06 22:17:08 +01:00
|
|
|
tooltip: 'Insert image',
|
2022-02-06 00:15:58 +01:00
|
|
|
onAction() {
|
|
|
|
window.ImageManager.show(function (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');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {WysiwygConfigOptions} options
|
|
|
|
* @return {register}
|
|
|
|
*/
|
|
|
|
export function getPlugin(options) {
|
|
|
|
return register;
|
|
|
|
}
|