Add upload button to CKEditor image dialog

This commit is contained in:
Kijin Sung 2024-05-25 00:59:53 +09:00
parent 0c3879d0c8
commit 7af4f93175
3 changed files with 13 additions and 7 deletions

View file

@ -574,16 +574,20 @@
}, },
validate: CKEDITOR.dialog.validate.notEmpty( editor.lang.image.urlMissing ) validate: CKEDITOR.dialog.validate.notEmpty( editor.lang.image.urlMissing )
}, },
// Rhymix upload integration
{ {
type: 'button', type: 'button',
id: 'browse', id: 'rx_upload',
// v-align with the 'txtUrl' field.
// TODO: We need something better than a fixed size here.
style: 'display:inline-block;margin-top:14px;', style: 'display:inline-block;margin-top:14px;',
align: 'center', align: 'center',
label: editor.lang.common.browseServer, label: editor.lang.image.upload,
hidden: true, hidden: !editor.config.rx_allow_upload,
filebrowser: 'info:txtUrl' onClick: function() {
const editor_container = _getCkeContainer(editor.config.xe_editor_sequence);
const upload_container = editor_container.nextAll('.xefu-container').first();
upload_container.find('input[type=file]').first().trigger('click');
this.getDialog().hide();
}
} ] } ]
} ] } ]
}, },

View file

@ -11,6 +11,7 @@ $ckconfig->toolbar = $editor_toolbar ?? 'default';
$ckconfig->hide_toolbar = $editor_toolbar_hide ?? false; $ckconfig->hide_toolbar = $editor_toolbar_hide ?? false;
$ckconfig->focus = $editor_focus ?? false; $ckconfig->focus = $editor_focus ?? false;
$ckconfig->ios_patch = (bool)preg_match('/i(Phone|Pad|Pod)/', $_SERVER['HTTP_USER_AGENT'] ?? ''); $ckconfig->ios_patch = (bool)preg_match('/i(Phone|Pad|Pod)/', $_SERVER['HTTP_USER_AGENT'] ?? '');
$ckconfig->allow_upload = $allow_fileupload ?? false;
// Plugin configuration // Plugin configuration
$ckconfig->add_plugins = $editor_additional_plugins ?: []; $ckconfig->add_plugins = $editor_additional_plugins ?: [];

View file

@ -52,7 +52,8 @@ $(function() {
language: config.language, language: config.language,
iframe_attributes: {}, iframe_attributes: {},
versionCheck: false, versionCheck: false,
xe_editor_sequence: editor_sequence rx_allow_upload: config.allow_upload,
xe_editor_sequence: editor_sequence,
}, },
loadXeComponent: true, loadXeComponent: true,
enableToolbar: true enableToolbar: true