2022-02-05 18:15:58 -05:00
|
|
|
/**
|
|
|
|
* @param {Editor} editor
|
|
|
|
*/
|
2023-04-19 05:46:13 -04:00
|
|
|
function register(editor) {
|
2022-02-05 18:15:58 -05:00
|
|
|
// 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() {
|
2023-04-18 17:20:02 -04:00
|
|
|
/** @type {ImageManager} * */
|
2022-11-16 10:21:22 -05:00
|
|
|
const imageManager = window.$components.first('image-manager');
|
2023-04-18 17:20:02 -04:00
|
|
|
imageManager.show(image => {
|
2023-10-01 08:05:18 -04:00
|
|
|
const imageUrl = image.thumbs?.display || image.url;
|
2022-02-05 18:15:58 -05:00
|
|
|
let html = `<a href="${image.url}" target="_blank">`;
|
|
|
|
html += `<img src="${imageUrl}" alt="${image.name}">`;
|
|
|
|
html += '</a>';
|
|
|
|
editor.execCommand('mceInsertContent', false, html);
|
|
|
|
}, 'gallery');
|
2023-04-18 17:20:02 -04:00
|
|
|
},
|
2022-02-05 18:15:58 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {register}
|
|
|
|
*/
|
2023-04-19 05:46:13 -04:00
|
|
|
export function getPlugin() {
|
2022-02-05 18:15:58 -05:00
|
|
|
return register;
|
2023-04-18 17:20:02 -04:00
|
|
|
}
|