2022-02-05 18:15:58 -05:00
|
|
|
/**
|
|
|
|
* @param {Editor} editor
|
|
|
|
* @param {String} url
|
|
|
|
*/
|
|
|
|
function register(editor, url) {
|
|
|
|
|
|
|
|
// Custom Image picker button
|
|
|
|
editor.ui.registry.addButton('imagemanager-insert', {
|
2022-02-06 16:17:08 -05:00
|
|
|
title: 'Insert image',
|
2022-02-05 18:15:58 -05:00
|
|
|
icon: 'image',
|
2022-02-06 16:17:08 -05:00
|
|
|
tooltip: 'Insert image',
|
2022-02-05 18:15:58 -05: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;
|
|
|
|
}
|