Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to chose file in tinyMCE? #107

Open
mariia-moiseienko opened this issue Sep 9, 2022 · 2 comments
Open

How to chose file in tinyMCE? #107

mariia-moiseienko opened this issue Sep 9, 2022 · 2 comments

Comments

@mariia-moiseienko
Copy link

mariia-moiseienko commented Sep 9, 2022

I have tinyMCE 6.2 in my project. How to chose file?

My code js:

function myFileBrowser(callback, value, meta) {
  var type = meta.filetype;
  var cmsURL = "file_manager/?conf=tiny";
  if (cmsURL.indexOf("?") < 0) {
    cmsURL = cmsURL + "?type=" + type;
  }
  else {
    cmsURL = cmsURL + "&type=" + type;
  }
  var windowManagerCSS = '<style type="text/css">' +
      '.tox-dialog {max-width: 100%!important; width:97.5%!important; overflow: hidden; height:95%!important; border-radius:0.25em;}' +
      '.tox-dialog__body { padding: 0!important; }' +
      '.tox-dialog__body-content > div { height: 100%; overflow:hidden}' +
      '</style> ';
  window.tinymceCallBackURL = '';
  window.tinymceWindowManager = tinymce.activeEditor.windowManager;
  tinymceWindowManager.open({
    title: 'Menedżer plików',
    url: cmsURL,
    body: {
      type: 'panel',
      items: [{
        type: 'htmlpanel',
        html: windowManagerCSS + `<iframe src="/file_manager/?conf=tiny&type=${type}" style="width:100%; height:500px" id="filemanager"></iframe>`
      }]
    },
    buttons: [],
    onClose: function () {
      if (tinymceCallBackURL != '')
        callback(tinymceCallBackURL, {}); //to set selected file path
    }
  });
}

TinyMCE init:
tinymce.init({ selector: '.tinymce', file_picker_callback: myFileBrowser, .......... }

image

And I can't choose an image by click or by check:

image

The selected file path is empty. Can you help me?

@artgris
Copy link
Owner

artgris commented Sep 22, 2022

Hi @mariia-moiseienko,

you need to add module=tiny in cmsURL :

var cmsURL = "file_manager/?module=tiny&conf=tiny";

and replace:
html: windowManagerCSS + '<iframe src="/file_manager/?conf=tiny&type=${type}" ... 🤔
with:
html: windowManagerCSS + '<iframe src="' + cmsURL ...

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

No branches or pull requests

2 participants