2022-02-06 07:15:58 +08:00
|
|
|
/**
|
|
|
|
* @param {Editor} editor
|
|
|
|
*/
|
2023-04-19 17:46:13 +08:00
|
|
|
function register(editor) {
|
2022-02-06 07:15:58 +08:00
|
|
|
// Custom Image picker button
|
|
|
|
editor.ui.registry.addButton('imagemanager-insert', {
|
2022-02-07 05:17:08 +08:00
|
|
|
title: 'Insert image',
|
2022-02-06 07:15:58 +08:00
|
|
|
icon: 'image',
|
2022-02-07 05:17:08 +08:00
|
|
|
tooltip: 'Insert image',
|
2022-02-06 07:15:58 +08:00
|
|
|
onAction() {
|
2023-04-19 05:20:02 +08:00
|
|
|
/** @type {ImageManager} * */
|
2022-11-16 23:21:22 +08:00
|
|
|
const imageManager = window.$components.first('image-manager');
|
2023-04-19 05:20:02 +08:00
|
|
|
imageManager.show(image => {
|
2022-02-06 07:15:58 +08:00
|
|
|
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');
|
2023-04-19 05:20:02 +08:00
|
|
|
},
|
2022-02-06 07:15:58 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {register}
|
|
|
|
*/
|
2023-04-19 17:46:13 +08:00
|
|
|
export function getPlugin() {
|
2022-02-06 07:15:58 +08:00
|
|
|
return register;
|
2023-04-19 05:20:02 +08:00
|
|
|
}
|