Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

I made it possible to use Kcfinder in tinymce5 #179

Open
emaeba opened this issue Mar 27, 2019 · 5 comments
Open

I made it possible to use Kcfinder in tinymce5 #179

emaeba opened this issue Mar 27, 2019 · 5 comments

Comments

@emaeba
Copy link

emaeba commented Mar 27, 2019

Hi!
I made it possible to use Kcfinder in tinymce5

・Tinymce Setting File

file_picker_callback: function (callback, url, type, win) {
	var windowManagerURL = '';// filemanager path
	window.tinymceCallBackURL = '';
	window.tinymceWindowManager = tinymce.activeEditor.windowManager;

	tinymce.activeEditor.windowManager.open({
		title: 'Image',
		size: 'large',
		body: {
		type: 'panel',
			items: [{
				type: 'htmlpanel',
				html: '<iframe src="' + windowManagerURL + '" frameborder="0" style="width:100%; height:360%"></iframe>'
			}]
		},
		buttons: [
		] ,
	onClose: function () {
		if (tinymceCallBackURL!='')
			callback(tinymceCallBackURL, {});
		} 
	});
}

・Kcfinder 
080.files.js

win = (window.opener ? window.opener : window.parent);
win.tinymceCallBackURL = fileURL;
win.tinymce.activeEditor.windowManager.close();

for your information.

@emaeba emaeba changed the title I enabled kcfinder in tinymce5. I made it possible to use Kcfinder in tinymce5 Mar 27, 2019
@nsoeth
Copy link

nsoeth commented Apr 5, 2019

Thanks. I can open it and upload files but I cannot select a file and insert it into my TinyMCE5 modal. Where exactly should I put the lines in the

080.files.js

file?

edit:

on line 193 I inserted

} else if (_.opener.name === "tinymce5") { win = (window.opener ? window.opener : window.parent); win.tinymceCallBackURL = fileURL; win.tinymce.activeEditor.windowManager.close();

and added the opener to the browser.php in my JS:

/browse.php?opener=tinymce5

@emaeba
Copy link
Author

emaeba commented Apr 12, 2019

HI!
Can I use tinymce5 after modifying the following files?

050.init.js

    // TinyMCE 5
     } else if (_.opener.name == "tinymce5")
         _.opener.callBack = true;

080.files.js

   } else if (_.opener.name == "tinymce5") {
    win = (window.opener ? window.opener : window.parent);
    win.tinymceCallBackURL = fileURL;
    win.tinymce.activeEditor.windowManager.close();

@nsoeth
Copy link

nsoeth commented Apr 15, 2019

why not? :)

@mustangpl
Copy link

instead of
file_picker_callback: function (callback, url, type, win)
you should use
file_picker_callback: function (callback, value, meta)
see more https://www.tiny.cloud/docs/configure/file-image-upload/
then in windowManagerURL you can use
/kcfinder/browse.php?opener=tinymce5&type=' + meta.filetype+ '&lang=pl
where meta.filetype will give type of file

@emaeba
Copy link
Author

emaeba commented Jan 31, 2020

Hello!
tinymce Version 5.0.4 or more.
Added back URL dialog functionality, which is now available via editor.windowManager.openUrl() #TINY-3382

file_picker_callback: function(callback, value, meta) {
window.tinymceCallBackURL = '';
title = "";
var dialogUrl = '';// filemanager path
var width = window.innerWidth - 30;
var height = window.innerHeight - 60;
if (width > 1800) width = 1800;
if (height > 1200) height = 1200;
if (width > 600) {
var width_reduce = (width - 20) % 138;
width = width - width_reduce + 10;
}
tinymce.activeEditor.windowManager.openUrl({
title: title,
url: dialogUrl,
width: width,
height: height,
resizable: true,
maximizable: true,
inline: 1,
onClose: function () {
if (tinymceCallBackURL!='')
callback(tinymceCallBackURL, {}); //to set selected file path
}
});
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants