First of all I need to say this:

Sun, you need an award for this man! What a great module!!! Especially the UI.

That said, I was working on adding the nicUpload plugin to the nicEdit editor. I needed to make some changes to wysiwyg's code, so I thought it would be wise to do this in a way other editors could also take advantage of this. This is what I've done:

wysiwyg.module:

  • Added a menu item with a callback function. Using hook_editor(), each editor can register a callback for handling file upload.
  • Added hook_perm in order to manage access to whom can upload files inside the editor.

wysiwyg.admin.inc:

  • Added the ability to let editors add plugin specific form elements to the buttons fieldset. Using hook_editor() editors can register their own plugin config callback.
  • Changed wysiwyg_profile_form_submit() and theme_wysiwyg_admin_button_table() to support this feature.

nicedit.inc:

  • Added 'plugin config callback' to wysiwyg_nicedit_editor() to be called to add a form textfield to set the upload path for nicUpload.
  • Added 'upload callback' to wysiwyg_nicedit_editor() to be called when a file is uploaded.
  • Added 'uploadURI' setting to wysiwyg_nicedit_editor().
  • Added the upload button to the button list in wysiwyg_nicedit_plugins().
  • Added both the wysiwyg_nicedit_plugins_config and wysiwyg_nicedit_upload callback functions.

nicedit.js:

  • Added a little script to add the current format to the upload uri.

I hope I haven't done something that already has been done and you find it useful.

Comments

sun’s picture

Version: 6.x-0.5 » 6.x-2.x-dev
Status: Needs review » Needs work

I'm not sure I want to add this (burden) to Wysiwyg API. For example, Image Assist will soon be available for Nicedit (resp. all editors at once), so the entire file browser logic would need to be swappable, but also configurable.

Like in TinyMCE's and FCKeditor's case, the "native" file browser rather is an external plugin, having the downside that all uploaded files are not managed by and unknown to Drupal. Thus, like IMCE module, which has proven to be a invalid concept in a CMS like Drupal.

CNW in any case, because new features go into HEAD only.

skilip’s picture

A single filemanager which covers all wysiwyg file handling for D..... Please wake me up, I must be dreaming. Where can I signup? ;)

sun’s picture

http://drupal.org/project/media

My current plan on this is: While a few of fellow Drupalers work on the media project (file handling, streams, low-level API, and also a first UI), plenty of work goes into Image Assist 3.x and Inline 2.x currently (to flesh out a "rich" editor plugin that works in any editor via Wysiwyg API). Afterwards, if the Media project was successful, we will use the experience and knowledge to allow the upcoming Media module to be an editor plugin like Image Assist.

Gentoo7’s picture

Hey all, How do I add this patches to my code?

G

skilip’s picture

sun’s picture

Status: Needs work » Closed (won't fix)

Let me first say: thank you for your work on this! It is nice to see that you were able to build something useful for your use-case.

However, I really think that all developers should rather join forces and work on Inline API, Image Assist, Media, or other Drupal modules to implement Drupal plugin support there. By doing so, those Drupal modules can provide file upload and file browsing features to all editors and not just one. That is the long-term goal we are heading to.

Because of that, I'm marking this issue won't fix - sorry.

skilip’s picture

You're right! All future effords should go there. I wish I'd heard of those projects before.

Luciuz’s picture

Status: Needs review » Closed (won't fix)

Hello
i have a problem with the last patch. (nicedit v0.9 is used)
what's need to add into nicedit.js?
Now i have not image after uploading. textarea has img from tmp directory ("//tmp/test.png") but there is no image in the directory.

Luciuz’s picture

Status: Closed (won't fix) » Needs review
twod’s picture

All you should need to add to wysiwyg/editors/js/nicedit.js is:

  if (settings.uploadURI) {
    settings.uploadURI += '/' + params.format;
  };

just at the top of the attach() function.

The serverside files need a lot more modifications tho, as the patches show.

Note that we do not give official support on this subject since we don't support the editors' native filebrowsers in Wysiwyg module.